The estimation module provides Kalman filter implementations for navigation and sensor fusion. All functions are stateless utilities that take in a filter state and return an updated state.
Quick Start
constexpr int N = 2;
constexpr int M = 1;
state.x << 0.0, 0.0;
state.P = Eigen::Matrix2d::Identity() * 10.0;
Eigen::Matrix2d F;
F << 1, dt, 0, 1;
Eigen::Matrix<double, M, N> H;
H << 1, 0;
Eigen::Matrix<double, M, 1> z; z << measurement;
Definition EstimationTypes.hpp:8
FilterState< Scalar, N > kf_update(const FilterState< Scalar, N > &state, const Eigen::Matrix< Scalar, M, 1 > &z, const Eigen::Matrix< double, M, N > &H, const MeasurementNoise< M > &noise)
Linear Kalman filter update step.
Definition KalmanFilter.hpp:100
FilterState< Scalar, N > kf_predict(const FilterState< Scalar, N > &state, const Eigen::Matrix< double, N, N > &F, const Eigen::Matrix< double, N, U > &B, const Eigen::Matrix< Scalar, U, 1 > &u, const ProcessNoise< N > &noise)
Linear Kalman filter predict step.
Definition KalmanFilter.hpp:31
Filter state container holding estimate and covariance.
Definition EstimationTypes.hpp:20
static MeasurementNoise< M > scalar(double variance)
Create scalar (isotropic) measurement noise.
Definition EstimationTypes.hpp:98
static ProcessNoise< N > scalar(double variance)
Create scalar (isotropic) process noise.
Definition EstimationTypes.hpp:65
Filter Types
Linear Kalman Filter (KF)
For linear systems with known dynamics:
| Function | Description |
| kf_predict | Propagate state: x⁻ = Fx + Bu, P⁻ = FPFᵀ + Q |
| kf_update | Incorporate measurement with Kalman gain |
| kf_step | Combined predict + update |
Extended Kalman Filter (EKF)
For nonlinear systems with user-provided Jacobians:
auto h = [](const Eigen::Vector2d& x) {
double r = x.norm();
double theta = std::atan2(x(1), x(0));
return Eigen::Vector2d(r, theta);
};
auto H = compute_jacobian(state.x);
FilterState< Scalar, N > ekf_update(const FilterState< Scalar, N > &state, const Eigen::Matrix< Scalar, M, 1 > &z, MeasurementFunc h, const Eigen::Matrix< double, M, N > &H, const MeasurementNoise< M > &noise)
Extended Kalman filter update step.
Definition ExtendedKF.hpp:103
Unscented Kalman Filter (UKF)
For nonlinear systems without requiring Jacobians:
FilterState< double, N > ukf_update(const FilterState< double, N > &state, const Eigen::Matrix< double, M, 1 > &z, MeasurementFunc h, const MeasurementNoise< M > &noise, const UKFParams ¶ms={})
Unscented Kalman filter update step.
Definition UnscentedKF.hpp:187
UKF tuning parameters.
Definition UnscentedKF.hpp:18
double alpha
Spread of sigma points around mean (1e-4 to 1).
Definition UnscentedKF.hpp:19
Utility Functions
Measurement Gating
Reject outlier measurements using chi-squared test:
}
bool passes_gate(const Eigen::Matrix< Scalar, M, 1 > &innovation, const Eigen::Matrix< Scalar, M, M > &S, double threshold)
Chi-squared gating for outlier rejection.
Definition EstimationUtils.hpp:58
double chi_squared_threshold(int dof, double confidence=0.95)
Chi-squared threshold lookup.
Definition EstimationUtils.hpp:136
Joseph Form Update
Numerically stable covariance update:
Eigen::Matrix< double, N, N > joseph_update(const Eigen::Matrix< double, N, N > &P_prior, const Eigen::Matrix< double, N, M > &K, const Eigen::Matrix< double, M, N > &H, const Eigen::Matrix< double, M, M > &R)
Joseph form covariance update.
Definition EstimationUtils.hpp:111
Common Types
| Type | Description |
| FilterState<Scalar, N> | State vector x and covariance P |
| ProcessNoise<N> | Process noise Q with factory methods |
| MeasurementNoise<M> | Measurement noise R with factory methods |
| UKFParams | UKF tuning: alpha, beta, kappa |
When to Use Which Filter
| Scenario | Recommended |
| Linear system | KF |
| Nonlinear, Jacobian available | EKF |
| Nonlinear, Jacobian hard to derive | UKF |
| Highly nonlinear / multi-modal | UKF |
Example Output
=== Linear Kalman Filter Demo ===
Step | True Pos | Est Pos | Est Vel | Pos Error
-----|----------|----------|----------|----------
0 | 0.50 | 0.93 | 0.41 | 0.43
1 | 1.00 | 1.37 | 2.47 | 0.37
...
19 | 10.00 | 9.98 | 4.96 | 0.02
See Also