itrFlt.hpp

Go to the documentation of this file.
00001 #ifndef _BAYES_FILTER_ITERATED_COVARIANCE
00002 #define _BAYES_FILTER_ITERATED_COVARIANCE
00003 
00004 /*
00005  * Bayes++ the Bayesian Filtering Library
00006  * Copyright (c) 2002 Michael Stevens
00007  * See accompanying Bayes++.htm for terms and conditions of use.
00008  *
00009  * $Id: itrFlt.hpp 562 2006-04-05 20:46:23 +0200 (Wed, 05 Apr 2006) mistevens $
00010  */
00011 
00012 /*
00013  * Iterated Covariance Filter Scheme.
00014  *  A non-linear Covariance (Kalman) filter with relinearisation and iteration
00015  *
00016  * The observe algorithm uses the iterated non-linear formulation 
00017  * from Bar-Shalom and Fortmann p.119 (full scheme)
00018  * Discontinous observe models require that state is normailised with
00019  * respect to the observation.
00020  *
00021  * The filter is operated by performing a
00022  *  predict, observe
00023  * cycle defined by the base class
00024  */
00025 #include "bayesFlt.hpp"
00026 
00027 /* Filter namespace */
00028 namespace Bayesian_filter
00029 {
00030 
00031 class Iterated_covariance_scheme;
00032 
00033 class Iterated_observe_model : virtual public Observe_model_base
00034 /* Linrz observation model which can be iterated
00035     Hx can be relinearised
00036  */
00037 {
00038 protected: // model is not sufficient, it is used to build observe model's
00039     Iterated_observe_model ()
00040     {}
00041 public:
00042     virtual void relinearise (const FM::Vec& x) = 0;
00043     // Relinearised about state x
00044 };
00045 
00046 
00047 class Iterated_terminator : public Bayes_base
00048 /*
00049  * Termination condition for filter Iteration
00050  *  Used by iterated observe to parameterise termination condition
00051  *  If iteration continues, the terminator must also relinearise the model about the filters new state
00052  *
00053  * Defaults to immediately terminating the iteration
00054  *
00055  * A more useful terminator can built by derivation.
00056  * For example terminator constructed with a reference to the filter and model can
00057  * detect convergence of x and/or X
00058  */
00059 {
00060 public:
00061     virtual bool term_or_relinearize (const Iterated_covariance_scheme& f)
00062     {
00063         return true;
00064     }
00065 };
00066 
00067 class Counted_iterated_terminator : public Iterated_terminator
00068 /*
00069  * Termination condition with a simple fixed number of iterations 
00070  */
00071 {
00072 public:
00073     Counted_iterated_terminator (Iterated_observe_model& model, unsigned iterations) :
00074         m(model), i(iterations)
00075     {}
00076     bool term_or_relinearize (const Iterated_covariance_scheme& f);
00077     Iterated_observe_model& m;
00078     unsigned i;
00079 };
00080 
00081 
00082 
00083 class Iterated_covariance_scheme : public Linrz_kalman_filter
00084 {
00085 public:
00086     Iterated_covariance_scheme (std::size_t x_size, std::size_t z_initialsize = 0);
00087     /* Initialised filter requries an addition iteration limit for the
00088        observe algorithm */
00089     Iterated_covariance_scheme& operator= (const Iterated_covariance_scheme&);
00090     // Optimise copy assignment to only copy filter state
00091 
00092     void init ();
00093     void update ();
00094     Float predict (Linrz_predict_model& f);
00095 
00096     Float observe (Linrz_uncorrelated_observe_model& h, Iterated_terminator& term, const FM::Vec& z);
00097     Float observe (Linrz_correlated_observe_model& h, Iterated_terminator& term, const FM::Vec& z);
00098     // Observe with iteration
00099     Float observe (Linrz_uncorrelated_observe_model& h, const FM::Vec& z)
00100     {   // Observe with default termination
00101         Iterated_terminator term;
00102         return observe (h, term, z);
00103     }
00104     Float observe (Linrz_correlated_observe_model& h, const FM::Vec& z)
00105     {   // Observe with default termination
00106         Iterated_terminator term;
00107         return observe (h, term, z);
00108     }
00109 
00110 public:                     // Exposed Numerical Results
00111     FM::SymMatrix S, SI;        // Innovation Covariance and Inverse
00112 
00113 protected:                  // Permenantly allocated temps
00114     FM::RowMatrix tempX;
00115 
00116 protected:                  // allow fast operation if z_size remains constant
00117     std::size_t last_z_size;
00118     void observe_size (std::size_t z_size);
00119                             // Permenantly allocated temps
00120     FM::Vec s;
00121     FM::Matrix HxT;
00122 };
00123 
00124 
00125 }//namespace
00126 #endif

Generated on Wed Oct 4 22:57:23 2006 for Bayes++ Bayesian Filtering Classes by  doxygen 1.4.6