![]() |
Ginan
|
Wrapper to simplify copying with default copy but overriding slightly. More...
Wrapper to simplify copying with default copy but overriding slightly.
Public Member Functions | |
KFState (const KFState &kfState) | |
KFState () | |
KFState & | operator= (const KFState &kfState) |
template<class ARCHIVE > | |
void | serialize (ARCHIVE &ar, const unsigned int &version) |
void | initFilterEpoch (Trace &trace) |
Clears and initialises the state transition matrix to identity at the beginning of an epoch. | |
int | getKFIndex (const KFKey &key) const |
Finds the position in the KF state vector of particular states. | |
E_Source | getKFValue (const KFKey &key, double &value, double *variance=nullptr, double *adjustment_ptr=nullptr, bool allowAlternate=true) const |
Returns the value and variance of a state within the kalman filter object. | |
E_Source | getPseudoValue (const KFKey &key, double &value, double *variance=nullptr, double *adjustment_ptr=nullptr) const |
Retrieve values from pseudo-states. | |
bool | getKFSigma (const KFKey &key, double &sigma) |
Returns the standard deviation of a state within the kalman filter object. | |
bool | addKFState (const KFKey &kfKey, const InitialState &initialState={}) |
Tries to add a state to the filter object. | |
bool | addPseudoState (const KFKey &kfKey, const map< KFKey, double > &coeffMap) |
Create a pseudo state that represents the linear combination of two or more perfectly correlated states. | |
void | setExponentialNoise (const KFKey &kfKey, const Exponential exponential) |
void | setAccelerator (const KFKey &element, const KFKey &dotElement, const KFKey &dotDotElement, const double value, const InitialState &initialState={}) |
void | setKFTrans (const KFKey &dest, const KFKey &source, const double value, const InitialState &initialState={}) |
Adds dynamics to a filter state by inserting off-diagonal, non-time dependent elements to transition matrix. | |
void | setKFTransRate (const KFKey &integral, const KFKey &rate, const double value, const InitialState &initialRateState={}, const InitialState &initialIntegralState={}) |
Adds dynamics to a filter state by inserting off-diagonal, time dependent elements to transition matrix. | |
void | addNoiseElement (const KFKey &obsKey, const double variance) |
void | removeState (const KFKey &kfKey, bool allowDeleteParent=true) |
Remove a state from a kalman filter object. | |
void | stateTransition (Trace &trace, GTime newTime, MatrixXd *stm_ptr=nullptr) |
Add process noise and dynamics to filter object according to time gap. | |
void | manualStateTransition (Trace &trace, GTime newTime, MatrixXd &stm, MatrixXd &procNoise) |
Add process noise and dynamics to filter object manually. | |
void | preFitSigmaCheck (RejectCallbackDetails &callbackDetails, KFStatistics &statistics, int begX, int numX, int begH, int numH) |
Compare variances of measurements and pre-filtered states to detect unreasonable values Ref: Wang et al. | |
void | postFitSigmaChecks (RejectCallbackDetails &callbackDetails, VectorXd &dx, KFStatistics &statistics, int begX, int numX, int begH, int numH) |
Compare variances of measurements and filtered states to detect unreasonable values. | |
double | stateChiSquare (Trace &trace, MatrixXd &Pp, VectorXd &dx, int begX, int numX, int begH, int numH) |
Compute Chi-square increment based on the change of fitting solution. | |
double | measChiSquare (Trace &trace, KFMeas &kfMeas, VectorXd &dx, int begX, int numX, int begH, int numH) |
Compute Chi-square increment based on post-fit residuals. | |
double | innovChiSquare (Trace &trace, KFMeas &kfMeas, int begX, int numX, int begH, int numH) |
Compute Chi-square increment based on pre-fit residuals (innovations) | |
bool | kFilter (Trace &trace, KFMeas &kfMeas, VectorXd &xp, MatrixXd &Pp, VectorXd &dx, int begX=0, int numX=-1, int begH=0, int numH=-1) |
Kalman filter. | |
bool | chiQC (Trace &trace, KFMeas &kfMeas, VectorXd &xp) |
Perform chi squared quality control. | |
void | outputStates (Trace &trace, string suffix="", int begX=0, int numX=-1) |
Output keys and states in human readable format. | |
void | outputConditionNumber (Trace &trace) |
void | outputCorrelations (Trace &trace) |
void | outputMeasurements (Trace &trace, KFMeas &meas) |
bool | doStateRejectCallbacks (RejectCallbackDetails rejectDetails) |
bool | doMeasRejectCallbacks (RejectCallbackDetails rejectDetails) |
void | filterKalman (Trace &trace, KFMeas &kfMeas, const string &suffix="", bool innovReady=false, map< string, FilterChunk > *filterChunkMap_ptr=nullptr) |
Kalman filter operation. | |
void | leastSquareInitStates (Trace &trace, KFMeas &kfMeas, bool initCovars=false, VectorXd *dx=nullptr, bool innovReady=false) |
Least squares estimator for new kalman filter states. | |
VectorXd | getSubState (map< KFKey, int > &kfKeyMap, MatrixXd *covarMat_ptr=nullptr, VectorXd *adjustVec_ptr=nullptr) const |
Get a portion of the state vector by passing a list of keys. | |
void | getSubState (map< KFKey, int > &kfKeyMap, KFState &kfState) const |
Get a portion of a state by passing in a list of keys. | |
KFState | getSubState (vector< KF >) const |
vector< KFKey > | decomposedStateKeys (const KFKey &composedKey) const |
Data Fields | |
recursive_mutex | kfStateMutex |
![]() | |
bool | lsqRequired = false |
Uninitialised parameters require least squares calculation. | |
GTime | time = {} |
VectorXd | x |
State. | |
MatrixXd | P |
State Covariance. | |
VectorXd | dx |
Last filter update. | |
map< KFKey, int > | kfIndexMap |
Map from key to indexes of parameters in the state vector. | |
map< KFKey, map< KFKey, map< int, double > > > | stateTransitionMap |
map< KFKey, double > | gaussMarkovTauMap |
map< KFKey, double > | gaussMarkovMuMap |
map< KFKey, double > | procNoiseMap |
map< KFKey, double > | initNoiseMap |
map< KFKey, double > | sigmaMaxMap |
map< KFKey, double > | outageLimitMap |
map< KFKey, Exponential > | exponentialNoiseMap |
map< KFKey, map< KFKey, double > > | pseudoStateMap |
Map of pseudo states, and a further map of their coefficients. | |
map< KFKey, KFKey > | pseudoParentMap |
Map from ordinary states to their combined pseudo state parent. | |
vector< StateRejectCallback > | stateRejectCallbacks |
vector< MeasRejectCallback > | measRejectCallbacks |
map< string, FilterChunk > | filterChunkMap |
map< string, string > | metaDataMap |
bool | chiQCPass = false |
double | chi = 0 |
int | dof = 0 |
string | id = "KFState" |
string | rts_basename = "" |
bool | output_residuals = false |
bool | outputMongoMeasurements = false |
KFState * | alternate_ptr = nullptr |
map< string, int > | statisticsMap |
map< string, int > | statisticsMapSum |
![]() | |
bool | simulate_filter_only = false |
bool | assume_linearity = false |
bool | advanced_postfits = false |
bool | joseph_stabilisation = false |
E_Inverter | inverter = E_Inverter::LDLT |
PrefitOptions | prefitOpts |
PostfitOptions | postfitOpts |
ChiSquareOptions | chiSquareTest |
![]() | |
string | rts_filename = "<RTS_DIRECTORY>/Filter-<RECEIVER>.rts" |
string | rts_directory = "./" |
int | rts_lag = -1 |
int | rts_interval = 0 |
string | rts_smoothed_suffix = "_smoothed" |
bool | queue_rts_outputs = false |
E_Inverter | rts_inverter = E_Inverter::LDLT |
Static Public Attributes | |
static const KFKey | oneKey = {.type = KF::ONE} |
KFStates generally contain a ONE state as the first element, used for converting matrix additions to matrix multiplications. | |
|
inline |
|
inline |
bool KFState::addKFState | ( | const KFKey & | kfKey, |
const InitialState & | initialState = {} ) |
Tries to add a state to the filter object.
If it does not exist, it adds it to a list of states to be added. Call consolidateKFState() to apply the list to the filter object
kfKey | The key to add to the state |
initialState | The initial conditions to add to the state |
void KFState::addNoiseElement | ( | const KFKey & | obsKey, |
const double | variance ) |
Create a pseudo state that represents the linear combination of two or more perfectly correlated states.
The configuration of the states that are combined are added according to the coefficients of correlation, which may not be appropriate for things like process noise or max sigmas, and should be configured accordingly.
Perform chi squared quality control.
trace | Trace to output to |
kfMeas | Measurements, noise, and design matrix |
xp | Post filtered state vector |
bool KFState::doMeasRejectCallbacks | ( | RejectCallbackDetails | rejectDetails | ) |
bool KFState::doStateRejectCallbacks | ( | RejectCallbackDetails | rejectDetails | ) |
void KFState::filterKalman | ( | Trace & | trace, |
KFMeas & | kfMeas, | ||
const string & | suffix = "", | ||
bool | innovReady = false, | ||
map< string, FilterChunk > * | filterChunkMap_ptr = nullptr ) |
Kalman filter operation.
trace | Trace file for output |
kfMeas | Measurement object |
suffix | Suffix to append to residuals block |
innovReady | Innovation already constructed |
filterChunkMap_ptr | Optional map of chunks for parallel processing of sub filters |
Finds the position in the KF state vector of particular states.
key | Key to search for in state |
bool KFState::getKFSigma | ( | const KFKey & | key, |
double & | sigma ) |
Returns the standard deviation of a state within the kalman filter object.
key | Key to search for in state |
sigma | Output value |
E_Source KFState::getKFValue | ( | const KFKey & | key, |
double & | value, | ||
double * | variance_ptr = nullptr, | ||
double * | adjustment_ptr = nullptr, | ||
bool | allowAlternate = true ) const |
Returns the value and variance of a state within the kalman filter object.
key | Key to search for in state |
value | Output value |
variance_ptr | Optional variance output |
adjustment_ptr | Optional adjustment output |
allowAlternate | Optional flag to disable alternate filter |
E_Source KFState::getPseudoValue | ( | const KFKey & | key, |
double & | value, | ||
double * | variance_ptr = nullptr, | ||
double * | adjustment_ptr = nullptr ) const |
Retrieve values from pseudo-states.
Pseudo states are linear combinations of correlated states, and this function returns the value of the states assuming that the correlations from the point of creation are still valid. It returns the entirety of the state component for the primary state, with others returning 0. Later linear combinations of these should return the correct value for the combined state.
key | Key to search for in state |
value | Output value |
variance_ptr | Optional variance output |
adjustment_ptr | Optional adjustment output |
Get a portion of a state by passing in a list of keys.
Only gets some aspects, as most aren't required
kfKeyMap | List of keys to return within substate |
subState | Output state |
VectorXd KFState::getSubState | ( | map< KFKey, int > & | kfKeyMap, |
MatrixXd * | covarMat_ptr = nullptr, | ||
VectorXd * | adjustVec_ptr = nullptr ) const |
Get a portion of the state vector by passing a list of keys.
kfKeyMap | List of keys to return within substate |
covarMat_ptr | Optional pointer to a matrix for output of covariance submatrix |
adjustVec_ptr | Optional pointer to a vector for output of last adjustments |
KFState KFState::getSubState | ( | vector< KF > | types | ) | const |
void KFState::initFilterEpoch | ( | Trace & | trace | ) |
Clears and initialises the state transition matrix to identity at the beginning of an epoch.
Also clears any noise that was being added for the initialisation of a new state.
double KFState::innovChiSquare | ( | Trace & | trace, |
KFMeas & | kfMeas, | ||
int | begX, | ||
int | numX, | ||
int | begH, | ||
int | numH ) |
Compute Chi-square increment based on pre-fit residuals (innovations)
trace | Trace to output to |
kfMeas | Measurements, noise, and design matrix |
begX | Index of first state element to process |
numX | Number of states elements to process |
begH | Index of first measurement to process |
numH | Number of measurements to process |
bool KFState::kFilter | ( | Trace & | trace, |
KFMeas & | kfMeas, | ||
VectorXd & | xp, | ||
MatrixXd & | Pp, | ||
VectorXd & | dx, | ||
int | begX = 0, | ||
int | numX = -1, | ||
int | begH = 0, | ||
int | numH = -1 ) |
Kalman filter.
trace | Trace to output to |
kfMeas | Measurements, noise, and design matrices |
xp | Post-update state vector |
Pp | Post-update covariance of states |
dx | Post-update state innovation |
begX | Index of first state element to process |
numX | Number of state elements to process |
begH | Index of first measurement to process |
numH | Number of measurements to process |
void KFState::leastSquareInitStates | ( | Trace & | trace, |
KFMeas & | kfMeas, | ||
bool | initCovars = false, | ||
VectorXd * | dx = nullptr, | ||
bool | innovReady = false ) |
Least squares estimator for new kalman filter states.
If new states have been added that do not contain variance values, the filter will assume that these states values and covariances should be estimated using least squares.
This function will extract the minimum required states from the existing state vector, and the minimum required measurements in order to perform least squares for the uninitialised states.
trace | Trace file for output |
kfMeas | Measurement object |
initCovars | Option to also initialise off-diagonal covariance values |
dx | Optional output of state deltas |
innovReady | Perform conversion between V & Y |
Add process noise and dynamics to filter object manually.
BEWARE! Not recommended for ordinary use, likely to break things. Dont touch unless you really know what you're doing. Hint - you dont really know what you're doing
double KFState::measChiSquare | ( | Trace & | trace, |
KFMeas & | kfMeas, | ||
VectorXd & | dx, | ||
int | begX, | ||
int | numX, | ||
int | begH, | ||
int | numH ) |
Compute Chi-square increment based on post-fit residuals.
trace | Trace file to output to |
kfMeas | Measurements, noise, and design matrix |
dx | The innovations from filtering to recalculate the deltas. |
begX | Index of first state element to process |
numX | Number of states elements to process |
begH | Index of first measurement to process |
numH | Number of measurements to process |
void KFState::outputConditionNumber | ( | Trace & | trace | ) |
void KFState::outputCorrelations | ( | Trace & | trace | ) |
Output keys and states in human readable format.
output | Trace to output to |
suffix | Suffix to append to state block info tag in trace files |
begX | Index of first state element to process |
numX | Number of state elements to process |
void KFState::postFitSigmaChecks | ( | RejectCallbackDetails & | callbackDetails, |
VectorXd & | dx, | ||
KFStatistics & | statistics, | ||
int | begX, | ||
int | numX, | ||
int | begH, | ||
int | numH ) |
Compare variances of measurements and filtered states to detect unreasonable values.
dx | The innovations from filtering to recalculate the deltas. |
statistics | Test statistics |
begX | Index of first state element to process |
numX | Number of state elements to process |
begH | Index of first measurement to process |
numH | Number of measurements to process |
void KFState::preFitSigmaCheck | ( | RejectCallbackDetails & | callbackDetails, |
KFStatistics & | statistics, | ||
int | begX, | ||
int | numX, | ||
int | begH, | ||
int | numH ) |
Compare variances of measurements and pre-filtered states to detect unreasonable values Ref: Wang et al.
(1997) - On Quality Control in Hydrographic GPS Surveying & Wieser et al. (2004) - Failure Scenarios to be Considered with Kinematic High Precision Relative GNSS Positioning - http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.573.9628&rep=rep1&type=pdf
statistics | Test statistics |
begX | Index of first state element to process |
numX | Number of states elements to process |
begH | Index of first measurement to process |
numH | Number of measurements to process |
void KFState::removeState | ( | const KFKey & | kfKey, |
bool | allowDeleteParent = true ) |
Remove a state from a kalman filter object.
kfKey | Key to search for in state |
|
inline |
void KFState::setAccelerator | ( | const KFKey & | element, |
const KFKey & | dotElement, | ||
const KFKey & | dotDotElement, | ||
const double | value, | ||
const InitialState & | initialState = {} ) |
void KFState::setExponentialNoise | ( | const KFKey & | kfKey, |
const Exponential | exponential ) |
void KFState::setKFTrans | ( | const KFKey & | dest, |
const KFKey & | source, | ||
const double | value, | ||
const InitialState & | initialState = {} ) |
Adds dynamics to a filter state by inserting off-diagonal, non-time dependent elements to transition matrix.
dest | Key to search for in state to change in transition |
source | Key to search for in state as source |
value | Input value |
initialState | Initial state. |
void KFState::setKFTransRate | ( | const KFKey & | integralKey, |
const KFKey & | rateKey, | ||
const double | value, | ||
const InitialState & | initialRateState = {}, | ||
const InitialState & | initialIntegralState = {} ) |
Adds dynamics to a filter state by inserting off-diagonal, time dependent elements to transition matrix.
integralKey | Key to search for in state to change in transition |
rateKey | Key to search for in state as source |
value | Input value |
initialRateState | Initial state for rate state. |
initialIntegralState | Initial state for the thing that is modified by the rate |
double KFState::stateChiSquare | ( | Trace & | trace, |
MatrixXd & | Pp, | ||
VectorXd & | dx, | ||
int | begX, | ||
int | numX, | ||
int | begH, | ||
int | numH ) |
Compute Chi-square increment based on the change of fitting solution.
trace | Trace file to output to |
Pp | Post-update covariance of states |
dx | The innovations from filtering to recalculate the deltas. |
begX | Index of first state element to process |
numX | Number of states elements to process |
begH | Index of first measurement to process |
numH | Number of measurements to process |
Add process noise and dynamics to filter object according to time gap.
This will also sort states according to their kfKey as a result of the way the state transition matrix is generated.
trace | Trace file for output |
newTime | Time of update for process noise and dynamics (s) |
stm_ptr | Optional pointer to output state transition matrix |
recursive_mutex KFState::kfStateMutex |
|
static |
KFStates generally contain a ONE state as the first element, used for converting matrix additions to matrix multiplications.