A no-std implementation of the Kalman and Extended Kalman Filter.
See the documentation and examples for usage.
See this blog post to understand why the library looks the way it does.
- Systems for modelling state transition / prediction
- Linear or Non-linear
- With and without inputs
- Measurements for modelling sensors / observations
- Linear or Non-linear
- Single measurement Kalman filter (Kalman1M) or multi-measurment / multi-rate (Kalman)
The example below is a position and velocity 2 state Kalman filter with position measurements.
use kfilter::{Kalman1M, KalmanPredict};
use nalgebra::{Matrix1, Matrix1x2, Matrix2, SMatrix};
// Create a new 2 state kalman filter
let mut k = Kalman1M::new(
Matrix2::new(1.0, 0.1, 0.0, 1.0), // F
SMatrix::identity(), // Q
Matrix1x2::new(1.0, 0.0), // H
SMatrix::identity(), // R
SMatrix::zeros(), // x
);
// Run 100 timesteps
for i in 0..100 {
// predict based on system model
k.predict();
// update based on new measurement
k.update(Matrix1::new(i as f64));
}