Skip to main content

KalmanFilterXY

Struct KalmanFilterXY 

Source
pub struct KalmanFilterXY {
    pub state: KalmanStateXY,
    pub P: Matrix3x3xM2x2f32,
    pub Q_velocity: f32,
    pub Q_bias: f32,
}
Expand description

Linear Kalman Filter in 2 dimensions.

Fields§

§state: KalmanStateXY

2D Kinematic State Vectors.

§P: Matrix3x3xM2x2f32

P: Prediction error covariance (aka state covariance matrix, the system’s internal uncertainty).

§Q_velocity: f32

Process Noise spectral density mapping to Velocity variance.

§Q_bias: f32

Process Noise spectral density mapping to Sensor Drift variance.

Implementations§

Source§

impl KalmanFilterXY

Source

pub fn new() -> Self

Constructor.

Source§

impl KalmanFilterXY

Source

pub fn pos(&self) -> Vector2f32

Source

pub fn vel(&self) -> Vector2f32

Source

pub fn acc_bias(&self) -> Vector2f32

Source§

impl KalmanFilterXY

Source

pub fn predict_state(&mut self, acc_measurement: Vector2f32, dt: f32)

Integrates raw IMU accelerometer data to predict new position and velocity vectors.

This forms the continuous dead reckoning pipeline driving vehicle kinetics forward.

§Physical Mechanics

pos_k = pos_k₋₁ + vel_k₋₁ * dt + 0.5 * acc * dt²
vel_k = vel_k₋₁ + acc * dt
Source

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

Predict covariance:

P = F * P * Fᵀ + Q.

P: State covariance matrix F: State transition matrix Q: Process noise covariance.

Source§

impl KalmanFilterXY

Source

pub fn correct_position_standard_form( &mut self, measurement: Vector2f32, predicted_measurement: Vector2f32, R: Vector2f32, )

Covariance correction step.

S = H * P * Hᵀ + R K = P * Hᵀ * S⁻¹ P = (I - K * H) * P.

R is measurement noise covariance.

Source

pub fn correct_position_joseph_stabilized_form( &mut self, measurement: Vector2f32, predicted_measurement: Vector2f32, R: Vector2f32, )

Joseph’s Stabilized Form for the covariance update step:

P{k} = (I - KH) * P{k-1} * (I - KH)ᵀ + KRKᵀ).

While computationally more expensive, it guarantees the result remains positive-definite. That is it ensures the covariance matrix has positive eigenvalues and remains valid and invertible for future updates.

Source

pub fn correct_position(&mut self, position: Vector2f32, R: Vector2f32)

Source

pub fn correct_position_joseph(&mut self, position: Vector2f32, R: Vector2f32)

Trait Implementations§

Source§

impl Clone for KalmanFilterXY

Source§

fn clone(&self) -> Self

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 Copy for KalmanFilterXY

Source§

impl Debug for KalmanFilterXY

Source§

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

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

impl Default for KalmanFilterXY

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for KalmanFilterXY

Source§

fn eq(&self, other: &Self) -> bool

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for KalmanFilterXY

Auto Trait Implementations§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.