Skip to content

Commit

Permalink
AP_NavEKF3: When dead reckoning, clip but don't reject airspeed
Browse files Browse the repository at this point in the history
  • Loading branch information
priseborough authored and tridge committed Jun 23, 2023
1 parent 7348043 commit 145d703
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions libraries/AP_NavEKF3/AP_NavEKF3_AirDataFusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,16 @@ void NavEKF3_core::FuseAirspeed()
// calculate the innovation consistency test ratio
tasTestRatio = sq(innovVtas) / (sq(MAX(0.01f * (ftype)frontend->_tasInnovGate, 1.0f)) * varInnovVtas);

// fail if the ratio is > 1, but don't fail if bad IMU data
const bool isConsistent = (tasTestRatio < 1.0f) || badIMUdata;
// when dead reckoning using airspeed measurements we cannot allow measurements to be rejected because
// this will cause the EKF to stop navigating so instead clip the measurement and accept it
const bool doingAirDataDeadReckoning = posTimeout || (PV_AidingMode != AID_ABSOLUTE);
ftype innovScaleFactor = 1.0f;
if (doingAirDataDeadReckoning && tasTestRatio > 1.0f) {
innovScaleFactor = sqrtF(1.0f / tasTestRatio);
}

// fail if the ratio is > 1, but don't fail if bad IMU data or doing air data dead reckoning
const bool isConsistent = (tasTestRatio < 1.0f) || badIMUdata || doingAirDataDeadReckoning;
tasTimeout = (imuSampleTime_ms - lastTasPassTime_ms) > frontend->tasRetryTime_ms;
if (!isConsistent) {
lastTasFailTime_ms = imuSampleTime_ms;
Expand All @@ -151,7 +159,7 @@ void NavEKF3_core::FuseAirspeed()

// correct the state vector
for (uint8_t j= 0; j<=stateIndexLim; j++) {
statesArray[j] = statesArray[j] - Kfusion[j] * innovVtas;
statesArray[j] = statesArray[j] - Kfusion[j] * innovVtas * innovScaleFactor;
}
stateStruct.quat.normalize();

Expand Down

0 comments on commit 145d703

Please sign in to comment.