FW rate controller: Don't constrain airspeed for scaling to maximum airspeed (#24622)

* don't constrain airspeed for scaling to maximum airspeed

Signed-off-by: RomanBapst <bapstroman@gmail.com>

* fix max function

Signed-off-by: RomanBapst <bapstroman@gmail.com>

* remove hardcoded max

Signed-off-by: RomanBapst <bapstroman@gmail.com>

---------

Signed-off-by: RomanBapst <bapstroman@gmail.com>
This commit is contained in:
Roman Bapst
2025-03-27 14:22:40 +01:00
committed by GitHub
parent 19d3e6285b
commit 550bbd9051
@@ -179,10 +179,16 @@ float FixedwingRateControl::get_airspeed_and_update_scaling()
*
* Forcing the scaling to this value allows reasonable handheld tests.
*/
const float airspeed_constrained = constrain(constrain(airspeed, _param_fw_airspd_stall.get(),
_param_fw_airspd_max.get()), 0.1f, 1000.0f);
_airspeed_scaling = (_param_fw_arsp_scale_en.get()) ? (_param_fw_airspd_trim.get() / airspeed_constrained) : 1.0f;
if (_param_fw_arsp_scale_en.get()) {
const float min_airspeed = math::max(_param_fw_airspd_stall.get(), 0.1f);
const float airspeed_constrained = math::max(airspeed, min_airspeed);
_airspeed_scaling = _param_fw_airspd_trim.get() / airspeed_constrained;
} else {
_airspeed_scaling = 1.0f;
}
return airspeed;
}