File tree 2 files changed +11
-0
lines changed 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -685,8 +685,10 @@ void NavEKF3_core::readGpsData()
685
685
gpsDataNew.lat = gpsloc.lat ;
686
686
gpsDataNew.lng = gpsloc.lng ;
687
687
if ((frontend->_originHgtMode & (1 <<2 )) == 0 ) {
688
+ // the height adjustment to match GPS is being achieved by adjusting the origin height
688
689
gpsDataNew.hgt = (ftype)((double )0.01 * (double )gpsloc.alt - ekfGpsRefHgt);
689
690
} else {
691
+ // the height adjustment to match GPS is being achieved by adjusting the measurements
690
692
gpsDataNew.hgt = 0.01 * (gpsloc.alt - EKF_origin.alt );
691
693
}
692
694
storedGPS.push (gpsDataNew);
Original file line number Diff line number Diff line change @@ -1278,6 +1278,11 @@ void NavEKF3_core::selectHeightForFusion()
1278
1278
hgtMea = MAX (rangeDataDelayed.rng * prevTnb.c .z , rngOnGnd);
1279
1279
// correct for terrain position relative to datum
1280
1280
hgtMea -= terrainState;
1281
+ // correct sensor so that local position height adjusts to match GPS
1282
+ if (frontend->_originHgtMode & (1 << 1 ) && frontend->_originHgtMode & (1 << 2 )) {
1283
+ // offset has to be applied to the measurement, not the NED origin
1284
+ hgtMea += (float )(ekfGpsRefHgt - 0.01 * (double )EKF_origin.alt );
1285
+ }
1281
1286
velPosObs[5 ] = -hgtMea;
1282
1287
// enable fusion
1283
1288
fuseHgtData = true ;
@@ -1304,6 +1309,10 @@ void NavEKF3_core::selectHeightForFusion()
1304
1309
} else if (baroDataToFuse && (activeHgtSource == AP_NavEKF_Source::SourceZ::BARO)) {
1305
1310
// using Baro data
1306
1311
hgtMea = baroDataDelayed.hgt - baroHgtOffset;
1312
+ // correct sensor so that local position height adjusts to match GPS
1313
+ if (frontend->_originHgtMode & (1 << 0 ) && frontend->_originHgtMode & (1 << 2 )) {
1314
+ hgtMea += (float )(ekfGpsRefHgt - 0.01 * (double )EKF_origin.alt );
1315
+ }
1307
1316
// enable fusion
1308
1317
fuseHgtData = true ;
1309
1318
// set the observation noise
You can’t perform that action at this time.
0 commit comments