AC_AttControl: get_throttle_avg_max always returns value in 0 to 1 range

throttle_avg_max is the total average throttle level (expressed as a number from 0 to 1) that the motors can safely be raised to in order to maintain attitude control.  This level can be higher than the pilot's or autopilot provided throttle level.
Previously passing in a negative throttle_in could result in a negative throttle_avg_max being returned.
This commit is contained in:
Randy Mackay 2016-08-03 11:44:22 +09:00
parent ac04fcd836
commit 24044e5611

View File

@ -203,6 +203,7 @@ float AC_AttitudeControl_Multi::get_throttle_boosted(float throttle_in)
// throttle value should be 0 ~ 1
float AC_AttitudeControl_Multi::get_throttle_avg_max(float throttle_in)
{
throttle_in = constrain_float(throttle_in, 0.0f, 1.0f);
return MAX(throttle_in, throttle_in*MAX(0.0f,1.0f-_throttle_rpy_mix)+_motors.get_throttle_hover()*_throttle_rpy_mix);
}