#kalman-filter #filter #kalman #zero-allocation #no-std

no-std ukalman

Super tiny zero allocation filters for embedded

1 unstable release

0.1.0 Nov 18, 2022

#12 in #kalman

Download history 14/week @ 2024-02-26 15/week @ 2024-04-01 209/week @ 2024-04-15

224 downloads per month

MIT license

20KB

uKalman

Super tiny zero allocation filters for embedded.

Currently, this crate only implements a tiny 1D kalman filter, useful for smoothing ADCs and similar 1D sensors. In the future, multidimensional and non-linear filters may be added.

use std::io::Read;
use ukalman::Kalman1D;

// Initialises filter
let mut filter = Kalman1D::new(2000.0, 67.4f32.powi(2));

let mut f = std::fs::File::open("test_assets/cap_full_throttle.txt").unwrap();
let mut str = String::new();
f.read_to_string(&mut str).unwrap();

// Estimate over some data
for val in str.lines().flat_map(|s| s.parse::<u16>()) {
    // Filter with a static state model, and small system noise
    let est = filter.filter(val as f32, 191.93f32.powi(2), |x| x, |v| v + 0.001);
    std::println!("{:.0}", est);
}

lib.rs:

Super tiny zero allocation filters for embedded.

Currently this crate only implements a tiny 1D kalman filter, useful for smoothing ADCs and similar 1D sensors. In the future, multidimensional and non-linear filters may be added.


// Initialises filter
let mut filter = Kalman1D::new(2000.0, 67.4f32.powi(2));

let mut f = std::fs::File::open("test_assets/cap_full_throttle.txt").unwrap();
let mut str = String::new();
f.read_to_string(&mut str).unwrap();

// Estimate over some data
for val in str.lines().flat_map(|s| s.parse::<u16>()) {
    // Filter with a static state model, and small system noise
    let est = filter.filter(val as f32, 191.93f32.powi(2), |x| x, |v| v + 0.001);
    std::println!("{:.0}", est);
}

No runtime deps