AR_AttitudeControl: fix braking

this fix ensures the output throttle is never in the opposite direction from the desired-speed
there is a possibility that this could lead to rougher throttle response when the vehicle is transitioning from forward to backwards motion because the throttle response will immediately go to zero when the desired speed cross over zero
This commit is contained in:
Randy Mackay 2017-10-25 22:21:52 +09:00
parent 49cbbf4d76
commit 2986d3eb7d
1 changed files with 2 additions and 2 deletions

View File

@ -303,11 +303,11 @@ float AR_AttitudeControl::get_throttle_out_speed(float desired_speed, bool skid_
// protect against reverse output being sent to the motors unless braking has been enabled
if (!_brake_enable) {
// if both desired speed and actual speed are positive, do not allow negative values
if (is_positive(speed) && is_positive(desired_speed) && !is_positive(throttle_out)) {
if ((desired_speed >= 0.0f) && (throttle_out <= 0.0f)) {
throttle_out = 0.0f;
_throttle_limit_low = true;
}
if (is_negative(speed) && is_negative(desired_speed) && !is_negative(throttle_out)) {
if ((desired_speed <= 0.0f) && (throttle_out >= 0.0f)) {
throttle_out = 0.0f;
_throttle_limit_high = true;
}