Skip to main content

ExtendedKalmanFilter

Struct ExtendedKalmanFilter 

Source
pub struct ExtendedKalmanFilter<const N: usize, const M: usize, Model> {
    pub x: [f32; N],
    pub p: [[f32; N]; N],
    pub q: [[f32; N]; N],
    pub r: [[f32; M]; M],
    pub model: Model,
}
Expand description

Extended Kalman filter with compile-time dimensions and a user EkfModel.

Measurement dimension M must be ≤ 16. Covariance update uses P ← (I − KH) P.

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)

§model: Model

Nonlinear process / measurement model

Implementations§

Source§

impl<const N: usize, const M: usize, Model: EkfModel<N, M>> ExtendedKalmanFilter<N, M, Model>

Source

pub fn new( x0: [f32; N], p0: [[f32; N]; N], q: [[f32; N]; N], r: [[f32; M]; M], model: Model, ) -> Self

Create an EKF with initial state, covariances, and model.

Source

pub fn from_variances( x0: [f32; N], p_var: f32, q_var: f32, r_var: f32, model: Model, ) -> Self

Create an EKF with diagonal covariances from scalar variances.

Source

pub fn predict(&mut self, dt: f32)

EKF predict: x ← f(x, dt), P ← F P Fᵀ + Q with F = ∂f/∂x.

Source

pub fn predict_with_input<const U: usize>(&mut self, dt: f32, u: &[f32; U])

EKF predict with an exogenous input u, via EkfModel::f_with_input / EkfModel::jacobian_f_with_input. See the module docs for when this is needed instead of ExtendedKalmanFilter::predict.

Source

pub fn update(&mut self, z: &[f32; M]) -> Status

EKF update with measurement z. Linearizes h at the current estimate.

On singular innovation covariance or M > 16, returns an error and leaves state unchanged.

Source

pub fn update_with_input<const U: usize>( &mut self, z: &[f32; M], u: &[f32; U], ) -> Status

EKF update with an exogenous input u, via EkfModel::h_with_input / EkfModel::jacobian_h_with_input. See the module docs for when this is needed instead of ExtendedKalmanFilter::update.

On singular innovation covariance or M > 16, returns an error and leaves state unchanged.

Trait Implementations§

Source§

impl<const N: usize, const M: usize, Model: Clone> Clone for ExtendedKalmanFilter<N, M, Model>

Source§

fn clone(&self) -> ExtendedKalmanFilter<N, M, Model>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<const N: usize, const M: usize, Model: Copy> Copy for ExtendedKalmanFilter<N, M, Model>

Source§

impl<const N: usize, const M: usize, Model: Debug> Debug for ExtendedKalmanFilter<N, M, Model>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<const N: usize, const M: usize, Model: PartialEq> PartialEq for ExtendedKalmanFilter<N, M, Model>

Source§

fn eq(&self, other: &ExtendedKalmanFilter<N, M, Model>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<const N: usize, const M: usize, Model: PartialEq> StructuralPartialEq for ExtendedKalmanFilter<N, M, Model>

Auto Trait Implementations§

§

impl<const N: usize, const M: usize, Model> Freeze for ExtendedKalmanFilter<N, M, Model>
where Model: Freeze,

§

impl<const N: usize, const M: usize, Model> RefUnwindSafe for ExtendedKalmanFilter<N, M, Model>
where Model: RefUnwindSafe,

§

impl<const N: usize, const M: usize, Model> Send for ExtendedKalmanFilter<N, M, Model>
where Model: Send,

§

impl<const N: usize, const M: usize, Model> Sync for ExtendedKalmanFilter<N, M, Model>
where Model: Sync,

§

impl<const N: usize, const M: usize, Model> Unpin for ExtendedKalmanFilter<N, M, Model>
where Model: Unpin,

§

impl<const N: usize, const M: usize, Model> UnsafeUnpin for ExtendedKalmanFilter<N, M, Model>
where Model: UnsafeUnpin,

§

impl<const N: usize, const M: usize, Model> UnwindSafe for ExtendedKalmanFilter<N, M, Model>
where Model: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.