The extended Kalman filter: it predicts the state with a non-linear motion model and corrects it with measurements from any number of observation models, each linearised about the current estimate.
More...
|
| | ExtendedKalmanFilter (motion_model_type &motion_model) |
| | A filter for the motion model, with the observation models given to update().
|
| template<typename O = ObservationModelTp> |
| | ExtendedKalmanFilter (motion_model_type &motion_model, const O &observation_model) |
| | A filter with an observation model of its own, for update(z).
|
| void | predict (const motion_model_input_type &input) |
| | Predict the state one step with the input, and its covariance with the Q set by set_matrix("Q").
|
| void | predict (const motion_model_input_type &input, const matrix_type &Q) |
| | Predict with the process noise covariance Q of this step, for noise that depends on the input.
|
| template<typename ObservationModel> |
| EKFUpdateResult | update (const ObservationModel &model, const DynVec< real_t > &z, const matrix_type &R, real_t gate=std::numeric_limits< real_t >::infinity()) |
| | Correct the state with the measurement z of the observation model, of noise covariance R. A measurement whose squared Mahalanobis distance is above gate is not used.
|
| EKFUpdateResult | update (const DynVec< real_t > &z) |
| | Correct the state with the measurement z of the filter's own observation model and the R set by set_matrix("R").
|
| void | estimate (const std::tuple< motion_model_input_type, DynVec< real_t > > &input) |
| | predict(), then update(z)
|
| void | set_matrix (const std::string &name, const matrix_type &mat) |
| | Set P, the covariance of the state, Q, of the process noise, or R, of the own observation model's noise.
|
| ExtendedKalmanFilter & | with_matrix (const std::string &name, const matrix_type &mat) |
| bool | has_matrix (const std::string &name) const |
| const matrix_type & | operator[] (const std::string &name) const |
| matrix_type & | operator[] (const std::string &name) |
| const state_type & | get_state () const |
| state_type & | get_state () |
| DynVec< real_t > | state_vector () const |
| | The state as a vector.
|
| real_t | get (const std::string &name) const |
template<typename MotionModelTp, typename ObservationModelTp = void>
class bitsim::estimation::ExtendedKalmanFilter< MotionModelTp, ObservationModelTp >
The extended Kalman filter: it predicts the state with a non-linear motion model and corrects it with measurements from any number of observation models, each linearised about the current estimate.
The motion model keeps the state. It has
- evaluate(input), which moves the state by one step, and
- get_matrix("F") and get_matrix("L"), the Jacobians of that step with respect to the state and to the process noise, at the state before the step.
predict() then propagates the covariance, \(P \leftarrow F P F^T + L Q L^T\).
An observation model says what a sensor should measure in a state. It has
- evaluate(x), the predicted measurement \(h(x)\) for the state as a vector, and
- get_matrix("H"), the Jacobian of h with respect to the state, valid after evaluate;
- optionally has_matrix(name): if it says it has "M", get_matrix("M") is the Jacobian with respect to the measurement noise; otherwise that is the identity;
- optionally residual(z, zpred), for measurements such as angles whose difference needs wrapping.
update(model, z, R, gate) corrects the state with a measurement z of noise covariance R:
\[S = H P H^T + M R M^T, \quad K = P H^T S^{-1}, \quad x \leftarrow x + K (z - h(x)), \quad
P \leftarrow (I - K H) P
\]
unless the squared Mahalanobis distance of the innovation, \(\nu^T S^{-1} \nu\), is above the gate: then it leaves the state alone, which keeps an outlier, a sonar echo off something the map does not have, from pulling the estimate away. Each sensor can have its own model, noise and gate, and be used whenever it has a reading.
The filter can also hold one observation model with its R, as set_matrix("R"), for update(z).