Vulcan
Aerospace Engineering Utilities Built on Janus
Loading...
Searching...
No Matches
State Estimation

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

using namespace vulcan::estimation;
// 2D position/velocity tracking
constexpr int N = 2; // State: [pos, vel]
constexpr int M = 1; // Measurement: pos only
// Initialize filter
state.x << 0.0, 0.0;
state.P = Eigen::Matrix2d::Identity() * 10.0;
// System matrices
Eigen::Matrix2d F;
F << 1, dt, 0, 1; // Constant velocity
Eigen::Matrix<double, M, N> H;
H << 1, 0; // Observe position
// Noise specification
auto Q = ProcessNoise<N>::scalar(0.01);
// Run one step
state = kf_predict<double, N>(state, F, Q);
Eigen::Matrix<double, M, 1> z; z << measurement;
state = kf_update<double, N, M>(state, z, H, R);
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:

// Nonlinear measurement (range-bearing)
auto h = [](const Eigen::Vector2d& x) {
double r = x.norm();
double theta = std::atan2(x(1), x(0));
return Eigen::Vector2d(r, theta);
};
// Jacobian at current state
auto H = compute_jacobian(state.x);
state = ekf_update<double, N, M>(state, z, h, H, R);
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:

UKFParams params;
params.alpha = 0.1; // Sigma point spread
// No Jacobian needed!
state = ukf_update<N, M>(state, z, h, R, params);
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 &params={})
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:

double threshold = chi_squared_threshold(M, 0.95);
if (passes_gate<double, M>(innovation, S, threshold)) {
state = kf_update(...);
}
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:

auto P = joseph_update<N, M>(P_prior, K, H, R);
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