From 745d4c4c8a4c53aeac5ac4d7a0a645e26c017855 Mon Sep 17 00:00:00 2001 From: bresch Date: Thu, 5 Nov 2026 11:47:52 +0100 Subject: [PATCH] feat(land_detector): detect movement from the specific force change The vibration metrics miss smooth accelerations such as a fixed-wing takeoff roll, which let at_rest be declared while moving. --- src/modules/land_detector/LandDetector.cpp | 19 +++++++++++++++++++ src/modules/land_detector/LandDetector.h | 5 +++++ 2 files changed, 24 insertions(+) diff --git a/src/modules/land_detector/LandDetector.cpp b/src/modules/land_detector/LandDetector.cpp index e4f8cccb676..f7cf79dede8 100644 --- a/src/modules/land_detector/LandDetector.cpp +++ b/src/modules/land_detector/LandDetector.cpp @@ -103,6 +103,25 @@ void LandDetector::Run() if (_vehicle_acceleration_sub.update(&vehicle_acceleration)) { _acceleration = matrix::Vector3f{vehicle_acceleration.xyz}; + + const bool first_sample = (_time_last_acceleration_sample_us == 0); + const float dt_s = (vehicle_acceleration.timestamp_sample - _time_last_acceleration_sample_us) * 1e-6f; + _time_last_acceleration_sample_us = vehicle_acceleration.timestamp_sample; + + if (first_sample || (dt_s > 1.f)) { + _specific_force_fast.reset(_acceleration); + _specific_force_slow.reset(_acceleration); + } + + // Catches smooth accelerations, such as a takeoff roll, that the high-passed vibration metrics miss. + static constexpr float kSpecificForceChangeMax = 0.3f; + + const matrix::Vector3f specific_force_change = _specific_force_fast.update(_acceleration, dt_s) + - _specific_force_slow.update(_acceleration, dt_s); + + if (specific_force_change.longerThan(kSpecificForceChangeMax)) { + _time_last_move_detect_us = vehicle_acceleration.timestamp_sample; + } } vehicle_angular_velocity_s vehicle_angular_velocity{}; diff --git a/src/modules/land_detector/LandDetector.h b/src/modules/land_detector/LandDetector.h index 7e82641d19b..e5677a5cd2e 100644 --- a/src/modules/land_detector/LandDetector.h +++ b/src/modules/land_detector/LandDetector.h @@ -46,6 +46,7 @@ #include #include +#include #include #include #include @@ -167,6 +168,10 @@ private: hrt_abstime _total_flight_time{0}; ///< total vehicle flight time in microseconds hrt_abstime _time_last_move_detect_us{0}; // timestamp of last movement detection event in microseconds + hrt_abstime _time_last_acceleration_sample_us{0}; + + AlphaFilter _specific_force_fast{0.5f}; + AlphaFilter _specific_force_slow{5.f}; perf_counter_t _cycle_perf{perf_alloc(PC_ELAPSED, MODULE_NAME": cycle")};