pub struct Kalman1D { /* private fields */ }
Expand description
Implementation of Discrete Kalman filter for case when there is only on variable X.
Implementations§
Source§impl Kalman1D
impl Kalman1D
Sourcepub fn new(dt: f32, u: f32, std_dev_a: f32, std_dev_m: f32) -> Self
pub fn new(dt: f32, u: f32, std_dev_a: f32, std_dev_m: f32) -> Self
Creates new Kalman1D
Basic usage:
use kalman_rust::kalman::Kalman1D;
let dt = 0.1; // Single cycle time
let u = 2.0; // Control input
let std_dev_a = 0.25; // Standart deviation of acceleration
let std_dev_m = 1.2; // Standart deviation of measurement
let mut kalman = Kalman1D::new(dt, u, std_dev_a, std_dev_m);
Sourcepub fn predict(&mut self)
pub fn predict(&mut self)
Projects the state and the error covariance ahead Mutates the state vector and the error covariance matrix
Basic usage:
use kalman_rust::kalman::Kalman1D;
let dt = 0.1; // Single cycle time
let u = 2.0; // Control input
let std_dev_a = 0.25; // Standart deviation of acceleration
let std_dev_m = 1.2; // Standart deviation of measurement
let mut kalman = Kalman1D::new(dt, u, std_dev_a, std_dev_m);
let measurements = vec![1.0, 2.0, 3.0, 4.0, 5.0];
for x in measurements.iter() {
// get measurement
kalman.predict();
// then do update
}
Sourcepub fn update(&mut self, _z: f32) -> Result<(), Kalman1DError>
pub fn update(&mut self, _z: f32) -> Result<(), Kalman1DError>
Computes the Kalman gain and then updates the state vector and the error covariance matrix Mutates the state vector and the error covariance matrix.
Basic usage:
use kalman_rust::kalman::Kalman1D;
let dt = 0.1; // Single cycle time
let u = 2.0; // Control input
let std_dev_a = 0.25; // Standart deviation of acceleration
let std_dev_m = 1.2; // Standart deviation of measurement
let mut kalman = Kalman1D::new(dt, u, std_dev_a, std_dev_m);
let measurements = vec![1.0, 2.0, 3.0, 4.0, 5.0];
for x in measurements {
kalman.predict();
kalman.update(x).unwrap(); // assuming that there is noise in measurement
}
Sourcepub fn get_vector_state(&self) -> SVector<f32, 2>
pub fn get_vector_state(&self) -> SVector<f32, 2>
Returns the current state (both X and Vx)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Kalman1D
impl RefUnwindSafe for Kalman1D
impl Send for Kalman1D
impl Sync for Kalman1D
impl Unpin for Kalman1D
impl UnwindSafe for Kalman1D
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.