38 #include <mathlib/mathlib.h> 56 float update(
float val,
float alpha,
float spike_limit)
58 float val_constrained =
math::constrain(val, -spike_limit, spike_limit);
59 float beta = 1.f - alpha;
61 _x = beta *
_x + alpha * val_constrained;
constexpr _Tp constrain(_Tp val, _Tp min_val, _Tp max_val)
void reset(float val=0.f)
float update(float val, float alpha, float spike_limit)
Update the filter with a new value and returns the filtered state The new value is constained by the ...
float _x
current state of the filter
static float computeAlphaFromDtAndTauInv(float dt, float tau_inv)
Helper function to compute alpha from dt and the inverse of tau.
Vector< float, 6 > f(float t, const Matrix< float, 6, 1 > &, const Matrix< float, 3, 1 > &)
First order "alpha" IIR digital filter with input saturation.