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
This commit is contained in:
Peter Barker 2022-01-04 10:40:26 +11:00 committed by Peter Barker
parent adff48c3ea
commit 709679ed60
1 changed files with 1 additions and 1 deletions

View File

@ -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;
}