38 template <
int n_states,
int n_inputs,
int n_measurements>
43 static constexpr int n = n_states;
44 static constexpr int m = n_inputs;
45 static constexpr int p = n_measurements;
46 static constexpr int w = 2 *
n + 1;
50 using X_t =
typename Eigen::Matrix<double, n, w>;
51 using Z_t =
typename Eigen::Matrix<double, p, w>;
52 using Pzz_t =
typename Eigen::Matrix<double, p, p>;
53 using K_t =
typename Eigen::Matrix<double, n, p>;
71 using W_t =
typename Eigen::Matrix<double, w, 1>;
82 const char* what()
const throw()
84 return "UKF: taking the square root of covariance update produced NANs!!!";
91 const char* what()
const throw()
93 return "UKF: inverting of Pzz in correction update produced NANs!!!";
153 void setConstants(
const double alpha,
const double kappa,
const double beta);
177 void computeWeights();
179 X_t computeSigmas(
const x_t& x,
const P_t& P)
const;
181 P_t computePaSqrt(
const P_t& P)
const;
185 virtual K_t computeKalmanGain([[maybe_unused]]
const x_t& x, [[maybe_unused]]
const z_t& inn,
const K_t& Pxz,
const Pzz_t& Pzz)
const;
187 double m_alpha, m_kappa, m_beta, m_lambda;
This abstract class defines common interfaces and types for a generic Kalman filter.
Definition kalman_filter.h:26
Eigen::Matrix< double, p, 1 > z_t
Measurement vector type .
Definition kalman_filter.h:35
Eigen::Matrix< double, p, p > R_t
Measurement noise covariance matrix type .
Definition kalman_filter.h:38
Eigen::Matrix< double, n, 1 > x_t
State vector type .
Definition kalman_filter.h:33
Eigen::Matrix< double, n, n > P_t
State uncertainty covariance matrix type .
Definition kalman_filter.h:37
Eigen::Matrix< double, n, n > Q_t
Process noise covariance matrix type .
Definition kalman_filter.h:39
Eigen::Matrix< double, m, 1 > u_t
Input vector type .
Definition kalman_filter.h:34
Implementation of the Unscented Kalman filter .
Definition ukf.h:40
static constexpr int p
Length of the measurement vector of the system.
Definition ukf.h:45
typename Eigen::Matrix< double, p, w > Z_t
Measurement sigma points matrix.
Definition ukf.h:51
typename Base_class::R_t R_t
measurement covariance p*p typedef
Definition ukf.h:67
typename Eigen::Matrix< double, n, w > X_t
State sigma points matrix.
Definition ukf.h:50
void setObservationModel(const observation_model_t &observation_model)
Changes the observation model function.
Definition ukf.hpp:95
static constexpr int w
Number of sigma points/weights.
Definition ukf.h:46
static constexpr int n
Length of the state vector of the system.
Definition ukf.h:43
virtual statecov_t predict(const statecov_t &sc, const u_t &u, const Q_t &Q, double dt) const override
Implements the state prediction step (time update).
Definition ukf.hpp:191
typename Base_class::x_t x_t
state vector n*1 typedef
Definition ukf.h:59
typename Base_class::statecov_t statecov_t
typedef of a helper struct for state and covariance
Definition ukf.h:73
void setConstants(const double alpha, const double kappa, const double beta)
Changes the Unscented Transform parameters.
Definition ukf.hpp:71
typename Base_class::u_t u_t
input vector m*1 typedef
Definition ukf.h:61
void setTransitionModel(const transition_model_t &transition_model)
Changes the transition model function.
Definition ukf.hpp:85
typename Base_class::z_t z_t
measurement vector p*1 typedef
Definition ukf.h:63
static constexpr int m
Length of the input vector of the system.
Definition ukf.h:44
typename std::function< x_t(const x_t &, const u_t &, double)> transition_model_t
function of the state transition model typedef
Definition ukf.h:75
typename Base_class::Q_t Q_t
process covariance n*n typedef
Definition ukf.h:69
typename Base_class::P_t P_t
state covariance n*n typedef
Definition ukf.h:65
typename std::function< z_t(const x_t &)> observation_model_t
function of the observation model typedef
Definition ukf.h:77
typename Eigen::Matrix< double, w, 1 > W_t
weights vector (2n+1)*1 typedef
Definition ukf.h:71
typename Eigen::Matrix< double, n, p > K_t
Kalman gain matrix.
Definition ukf.h:53
UKF()
Convenience default constructor.
Definition ukf.hpp:23
virtual statecov_t correct(const statecov_t &sc, const z_t &z, const R_t &R) const override
Implements the state correction step (measurement update).
Definition ukf.hpp:237
typename Eigen::Matrix< double, p, p > Pzz_t
Pzz helper matrix.
Definition ukf.h:52
Defines KalmanFilter - an abstract class, defining common interfaces and types for a generic Kalman f...
All mrs_lib functions, classes, variables and definitions are contained in this namespace.
Definition attitude_converter.h:24
Helper struct for passing around the state and its covariance in one variable.
Definition kalman_filter.h:47
is thrown when taking the inverse of a matrix fails during kalman gain calculation
Definition ukf.h:90
is thrown when taking the square root of a matrix fails during sigma generation
Definition ukf.h:81
Implements UKF - a class implementing the Unscented Kalman Filter.