From 5df4249fe40c7bb4c031bbc7309256cb9e30977b Mon Sep 17 00:00:00 2001 From: bresch Date: Fri, 13 Nov 2026 09:33:39 +0100 Subject: [PATCH] feat(land_detector): detect movement from the aided velocity The IMU tests cannot see motion at constant speed, which an aided velocity estimate does. --- src/modules/land_detector/LandDetector.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/modules/land_detector/LandDetector.cpp b/src/modules/land_detector/LandDetector.cpp index f7cf79dede8..bb36559df4e 100644 --- a/src/modules/land_detector/LandDetector.cpp +++ b/src/modules/land_detector/LandDetector.cpp @@ -136,7 +136,20 @@ void LandDetector::Run() } } - _vehicle_local_position_sub.update(&_vehicle_local_position); + if (_vehicle_local_position_sub.update(&_vehicle_local_position)) { + // Catches constant velocity motion where the acceleration and vibration checks would fail. + static constexpr float kAidedVelocityMax = 1.f; + static constexpr float kAidedVelocityStdDevMax = 5.f; + + const matrix::Vector2f velocity_xy{_vehicle_local_position.vx, _vehicle_local_position.vy}; + const float velocity_threshold = math::max(kAidedVelocityMax, kAidedVelocityStdDevMax * _vehicle_local_position.evh); + + if (_vehicle_local_position.v_xy_valid && !_vehicle_local_position.dead_reckoning + && velocity_xy.longerThan(velocity_threshold)) { + _time_last_move_detect_us = _vehicle_local_position.timestamp_sample; + } + } + _vehicle_status_sub.update(&_vehicle_status); _update_topics();