Kalman Crate
A simple Rust crate that implements a Kalman filter.
Example
use KalmanFilter;
use ;
let mut kf = new;
// You usually do this on a loop
kf.predict;
let state = kf.state;
For a complete example check the tests on src/lib.rs
How to use it
First you need to create a filter, it has this parameters
- Initial state: A vector with the initial system state
- Initial uncertainty: A vector with the uncertainty of each state value
- F: Function
(dt, state) -> Matrixthat describes state transition - G: Function
(dt, state) -> Matrixthat describes control input - Variance: Prediction variance, tweakable to adjust filter behavior
To get the values of F and G this equation must be followed next_x = Fx + Gmeasurement
Circular motion example
On src/lib.rs the test_mcu can be found, it tries to predict the position of a circular motion
The state consists of x, y, angle, rotational_velocity, velocity and acceleration
From this, the following equations can be derived

And from that, the shape of both the matrix F and G can be derived

And those are the values used on the example for F and G