mirror of
https://github.com/okalachev/flix.git
synced 2026-06-27 21:46:38 +00:00
Bring back initializing the lpf with the first input value
It's much better for voltage measuring and slightly better for gyro bias estimation.
This commit is contained in:
+8
-1
@@ -14,6 +14,10 @@ public:
|
|||||||
LowPassFilter(float alpha): alpha(alpha) {};
|
LowPassFilter(float alpha): alpha(alpha) {};
|
||||||
|
|
||||||
T update(const T input) {
|
T update(const T input) {
|
||||||
|
if (!init) {
|
||||||
|
init = true;
|
||||||
|
return output = input;
|
||||||
|
}
|
||||||
return output += alpha * (input - output);
|
return output += alpha * (input - output);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22,6 +26,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void reset() {
|
void reset() {
|
||||||
output = T(); // set to zero
|
init = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool init = false;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user