36template <
typename T,
int N_size,
int P_size,
int M_size = 1>
40 using MatrixNN = Eigen::Matrix<T, N_size, N_size>;
41 using MatrixPN = Eigen::Matrix<T, P_size, N_size>;
42 using MatrixNP = Eigen::Matrix<T, N_size, P_size>;
43 using MatrixPP = Eigen::Matrix<T, P_size, P_size>;
44 using MatrixNM = Eigen::Matrix<T, N_size, M_size>;
69 : F(config.F), H(config.H), Q(config.Q), R(config.R), P(config.P),
70 G(config.G), S(
MatrixPP::Zero(P_size, P_size)),
71 K(
MatrixNP::Zero(N_size, P_size)), x(config.x)
84 S = MatrixPP::Zero(P_size, P_size);
85 K = MatrixNP::Zero(N_size, P_size);
95 P = F * P * F.transpose() + Q;
115 x = F * x + G * control;
116 P = F * P * F.transpose() + Q;
139 S = H * P * H.transpose() + R;
143 if (S.determinant() < 1e-3)
146 K = P * H.transpose() * S.inverse();
149 x = x + K * (y - H * x);
182 for (uint32_t i = 0; i < k; i++)
Implementation of a generic Kalman filter using the Eigen library.
const CVectorP getOutput()
Eigen::Matrix< T, N_size, N_size > MatrixNN
Eigen::Vector< T, N_size > CVectorN
Eigen::Matrix< T, P_size, N_size > MatrixPN
void predictWithControl(const CVectorM &control)
Prediction step with previous F matrix and with the control vector.
void predictUpdateF(const MatrixNN &F_new)
Prediction step.
Eigen::Vector< T, P_size > CVectorP
const CVectorN predictState(uint32_t k)
Predicts k steps ahead the state.
const CVectorP getResidual()
void setConfig(const KalmanConfig &config)
Eigen::Matrix< T, P_size, P_size > MatrixPP
const CVectorN getState()
bool correct(const CVectorP &y)
Correction step.
void predictWithControlUpdateF(const MatrixNN &F_new, const CVectorM &control)
Prediction step.
Eigen::Vector< T, M_size > CVectorM
void predict()
Prediction step with previous F matrix.
Eigen::Matrix< T, N_size, M_size > MatrixNM
Eigen::Matrix< T, N_size, P_size > MatrixNP
const CVectorP predictOutput(uint32_t k)
Predicts k steps ahead the output.
Kalman(const KalmanConfig &config)
Creates a Kalman filter object.
This file includes all the types the logdecoder script will decode.
Configuration struct for the Kalman class.