diff --git a/libraries/AP_Vehicle/AP_Vehicle.cpp b/libraries/AP_Vehicle/AP_Vehicle.cpp index 338081b6c9..81dab2e9c9 100644 --- a/libraries/AP_Vehicle/AP_Vehicle.cpp +++ b/libraries/AP_Vehicle/AP_Vehicle.cpp @@ -388,17 +388,18 @@ bool AP_Vehicle::is_crashed() const // run notch update at either loop rate or 200Hz void AP_Vehicle::update_dynamic_notch_at_specified_rate() { - if (ins.has_harmonic_option(HarmonicNotchFilterParams::Options::LoopRateUpdate)) { - update_dynamic_notch(); - return; - } + for (uint8_t i=0; i 5) { - _last_notch_update_ms = now; - update_dynamic_notch(); + if (now - _last_notch_update_ms[i] > 5) { + _last_notch_update_ms[i] = now; + update_dynamic_notch(i); + } + } } } diff --git a/libraries/AP_Vehicle/AP_Vehicle.h b/libraries/AP_Vehicle/AP_Vehicle.h index 787a0b9c73..910f44bcf8 100644 --- a/libraries/AP_Vehicle/AP_Vehicle.h +++ b/libraries/AP_Vehicle/AP_Vehicle.h @@ -248,7 +248,7 @@ public: #endif // AP_SCRIPTING_ENABLED // update the harmonic notch - virtual void update_dynamic_notch() {}; + virtual void update_dynamic_notch(uint8_t idx) {}; // zeroing the RC outputs can prevent unwanted motor movement: virtual bool should_zero_rc_outputs_on_reboot() const { return false; } @@ -409,7 +409,7 @@ private: bool likely_flying; // true if vehicle is probably flying uint32_t _last_flying_ms; // time when likely_flying last went true - uint32_t _last_notch_update_ms; // last time update_dynamic_notch() was run + uint32_t _last_notch_update_ms[HAL_INS_NUM_HARMONIC_NOTCH_FILTERS]; // last time update_dynamic_notch() was run static AP_Vehicle *_singleton;