AP_Motors: get_compensation_gain gets div-by-zero check

This commit is contained in:
Randy Mackay 2015-04-29 14:13:07 +09:00
parent 1b381b5675
commit bae1722946
1 changed files with 5 additions and 0 deletions

View File

@ -368,6 +368,11 @@ void AP_Motors::update_throttle_low_comp()
float AP_Motors::get_compensation_gain() const
{
// avoid divide by zero
if (_lift_max <= 0.0f) {
return 1.0f;
}
float ret = 1.0f / _lift_max;
// air density ratio is increasing in density / decreasing in altitude