AC_AttitudeControl: AC_PosControl: limit_accel_xy: take a normalised velocity
pre-commit / ci (push) Canceled after 0s
test scripts / build (astyle-cleanliness) (push) Canceled after 0s
test scripts / build (check_autotest_options) (push) Canceled after 0s
test scripts / build (logger_metadata) (push) Canceled after 0s
test scripts / build (param-file-validation) (push) Canceled after 0s
test scripts / build (param_parse) (push) Canceled after 0s
test scripts / build (python-cleanliness) (push) Canceled after 0s
test scripts / build (shellcheck) (push) Canceled after 0s
test scripts / build (validate_board_list) (push) Canceled after 0s

This commit is contained in:
Leonard Thall
2026-07-27 12:10:17 +09:00
committed by Randy Mackay
parent 044b249da5
commit 2b5cebb933
@@ -764,7 +764,12 @@ void AC_PosControl::NE_update_controller()
const float accel_max_mss = angle_rad_to_accel_mss(angle_max_rad);
// Save unbounded target for use in "limited" check (not unit-consistent with z!)
_limit_vector_ned.xy() = _accel_target_ned_mss.xy();
if (!limit_accel_xy(_vel_desired_ned_ms.xy(), _accel_target_ned_mss.xy(), accel_max_mss)) {
// Normalise desired velocity by max speed for the cross-track reference (guard zero max speed).
Vector2f vel_norm_ne;
if (is_positive(_vel_max_ne_ms)) {
vel_norm_ne = _vel_desired_ned_ms.xy() / _vel_max_ne_ms;
}
if (!limit_accel_xy(vel_norm_ne, _accel_target_ned_mss.xy(), accel_max_mss)) {
// _accel_target_ned_mss was not limited so we can zero the xy limit vector
_limit_vector_ned.xy().zero();
}