APM_Control: Correct use of deceleration

This commit is contained in:
Stephen Dade 2024-10-24 21:52:24 +11:00 committed by Randy Mackay
parent 4c9da021eb
commit 3764f377d8
1 changed files with 3 additions and 4 deletions

View File

@ -1058,15 +1058,14 @@ float AR_AttitudeControl::get_desired_speed_accel_limited(float desired_speed, f
float AR_AttitudeControl::get_stopping_distance(float speed) const float AR_AttitudeControl::get_stopping_distance(float speed) const
{ {
// get maximum vehicle deceleration // get maximum vehicle deceleration
const float accel_max = get_accel_max(); const float decel_max = get_decel_max();
// avoid divide by zero if ((decel_max <= 0.0f) || is_zero(speed)) {
if ((accel_max <= 0.0f) || is_zero(speed)) {
return 0.0f; return 0.0f;
} }
// assume linear deceleration // assume linear deceleration
return 0.5f * sq(speed) / accel_max; return 0.5f * sq(speed) / decel_max;
} }
// relax I terms of throttle and steering controllers // relax I terms of throttle and steering controllers