Class Filter

Inheritance Relationships

Base Types

Derived Types

Class Documentation

class Filter : public lupnt::Object<Filter>, public lupnt::DataLogger

Abstract base class for recursive (sequential) navigation filters that maintain a state estimate x_ and covariance P_, propagated by f_dyn_/f_proc_ and corrected by f_meas_.

Concrete filters (EKF, UDUEKF, UKF) implement the Predict/Update pair below with algorithm-specific propagation/correction math. Application code (e.g. the LNSS/rover applications) configures a Filter via SetDynamicsFunction/SetProcessNoiseFunction/ SetMeasurementFunction, initializes x_/P_ via SetState/SetCovariance, and then drives the estimation loop by alternating Predict(t) (propagate to time t) and Update(z_true) (incorporate a new measurement vector).

Subclassed by lupnt::KalmanFilter, lupnt::UKF

Public Functions

Filter() = default
inline Filter(Config &config)

Construct a filter from a YAML config node, taking its name field (or the auto-generated object id if absent).

virtual ~Filter() = default
inline void SetName(const std::string &name)

Set the filter’s display/log name (used as the prefix for Log entries).

inline std::string GetName() const

Get the filter’s display/log name.

inline void SetDynamicsFunction(FilterDynamicsFunction f_dyn)

Register the state-propagation function used by Predict.

inline void SetProcessNoiseFunction(ProcessNoiseFunction f_proc)

Register the process-noise covariance function used by Predict.

inline void SetMeasurementFunction(FilterMeasurementFunction f_meas)

Register the measurement-prediction function used by Update.

inline void SetTime(Real t)

Set the filter’s current epoch t_ (used as the t0 argument of the next Predict call).

inline virtual void SetState(const State &x)

Initialize the state estimate x_ (and prior/posterior copies) at filter setup.

Called once by application setup code before the estimation loop begins. Overridden by UDUEKF::SetCovariance’s sibling (see SetCovariance) but SetState itself is not specialized by the UD filter.

Parameters:

x – Initial state estimate

inline virtual void SetCovariance(const MatXd &P)

Initialize the state covariance P_ (and prior/posterior copies) at filter setup.

Called once by application setup code before the estimation loop begins. UDUEKF::SetCovariance overrides this to additionally factor P into U_/D_diag_.

Parameters:

P – Initial state covariance matrix, size [n_x x n_x]

virtual void Predict(Real t, const State *u = nullptr) = 0

Propagate the state estimate and covariance from the current epoch t_ to time t, using f_dyn_/f_proc_, storing the result in x_/P_ (and the prior copies x_prior_/P_prior_).

Called once per estimation step (before Update) by the application’s filtering loop, e.g. once per epoch in the LNSS/rover navigation applications. EKF::Predict linearizes via the STM F_ from f_dyn_; UKF::Predict propagates unscented transform sigma points; UDUEKF::Predict does the same as EKF::Predict but maintains P_ as a UDU (Bierman-Thornton) factorization.

Parameters:
  • t – Target epoch to propagate to [s]

  • u – Optional control/input state passed through to f_dyn_ (nullptr if unused)

virtual void Update(const VecX &z_true) = 0

Incorporate a new measurement vector z_true into the state estimate and covariance via f_meas_, updating x_/P_ (and the posterior copies x_post_/P_post_).

Called once per estimation step (after Predict) whenever a new measurement is available. EKF::Update performs a linearized Joseph-form Kalman update; UKF::Update performs an unscented-transform-based update; UDUEKF::Update performs a sequential Carlson (UD/Bierman-Thornton) update.

Parameters:

z_true – Observed measurement vector, size [n_z]

inline Real GetTime()

Get the filter’s current epoch [s].

inline State GetState()

Get the current state estimate.

inline State GetStatePrior()

Get the predicted (pre-update) state estimate from the last Predict call.

inline State GetStatePost()

Get the corrected (post-update) state estimate from the last Update call.

inline MatXd GetCovariance()

Get the current state covariance, size [n_x x n_x].

inline MatXd GetCovariancePrior()

Get the predicted (pre-update) state covariance from the last Predict call.

inline MatXd GetCovariancePost()

Get the corrected (post-update) state covariance from the last Update call.

inline MatXd GetCovarianceBar()

Get the propagated-only covariance F P F^T (before adding process noise) from the last Predict call.

double ComputeResidualRMS(VecXd z_true, const State &x_est)

Compute the (unweighted-by-size) chi-square measurement residual sum sum_i dz_i^2 / R_ii for z_true against the measurement predicted at x_est, skipping any NaN or non-positive-variance components.

Used as a goodness-of-fit / outlier diagnostic; returns 0 if z_true is empty.

Parameters:
  • z_true – Observed measurement vector, size [n_z] (or empty)

  • x_estState at which to evaluate the measurement function f_meas_

Returns:

Sum of squared, variance-normalized measurement residuals

virtual void Log(Real time) override

Log the current epoch, state, and covariance diagonals (current, prior, and posterior) to the DataLogger under the <name_>/... keys.

Called once per estimation step by the application’s logging loop to record filter history for post-run analysis/plotting.

Parameters:

time – Current simulation time [s] (unused; t_ is logged instead)

Protected Attributes

Config config_
std::string name_
FilterDynamicsFunction f_dyn_
ProcessNoiseFunction f_proc_
FilterMeasurementFunction f_meas_
Real t_ = 0.0
State x_
State x_prior_
State x_post_
MatXd P_
MatXd P_prior_
MatXd P_post_
MatXd P_bar_