pub struct KalmanFilter<const N: usize, const M: usize> {
pub x: [f32; N],
pub p: [[f32; N]; N],
pub q: [[f32; N]; N],
pub r: [[f32; M]; M],
}Expand description
Const-generic linear Kalman filter: x' = F x (+ B u) + w, z = H x + v.
Measurement dimension M must be ≤ 16 so the innovation covariance can be inverted
with the crate’s stack-limited matrix inverse.
Fields§
§x: [f32; N]State estimate
p: [[f32; N]; N]State covariance P (N×N)
q: [[f32; N]; N]Process noise covariance Q (N×N)
r: [[f32; M]; M]Measurement noise covariance R (M×M)
Implementations§
Source§impl<const N: usize, const M: usize> KalmanFilter<N, M>
impl<const N: usize, const M: usize> KalmanFilter<N, M>
Sourcepub fn new(
x0: [f32; N],
p0: [[f32; N]; N],
q: [[f32; N]; N],
r: [[f32; M]; M],
) -> Self
pub fn new( x0: [f32; N], p0: [[f32; N]; N], q: [[f32; N]; N], r: [[f32; M]; M], ) -> Self
Create a filter with initial state x0, covariance p0, and noise covariances q / r.
Sourcepub fn from_variances(x0: [f32; N], p_var: f32, q_var: f32, r_var: f32) -> Self
pub fn from_variances(x0: [f32; N], p_var: f32, q_var: f32, r_var: f32) -> Self
Create a filter with diagonal P, Q, and R initialized from scalar variances.
Sourcepub fn predict(&mut self, f: &[[f32; N]; N])
pub fn predict(&mut self, f: &[[f32; N]; N])
Prediction without control input: x ← F x, P ← F P Fᵀ + Q.
Trait Implementations§
Source§impl<const N: usize, const M: usize> Clone for KalmanFilter<N, M>
impl<const N: usize, const M: usize> Clone for KalmanFilter<N, M>
Source§fn clone(&self) -> KalmanFilter<N, M>
fn clone(&self) -> KalmanFilter<N, M>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl<const N: usize, const M: usize> Copy for KalmanFilter<N, M>
impl<const N: usize, const M: usize> StructuralPartialEq for KalmanFilter<N, M>
Auto Trait Implementations§
impl<const N: usize, const M: usize> Freeze for KalmanFilter<N, M>
impl<const N: usize, const M: usize> RefUnwindSafe for KalmanFilter<N, M>
impl<const N: usize, const M: usize> Send for KalmanFilter<N, M>
impl<const N: usize, const M: usize> Sync for KalmanFilter<N, M>
impl<const N: usize, const M: usize> Unpin for KalmanFilter<N, M>
impl<const N: usize, const M: usize> UnsafeUnpin for KalmanFilter<N, M>
impl<const N: usize, const M: usize> UnwindSafe for KalmanFilter<N, M>
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