This is a C++ implementation of the famous Kalman Filter.
It use the Eigen Library for matrix manipulation and calculation.
- KalmanFilter.h - Kalman class declaration
- KalmanFilter.cpp - Kalman class implementation
- main.cpp - Example that use the Kalman class
- makefile
The example is based on a monodimensional problem explained here (look for: A Simple Example):
http://bilgin.esme.org/BitsAndBytes/KalmanFilterforDummies
It simulate a noisy voltage reading from a constant source.
- Download or clone the repo
- Install Eigen Library (https://eigen.tuxfamily.org/dox/GettingStarted.html)
On Mac you could simply do:brew install eigen
.
NOTE: Maybe you need to change the include path in the makefile:-I /usr/local/include/eigen3
- Open Terminal ->
cd
to this directory -> $make
-> $./main
You should see the voltage filter output values
You have to use the correct dimension for the matrix:
n: State vector dimension
m: Control vector dimension (input)
A: n x n
B: n x m
H: n x n
Q: n x n
R: n x n
I: n x n
X: n x 1
U: m x 1
Z: n x 1
P: n x n
K: n x n
If the problem has not input, use the setFixed()
and predict()
functions versions that doesn't not need the input control vector (vector U) and the matrix B.