From 5f4c7e0f93e535bba6e5068afcbf513fe4eec297 Mon Sep 17 00:00:00 2001 From: RomanBapst Date: Fri, 31 May 2024 07:50:56 +0200 Subject: [PATCH] FilteredDerivative: set initialised to false if sample interval is invalid Signed-off-by: RomanBapst --- src/lib/mathlib/math/filter/FilteredDerivative.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib/mathlib/math/filter/FilteredDerivative.hpp b/src/lib/mathlib/math/filter/FilteredDerivative.hpp index 09b1fd49777e..f0099334d2e7 100644 --- a/src/lib/mathlib/math/filter/FilteredDerivative.hpp +++ b/src/lib/mathlib/math/filter/FilteredDerivative.hpp @@ -89,6 +89,9 @@ class FilteredDerivative if (_initialized) { if (_sample_interval > FLT_EPSILON) { _alpha_filter.update((sample - _previous_sample) / _sample_interval); + + } else { + _initialized = false; } } else {