Browse Source

Copter: add div-by-zero check to get_pilot_desired_throttle

This divide by zero is only possible if there was a coding error in the setup of the throttle channel but added to make Covarity happy
mission-4.1.18
Randy Mackay 9 years ago
parent
commit
f4fee69f29
  1. 5
      ArduCopter/Attitude.cpp

5
ArduCopter/Attitude.cpp

@ -142,6 +142,11 @@ float Copter::get_pilot_desired_throttle(int16_t throttle_control) @@ -142,6 +142,11 @@ float Copter::get_pilot_desired_throttle(int16_t throttle_control)
int16_t mid_stick = channel_throttle->get_control_mid();
// protect against unlikely divide by zero
if (mid_stick <= 0) {
mid_stick = 500;
}
// ensure reasonable throttle values
throttle_control = constrain_int16(throttle_control,0,1000);

Loading…
Cancel
Save