mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-02 05:04:08 +08:00
Add measurementUpdate function
This commit is contained in:
parent
f6252ff533
commit
404edde7f3
23
EKF/ekf.h
23
EKF/ekf.h
@ -689,6 +689,29 @@ private:
|
||||
return KHP;
|
||||
}
|
||||
|
||||
// measurement update with a single measurement
|
||||
// returns true if fusion is performed
|
||||
template <size_t ...Idxs>
|
||||
bool measurementUpdate(const Vector24f& K, const SparseVector24f<Idxs...>& H, float innovation) {
|
||||
// apply covariance correction via P_new = (I -K*H)*P
|
||||
// first calculate expression for KHP
|
||||
// then calculate P - KHP
|
||||
const SquareMatrix24f KHP = computeKHP(K, H);
|
||||
|
||||
const bool is_healthy = checkAndFixCovarianceUpdate(KHP);
|
||||
|
||||
if (is_healthy) {
|
||||
// apply the covariance corrections
|
||||
P -= KHP;
|
||||
|
||||
fixCovarianceErrors(true);
|
||||
|
||||
// apply the state corrections
|
||||
fuse(K, innovation);
|
||||
}
|
||||
return is_healthy;
|
||||
}
|
||||
|
||||
// if the covariance correction will result in a negative variance, then
|
||||
// the covariance matrix is unhealthy and must be corrected
|
||||
bool checkAndFixCovarianceUpdate(const SquareMatrix24f& KHP);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user