mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 06:28:27 -04:00
AP_NavEKF2: Add error checking and isolation to pos vel fusion
This commit is contained in:
parent
b1e9207c0f
commit
51a3df0319
@ -495,6 +495,34 @@ void NavEKF2_core::FuseVelPosNED()
|
||||
Kfusion[23] = 0.0f;
|
||||
}
|
||||
|
||||
// update the covariance - take advantage of direct observation of a single state at index = stateIndex to reduce computations
|
||||
// this is a numerically optimised implementation of standard equation P = (I - K*H)*P;
|
||||
for (uint8_t i= 0; i<=stateIndexLim; i++) {
|
||||
for (uint8_t j= 0; j<=stateIndexLim; j++)
|
||||
{
|
||||
KHP[i][j] = Kfusion[i] * P[stateIndex][j];
|
||||
}
|
||||
}
|
||||
// Check that we are not going to drive any variances negative and skip the update if so
|
||||
bool healthyFusion = true;
|
||||
for (uint8_t i= 0; i<=stateIndexLim; i++) {
|
||||
if (KHP[i][i] > P[i][i]) {
|
||||
healthyFusion = false;
|
||||
}
|
||||
}
|
||||
if (healthyFusion) {
|
||||
// update the covariance matrix
|
||||
for (uint8_t i= 0; i<=stateIndexLim; i++) {
|
||||
for (uint8_t j= 0; j<=stateIndexLim; j++) {
|
||||
P[i][j] = P[i][j] - KHP[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
// force the covariance matrix to be symmetrical and limit the variances to prevent ill-condiioning.
|
||||
ForceSymmetry();
|
||||
ConstrainVariances();
|
||||
|
||||
// update the states
|
||||
// zero the attitude error state - by definition it is assumed to be zero before each observaton fusion
|
||||
stateStruct.angErr.zero();
|
||||
|
||||
@ -512,28 +540,40 @@ void NavEKF2_core::FuseVelPosNED()
|
||||
if (obsIndex != 5) {
|
||||
tiltErrVec += stateStruct.angErr;
|
||||
}
|
||||
|
||||
// update the covariance - take advantage of direct observation of a single state at index = stateIndex to reduce computations
|
||||
// this is a numerically optimised implementation of standard equation P = (I - K*H)*P;
|
||||
for (uint8_t i= 0; i<=stateIndexLim; i++) {
|
||||
for (uint8_t j= 0; j<=stateIndexLim; j++)
|
||||
{
|
||||
KHP[i][j] = Kfusion[i] * P[stateIndex][j];
|
||||
// record good fusion status
|
||||
if (obsIndex == 0) {
|
||||
faultStatus.bad_nvel = false;
|
||||
} else if (obsIndex == 1) {
|
||||
faultStatus.bad_evel = false;
|
||||
} else if (obsIndex == 2) {
|
||||
faultStatus.bad_dvel = false;
|
||||
} else if (obsIndex == 3) {
|
||||
faultStatus.bad_npos = false;
|
||||
} else if (obsIndex == 4) {
|
||||
faultStatus.bad_epos = false;
|
||||
} else if (obsIndex == 5) {
|
||||
faultStatus.bad_dpos = false;
|
||||
}
|
||||
}
|
||||
for (uint8_t i= 0; i<=stateIndexLim; i++) {
|
||||
for (uint8_t j= 0; j<=stateIndexLim; j++) {
|
||||
P[i][j] = P[i][j] - KHP[i][j];
|
||||
} else {
|
||||
// record bad fusion status
|
||||
if (obsIndex == 0) {
|
||||
faultStatus.bad_nvel = true;
|
||||
} else if (obsIndex == 1) {
|
||||
faultStatus.bad_evel = true;
|
||||
} else if (obsIndex == 2) {
|
||||
faultStatus.bad_dvel = true;
|
||||
} else if (obsIndex == 3) {
|
||||
faultStatus.bad_npos = true;
|
||||
} else if (obsIndex == 4) {
|
||||
faultStatus.bad_epos = true;
|
||||
} else if (obsIndex == 5) {
|
||||
faultStatus.bad_dpos = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// force the covariance matrix to be symmetrical and limit the variances to prevent ill-condiioning.
|
||||
ForceSymmetry();
|
||||
ConstrainVariances();
|
||||
|
||||
// stop performance timer
|
||||
hal.util->perf_end(_perf_FuseVelPosNED);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user