Plane: prevent a division by zero in takeoff code

This commit is contained in:
Andrew Tridgell 2016-04-26 12:06:57 +10:00
parent 831ae72908
commit 1ebe0a2583

View File

@ -165,6 +165,7 @@ int16_t Plane::get_takeoff_pitch_min_cd(void)
}
// are we entering the region where we want to start leveling off before we reach takeoff alt?
if (auto_state.sink_rate < -0.1f) {
float sec_to_target = (remaining_height_to_target_cm * 0.01f) / (-auto_state.sink_rate);
if (sec_to_target > 0 &&
relative_alt_cm >= 1000 &&
@ -174,6 +175,7 @@ int16_t Plane::get_takeoff_pitch_min_cd(void)
auto_state.height_below_takeoff_to_level_off_cm = remaining_height_to_target_cm;
}
}
}
return auto_state.takeoff_pitch_cd;
}