Skip to main content

flight_solver/rls/
mod.rs

1//! Recursive Least Squares (RLS) solvers for online parameter estimation.
2//!
3//! Two solver variants are provided:
4//!
5//! | Variant | Internal state | Numerical properties |
6//! |---------|---------------|---------------------|
7//! | [`standard`] | Covariance `P` | Requires numerical guards; matches indiflight C reference |
8//! | [`inverse_qr`] | Info-matrix factor `L` | Inherently well-conditioned; no guards needed |
9//!
10//! Both support exponential forgetting (`λ`) and parallel multi-output mode
11//! with shared regressors.
12//!
13//! # Quick start
14//!
15//! ```no_run
16//! use flight_solver::rls::{RlsParallel, CovarianceGuards};
17//!
18//! // 4 regressors, 3 parallel outputs (e.g. motor → roll/pitch/yaw)
19//! let mut rls = RlsParallel::<4, 3>::new(1e2, 0.995, CovarianceGuards::default());
20//!
21//! // Each control loop iteration:
22//! let a = nalgebra::SVector::<f32, 4>::new(0.1, -0.2, 0.3, 0.05);
23//! let y = nalgebra::SVector::<f32, 3>::new(0.5, -0.3, 0.1);
24//! let _stats = rls.update(&a, &y);
25//!
26//! let params = rls.params(); // 4×3 estimated parameter matrix
27//! ```
28
29pub mod inverse_qr;
30pub mod standard;
31pub mod types;
32
33pub use self::types::{CovarianceGuards, ExitCode, UpdateStats};
34pub use inverse_qr::InverseQrRls;
35pub use standard::{Rls, RlsParallel};