kalman
Class CvKalman

java.lang.Object
  extended by kalman.CvKalman

public class CvKalman
extends java.lang.Object

Kalman filter (state).

The structure CvKalman is used to keep Kalman filter state. It is created by constructor function, updated by cvKalmanPredict and cvKalmanCorrect functions.

Normally, the structure is used for standard Kalman filter (notation and the formulae below are borrowed from the excellent Kalman tutorial [Welch95]):

 xk=A*xk-1+B*uk+wk
 zk=Hxk+vk,
 

where:

 xk (xk-1) - state of the system at the moment k (k-1)
 zk - measurement of the system state at the moment k
 uk - external control applied at the moment k
 wk and vk are normally-distributed process and measurement noise, respectively:
 p(w) ~ N(0,Q)
 p(v) ~ N(0,R),
 that is,
 Q - process noise covariance matrix, constant or variable,
 R - measurement noise covariance matrix, constant or variable
 

In case of standard Kalman filter, all the matrices: A, B, H, Q and R are initialized once after CvKalman structure is allocated via constructor. However, the same structure and the same functions may be used to simulate extended Kalman filter by linearizing extended Kalman filter equation in the current system state neighborhood, in this case A, B, H (and, probably, Q and R) should be updated on every step.


Constructor Summary
CvKalman(int dynam_params, int measure_params)
          Constructor in case of no control.
CvKalman(int dynam_params, int measure_params, int control_params)
          The function cvCreateKalman allocates CvKalman and all its matrices and initializes them somehow.
 
Method Summary
 CvMat cvKalmanCorrect(CvMat measurement)
          Adjusts model state.
 CvMat cvKalmanPredict(CvMat control)
          Estimates subsequent model state.
static void main(java.lang.String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CvKalman

public CvKalman(int dynam_params,
                int measure_params,
                int control_params)
         throws java.lang.Exception
The function cvCreateKalman allocates CvKalman and all its matrices and initializes them somehow.

Parameters:
dynam_params -
measure_params -
control_params -
Throws:
java.lang.Exception - Kalman Exception.

CvKalman

public CvKalman(int dynam_params,
                int measure_params)
         throws java.lang.Exception
Constructor in case of no control.

Parameters:
dynam_params -
measure_params -
Throws:
java.lang.Exception
Method Detail

cvKalmanPredict

public CvMat cvKalmanPredict(CvMat control)
Estimates subsequent model state.

The function cvKalmanPredict estimates the subsequent stochastic model state by its current state and stores it at kalman->state_pre:

 x'k=A*xk+B*uk
 P'k=A*Pk-1*AT + Q,
 where
 x'k is predicted state (kalman->state_pre),
 xk-1 is corrected state on the previous step (kalman->state_post)
     (should be initialized somehow in the beginning, zero vector by default),
 uk is external control (control parameter),
 P'k is priori error covariance matrix (kalman->error_cov_pre)
 Pk-1 is posteriori error covariance matrix on the previous step (kalman->error_cov_post)
     (should be initialized somehow in the beginning, identity matrix by default),
 

Parameters:
control - Control vector (uk), should be NULL if there is no external control (control_params=0).
Returns:
The function returns the estimated state.

cvKalmanCorrect

public CvMat cvKalmanCorrect(CvMat measurement)
Adjusts model state.
const CvMat* cvKalmanCorrect( CvKalman* kalman, const CvMat* measurement );
#define cvKalmanUpdateByMeasurement cvKalmanCorrect

kalman
Pointer to the structure to be updated.
measurement
Pointer to the structure CvMat containing the measurement vector.

The function cvKalmanCorrect adjusts stochastic model state on the basis of the given measurement of the model state:

Kk=P'k*HT*(H*P'k*HT+R)-1

xk=x'k+Kk*(zk-H*x'k)
Pk=(I-Kk*H)*P'k

where
zk - given measurement (mesurement parameter)
Kk - Kalman "gain" matrix.

The function stores adjusted state at kalman->state_post and returns it on output.

Parameters:
measurement -
Returns:

main

public static void main(java.lang.String[] args)