pub struct SquareRootKalmanFilter<const N: usize, const M: usize> {
pub x: [f32; N],
pub s: [[f32; N]; N],
pub f: [[f32; N]; N],
pub s_q: [[f32; N]; N],
pub h: [[f32; N]; M],
pub s_r: [[f32; M]; M],
}Expand description
Square-Root Covariance Kalman Filter (SRKF) for $N$-state, $M$-measurement linear systems.
Propagates the lower-triangular Cholesky factor $S$ of the covariance matrix ($P = S S^T$). By operating directly on the square-root factors via orthogonal Givens transformations, the filter guarantees numerical positive-definiteness and never diverges due to roundoff error.
Fields§
§x: [f32; N]State estimate vector $\hat{x} \in \mathbb{R}^N$.
s: [[f32; N]; N]Lower-triangular Cholesky factor of state covariance $P = S S^T$.
f: [[f32; N]; N]State transition matrix $F \in \mathbb{R}^{N \times N}$.
s_q: [[f32; N]; N]Lower-triangular Cholesky factor of process noise covariance $Q = S_Q S_Q^T$.
h: [[f32; N]; M]Measurement matrix $H \in \mathbb{R}^{M \times N}$.
s_r: [[f32; M]; M]Lower-triangular Cholesky factor of measurement noise $R = S_R S_R^T$.
Implementations§
Source§impl<const N: usize, const M: usize> SquareRootKalmanFilter<N, M>
impl<const N: usize, const M: usize> SquareRootKalmanFilter<N, M>
Sourcepub fn new(
x0: [f32; N],
s0: [[f32; N]; N],
f: [[f32; N]; N],
s_q: [[f32; N]; N],
h: [[f32; N]; M],
s_r: [[f32; M]; M],
) -> Self
pub fn new( x0: [f32; N], s0: [[f32; N]; N], f: [[f32; N]; N], s_q: [[f32; N]; N], h: [[f32; N]; M], s_r: [[f32; M]; M], ) -> Self
Initialize a new Square-Root Kalman Filter from explicit Cholesky factors.
Sourcepub fn predict(&mut self)
pub fn predict(&mut self)
Predict step: propagates state $\hat{x}^- = F \hat{x}$ and triangularizes $[F S \quad S_Q]$.
Sourcepub fn update(&mut self, z: &[f32; M]) -> Status
pub fn update(&mut self, z: &[f32; M]) -> Status
Update step: updates state $\hat{x}^+$ and factor $S^+$ given measurement vector $z \in \mathbb{R}^M$.
Sourcepub fn covariance(&self) -> [[f32; N]; N]
pub fn covariance(&self) -> [[f32; N]; N]
Reconstructs the full covariance matrix $P = S S^T$.
Trait Implementations§
Auto Trait Implementations§
impl<const N: usize, const M: usize> Freeze for SquareRootKalmanFilter<N, M>
impl<const N: usize, const M: usize> RefUnwindSafe for SquareRootKalmanFilter<N, M>where
[f32; N]: RefUnwindSafe,
[[f32; N]; N]: RefUnwindSafe,
[[f32; N]; M]: RefUnwindSafe,
[[f32; M]; M]: RefUnwindSafe,
impl<const N: usize, const M: usize> Send for SquareRootKalmanFilter<N, M>
impl<const N: usize, const M: usize> Sync for SquareRootKalmanFilter<N, M>
impl<const N: usize, const M: usize> Unpin for SquareRootKalmanFilter<N, M>
impl<const N: usize, const M: usize> UnsafeUnpin for SquareRootKalmanFilter<N, M>where
[f32; N]: UnsafeUnpin,
[[f32; N]; N]: UnsafeUnpin,
[[f32; N]; M]: UnsafeUnpin,
[[f32; M]; M]: UnsafeUnpin,
impl<const N: usize, const M: usize> UnwindSafe for SquareRootKalmanFilter<N, M>where
[f32; N]: UnwindSafe,
[[f32; N]; N]: UnwindSafe,
[[f32; N]; M]: UnwindSafe,
[[f32; M]; M]: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
Source§fn lossless_try_into(self) -> Option<Dst>
fn lossless_try_into(self) -> Option<Dst>
Source§impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
Source§fn lossy_into(self) -> Dst
fn lossy_into(self) -> Dst
Source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Source§impl<T> StrictAs for T
impl<T> StrictAs for T
Source§fn strict_as<Dst>(self) -> Dstwhere
T: StrictCast<Dst>,
fn strict_as<Dst>(self) -> Dstwhere
T: StrictCast<Dst>,
Source§impl<Src, Dst> StrictCastFrom<Src> for Dstwhere
Src: StrictCast<Dst>,
impl<Src, Dst> StrictCastFrom<Src> for Dstwhere
Src: StrictCast<Dst>,
Source§fn strict_cast_from(src: Src) -> Dst
fn strict_cast_from(src: Src) -> Dst
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>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
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
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.