![]() |
My Project
|
Kalman implementation. More...
#include <Kalman.h>
Public Member Functions | |
Kalman (int _n) | |
Constructor. More... | |
~Kalman () | |
Destructor. | |
virtual void | update_F (unsigned long tick) |
cv::Mat & | predict (unsigned long tick) |
Predict the Kalman state vector for the given time step This calls updateF for updating the transition matrix based on the real time step. More... | |
cv::Mat & | predict_update (KalmanSensor *sensor, unsigned long tick) |
Predict the Kalman state vector for the given time step and update the state using the Kalman gain. More... | |
double | seconds_since_update (unsigned long tick) |
Helper method. | |
![]() | |
KalmanCore (const KalmanCore &s) | |
Copy constructor. | |
KalmanCore (int _n) | |
Constructor. More... | |
~KalmanCore () | |
Destructor. | |
int | get_n () |
Accessor for n. | |
virtual cv::Mat & | predict () |
Predict the Kalman state vector for the given time step . x_pred = F * x. | |
cv::Mat & | predict_update (KalmanSensorCore *sensor) |
Predict the Kalman state vector and update the state using the constant Kalman gain. x = x_pred + K* ( z - H*x_pred) | |
Public Attributes | |
cv::Mat | P |
The error covariance matrix describing the accuracy of the state estimate. | |
cv::Mat | Q |
The covariance matrix for the process noise. | |
cv::Mat | P_pred |
The predicted error covariance matrix. | |
![]() | |
cv::Mat | x |
The Kalman state vector (n*1) | |
cv::Mat | F |
The matrix (n*n) containing the transition model for the internal state. | |
cv::Mat | x_pred |
Predicted state, TODO: should be protected?! | |
Protected Member Functions | |
void | predict_P () |
![]() | |
virtual void | predict_x (unsigned long tick) |
Protected Attributes | |
int | prev_tick |
![]() | |
int | n |
cv::Mat | F_trans |
Kalman implementation.
The Kalman filter provides an effective way of estimating a system/process recursively (http://www.cs.unc.edu/~welch/media/pdf/kalman_intro.pdf). In this implementation we have separated the Kalman class (KalmanCore, Kalman or KalmanEkf) from the sensor class (KalmanSensorCore, KalmanSensor or KalmanSensorEkf). The selected Kalman class contains always the latest estimation of the process. The estimation can be updated using one or several sensors. This implementation allows SCAAT approach, where there may be several sensors (and several controls) for each Kalman filter (See http://www.cs.unc.edu/~welch/scaat.html).
Currently we have have three levels of implementations for both Kalman and Sensor (core, "normal" and EKF).
The core implementations can be used for really fast bare-bones core implementations when we have precalculated and constant K. In systems where F, H, Q and R are constants the K will converge into a constant and it can be precalculated. Note, that the core implementation need to assume constant frame rate if F depends on the timestep between frames. Note also, that the core-classes cannot use EKF Jacobians because they change the H.
The "normal" implementations are used when we have a linear F for Kalman, or linear H for KalmanSensor. The EKF implementations are used when we have non-linear function f() for KalmanEkf, or non-linear function h() for KalmanSensorEkf.
Furthermore we have a class KalmanVisualize for visualizing the internal state of Kalman.
Note, that now the KalmanControl is left out from this implementation. But it could be added using similar conventions as the KalmanSensor.
Kalman | ( | int | _n | ) |
Constructor.
n | The number of items in the Kalman state vector |
_m | The number of measurements given by this sensor |
cv::Mat& predict | ( | unsigned long | tick | ) |
Predict the Kalman state vector for the given time step This calls updateF for updating the transition matrix based on the real time step.
x_pred = F*x P_pred = F*P*trans(F) + Q
cv::Mat& predict_update | ( | KalmanSensor * | sensor, |
unsigned long | tick | ||
) |
|
virtual |
If your transition matrix F is based on time you need to override this method.
Reimplemented in KalmanEkf.