diff options
author | Mark Whitehorn <kd0aij@gmail.com> | 2014-12-22 13:47:20 -0700 |
---|---|---|
committer | Mark Whitehorn <kd0aij@gmail.com> | 2015-01-13 09:06:00 -0700 |
commit | 3c98c7119ebe956d1dc9c10379e9158567d16642 (patch) | |
tree | 91f45457740a6c19d2afbd46b48ed7823014cb21 /src/lib/mathlib/math | |
parent | 78b603bb3532e927e617fe1946a1090b509e72ad (diff) | |
download | px4-firmware-3c98c7119ebe956d1dc9c10379e9158567d16642.tar.gz px4-firmware-3c98c7119ebe956d1dc9c10379e9158567d16642.tar.bz2 px4-firmware-3c98c7119ebe956d1dc9c10379e9158567d16642.zip |
use non-uniform 1st order IIR lowpass filters for baro_gps_offset estimation
Diffstat (limited to 'src/lib/mathlib/math')
-rw-r--r-- | src/lib/mathlib/math/filter/LowPassFilter2p.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/lib/mathlib/math/filter/LowPassFilter2p.cpp b/src/lib/mathlib/math/filter/LowPassFilter2p.cpp index 6f640c9f9..c709a2834 100644 --- a/src/lib/mathlib/math/filter/LowPassFilter2p.cpp +++ b/src/lib/mathlib/math/filter/LowPassFilter2p.cpp @@ -66,6 +66,7 @@ float LowPassFilter2p::apply(float sample) // no filtering return sample; } + // do the filtering float delay_element_0 = sample - _delay_element_1 * _a1 - _delay_element_2 * _a2; if (isnan(delay_element_0) || isinf(delay_element_0)) { @@ -82,7 +83,9 @@ float LowPassFilter2p::apply(float sample) } float LowPassFilter2p::reset(float sample) { - _delay_element_1 = _delay_element_2 = sample; + float dval = sample / (_b0 + _b1 + _b2); + _delay_element_1 = dval; + _delay_element_2 = dval; return apply(sample); } |