pub struct KalmanFilterXY {
pub pos: Vector2f32,
pub vel: Vector2f32,
pub acc_bias: Vector2f32,
pub P: Matrix3x3xM2x2f32,
pub Q_velocity: f32,
pub Q_bias: f32,
}Expand description
Linear Kalman Filter in 2 dimensions.
Fields§
§pos: Vector2f32Position (x, y).
vel: Vector2f32Velocity (x, y).
acc_bias: Vector2f32Accelerometer Bias (x, y).
P: Matrix3x3xM2x2f32P: Prediction error covariance (aka state covariance matrix, the system’s internal uncertainty).
Q_velocity: f32Process Noise spectral density mapping to Velocity variance.
Q_bias: f32Process Noise spectral density mapping to Sensor Drift variance.
Implementations§
Source§impl KalmanFilterXY
impl KalmanFilterXY
pub fn pos(&self) -> Vector2f32
pub fn vel(&self) -> Vector2f32
pub fn acc_bias(&self) -> Vector2f32
Source§impl KalmanFilterXY
impl KalmanFilterXY
Sourcepub fn predict_state(&mut self, acc_measurement: Vector2f32, dt: f32)
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_true * dT²
vel_k = vel_k₋₁ + acc_true * dTSourcepub fn predict_covariance(&mut self, dt: f32)
pub fn predict_covariance(&mut self, dt: f32)
Predict covariance:
P = F * P * F^T + Q.
P: State covariance matrix F: State transition matrix Q: Process noise covariance.
Source§impl KalmanFilterXY
impl KalmanFilterXY
Sourcepub fn correct_position_delayed(
&mut self,
position: Vector2f32,
past_pos: Vector2f32,
R: Vector2f32,
)
pub fn correct_position_delayed( &mut self, position: Vector2f32, past_pos: Vector2f32, R: Vector2f32, )
Covariance correction step.
S = H * P * H^T + R
K = P * H^T * S^-1
P = (I - K * H) * P.
R is measurement noise covariance.
Sourcepub fn correct_position_delayed_joseph(
&mut self,
position: Vector2f32,
past_pos: Vector2f32,
R: Vector2f32,
)
pub fn correct_position_delayed_joseph( &mut self, position: Vector2f32, past_pos: Vector2f32, R: Vector2f32, )
Joseph’s Stabilized Form for the covariance update step:
P{k} = (I - KH) * P{k-1} * (I - KH)^T + KRK^T).
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.
pub fn correct_position(&mut self, position: Vector2f32, R: Vector2f32)
pub fn correct_position_joseph(&mut self, position: Vector2f32, R: Vector2f32)
Trait Implementations§
Source§impl Clone for KalmanFilterXY
impl Clone for KalmanFilterXY
Source§fn clone(&self) -> KalmanFilterXY
fn clone(&self) -> KalmanFilterXY
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more