mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-03 07:28:54 +08:00
RpmControl: remove raw RPM spikes using median filter
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user