30template <
typename Scalar,
int N,
int U>
32 const Eigen::Matrix<double, N, N> &F,
33 const Eigen::Matrix<double, N, U> &B,
34 const Eigen::Matrix<Scalar, U, 1> &u,
40 F.template cast<Scalar>() * state.x + B.template cast<Scalar>() * u;
43 auto F_scalar = F.template cast<Scalar>();
44 predicted.
P = F_scalar * state.P * F_scalar.transpose() +
45 noise.
Q.template cast<Scalar>();
60template <
typename Scalar,
int N>
62 const Eigen::Matrix<double, N, N> &F,
67 predicted.
x = F.template cast<Scalar>() * state.x;
70 auto F_scalar = F.template cast<Scalar>();
71 predicted.
P = F_scalar * state.P * F_scalar.transpose() +
72 noise.
Q.template cast<Scalar>();
99template <
typename Scalar,
int N,
int M>
101 const Eigen::Matrix<Scalar, M, 1> &z,
102 const Eigen::Matrix<double, M, N> &H,
105 auto H_scalar = H.template cast<Scalar>();
106 auto R_scalar = noise.
R.template cast<Scalar>();
109 Eigen::Matrix<Scalar, M, M> S =
110 H_scalar * state.P * H_scalar.transpose() + R_scalar;
113 Eigen::Matrix<Scalar, N, M> K =
114 state.P * H_scalar.transpose() * S.inverse();
117 Eigen::Matrix<Scalar, M, 1> innovation = z - H_scalar * state.x;
121 updated.
x = state.x + K * innovation;
124 Eigen::Matrix<Scalar, N, N> I = Eigen::Matrix<Scalar, N, N>::Identity();
125 updated.
P = (I - K * H_scalar) * state.P;
144template <
typename Scalar,
int N,
int U,
int M>
147 const Eigen::Matrix<Scalar, M, 1> &z,
const Eigen::Matrix<double, N, N> &F,
148 const Eigen::Matrix<double, N, U> &B,
const Eigen::Matrix<double, M, N> &H,
160template <
typename Scalar,
int N,
int M>
162 const Eigen::Matrix<Scalar, M, 1> &z,
163 const Eigen::Matrix<double, N, N> &F,
164 const Eigen::Matrix<double, M, N> &H,
Definition EstimationTypes.hpp:8
FilterState< Scalar, N > kf_update(const FilterState< Scalar, N > &state, const Eigen::Matrix< Scalar, M, 1 > &z, const Eigen::Matrix< double, M, N > &H, const MeasurementNoise< M > &noise)
Linear Kalman filter update step.
Definition KalmanFilter.hpp:100
FilterState< Scalar, N > kf_step(const FilterState< Scalar, N > &state, const Eigen::Matrix< Scalar, U, 1 > &u, const Eigen::Matrix< Scalar, M, 1 > &z, const Eigen::Matrix< double, N, N > &F, const Eigen::Matrix< double, N, U > &B, const Eigen::Matrix< double, M, N > &H, const ProcessNoise< N > &Q, const MeasurementNoise< M > &R)
Combined Kalman filter step (predict + update).
Definition KalmanFilter.hpp:145
FilterState< Scalar, N > kf_predict(const FilterState< Scalar, N > &state, const Eigen::Matrix< double, N, N > &F, const Eigen::Matrix< double, N, U > &B, const Eigen::Matrix< Scalar, U, 1 > &u, const ProcessNoise< N > &noise)
Linear Kalman filter predict step.
Definition KalmanFilter.hpp:31
Filter state container holding estimate and covariance.
Definition EstimationTypes.hpp:20
Eigen::Matrix< Scalar, N, 1 > x
State estimate.
Definition EstimationTypes.hpp:21
Eigen::Matrix< Scalar, N, N > P
State covariance.
Definition EstimationTypes.hpp:22
Measurement noise specification.
Definition EstimationTypes.hpp:79
Eigen::Matrix< double, M, M > R
Measurement noise covariance.
Definition EstimationTypes.hpp:80
Process noise specification.
Definition EstimationTypes.hpp:46
Eigen::Matrix< double, N, N > Q
Process noise covariance.
Definition EstimationTypes.hpp:47