From 680162cef0fe6c47c78bc2666a3ed749410f6877 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 23 Mar 2022 11:29:29 +1100 Subject: [PATCH] Plane: added a value for RTL_AUTOLAND to disable arming check set RTL_AUTOLAND=3 to get go-around but not RTL DO_LAND_START usage --- ArduPlane/AP_Arming.cpp | 2 +- ArduPlane/Parameters.cpp | 6 +++--- ArduPlane/Parameters.h | 2 +- ArduPlane/defines.h | 9 +++++++++ ArduPlane/events.cpp | 2 +- ArduPlane/mode_rtl.cpp | 4 ++-- 6 files changed, 17 insertions(+), 8 deletions(-) diff --git a/ArduPlane/AP_Arming.cpp b/ArduPlane/AP_Arming.cpp index 60d5f7f3b3..df97ad5ec3 100644 --- a/ArduPlane/AP_Arming.cpp +++ b/ArduPlane/AP_Arming.cpp @@ -368,7 +368,7 @@ bool AP_Arming_Plane::mission_checks(bool report) { // base checks bool ret = AP_Arming::mission_checks(report); - if (plane.mission.get_landing_sequence_start() > 0 && plane.g.rtl_autoland.get() == 0) { + if (plane.mission.get_landing_sequence_start() > 0 && plane.g.rtl_autoland == RtlAutoland::RTL_DISABLE) { ret = false; check_failed(ARMING_CHECK_MISSION, report, "DO_LAND_START set and RTL_AUTOLAND disabled"); } diff --git a/ArduPlane/Parameters.cpp b/ArduPlane/Parameters.cpp index f6563e24a3..f287fddfd8 100644 --- a/ArduPlane/Parameters.cpp +++ b/ArduPlane/Parameters.cpp @@ -716,10 +716,10 @@ const AP_Param::Info Plane::var_info[] = { // @Param: RTL_AUTOLAND // @DisplayName: RTL auto land - // @Description: Automatically begin landing sequence after arriving at RTL location. This requires the addition of a DO_LAND_START mission item, which acts as a marker for the start of a landing sequence. The closest landing sequence will be chosen to the current location. - // @Values: 0:Disable,1:Enable - go HOME then land,2:Enable - go directly to landing sequence + // @Description: Automatically begin landing sequence after arriving at RTL location. This requires the addition of a DO_LAND_START mission item, which acts as a marker for the start of a landing sequence. The closest landing sequence will be chosen to the current location. If this is set to 0 and there is a DO_LAND_START mission item then you will get an arming check failure. You can set to a value of 3 to avoid the arming check failure and use the DO_LAND_START for go-around without it changing RTL behaviour. For a value of 1 a rally point will be used instead of HOME if in range (see rally point documentation). + // @Values: 0:Disable,1:Fly HOME then land,2:Go directly to landing sequence, 3:OnlyForGoAround // @User: Standard - GSCALAR(rtl_autoland, "RTL_AUTOLAND", 0), + GSCALAR(rtl_autoland, "RTL_AUTOLAND", float(RtlAutoland::RTL_DISABLE)), // @Param: CRASH_ACC_THRESH // @DisplayName: Crash Deceleration Threshold diff --git a/ArduPlane/Parameters.h b/ArduPlane/Parameters.h index bae6c1a3de..9334c87d5c 100644 --- a/ArduPlane/Parameters.h +++ b/ArduPlane/Parameters.h @@ -362,7 +362,7 @@ public: AP_Int16 sysid_my_gcs; AP_Int8 telem_delay; - AP_Int8 rtl_autoland; + AP_Enum rtl_autoland; AP_Int8 crash_accel_threshold; diff --git a/ArduPlane/defines.h b/ArduPlane/defines.h index 3bcfd2e8c7..8da58b7e69 100644 --- a/ArduPlane/defines.h +++ b/ArduPlane/defines.h @@ -50,6 +50,15 @@ enum class StickMixing { VTOL_YAW = 3, }; +// values for RTL_AUTOLAND +enum class RtlAutoland { + RTL_DISABLE = 0, + RTL_THEN_DO_LAND_START = 1, + RTL_IMMEDIATE_DO_LAND_START = 2, + NO_RTL_GO_AROUND = 3, +}; + + enum ChannelMixing { MIXING_DISABLED = 0, MIXING_UPUP = 1, diff --git a/ArduPlane/events.cpp b/ArduPlane/events.cpp index 3b900f4a35..090c8364f1 100644 --- a/ArduPlane/events.cpp +++ b/ArduPlane/events.cpp @@ -261,7 +261,7 @@ void Plane::handle_battery_failsafe(const char *type_str, const int8_t action) #endif if (!already_landing) { // never stop a landing if we were already committed - if (g.rtl_autoland == 2 && plane.mission.is_best_land_sequence()) { + if (g.rtl_autoland == RtlAutoland::RTL_IMMEDIATE_DO_LAND_START && plane.mission.is_best_land_sequence()) { // continue mission as it will reach a landing in less distance plane.mission.set_in_landing_sequence_flag(true); break; diff --git a/ArduPlane/mode_rtl.cpp b/ArduPlane/mode_rtl.cpp index 42f38d560e..7c59ac1f99 100644 --- a/ArduPlane/mode_rtl.cpp +++ b/ArduPlane/mode_rtl.cpp @@ -75,7 +75,7 @@ void ModeRTL::navigate() } #endif - if (plane.g.rtl_autoland == 1 && + if (plane.g.rtl_autoland == RtlAutoland::RTL_THEN_DO_LAND_START && !plane.auto_state.checked_for_autoland && plane.reached_loiter_target() && labs(plane.altitude_error_cm) < 1000) { @@ -90,7 +90,7 @@ void ModeRTL::navigate() // on every loop plane.auto_state.checked_for_autoland = true; } - else if (plane.g.rtl_autoland == 2 && + else if (plane.g.rtl_autoland == RtlAutoland::RTL_IMMEDIATE_DO_LAND_START && !plane.auto_state.checked_for_autoland) { // Go directly to the landing sequence if (plane.mission.jump_to_landing_sequence()) {