revert position.c changes

This commit is contained in:
s0up 2018-06-07 13:34:12 -07:00
parent 96692af0f8
commit 1b1837905c
1 changed files with 6 additions and 4 deletions

View File

@ -86,13 +86,15 @@ if (sensors(SENSOR_GPS) && STATE(GPS_FIX)) {
}
#endif
if (!ARMING_FLAG(ARMED)) {
if (ARMING_FLAG(ARMED) && !altitudeOffsetSet) {
baroAltOffset = baroAlt;
gpsAltOffset = gpsAlt;
} else {
baroAlt -= baroAltOffset;
gpsAlt -= gpsAltOffset;
altitudeOffsetSet = true;
} else if (!ARMING_FLAG(ARMED) && altitudeOffsetSet) {
altitudeOffsetSet = false;
}
baroAlt -= baroAltOffset;
gpsAlt -= gpsAltOffset;
if (haveGpsAlt && haveBaroAlt) {
estimatedAltitude = gpsAlt * gpsTrust + baroAlt * (1 - gpsTrust);