RpmControl: remove raw RPM spikes using median filter

This commit is contained in:
bresch
2024-12-19 07:30:25 +01:00
committed by Matthias Grob
parent f687e3d8a4
commit 1b105c937d
2 changed files with 3 additions and 1 deletions
+1 -1
View File
@@ -138,7 +138,7 @@ void RPMCapture::Run()
const float dt = math::constrain((now - _timestamp_last_update) * 1e-6f, 0.01f, 1.f);
_timestamp_last_update = now;
_rpm_filter.setParameters(dt, 0.5f);
_rpm_filter.update(rpm_raw);
_rpm_filter.update(_rpm_median_filter.apply(rpm_raw));
rpm_s rpm{};
rpm.timestamp = now;
+2
View File
@@ -35,6 +35,7 @@
#include <drivers/drv_hrt.h>
#include <lib/mathlib/math/filter/AlphaFilter.hpp>
#include <lib/mathlib/math/filter/MedianFilter.hpp>
#include <px4_arch/micro_hal.h>
#include <px4_platform_common/module.h>
#include <px4_platform_common/px4_work_queue/ScheduledWorkItem.hpp>
@@ -85,4 +86,5 @@ private:
hrt_abstime _timestamp_last_update{0}; ///< to caluclate dt
AlphaFilter<float> _rpm_filter;
MedianFilter<float, 5> _rpm_median_filter;
};