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: ModelNonlinear process / measurement model
Implementations§
Source§impl<const N: usize, const M: usize, Model: EkfModel<N, M>> ExtendedKalmanFilter<N, M, Model>
impl<const N: usize, const M: usize, Model: EkfModel<N, M>> ExtendedKalmanFilter<N, M, Model>
Sourcepub fn new(
x0: [f32; N],
p0: [[f32; N]; N],
q: [[f32; N]; N],
r: [[f32; M]; M],
model: Model,
) -> Self
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.
Sourcepub fn from_variances(
x0: [f32; N],
p_var: f32,
q_var: f32,
r_var: f32,
model: Model,
) -> Self
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.
Sourcepub fn predict_with_input<const U: usize>(&mut self, dt: f32, u: &[f32; U])
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.
Sourcepub fn update(&mut self, z: &[f32; M]) -> Status
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.
Sourcepub fn update_with_input<const U: usize>(
&mut self,
z: &[f32; M],
u: &[f32; U],
) -> Status
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>
impl<const N: usize, const M: usize, Model: Clone> Clone for ExtendedKalmanFilter<N, M, Model>
Source§fn clone(&self) -> ExtendedKalmanFilter<N, M, Model>
fn clone(&self) -> ExtendedKalmanFilter<N, M, Model>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more