From 674f75fce16cfc128b6a49237bb68b4c448e439d Mon Sep 17 00:00:00 2001 From: Iampete1 Date: Wed, 21 Feb 2024 18:53:33 +0000 Subject: [PATCH] Plane: move manual mode throttle limits to main throttle limit function. --- ArduPlane/mode.h | 2 +- ArduPlane/mode_manual.cpp | 27 ++++++++++++--------------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/ArduPlane/mode.h b/ArduPlane/mode.h index 3721eb8de3..597399cc21 100644 --- a/ArduPlane/mode.h +++ b/ArduPlane/mode.h @@ -400,7 +400,7 @@ public: void run() override; // true if throttle min/max limits should be applied - bool use_throttle_limits() const override { return false; } + bool use_throttle_limits() const override; // true if voltage correction should be applied to throttle bool use_battery_compensation() const override { return false; } diff --git a/ArduPlane/mode_manual.cpp b/ArduPlane/mode_manual.cpp index 1f8fcd702c..8c5a834102 100644 --- a/ArduPlane/mode_manual.cpp +++ b/ArduPlane/mode_manual.cpp @@ -6,22 +6,8 @@ void ModeManual::update() SRV_Channels::set_output_scaled(SRV_Channel::k_aileron, plane.roll_in_expo(false)); SRV_Channels::set_output_scaled(SRV_Channel::k_elevator, plane.pitch_in_expo(false)); output_rudder_and_steering(plane.rudder_in_expo(false)); - float throttle = plane.get_throttle_input(true); - -#if HAL_QUADPLANE_ENABLED - if (quadplane.available() && quadplane.option_is_set(QuadPlane::OPTION::IDLE_GOV_MANUAL)) { - // for quadplanes it can be useful to run the idle governor in MANUAL mode - // as it prevents the VTOL motors from running - int8_t min_throttle = plane.aparm.throttle_min.get(); - - // apply idle governor -#if AP_ICENGINE_ENABLED - plane.g2.ice_control.update_idle_governor(min_throttle); -#endif - throttle = MAX(throttle, min_throttle); - } -#endif + const float throttle = plane.get_throttle_input(true); SRV_Channels::set_output_scaled(SRV_Channel::k_throttle, throttle); plane.nav_roll_cd = ahrs.roll_sensor; @@ -32,3 +18,14 @@ void ModeManual::run() { reset_controllers(); } + +// true if throttle min/max limits should be applied +bool ModeManual::use_throttle_limits() const +{ +#if HAL_QUADPLANE_ENABLED + if (quadplane.available() && quadplane.option_is_set(QuadPlane::OPTION::IDLE_GOV_MANUAL)) { + return true; + } +#endif + return false; +}