SimpleKalmanFilter.hpp

Go to the documentation of this file.
00001 #pragma ident "$Id: SimpleKalmanFilter.hpp 2570 2011-04-21 17:33:49Z yanweignss $"
00002 
00008 #ifndef SIMPLEKALMANFILTER_HPP
00009 #define SIMPLEKALMANFILTER_HPP
00010 
00011 //============================================================================
00012 //
00013 //  This file is part of GPSTk, the GPS Toolkit.
00014 //
00015 //  The GPSTk is free software; you can redistribute it and/or modify
00016 //  it under the terms of the GNU Lesser General Public License as published
00017 //  by the Free Software Foundation; either version 2.1 of the License, or
00018 //  any later version.
00019 //
00020 //  The GPSTk is distributed in the hope that it will be useful,
00021 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 //  GNU Lesser General Public License for more details.
00024 //
00025 //  You should have received a copy of the GNU Lesser General Public
00026 //  License along with GPSTk; if not, write to the Free Software Foundation,
00027 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00028 //
00029 //  Dagoberto Salazar - gAGE ( http://www.gage.es ). 2007, 2008
00030 //
00031 //============================================================================
00032 
00033 
00034 
00035 #include "Exception.hpp"
00036 #include "Matrix.hpp"
00037 #include "Vector.hpp"
00038 #include "SolverBase.hpp"
00039 
00040 
00041 namespace gpstk
00042 {
00043 
00045 
00046 
00048 
00113    class SimpleKalmanFilter
00114    {
00115    public:
00116 
00118       SimpleKalmanFilter()
00119          : xhat(1,0.0), P(1,1,0.0), xhatminus(1,0.0), Pminus(1,1,0.0) {};
00120 
00121 
00129       SimpleKalmanFilter( const Vector<double>& initialState,
00130                           const Matrix<double>& initialErrorCovariance )
00131          : xhat(initialState), P(initialErrorCovariance),
00132            xhatminus(initialState.size(), 0.0),
00133            Pminus( initialErrorCovariance.rows(),
00134                    initialErrorCovariance.cols(), 0.0) {};
00135 
00136 
00144       SimpleKalmanFilter( const double& initialValue,
00145                           const double& initialErrorVariance )
00146          : xhat(1,initialValue),
00147            P(1,1,initialErrorVariance), xhatminus(1,0.0),
00148            Pminus(1,1,0.0) {};
00149 
00150 
00161       virtual void Reset( const Vector<double>& initialState,
00162                           const Matrix<double>& initialErrorCovariance );
00163 
00164 
00175       virtual void Reset( const double& initialValue,
00176                           const double& initialErrorVariance );
00177 
00178 
00196       virtual int Compute( const Matrix<double>& phiMatrix,
00197                            const Matrix<double>& controlMatrix,
00198                            const Vector<double>& controlInput,
00199                            const Matrix<double>& processNoiseCovariance,
00200                            const Vector<double>& measurements,
00201                            const Matrix<double>& measurementsMatrix,
00202                            const Matrix<double>& measurementsNoiseCovariance )
00203          throw(InvalidSolver);
00204 
00205 
00222       virtual int Compute( const Matrix<double>& phiMatrix,
00223                            const Matrix<double>& processNoiseCovariance,
00224                            const Vector<double>& measurements,
00225                            const Matrix<double>& measurementsMatrix,
00226                            const Matrix<double>& measurementsNoiseCovariance )
00227          throw(InvalidSolver);
00228 
00229 
00246       virtual int Compute( const double& phiValue,
00247                            const double& controlGain,
00248                            const double& controlInput,
00249                            const double& processNoiseVariance,
00250                            const double& measurement,
00251                            const double& measurementsGain,
00252                            const double& measurementsNoiseVariance )
00253          throw(InvalidSolver);
00254 
00255 
00270       virtual int Compute( const double& phiValue,
00271                            const double& processNoiseVariance,
00272                            const double& measurement,
00273                            const double& measurementsGain,
00274                            const double& measurementsNoiseVariance )
00275          throw(InvalidSolver);
00276 
00277 
00289       virtual int TimeUpdate()
00290       { xhatminus=xhat;Pminus=P; return 0;}
00291 
00292 
00305       virtual int TimeUpdate( const Matrix<double>& phiMatrix,
00306                               const Matrix<double>& processNoiseCovariance )
00307          throw(InvalidSolver)
00308       { return Predict(phiMatrix,xhat,processNoiseCovariance); }
00309 
00310 
00325       virtual int TimeUpdate( const Matrix<double>& phiMatrix,
00326                               const Vector<double>& previousState,
00327                               const Matrix<double>& processNoiseCovariance )
00328          throw(InvalidSolver)
00329       { return Predict(phiMatrix,previousState,processNoiseCovariance); }
00330 
00331 
00332 
00349       virtual int MeasUpdate( const Vector<double>& measurements,
00350                               const Matrix<double>& measurementsMatrix,
00351                               const Matrix<double>& measurementsNoiseCovariance)
00352          throw(InvalidSolver)
00353       { 
00354          return Correct(measurements,
00355                         measurementsMatrix,
00356                         measurementsNoiseCovariance); 
00357       }
00358 
00359 
00361       virtual ~SimpleKalmanFilter() {};
00362 
00363 
00365       Vector<double> xhat;
00366 
00367 
00369       Matrix<double> P;
00370 
00371 
00373       Vector<double> xhatminus;
00374 
00375 
00377       Matrix<double> Pminus;
00378 
00379 
00380    private:
00381 
00382 
00398       virtual int Predict( const Matrix<double>& phiMatrix,
00399                            const Vector<double>& previousState,
00400                            const Matrix<double>& controlMatrix,
00401                            const Vector<double>& controlInput,
00402                            const Matrix<double>& processNoiseCovariance )
00403          throw(InvalidSolver);
00404 
00405 
00421       virtual int Predict( const double& phiValue,
00422                            const double& previousState,
00423                            const double& controlGain,
00424                            const double& controlInput,
00425                            const double& processNoiseVariance )
00426          throw(InvalidSolver);
00427 
00428 
00443       virtual int Predict( const Matrix<double>& phiMatrix,
00444                            const Vector<double>& previousState,
00445                            const Matrix<double>& processNoiseCovariance )
00446          throw(InvalidSolver);
00447 
00448 
00463       virtual int Predict( const double& phiValue,
00464                            const double& previousState,
00465                            const double& processNoiseVariance )
00466          throw(InvalidSolver);
00467 
00468 
00485       virtual int Correct( const Vector<double>& measurements,
00486                            const Matrix<double>& measurementsMatrix,
00487                            const Matrix<double>& measurementsNoiseCovariance )
00488          throw(InvalidSolver);
00489 
00490 
00505       virtual int Correct( const double& measurement,
00506                            const double& measurementsGain,
00507                            const double& measurementsNoiseVariance )
00508          throw(InvalidSolver);
00509 
00510 
00511    }; // End of class 'SimpleKalmanFilter'
00512 
00514 
00515 }  // End of namespace gpstk
00516 #endif // SIMPLEKALMANFILTER_HPP

Generated on Tue May 22 03:31:01 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1