|
| | UnscentedKalmanFilter (const std::function< StateVector(const StateVector &, const InputVector &)> &f, const std::function< OutputVector(const StateVector &, const InputVector &)> &h, const WithInputIntegrator &integrator, const StateVector &state_stddevs, const OutputVector &measurement_stddevs) |
| |
| | UnscentedKalmanFilter (const std::function< StateVector(const StateVector &, const InputVector &)> &f, const std::function< OutputVector(const StateVector &, const InputVector &)> &h, const WithInputIntegrator &integrator, const StateVector &state_stddevs, const OutputVector &measurement_stddevs, const std::function< StateVector(const EMat< STATES, NUM_SIGMAS > &, const EVec< NUM_SIGMAS > &)> &mean_func_X, const std::function< OutputVector(const EMat< OUTPUTS, NUM_SIGMAS > &, const EVec< NUM_SIGMAS > &)> &mean_func_Y, const std::function< StateVector(const StateVector &, const StateVector &)> &residual_func_X, const std::function< OutputVector(const OutputVector &, const OutputVector &)> &residual_func_Y, const std::function< StateVector(const StateVector &, const StateVector &)> &add_func_X) |
| |
| StateMatrix | S () const |
| |
| double | S (int i, int j) const |
| |
| void | set_S (const StateMatrix &S) |
| |
| StateMatrix | P () const |
| |
| void | set_P (const StateMatrix &P) |
| |
| StateVector | xhat () const |
| |
| double | xhat (int i) const |
| |
| void | set_xhat (const StateVector &xhat) |
| |
| void | set_xhat (int i, double value) |
| |
| void | reset () |
| |
| void | predict (const InputVector &u, double dt) |
| |
| void | correct (const InputVector &u, const OutputVector &y) |
| |
| void | correct (const InputVector &u, const OutputVector &y, const EVec< OUTPUTS > &measurement_stddevs) |
| |
| template<int ROWS> |
| void | correct (const InputVector &u, const EVec< ROWS > &y, const std::function< EVec< ROWS >(const StateVector &, const InputVector &)> &h, const EVec< ROWS > &measurement_stddevs) |
| |
| template<int ROWS> |
| void | correct (const InputVector &u, const EVec< ROWS > &y, const std::function< EVec< ROWS >(const StateVector &, const InputVector &)> &h, const EVec< ROWS > measurement_stddevs, const std::function< EVec< ROWS >(const EMat< ROWS, NUM_SIGMAS > &, const EVec< NUM_SIGMAS > &)> &mean_func_Y, const std::function< EVec< ROWS >(const EVec< ROWS > &, const EVec< ROWS > &)> &residual_func_Y, const std::function< StateVector(const StateVector &, const StateVector &)> &residual_func_X, const std::function< StateVector(const StateVector &, const StateVector &)> &add_func_X) |
| |
template<int STATES, int INPUTS, int OUTPUTS>
class UnscentedKalmanFilter< STATES, INPUTS, OUTPUTS >
Kalman filters combine predictions from a model and measurements to estimate a system's true state.
The Unscented Kalman Filter is a nonlinear estimator, meaning that the model used to predict how the state changes over time can be nonlinear. The model that determines the expected measurement given the current state can also be nonlinear.
At each timestep, sigma points are generated close to the mean, they are all propagated forward in time according to the nonlinear model. The Unscented Transform uses the propagated sigma points to compute the prior state and covariance.
When correcting the state and covariance with a measurement, sigma points are again generated, but are transformed into the measurement space using the measurement function. A Kalman gain matrix K is then computed, and used to update the state and covariance.
To read more about Kalman filters and the standard UKF read: https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python
This implementation is somewhat non-standard. The square-root form of the UKF (SR-UKF) is used, and the way the sigma points are generated is different than most implementations. The square-root form is used to ensure that the covariance matrix remains positive definite.
To learn more about the SR-UKF, and see the exact formulation that most of this implementation follows, read: https://www.researchgate.net/publication/3908304
The sigma points are not generated symmetrically around the mean, instead they are generated as vertices of a simplex. Using N = # of states, this method uses N + 2 sigma points instead of the standard 2N + 1 sigma points. This reduces computation up to 50%. To learn more about this method, read: https://www.sciencedirect.com/science/article/pii/S0888327020308190
This filter uses a method of "recalibrating" by essentially applying a measurement twice instead of once, and only using it if it is more accurate than before the measurement was applied. To learn more about this framework for nonlinear filters, read: https://arxiv.org/pdf/2407.05717
- Template Parameters
-
| STATES | Dimension of the state vector. |
| INPUTS | Dimension of the control input vector. |
| OUTPUTS | Dimension of the measurement vector. |