Go to the documentation of this file.
41 #ifndef KALMAN_FILTER_INCLUDE
42 #define KALMAN_FILTER_INCLUDE
384 Invert(std::string(
"Invert after adding a priori info"));
386 else if (isInfo == 1)
389 Invert(std::string(
"Invert after adding a priori info"));
404 e.
addText(
"Failed to add apriori");
442 std::string(
"Filter time step must be ") +
443 (
timeReversed ? std::string(
"< 0") : std::string(
"> 0")));
468 Invert(std::string(
"Invert after interim 1"));
479 double nexttime =
time;
492 Invert(std::string(
"Invert after MU"));
510 Invert(std::string(
"Invert after interim 2"));
516 double deltaT = nexttime -
time;
518 if (::fabs(deltaT) > 1.5 * ::fabs(
nominalDT))
529 Invert(std::string(
"Invert after TU"));
540 Invert(std::string(
"Invert after interim 3"));
606 Invert(std::string(
"Invert after SRISU"));
640 std::ostringstream oss;
644 LOG(
ERROR) <<
"Kalman stage not defined in output().";
647 LOG(
DEBUG) <<
"Enter KalmanFilter::output(" << N <<
")";
654 <<
" " << std::fixed << N <<
" " << std::setprecision(3)
657 for (i = 0; i < NL.
size(); i++)
658 oss << std::setw(10) << NL.
getName(i);
686 LOG(
INFO) <<
"Kalman stage not defined." << std::endl;
692 oss << std::fixed << N <<
" " << std::setprecision(3) <<
time;
696 oss <<
" " << std::setw(9) <<
State(i);
699 oss << std::scientific << std::setprecision(2);
701 oss <<
" " << std::setw(10) << (
singular ? 0.0 : ::sqrt(
Cov(i, i)));
789 double timesave(
time);
983 void Invert(
const std::string& msg = std::string())
987 LOG(
INFO) <<
"Dry invert" << (msg.empty() ?
"" :
" " + msg);
992 LOG(
DEBUG) << msg <<
" (doInversions false)";
1003 LOG(
DEBUG) << msg <<
" (non-singular)";
1009 LOG(
DEBUG) << msg <<
" (singular)";
1013 catch (std::exception& e)
std::string getTag()
KF tag is a user-defined string output on each line.
int NTU
count of time updates: ++ in TU, – in SU
void setDryRun(bool t=true)
if dryRun, do not operate the filter, just print
gnsstk::Matrix< double > Rw
SRIF matrix used internally.
virtual int defineInitial(double &T0, gnsstk::Vector< double > &X, gnsstk::Matrix< double > &Cov)=0
int NMU
count of measurement updates
gnsstk::Vector< double > SMResid
post-smoother residuals - value after SU
gnsstk::Matrix< double > G
void setTag(std::string tag)
void zeroState()
Zero out (set all elements to zero) the state (Vector Z) only.
gnsstk::Vector< double > PFResid
post-fit residuals - valid after MU
unsigned int size() const
void addAPriori(const Matrix< double > &Cov, const Vector< double > &X)
gnsstk::Vector< double > State
filter state
bool inverted
if true then the SRI has been inverted and State and Cov are valid
void setDoInvert(bool on)
virtual void KalmanTimeUpdate(double T, double DT)
gnsstk::Matrix< double > Rw
gnsstk::Vector< double > Control
virtual void ForwardFilter(double finalT, double DT)
void initialize(const gnsstk::Namelist &NL)
void setSmoother(bool ext)
if smoother, save info during forward filter for use by backward filter
gnsstk::Vector< double > getState()
get the state (must be non-singular)
void setDoOutput(bool on)
virtual int KalmanInterim(int which, double Time)
int NSU
count of smoother updates
int getNMU()
get number of measurements processed
void measurementUpdate(const Matrix< double > &H, Vector< double > &D, const Matrix< double > &CM=SRINullMatrix)
virtual void initializeFilter()
size_t rows() const
The number of rows in the matrix.
bool getDoOutput()
if doOutput, output() is called at each step
gnsstk::Matrix< double > Partials
matrix defined by defineM() and used in MU
void Invert(const std::string &msg=std::string())
std::map< int, SmootherStoreRec > SmootherStore
void timeUpdate(Matrix< double > &PhiInv, Matrix< double > &Rw, Matrix< double > &G, Vector< double > &Zw, Matrix< double > &Rwx)
bool getDoInvert()
if doInversions, SRIF is inverted at each step, defining State and Cov
virtual KalmanReturn KalmanMeasurementUpdate(double &T)
bool doOutput
if true, output at each stage using output() routine. NB used inside output()
gnsstk::Matrix< double > G
SRIF matrix used internally - noise.
bool isExtended()
if extended, use an extended Kalman (not implemented)
double time
seconds since start
double nominalDT
change in time for one TU seconds
void setSRI(gnsstk::SRI &sri)
get the filter SRI
gnsstk::Namelist getNames()
get the state namelist
enum gnsstk::KalmanFilter::FilterStageEnum FilterStage
bool timeReversed
if true then independent variable "time" decreases
virtual void output(int N)
FilterStage stage
current stage of the filter - see enum
virtual void KalmanSmootherUpdate()
gnsstk::Vector< double > Data
vector defined by defineM() and used in MU
void smootherUpdate(Matrix< double > &Phi, Matrix< double > &Rw, Matrix< double > &G, Vector< double > &Zw, Matrix< double > &Rwx)
enum gnsstk::KalmanFilter::KalmanMUReturnValuesEnum KalmanReturn
gnsstk::SRIFilter srif
SRIF.
gnsstk::Matrix< double > MCov
measurement covariance (defineM() for MU)
unsigned int size() const
return the size of the list.
std::string getName(const unsigned int in) const
gnsstk::Matrix< double > Rwx
bool isSingular()
true when filter is singular
static void DMsmootherUpdate(Matrix< double > &P, Vector< double > &X, Matrix< double > &Phinv, Matrix< double > &Rw, Matrix< double > &G, Vector< double > &Zw, Matrix< double > &Rwx)
#define GNSSTK_RETHROW(exc)
virtual int defineInterim(int which, double Time)
gnsstk::Matrix< double > Cov
filter covariance
virtual KalmanReturn defineMeasurements(double &T, const gnsstk::Vector< double > &X, const gnsstk::Matrix< double > &C, bool useFlag)=0
gnsstk::Matrix< double > PhiInv
SRIF matrix used internally - inv state trans.
KalmanFilter(const gnsstk::Namelist &NL)
#define LOG(level)
define the macro that is used to write to the log stream
virtual void defineTimestep(double T, double DT, const gnsstk::Vector< double > &State, const gnsstk::Matrix< double > &Cov, bool useFlag)=0
std::string KFtag
optional tag to put in output (2nd field)
size_t size() const
STL size.
void addAPrioriInformation(const Matrix< double > &ICov, const Vector< double > &X)
Namelist getNames() const
void setSRISU(bool ext)
if doSRISU use SRIF form of smoother, else DM smoother
void Reset(const gnsstk::Namelist &NL)
gnsstk::Vector< double > Zw
SRIF vector used internally.
virtual void BackwardFilter(int M)
void shift(const Vector< double > &X0)
gnsstk::Vector< double > Zw
Exception & addText(const std::string &errorText)
#define GNSSTK_THROW(exc)
gnsstk::Matrix< double > getCovariance()
get the covariance (must be non-singular)
double small
condition number at last inversion = b/s
Storage for smoothing algorithm; stored by forward filter, used by SU.
SparseMatrix< T > inverse(const SparseMatrix< T > &A)
void setExtended(bool ext)
virtual ~KalmanFilter()
destructor
int Nstate
number of state elements
gnsstk::Matrix< double > PhiInv
void setTimeReverse(bool tr=true)
if timeReversed, time T decreases during the forward filter
void getStateAndCovariance(Vector< double > &X, Matrix< double > &C, double *ptrSmall=NULL, double *ptrBig=NULL) const
void BackwardFilter(double M)
int Nnoise
Nnoise is there only for the user.
gnsstk::Vector< double > Control
SRIF vector used internally.
struct gnsstk::KalmanFilter::Smoother_storage_record SmootherStoreRec
Storage for smoothing algorithm; stored by forward filter, used by SU.
gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:39