|
EmrysFilter 0.1.0
State estimation utilities in C++23 using Eigen
|
The square-root Kalman filter: a KalmanFilter whose state is a SqrtGaussianParams, a mean and a lower-triangular factor of the covariance (decisions.md [gaussian-forms]). More...
#include <EmrysFilter/Filters/SqrtKalmanFilter.h>
Public Types | |
| using | Base |
| the filter this is | |
| Public Types inherited from Emrys::KalmanFilter< Component_, Model_, Method_, Recursion_, Upkeep_ > | |
| using | Scalar = typename Params<Component_>::Scalar |
| the scalar type | |
| using | SpaceType = typename Params<Component_>::SpaceType |
| the state space | |
| using | ModelType = Model_ |
| the process model | |
| using | MethodType = Method_ |
| the prediction method | |
| using | StateType = Params<Component_> |
| the state the filter owns | |
| using | RecursionType = Recursion_ |
| the steps it runs (see Recursion) | |
Public Member Functions | |
| SqrtKalmanFilter (Model_ model, SqrtGaussianParams< Space_, Scalar_ > state, MethodFor< Model_, Method_ > method={}, std::type_identity_t< Upkeep_ > upkeep={}) | |
| A filter with process model model, initial state state, and prediction method method; a fixed-step model carries its own, so there is none to give. | |
| SqrtKalmanFilter (Model_ model, SqrtGaussianParams< Space_, Scalar_ > state, std::type_identity_t< Upkeep_ > upkeep) | |
| A filter with process model model, initial state state, the default prediction method, and upkeep upkeep, which maintain() runs. | |
| Public Member Functions inherited from Emrys::KalmanFilter< Component_, Model_, Method_, Recursion_, Upkeep_ > | |
| KalmanFilter (Model_ model, Params< Component_ > state, MethodFor< Model_, Method_ > method={}, std::type_identity_t< Upkeep_ > upkeep={}) | |
| A filter with process model model, initial state state, prediction method method, and upkeep upkeep, which maintain() runs; a fixed-step model carries its own method, so there is none to give. | |
| KalmanFilter (Model_ model, Params< Component_ > state, std::type_identity_t< Upkeep_ > upkeep) | |
| A filter with process model model, initial state state, the default prediction method, and upkeep upkeep, which maintain() runs. | |
| KalmanFilter (Recursion_ recursion, StateType state, std::type_identity_t< Upkeep_ > upkeep={}) | |
| A filter that runs recursion, the library's or one of the user's own (see Recursion), on the initial state state, whose space the recursion's model must partition, with upkeep upkeep, which maintain() runs. | |
| StateType const & | state () const |
| StateType & | state () |
| void | setState (StateType state) |
| Replaces the state estimate, as when reinitializing, with one whose space the process model's writes partition, as the constructor's must. | |
| RecursionType const & | recursion () const |
| Model_ const & | model () const |
| Model_ & | model () |
| Method_ const & | method () const |
| template<typename... Inputs> requires (!isFixedStep<Model_>) | |
| auto | predict (TimeStep< Scalar > auto const &dt, Inputs const &... inputs) |
| Moves the state forward by dt, any TimeStep (see Time steps), through the process model, with inputs passed to its model as in Emrys::predict(): an uncertain input carries its uncertainty through the dynamics, and anything else is known. | |
|
template<typename... Inputs> requires (isFixedStep<Model_> && !internal::leadsWithSteps<Inputs...>) | |
| auto | predict (Inputs const &... inputs) |
| Moves the state forward by the fixed-step model's step, with inputs passed as in Emrys::predict(), returning as predict(dt, inputs...) does. | |
| template<typename... Inputs> requires isFixedStep<Model_> | |
| auto | predict (Steps steps, Inputs const &... inputs) |
| Moves the state forward by steps of the fixed-step model, as that many calls of predict(inputs...) do, with inputs at every step. | |
| template<typename... Inputs> requires (!isFixedStep<Model_> && !IsForm) | |
| PredictedJoint< SpaceType, Scalar > | predictJoint (TimeStep< Scalar > auto const &dt, Inputs const &... inputs) |
| Moves the state forward as predict(dt, inputs...) does. | |
| template<typename... Inputs> requires (isFixedStep<Model_> && !IsForm && !internal::leadsWithSteps<Inputs...>) | |
| PredictedJoint< SpaceType, Scalar > | predictJoint (Inputs const &... inputs) |
| Moves the state forward as predict(inputs...) does with a fixed-step model. | |
| template<Measurement M, typename Policy = reductions::Collapse> requires (!internal::isLinearizedAbout<Policy>) | |
| auto | update (M const &measurement, Policy const &policy={}) |
| Conditions the state on measurement, by the measurement's own method, and reduces the branches to the new state with policy, a ReductionPolicy to the component (Collapse, Select, or a Gate). | |
| template<Measurement M, typename Reference, typename Policy = reductions::Collapse> | |
| auto | update (M const &measurement, LinearizedAbout< Reference > const &about, Policy const &policy={}) |
| Conditions the state on measurement as update(measurement, policy) does, with the measurement linearized about about, a point or a distribution (see linearizedAbout()), rather than at the state (decisions.md [linearization-reference]): a shadow filter's update about another filter's state, which with predict(dt, about) runs the shadow's whole step about it. | |
| template<Measurement M, typename Policy, typename Result> requires (!internal::isLinearizedAbout<Policy>) | |
| std::expected< void, GaussianError > | update (M const &measurement, Policy const &policy, Result &result) |
As update(measurement, policy), but into result, the update inside the std::expected that update() returns, whose storage is reused: with the same result at every step, an update under mixture noise, whose branches are a run-time count, allocates nothing once the result has held as many (see Allocation). | |
| template<Measurement M, typename Reference, typename Policy, typename Result> | |
| std::expected< void, GaussianError > | update (M const &measurement, LinearizedAbout< Reference > const &about, Policy const &policy, Result &result) |
| As update(measurement, about, policy), but into result, as update(measurement, policy, result) fills it. | |
The square-root Kalman filter: a KalmanFilter whose state is a SqrtGaussianParams, a mean and a lower-triangular factor of the covariance (decisions.md [gaussian-forms]).
Prediction triangularizes \( [\,F S \;\; Q^{1/2}\,] \), with \( F \) the model's transition or the step's Jacobian, or under Unscented the weighted deviations of sigma points spread from the factor itself (van der Merwe and Wan (2001)). The update triangularizes the joint array of the innovation and the state, whose factor holds the innovation's factor, the gain, and the posterior factor (the array algorithms of Kaminski, Bryson, and Schmidt (1971)), with \( H \) and \( S_0 \) the statistical linearization of the measurement by its own method [covariance-update-forms]. The factor represents the covariance at twice the precision and stays positive semidefinite where the covariance form's subtraction can lose definiteness, which is the case of a measurement far more precise than the prior. predict() returns a std::expected, empty only when an Unscented with a negative center weight leaves the predicted covariance indefinite; update() returns one too, empty only when the innovation's factor has a zero on its diagonal [innovation-cholesky]. Measurement noise has one component and the policy is Collapse, Select, or a Gate over them; there is no predictJoint().
It is the KalmanFilter it names with nothing added, as a derived class rather than an alias so that its arguments deduce on every compiler [filters-and-recursions]: SqrtKalmanFilter filter{model, *toSqrt(initial)}.
| Space_ | the state space (see Spaces) |
| Model_ | the process model, a ProcessModel or a FixedStepModel |
| Method_ | the prediction method; a FixedStepModel's own |
| Scalar_ | scalar type, double by default |
| Upkeep_ | the upkeep maintain() runs on the state (see Upkeep), upkeep::None unless given one; RepairCovariance does not apply to this form |
| using Emrys::SqrtKalmanFilter< Space_, Model_, Method_, Scalar_, Upkeep_ >::Base |
the filter this is
|
inline |
A filter with process model model, initial state state, and prediction method method; a fixed-step model carries its own, so there is none to give.
Declared rather than inherited so that only the deduction guide below deduces the filter's arguments.