| Crates.io | kalman |
| lib.rs | kalman |
| version | 0.2.0 |
| created_at | 2025-09-19 10:36:34.685449+00 |
| updated_at | 2025-09-19 18:15:01.820979+00 |
| description | A Rust implementation of the Kalman filter |
| homepage | https://github.com/Asempere123123/kalman |
| repository | https://github.com/Asempere123123/kalman |
| max_upload_size | |
| id | 1846259 |
| size | 1,629,411 |
A simple Rust crate that implements a Kalman filter.
use kalman_crate::KalmanFilter;
use nalgebra::{SVector, SMatrix};
let mut kf = KalmanFilter::new(
SVector::from_row_slice(&[0., 0., 0.]),
&SVector::from_row_slice(&[1e12, 0., 0.]),
|dt, _s| SMatrix::from_row_slice(&[1.0, dt, 0.5 * dt * dt, 0.0, 1.0, dt, 0.0, 0.0, 1.0]),
|_dt, _s| SMatrix::identity(),
1e-10,
);
// You usually do this on a loop
kf.predict(meas, meas_sd, dt);
let state = kf.state();
For a complete example check the tests on src/lib.rs
First you need to create a filter, it has this parameters
(dt, state) -> Matrix that describes state transition(dt, state) -> Matrix that describes control inputTo get the values of F and G this equation must be followed next_x = Fx + Gmeasurement
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