From dba31584465b18d1e9f8d55a65e3be03ec0b22d9 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Thu, 3 Sep 2020 09:31:08 +1000 Subject: [PATCH] Copter: correct mode change for GCS failsafe in SmartRTL mode In the case that you: - have previously done a successful SmartRTL flight - get a mid-air gcs failsafe and enter SmartRTL - recover from that gcs failsafe but remain in SmartRTL - get another mid-air failsafe then without this patch you will enter LAND mode. When determining our failsafe action, we were looking at whether we should just continue landing. To do that, we ask the current mode if we are landing. Problem is that SmartRTL was handing back the wrong answer - it was handing back ModeRTL's answer rather than its own, and ModeRTL's answer was "yes, I'm landing", as that's the last state that step 1 in the above list leaves that mode in. This patch simply hands back the correct answer for, "am I landing" --- ArduCopter/mode.h | 4 +++- ArduCopter/mode_smart_rtl.cpp | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ArduCopter/mode.h b/ArduCopter/mode.h index e0f1f7c018..aa906edefb 100644 --- a/ArduCopter/mode.h +++ b/ArduCopter/mode.h @@ -1052,7 +1052,7 @@ public: // this should probably not be exposed bool state_complete() { return _state_complete; } - bool is_landing() const override; + virtual bool is_landing() const override; void restart_without_terrain(); @@ -1133,6 +1133,8 @@ public: void save_position(); void exit(); + bool is_landing() const override; + protected: const char *name() const override { return "SMARTRTL"; } diff --git a/ArduCopter/mode_smart_rtl.cpp b/ArduCopter/mode_smart_rtl.cpp index dde31446e3..73d13a1cdd 100644 --- a/ArduCopter/mode_smart_rtl.cpp +++ b/ArduCopter/mode_smart_rtl.cpp @@ -59,6 +59,11 @@ void ModeSmartRTL::run() } } +bool ModeSmartRTL::is_landing() const +{ + return smart_rtl_state == SmartRTL_Land; +} + void ModeSmartRTL::wait_cleanup_run() { // hover at current target position