From edaddc043166189938aa7654e9a6e72c06a0b6d0 Mon Sep 17 00:00:00 2001 From: Michael du Breuil Date: Wed, 3 Jul 2024 10:33:57 -0700 Subject: [PATCH] AP_TECS: Use aircraft stall speed When stall prevention is enabled we were scaling from the aircraft's minimum flight speed. However this is normally already picked as being above the stall speed, and for a variety of reasons we may want to pin the aircraft at a higher minimum speed. But if the aircraft was commanded to fly to close to that minimum speed as soon as it banked for a pattern it would command a increase in speed to keep it away from stalling. However if your minimum speed is far from stalling this increase was incorrect. To make it worse what this actually results in happening is an aircraft diving for more speed (over 10 m/s on some aircraft) as well as descending to gain that speed resulting in over 200 foot deviations in altitude control. --- libraries/AP_TECS/AP_TECS.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/AP_TECS/AP_TECS.cpp b/libraries/AP_TECS/AP_TECS.cpp index 9307502caa..55fb024043 100644 --- a/libraries/AP_TECS/AP_TECS.cpp +++ b/libraries/AP_TECS/AP_TECS.cpp @@ -415,7 +415,11 @@ void AP_TECS::_update_speed(float DT) if (aparm.stall_prevention) { // when stall prevention is active we raise the minimum // airspeed based on aerodynamic load factor - _TASmin *= _load_factor; + if (is_positive(aparm.airspeed_stall)) { + _TASmin = MAX(_TASmin, aparm.airspeed_stall*EAS2TAS*_load_factor); + } else { + _TASmin *= _load_factor; + } } if (_TASmax < _TASmin) {