Browse Source

Copter: compassmot: use is_positive for float comparison

tridge noted on the DevCall that very, very small numbers could yield
numerical errors during divisions further down
gps-1.3.1
Peter Barker 3 years ago committed by Peter Barker
parent
commit
709679ed60
  1. 2
      ArduCopter/compassmot.cpp

2
ArduCopter/compassmot.cpp

@ -169,7 +169,7 @@ MAV_RESULT Copter::mavlink_compassmot(const GCS_MAVLINK &gcs_chan) @@ -169,7 +169,7 @@ MAV_RESULT Copter::mavlink_compassmot(const GCS_MAVLINK &gcs_chan)
current_amps_max = MAX(current_amps_max, current);
// if throttle is near zero, update base x,y,z values
if (throttle_pct <= 0.0f) {
if (!is_positive(throttle_pct)) {
for (uint8_t i=0; i<compass.get_count(); i++) {
compass_base[i] = compass_base[i] * 0.99f + compass.get_field(i) * 0.01f;
}

Loading…
Cancel
Save