Browse Source

Plane: Protect against a divide by 0 when calculating the forward throttle compensation

zr-v5.1
Michael du Breuil 5 years ago committed by Andrew Tridgell
parent
commit
911570e9f3
  1. 5
      ArduPlane/servos.cpp

5
ArduPlane/servos.cpp

@ -361,6 +361,11 @@ void Plane::throttle_voltage_comp() @@ -361,6 +361,11 @@ void Plane::throttle_voltage_comp()
// constrain read voltage to min and max params
batt_voltage_resting_estimate = constrain_float(batt_voltage_resting_estimate,g2.fwd_thr_batt_voltage_min,g2.fwd_thr_batt_voltage_max);
// don't apply compensation if the voltage is excessively low
if (batt_voltage_resting_estimate < 1) {
return;
}
// Scale the throttle up to compensate for voltage drop
// Ratio = 1 when voltage = voltage max, ratio increases as voltage drops
const float ratio = g2.fwd_thr_batt_voltage_max / batt_voltage_resting_estimate;

Loading…
Cancel
Save