Kalman implementation. More...
#include <Kalman.h>
Public Member Functions | |
Kalman (int _n) | |
Constructor. | |
CvMat * | 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. | |
CvMat * | 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. | |
double | seconds_since_update (unsigned long tick) |
Helper method. | |
virtual void | update_F (unsigned long tick) |
~Kalman () | |
Destructor. | |
Public Attributes | |
CvMat * | P |
The error covariance matrix describing the accuracy of the state estimate. | |
CvMat * | P_pred |
The predicted error covariance matrix. | |
CvMat * | Q |
The covariance matrix for the process noise. | |
Protected Member Functions | |
void | predict_P () |
Protected Attributes | |
int | prev_tick |
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.
alvar::Kalman::Kalman | ( | int | _n | ) |
Constructor.
n | The number of items in the Kalman state vector |
_m | The number of measurements given by this sensor |
Definition at line 161 of file Kalman.cpp.
Destructor.
Definition at line 168 of file Kalman.cpp.
CvMat * alvar::Kalman::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
Definition at line 178 of file Kalman.cpp.
void alvar::Kalman::predict_P | ( | ) | [protected] |
Definition at line 153 of file Kalman.cpp.
CvMat * alvar::Kalman::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.
Definition at line 185 of file Kalman.cpp.
double alvar::Kalman::seconds_since_update | ( | unsigned long | tick | ) |
Helper method.
Definition at line 195 of file Kalman.cpp.
void alvar::Kalman::update_F | ( | unsigned long | tick | ) | [virtual] |
If your transition matrix F is based on time you need to override this method.
Reimplemented in alvar::KalmanEkf.
Definition at line 174 of file Kalman.cpp.
CvMat* alvar::Kalman::P |
CvMat* alvar::Kalman::P_pred |
int alvar::Kalman::prev_tick [protected] |
CvMat* alvar::Kalman::Q |