My Project
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Kalman Class Reference

Kalman implementation. More...

#include <Kalman.h>

Inheritance diagram for Kalman:
KalmanCore KalmanEkf

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.

 
- Public Member Functions inherited from KalmanCore
 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.
 
- Public Attributes inherited from KalmanCore
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 ()
 
- Protected Member Functions inherited from KalmanCore
virtual void predict_x (unsigned long tick)
 

Protected Attributes

int prev_tick
 
- Protected Attributes inherited from KalmanCore
int n
 
cv::Mat F_trans
 

Detailed Description

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.

Definition at line 201 of file Kalman.h.

Constructor & Destructor Documentation

◆ Kalman()

Kalman ( int  _n)

Constructor.

Parameters
nThe number of items in the Kalman state vector
_mThe number of measurements given by this sensor

Member Function Documentation

◆ predict()

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

◆ predict_update()

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.

  • Calls first the predict to ensure that the prediction is based on same timestep as the update
  • K = P_pred * trans(H) * inv(H*P_pred*trans(H) + R)
  • x = x_pred + K* ( z - H*x_pred)
  • P = (I - K*H) * P_pred

◆ update_F()

virtual void update_F ( unsigned long  tick)
virtual

If your transition matrix F is based on time you need to override this method.

Reimplemented in KalmanEkf.


The documentation for this class was generated from the following file: