From f63f2343f41226c026f4f2cb78bff074ee35ea9a Mon Sep 17 00:00:00 2001 From: treston Date: Mon, 12 Oct 2026 22:55:57 -0500 Subject: [PATCH] fix(fw_lateral_longitudinal_control): reject a negative lateral acceleration limit A finite negative lateral_control_configuration.lateral_accel_max was stored as the limit, and constrain(setpoint, -max, +max) with inverted bounds returns +|max| for every setpoint, holding the vehicle in a bank. Treat a negative limit like NaN and use the roll-limit default. --- .../FwLateralLongitudinalControl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/fw_lateral_longitudinal_control/FwLateralLongitudinalControl.cpp b/src/modules/fw_lateral_longitudinal_control/FwLateralLongitudinalControl.cpp index 9e29c090c3a..0f8bee75b2c 100644 --- a/src/modules/fw_lateral_longitudinal_control/FwLateralLongitudinalControl.cpp +++ b/src/modules/fw_lateral_longitudinal_control/FwLateralLongitudinalControl.cpp @@ -372,7 +372,8 @@ void FwLateralLongitudinalControl::updateControllerConfiguration(hrt_abstime tim _lateral_control_configuration_sub.copy(&configuration_in); _lateral_configuration.timestamp = configuration_in.timestamp; - if (PX4_ISFINITE(configuration_in.lateral_accel_max)) { + // a negative limit would invert the constrain() bounds of the setpoint; treat it like an unset one + if (PX4_ISFINITE(configuration_in.lateral_accel_max) && (configuration_in.lateral_accel_max >= 0.f)) { _lateral_configuration.lateral_accel_max = min(configuration_in.lateral_accel_max, tanf(radians( _param_fw_r_lim.get())) * CONSTANTS_ONE_G);