kalman-cpp
Implementation of Kalman Filter in C++
EKF2 Class Reference

Implemetation of the extended Kalman filter. This class needs to be derived. More...

#include <ekf2.h>

Public Member Functions

 EKF2 ()
 Constructor, nothing happens here. More...
 
 ~EKF2 ()
 Destructur, nothing happens here. More...
 
void InitSystem (int n_states, int n_outputs, const mat &Q, const mat &R)
 Tell me how many states and outputs you have! More...
 
virtual colvec f (const colvec &x, const colvec &u)
 Define model of your system. More...
 
virtual colvec h (const colvec &x)
 Define the output model of your system. More...
 
void InitSystemState (const colvec &x0)
 Initialize the system states. Must be called after InitSystem. If not called, system state is initialized to zero. More...
 
void InitSystemStateCovariance (const mat &P0)
 Initialize the system state covariance. Must be called after InitSystem. If not called, state covariance is initialized to an identity matrix. More...
 
void EKalmanf (const colvec &u)
 Do the extended Kalman iteration step-by-step while simulating the system. Simulating the system is done to calculate system states and outputs. More...
 
void EKalmanf (const colvec &z, const colvec &u)
 Do the extended Kalman iteration step-by-step without simulating the system. Use this if measurement is available and simulating the system is unnecessary. Here, true system states and system outputs do not matter. The only thing that matters is the estimated states. More...
 
colvec * GetCurrentState ()
 Get current simulated true state. More...
 
colvec * GetCurrentOutput ()
 Get current simulated true output. This is analogous to the measurements. More...
 
colvec * GetCurrentEstimatedState ()
 Get current estimated state. This is analogous to the filtered measurements. More...
 
colvec * GetCurrentEstimatedOutput ()
 Get current estimated output. More...
 

Protected Attributes

int nStates_
 Number of the states. More...
 
int nOutputs_
 Number of outputs. More...
 
colvec x_
 State vector. More...
 
colvec z_
 Output matrix. More...
 

Detailed Description

Implemetation of the extended Kalman filter. This class needs to be derived.

Constructor & Destructor Documentation

◆ EKF2()

EKF2::EKF2 ( )

Constructor, nothing happens here.

◆ ~EKF2()

EKF2::~EKF2 ( )

Destructur, nothing happens here.

Member Function Documentation

◆ EKalmanf() [1/2]

void EKF2::EKalmanf ( const colvec &  u)

Do the extended Kalman iteration step-by-step while simulating the system. Simulating the system is done to calculate system states and outputs.

Parameters
uThe applied input to the system

◆ EKalmanf() [2/2]

void EKF2::EKalmanf ( const colvec &  z,
const colvec &  u 
)

Do the extended Kalman iteration step-by-step without simulating the system. Use this if measurement is available and simulating the system is unnecessary. Here, true system states and system outputs do not matter. The only thing that matters is the estimated states.

Parameters
zThe measurement outputs, this is a returned value
uThe applied input to the system

◆ f()

colvec EKF2::f ( const colvec &  x,
const colvec &  u 
)
virtual

Define model of your system.

Parameters
xSystem states
uSystem inputs

◆ GetCurrentEstimatedOutput()

colvec * EKF2::GetCurrentEstimatedOutput ( )

Get current estimated output.

Returns
Current estimated output \(\hat{z}_k\)

◆ GetCurrentEstimatedState()

colvec * EKF2::GetCurrentEstimatedState ( )

Get current estimated state. This is analogous to the filtered measurements.

Returns
Current estimated state \(\hat{x}_k\)

◆ GetCurrentOutput()

colvec * EKF2::GetCurrentOutput ( )

Get current simulated true output. This is analogous to the measurements.

Returns
Current simulated output \(z_k\)

◆ GetCurrentState()

colvec * EKF2::GetCurrentState ( )

Get current simulated true state.

Returns
Current simulated state of the system \(x_k\)

◆ h()

colvec EKF2::h ( const colvec &  x)
virtual

Define the output model of your system.

Parameters
xSystem states

◆ InitSystem()

void EKF2::InitSystem ( int  n_states,
int  n_outputs,
const mat &  Q,
const mat &  R 
)

Tell me how many states and outputs you have!

Parameters
n_statesNumber of the elements on the input vector x
n_outputsNumber of the elements on the otput vector z
QProcess noise covariance
RMeasurement noise covariance

◆ InitSystemState()

void EKF2::InitSystemState ( const colvec &  x0)

Initialize the system states. Must be called after InitSystem. If not called, system state is initialized to zero.

Parameters
x0Inital value for the system state

◆ InitSystemStateCovariance()

void EKF2::InitSystemStateCovariance ( const mat &  P0)

Initialize the system state covariance. Must be called after InitSystem. If not called, state covariance is initialized to an identity matrix.

Parameters
P0Inital value for the state covariance

Member Data Documentation

◆ nOutputs_

int EKF2::nOutputs_
protected

Number of outputs.

◆ nStates_

int EKF2::nStates_
protected

Number of the states.

◆ x_

colvec EKF2::x_
protected

State vector.

◆ z_

colvec EKF2::z_
protected

Output matrix.


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