From d1b270d5b2b2d35cdfec2299b188ef9a6e916b16 Mon Sep 17 00:00:00 2001 From: Matthias Grob <maetugr@gmail.com> Date: Wed, 19 Apr 2017 12:03:03 +0200 Subject: [PATCH] land_detector: fix sanity condition that we have ground contact when we are landed to include the hysteresis flag because the condition was looking for the instantaneous flag and during the hysteresis time the state did not change anymore --- src/modules/land_detector/LandDetector.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/modules/land_detector/LandDetector.cpp b/src/modules/land_detector/LandDetector.cpp index 071f25d534..e5cb88f1a9 100644 --- a/src/modules/land_detector/LandDetector.cpp +++ b/src/modules/land_detector/LandDetector.cpp @@ -198,15 +198,11 @@ void LandDetector::_check_params(const bool force) void LandDetector::_update_state() { - /* ground contact and landed can be true simultaneously but only one state can be true at a particular time + /* when we are landed we also have ground contact for sure but only one output state can be true at a particular time * with higher priority for landed */ - bool freefall = _get_freefall_state(); - bool landed = _get_landed_state(); - bool groundContact = (landed || _get_ground_contact_state()); - - _freefall_hysteresis.set_state_and_update(freefall); - _landed_hysteresis.set_state_and_update(landed); - _ground_contact_hysteresis.set_state_and_update(groundContact); + _freefall_hysteresis.set_state_and_update(_get_freefall_state()); + _landed_hysteresis.set_state_and_update(_get_landed_state()); + _ground_contact_hysteresis.set_state_and_update(_landed_hysteresis.get_state() || _get_ground_contact_state()); if (_freefall_hysteresis.get_state()) { _state = LandDetectionState::FREEFALL; -- GitLab