Class Filter¶
Defined in File filter.h
Inheritance Relationships¶
Base Types¶
public lupnt::Object< Filter >(Template Class Object)public lupnt::DataLogger(Class DataLogger)
Derived Types¶
public lupnt::KalmanFilter(Class KalmanFilter)public lupnt::UKF(Class UKF)
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 covarianceP_, propagated byf_dyn_/f_proc_and corrected byf_meas_.Concrete filters (EKF, UDUEKF, UKF) implement the
Predict/Updatepair below with algorithm-specific propagation/correction math. Application code (e.g. the LNSS/rover applications) configures aFilterviaSetDynamicsFunction/SetProcessNoiseFunction/SetMeasurementFunction, initializesx_/P_viaSetState/SetCovariance, and then drives the estimation loop by alternatingPredict(t)(propagate to timet) andUpdate(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
namefield (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
Logentries).
-
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 thet0argument of the nextPredictcall).
-
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 (seeSetCovariance) butSetStateitself 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::SetCovarianceoverrides this to additionally factorPintoU_/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 timet, usingf_dyn_/f_proc_, storing the result inx_/P_(and the prior copiesx_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::Predictlinearizes via the STMF_fromf_dyn_;UKF::Predictpropagates unscented transform sigma points;UDUEKF::Predictdoes the same asEKF::Predictbut maintainsP_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_trueinto the state estimate and covariance viaf_meas_, updatingx_/P_(and the posterior copiesx_post_/P_post_).Called once per estimation step (after
Predict) whenever a new measurement is available.EKF::Updateperforms a linearized Joseph-form Kalman update;UKF::Updateperforms an unscented-transform-based update;UDUEKF::Updateperforms a sequential Carlson (UD/Bierman-Thornton) update.- Parameters:
z_true – Observed measurement vector, size [n_z]
-
inline State GetStatePrior()¶
Get the predicted (pre-update) state estimate from the last
Predictcall.
-
inline State GetStatePost()¶
Get the corrected (post-update) state estimate from the last
Updatecall.
-
inline MatXd GetCovariancePrior()¶
Get the predicted (pre-update) state covariance from the last
Predictcall.
-
inline MatXd GetCovariancePost()¶
Get the corrected (post-update) state covariance from the last
Updatecall.
-
inline MatXd GetCovarianceBar()¶
Get the propagated-only covariance
F P F^T(before adding process noise) from the lastPredictcall.
-
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_iiforz_trueagainst the measurement predicted atx_est, skipping any NaN or non-positive-variance components.Used as a goodness-of-fit / outlier diagnostic; returns 0 if
z_trueis empty.- Parameters:
z_true – Observed measurement vector, size [n_z] (or empty)
x_est – State 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
DataLoggerunder 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)
-
Filter() = default¶