Skip to content

armgit / flix

Public Imported from GitHub
0

Making an ESP32-based quadcopter from scratch

Bring back initializing the lpf with the first input value It's much better for voltage measuring and slightly better for gyro bias estimation.

Oleg Kalachev3816ae376fe5
diff --git a/flix/lpf.h b/flix/lpf.h
index 9eae80d..9ee4e0a 100644
--- a/flix/lpf.h
+++ b/flix/lpf.h
@@ -14,6 +14,10 @@ public:
LowPassFilter(float alpha): alpha(alpha) {};
T update(const T input) {
+ if (!init) {
+ init = true;
+ return output = input;
+ }
return output += alpha * (input - output);
}
@@ -22,6 +26,9 @@ public:
}
void reset() {
- output = T(); // set to zero
+ init = false;
}
+
+private:
+ bool init = false;
};