mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 06:28:27 -04:00
Plane: prevent a division by zero in takeoff code
This commit is contained in:
parent
831ae72908
commit
1ebe0a2583
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user