From b2744f965dd1b56a58005848af232d0462eeb12e Mon Sep 17 00:00:00 2001 From: Roman Bapst Date: Thu, 3 Mar 2016 10:46:48 +0100 Subject: [PATCH] use in_air flag from land detector to determine if we are on the ground --- EKF/control.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/EKF/control.cpp b/EKF/control.cpp index 2a4e16c60d..7a0d753393 100644 --- a/EKF/control.cpp +++ b/EKF/control.cpp @@ -198,12 +198,13 @@ void Ekf::calculateVehicleStatus() } // Transition to in-air occurs when armed and when altitude has increased sufficiently from the altitude at arming - if (!_control_status.flags.in_air && _control_status.flags.armed && (_state.pos(2) - _last_disarmed_posD) < -1.0f) { + bool in_air = _control_status.flags.armed && (_state.pos(2) - _last_disarmed_posD) < -1.0f; + if (!_control_status.flags.in_air && in_air) { _control_status.flags.in_air = true; } - // Transition to on-ground occurs when disarmed. - if (_control_status.flags.in_air && !_control_status.flags.armed) { + // Transition to on-ground occurs when disarmed or if the land detector indicated landed state + if (_control_status.flags.in_air && (!_control_status.flags.armed || !_in_air)) { _control_status.flags.in_air = false; } }