EKFilterUnicycle2D.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // $Id$
00004 //
00005 // Copyright 2008, 2009, 2010, 2011, 2012  Antonio Franchi and Paolo Stegagno    
00006 //
00007 // This file is part of MIP.
00008 //
00009 // MIP is free software: you can redistribute it and/or modify
00010 // it under the terms of the GNU General Public License as published by
00011 // the Free Software Foundation, either version 3 of the License, or
00012 // (at your option) any later version.
00013 //
00014 // MIP is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 // GNU General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU General Public License
00020 // along with MIP. If not, see <http://www.gnu.org/licenses/>.
00021 //
00022 // Contact info: antonio.franchi@tuebingen.mpg.de stegagno@diag.uniroma1.it
00023 //
00024 // ----------------------------------------------------------------------------
00025 
00029 
00030 #ifndef __EKF_FILTER_UNICYCLE2D_H
00031 #define __EKF_FILTER_UNICYCLE2D_H
00032 
00033 #include <Spaces.h>
00034 #include <armadillo>
00035 #include <math.h>
00036 #include <Gaussian.h>
00037 
00038 
00039 using namespace MipBaselib;
00040 using namespace arma;
00041 
00042 namespace MipAlgorithms{
00043  
00045  /* @{ */
00046  
00049  enum EKFilterUnicycle2DInputType{
00050   EKF_UNICYCLE2D_INPUT_NONE,
00051   EKF_UNICYCLE2D_INPUT_POSE,
00052   EKF_UNICYCLE2D_INPUT_VELOCITIES,
00053   EKF_UNICYCLE2D_INPUT_TYPE_NUM
00054  };
00055  
00058  static const char* EKFilterUnicycle2DInputTypeName[EKF_UNICYCLE2D_INPUT_TYPE_NUM] ={
00059   "EKFUnicycle2DInputNone",
00060   "EKFUnicycle2DInputPose",
00061   "EKFUnicycle2DInputVelocities"
00062  };
00063  
00066  enum EKFilterUnicycle2DMeasurementType{
00067   EKF_UNICYCLE2D_MEASUREMENT_NONE,
00068   EKF_UNICYCLE2D_MEASUREMENT_POSE,
00069   EKF_UNICYCLE2D_MEASUREMENT_POSITION,
00070   EKF_UNICYCLE2D_MEASUREMENT_DISTANCE,
00071   EKF_UNICYCLE2D_MEASUREMENT_BEARING,
00072   EKF_UNICYCLE2D_MEASUREMENT_ORIENTATION,
00073   EKF_UNICYCLE2D_MEASUREMENT_TYPE_NUM
00074  };
00075  
00078  static const char* EKFilterUnicycle2DMeasurementTypeName[EKF_UNICYCLE2D_MEASUREMENT_TYPE_NUM] ={
00079   "EKFUnicycle2DMeasurementNone",
00080   "EKFUnicycle2DMeasurementPose",
00081   "EKFUnicycle2DMeasurementPosition",
00082   "EKFUnicycle2DMeasurementDistance",
00083   "EKFUnicycle2DMeasurementBearing",
00084   "EKFUnicycle2DMeasurementOrientation"
00085  };
00086  
00087  
00091  class EKFilterUnicycle2DIn{
00092   public:
00093    
00094    // odometries
00095    EKFilterUnicycle2DInputType itype;
00096    
00097    Time hisInputTime;
00098    Decimal hisLinVel;
00099    Decimal hisAngVel;
00100    
00101    Time myInputTime;
00102    Decimal myLinVel;
00103    Decimal myAngVel;
00104    
00105    Pose myPose;
00106    Pose hisPose;
00107    
00108    // measures
00109    EKFilterUnicycle2DMeasurementType mtype;
00110    Pose pose;
00111    DMat::fixed<3,3> poseCov;
00112    
00113    Position position;
00114    DMat::fixed<2,2> positionCov;
00115    
00116    Decimal distance;
00117    Decimal distanceCov;
00118    
00119    Angle bearing;
00120    Decimal bearingCov;
00121    
00122    Angle orientation;
00123    Decimal orientationCov;
00124    
00125    EKFilterUnicycle2DIn(){
00126     itype = EKF_UNICYCLE2D_INPUT_NONE;
00127     mtype = EKF_UNICYCLE2D_MEASUREMENT_NONE;
00128    }
00129  };
00130  
00131  
00135  class EKFilterUnicycle2DPars {
00136   public:
00137    
00138    Time timeBetweenUpdates;
00139    Time timeBetweenPredictions;
00140    Decimal startingOrientation;
00141    Mat< Decimal >::fixed< 2, 2 > N_n_x;
00142    
00144    EKFilterUnicycle2DPars();
00145    
00150    EKFilterUnicycle2DPars(Time tu, Time tp, Decimal so);
00151    
00154    EKFilterUnicycle2DPars(const EKFilterUnicycle2DPars& ekp);
00155    
00158    void operator=(const EKFilterUnicycle2DPars& ekp);
00159 };
00160  
00161  
00165  class EKFilterUnicycle2DVars {
00166   public:
00167    
00168    MipBaselib::Gaussian _bel;
00169    bool _firstStep;
00170    
00171    // these quantities are used when the time update is made using the already integrated odometries
00172    Pose _myOdo;
00173    Pose _hisOdo;
00174    
00175    Pose _lastMyPose;
00176    Pose _lastHisPose;
00177    
00178    // these quantities are used when the time update of the filter is made using the control inputs
00179    vector<Time> _lastMyInputTime;
00180    vector<Decimal> _lastMyLinVel;
00181    vector<Decimal> _lastMyAngVel;
00182    
00183    vector<Time> _lastHisInputTime;
00184    vector<Decimal> _lastHisLinVel;
00185    vector<Decimal> _lastHisAngVel;
00186    
00187    int _counterHisInput;
00188    int _counterMyInput;
00189    
00190    Time _lastIntegrationTime;
00191    bool _lastIntegrationTimeMine;
00192    int _lastIntegrationTimeIndex;
00193    
00194    // these timers take the time from the last prediction and update steps
00195    Timer _timeFromLastUpdate;
00196    Timer _timeFromLastPrediction;
00197    
00199    EKFilterUnicycle2DVars();
00200    
00203    EKFilterUnicycle2DVars(const EKFilterUnicycle2DVars& ekv);
00204    
00207    void operator=(const EKFilterUnicycle2DVars& ekv);
00208  };
00209  
00210  
00214  class EKFilterUnicycle2D {
00215   protected:
00216    EKFilterUnicycle2DVars* _vars;
00217    EKFilterUnicycle2DPars* _pars;
00218   public:
00219    EKFilterUnicycle2D();
00220    
00221    EKFilterUnicycle2D(EKFilterUnicycle2DPars &inParams);
00222    
00223    EKFilterUnicycle2D(const EKFilterUnicycle2D& ekf);
00224    
00225    virtual void step(EKFilterUnicycle2DIn &in);
00226    
00227    virtual string print() const;
00228    
00229    virtual bool initialized();
00230    
00231    virtual MipBaselib::Gaussian getState();
00232    
00233    virtual void operator=(const EKFilterUnicycle2D& ekf);
00234    
00235    virtual EKFilterUnicycle2DPars* getPars();
00236    
00237    virtual void reset();
00238    
00239   protected:
00240    
00241    virtual void _computeOdometries(EKFilterUnicycle2DIn &in);
00242    virtual void _initialize(EKFilterUnicycle2DIn &in);
00243    virtual void _normalStep(EKFilterUnicycle2DIn &in);
00244    
00245    virtual void _velocitiesPrediction(EKFilterUnicycle2DIn &in);
00246    virtual void _velocitiesPrediction(Time &t1, Time &t2, Decimal mv, Decimal mw, Decimal hv, Decimal hw);
00247    virtual void _posePrediction();
00248    virtual void _updateWithPose(EKFilterUnicycle2DIn &in);
00249    virtual void _updateWithPosition(EKFilterUnicycle2DIn &in);
00250    
00251  };
00252  
00253  /* @} */
00254  
00255 }
00256 
00257 
00258 #endif
00259 
00260 
00261 
00262 
00263 
00264 
00265 
00266 

Generated on Mon Feb 20 07:01:06 2017 for MIP by  doxygen 1.5.6