11#include <ArduinoEigen.h>
21#define DIM_Z NUM_LANDMARKS
51 const Matrix<double, DIM_X, 1>&
vecX()
const {
return m_vecX; }
63 const Matrix<double, DIM_X, DIM_X>&
matP()
const {
return m_matP; }
70 void predict(
const Matrix<double, DIM_X, DIM_X>& matF,
const Matrix<double, DIM_X, DIM_X>& matQ)
82 void correct(
const Matrix<double, DIM_Z, 1>& vecZ,
const Matrix<double, DIM_Z, DIM_Z>& matR,
const Matrix<double, DIM_Z, DIM_X>& matH)
84 const Matrix<double, DIM_X, DIM_X> matI = Matrix<double, DIM_X, DIM_X>::Identity();
85 const Matrix<double, DIM_Z, DIM_Z> matSk = matH *
m_matP * matH.transpose() + matR;
86 const Matrix<double, DIM_X, DIM_Z> matKk =
m_matP * matH.transpose() * matSk.inverse();
99 template<
typename PredictionModelCallback>
100 void predictEkf(PredictionModelCallback
predictionModel,
const Matrix<double, DIM_X, DIM_X>& matJacobF,
const Matrix<double, DIM_X, DIM_X>& matQ)
103 m_matP = matJacobF *
m_matP * matJacobF.transpose() + matQ;
114 template<
typename MeasurementModelCallback>
115 void correctEkf(MeasurementModelCallback measurementModel,
const Matrix<double, DIM_Z, 1>& vecZ,
const Matrix<double, DIM_Z, DIM_Z>& matR,
const Matrix<double, DIM_Z, DIM_X>& matJcobH)
117 const Matrix<double, DIM_X, DIM_X> matI = Matrix<double, DIM_X, DIM_X>::Identity();
118 const Matrix<double, DIM_Z, DIM_Z> matSk = matJcobH *
m_matP * matJcobH.transpose() + matR;
119 const Matrix<double, DIM_X, DIM_Z> matKk =
m_matP * matJcobH.transpose() * matSk.inverse();
126 Matrix<double, DIM_X, 1>
m_vecX{ Matrix<double, DIM_X, 1>::Zero() };
127 Matrix<double, DIM_X, DIM_X>
m_matP{ Matrix<double, DIM_X, DIM_X>::Zero() };
136static Matrix<double, DIM_X, 1>
x_kminus1 = (Eigen::Matrix<double, DIM_X, 1>() << 0.0, 0.0, 0.0).finished();
138static Matrix<double, NUM_LANDMARKS, 3>
landmarkPositions { Matrix<double, NUM_LANDMARKS, 3>::Zero() };
145Matrix<double, DIM_X, 1>
predictionModel(
const Matrix<double, DIM_X, 1>& currentState);
Extended Kalman Filter (EKF) class for state estimation.
Definition: extended-kalman.h:28
void predictEkf(PredictionModelCallback predictionModel, const Matrix< double, DIM_X, DIM_X > &matJacobF, const Matrix< double, DIM_X, DIM_X > &matQ)
Perform the prediction step of the EKF using a user-defined prediction model.
Definition: extended-kalman.h:100
void correctEkf(MeasurementModelCallback measurementModel, const Matrix< double, DIM_Z, 1 > &vecZ, const Matrix< double, DIM_Z, DIM_Z > &matR, const Matrix< double, DIM_Z, DIM_X > &matJcobH)
Perform the correction step of the EKF using a user-defined measurement model.
Definition: extended-kalman.h:115
Matrix< double, DIM_X, DIM_X > m_matP
estimated state vector
Definition: extended-kalman.h:127
void predict(const Matrix< double, DIM_X, DIM_X > &matF, const Matrix< double, DIM_X, DIM_X > &matQ)
Perform the prediction step of the EKF.
Definition: extended-kalman.h:70
Matrix< double, DIM_X, 1 > m_vecX
Definition: extended-kalman.h:126
~EKF_Filter()
Destructor of Kalman-Filter Object, cleanup recources.
Definition: extended-kalman.h:39
const Matrix< double, DIM_X, 1 > & vecX() const
Get the estimated state vector (const version).
Definition: extended-kalman.h:51
void correct(const Matrix< double, DIM_Z, 1 > &vecZ, const Matrix< double, DIM_Z, DIM_Z > &matR, const Matrix< double, DIM_Z, DIM_X > &matH)
Perform the correction step of the EKF.
Definition: extended-kalman.h:82
void read_landmarks_from_eeprom(void)
state covariance matrix
Definition: extended-kalman.cpp:11
Matrix< double, DIM_X, 1 > & vecX()
Get the estimated state vector.
Definition: extended-kalman.h:45
const Matrix< double, DIM_X, DIM_X > & matP() const
Get the state covariance matrix (const version).
Definition: extended-kalman.h:63
EKF_Filter()
Default constructor for the EKF_Filter class. Initializes the EKF and reads the Anchor positions from...
Definition: extended-kalman.cpp:6
Matrix< double, DIM_X, DIM_X > & matP()
Get the state covariance matrix.
Definition: extended-kalman.h:57
Defines custom data types used in the UWB device code.
Definition: extended-kalman.h:18
static Matrix< double, NUM_LANDMARKS, 3 > landmarkPositions
Definition: extended-kalman.h:138
Matrix< double, DIM_X, 1 > predictionModel(const Matrix< double, DIM_X, 1 > ¤tState)
Prediction model for the Extended Kalman Filter (EKF).
Definition: extended-kalman.cpp:22
Matrix< double, DIM_Z, DIM_X > calculateJacobianMatrix(const Matrix< double, DIM_X, 1 > &vecX)
Calculate the Jacobian matrix for the measurement model.
Definition: extended-kalman.cpp:39
static uint32_t lastTime
Definition: extended-kalman.h:135
static Matrix< double, DIM_X, 1 > x_kminus1
Definition: extended-kalman.h:136
Matrix< double, DIM_Z, 1 > calculateMeasurement(const Matrix< double, DIM_X, 1 > ¤tPosition)
Calculate the measurement vector.
Definition: extended-kalman.cpp:58