@@ -607,7 +607,6 @@ void NavEKF3_core::SelectVelPosFusion()
607
607
608
608
// if we are using GPS, check for a change in receiver and reset position and height
609
609
if (gpsDataToFuse && (PV_AidingMode == AID_ABSOLUTE) && (posxy_source == AP_NavEKF_Source::SourceXY::GPS) && (gpsDataDelayed.sensor_idx != last_gps_idx || posxy_source_reset)) {
610
- GCS_SEND_TEXT (MAV_SEVERITY_INFO, " fuse gps 2, %u" , gpsDataToFuse);
611
610
// mark a source reset as consumed
612
611
posxy_source_reset = false ;
613
612
@@ -844,8 +843,6 @@ void NavEKF3_core::FuseVelPosNED()
844
843
varInnovVelPos[3 ] = P[7 ][7 ] + R_OBS_DATA_CHECKS[3 ];
845
844
varInnovVelPos[4 ] = P[8 ][8 ] + R_OBS_DATA_CHECKS[4 ];
846
845
847
- // TODO (EF): enabling this pos check causes conflict with GPS using external nav
848
- if (gpsDataToFuse) {
849
846
// Apply an innovation consistency threshold test
850
847
// Don't allow test to fail if not navigating and using a constant position
851
848
// assumption to constrain tilt errors because innovations can become large
@@ -857,7 +854,7 @@ void NavEKF3_core::FuseVelPosNED()
857
854
if (posTestRatio < 1 .0f || (PV_AidingMode == AID_NONE)) {
858
855
posCheckPassed = true ;
859
856
lastGpsPosPassTime_ms = imuSampleTime_ms;
860
- } else if ((frontend->_gpsGlitchRadiusMax <= 0 ) && (PV_AidingMode != AID_NONE)) {
857
+ } else if ((gpsDataToFuse && frontend->_gpsGlitchRadiusMax <= 0 ) && (PV_AidingMode != AID_NONE)) {
861
858
// Handle the special case where the glitch radius parameter has been set to a non-positive number.
862
859
// The innovation variance is increased to limit the state update to an amount corresponding
863
860
// to a test ratio of 1.
@@ -873,8 +870,23 @@ void NavEKF3_core::FuseVelPosNED()
873
870
if (posCheckPassed || posTimeout || badIMUdata) {
874
871
// if timed out or outside the specified uncertainty radius, reset to the external sensor
875
872
// if velocity drift is being constrained, dont reset until gps passes quality checks
876
- const bool posVarianceIsTooLarge = (frontend->_gpsGlitchRadiusMax > 0 ) && (P[8 ][8 ] + P[7 ][7 ]) > sq (ftype (frontend->_gpsGlitchRadiusMax ));
877
- if ((posTimeout || posVarianceIsTooLarge) && (!velAiding || gpsGoodToAlign)) {
873
+ bool posVarianceIsTooLarge = false ;
874
+ if (extNavDataToFuse)
875
+ {
876
+ posVarianceIsTooLarge = (P[8 ][8 ] + P[7 ][7 ]) > sq (ftype (extNavDataDelayed.posErr ));
877
+ }
878
+ else if (gpsDataToFuse)
879
+ {
880
+ posVarianceIsTooLarge = (frontend->_gpsGlitchRadiusMax > 0 ) && (P[8 ][8 ] + P[7 ][7 ]) > sq (ftype (frontend->_gpsGlitchRadiusMax ));
881
+ }
882
+ else
883
+ {
884
+ // (EF): This triggers on the ground
885
+ // TODO (EF): Do we need to handle this case for beacons?
886
+ // GCS_SEND_TEXT(MAV_SEVERITY_INFO, "posVarianceIsTooLarge w/o extnav or GPS");
887
+ }
888
+
889
+ if ((posTimeout || posVarianceIsTooLarge) && (!velAiding || (gpsGoodToAlign && gpsDataToFuse))) {
878
890
// reset the position to the current external sensor position
879
891
ResetPosition (resetDataSource::DEFAULT);
880
892
@@ -884,7 +896,19 @@ void NavEKF3_core::FuseVelPosNED()
884
896
// Reset the position variances and corresponding covariances to a value that will pass the checks
885
897
zeroRows (P,7 ,8 );
886
898
zeroCols (P,7 ,8 );
887
- P[7 ][7 ] = sq (ftype (0 .5f *frontend->_gpsGlitchRadiusMax ));
899
+ if (extNavDataToFuse)
900
+ {
901
+ P[7 ][7 ] = sq (ftype (0 .5f *extNavDataDelayed.posErr ));
902
+ }
903
+ else if (gpsDataToFuse)
904
+ {
905
+ P[7 ][7 ] = sq (ftype (0 .5f *frontend->_gpsGlitchRadiusMax ));
906
+ }
907
+ else
908
+ {
909
+ // (EF): Doesn't seem to trigger
910
+ GCS_SEND_TEXT (MAV_SEVERITY_INFO, " reset pos variance w/o extnav or GPS" );
911
+ }
888
912
P[8 ][8 ] = P[7 ][7 ];
889
913
890
914
// Reset the normalised innovation to avoid failing the bad fusion tests
@@ -904,7 +928,6 @@ void NavEKF3_core::FuseVelPosNED()
904
928
} else {
905
929
fusePosData = false ;
906
930
}
907
- }
908
931
}
909
932
910
933
// Test velocity measurements
@@ -933,7 +956,7 @@ void NavEKF3_core::FuseVelPosNED()
933
956
if (velTestRatio < 1.0 ) {
934
957
velCheckPassed = true ;
935
958
lastVelPassTime_ms = imuSampleTime_ms;
936
- } else if (frontend->_gpsGlitchRadiusMax <= 0 ) {
959
+ } else if (gpsDataToFuse && frontend->_gpsGlitchRadiusMax <= 0 ) {
937
960
// Handle the special case where the glitch radius parameter has been set to a non-positive number.
938
961
// The innovation variance is increased to limit the state update to an amount corresponding
939
962
// to a test ratio of 1.
0 commit comments