From 2d2195d841b31ace59b94831595a9e22cd366f25 Mon Sep 17 00:00:00 2001 From: breadoven <56191411+breadoven@users.noreply.github.com> Date: Tue, 29 Aug 2023 11:41:39 +0100 Subject: [PATCH] fix landing detector active state logic --- src/main/fc/fc_core.c | 2 ++ src/main/navigation/navigation.c | 13 +++++++------ src/main/navigation/navigation.h | 1 + 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/fc/fc_core.c b/src/main/fc/fc_core.c index a00e79724..92705ab69 100755 --- a/src/main/fc/fc_core.c +++ b/src/main/fc/fc_core.c @@ -558,6 +558,8 @@ void tryArm(void) ENABLE_STATE(NAV_EXTRA_ARMING_SAFETY_BYPASSED); } + resetLandingDetectorActiveState(); // reset landing detector after arming to avoid false detection before flight + lastDisarmReason = DISARM_NONE; ENABLE_ARMING_FLAG(ARMED); diff --git a/src/main/navigation/navigation.c b/src/main/navigation/navigation.c index eba38c68b..63c5b9884 100644 --- a/src/main/navigation/navigation.c +++ b/src/main/navigation/navigation.c @@ -2809,16 +2809,12 @@ void updateLandingStatus(timeMs_t currentTimeMs) DEBUG_SET(DEBUG_LANDING, 1, STATE(LANDING_DETECTED)); if (!ARMING_FLAG(ARMED)) { - if (STATE(LANDING_DETECTED)) { - resetLandingDetector(); - landingDetectorIsActive = false; - } + resetLandingDetector(); + if (!IS_RC_MODE_ACTIVE(BOXARM)) { DISABLE_ARMING_FLAG(ARMING_DISABLED_LANDING_DETECTED); } return; - } else if (getArmTime() < 0.25f && landingDetectorIsActive) { // force reset landing detector immediately after arming - landingDetectorIsActive = false; } if (!landingDetectorIsActive) { @@ -2851,6 +2847,11 @@ void resetLandingDetector(void) posControl.flags.resetLandingDetector = true; } +void resetLandingDetectorActiveState(void) +{ + landingDetectorIsActive = false; +} + bool isFlightDetected(void) { return STATE(AIRPLANE) ? isFixedWingFlying() : isMulticopterFlying(); diff --git a/src/main/navigation/navigation.h b/src/main/navigation/navigation.h index 9ffe532e6..3fd213a24 100644 --- a/src/main/navigation/navigation.h +++ b/src/main/navigation/navigation.h @@ -611,6 +611,7 @@ float calculateAverageSpeed(void); void updateLandingStatus(timeMs_t currentTimeMs); bool isProbablyStillFlying(void); +void resetLandingDetectorActiveState(void); const navigationPIDControllers_t* getNavigationPIDControllers(void); -- 2.11.4.GIT