MutLocFASTSlam.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 
00026 
00030 
00034 
00036 /* @{ */
00037 
00038 #ifndef __MUT_LOC_FAST_SLAM_H
00039 #define __MUT_LOC_FAST_SLAM_H
00040 
00041 #include <Spaces.h>
00042 #include <EKFilterUnicycle2D.h>
00043 #include <Roulette.h>
00044 
00045 #define EKFILTERUNICYCLE2D_NUMPARTICLES 1000
00046 
00047 namespace MipAlgorithms{
00048  
00052  class MutLocFASTSlamParticle{
00053   
00054   public:
00055    
00056    
00057    vector<int> _ekfsIds;
00058    map<int, EKFilterUnicycle2D*> _ekfs;
00059    map<int, Decimal> _ekfsVals;
00060    
00061    vector<EKFilterUnicycle2D*> _stekfs;
00062    vector<Decimal> _stekfsVals;
00063    Decimal weigth;
00064    int weigthNum;
00065    
00066    
00067    MutLocFASTSlamParticle();
00068    
00069    MutLocFASTSlamParticle(const MutLocFASTSlamParticle& mfp);
00070    
00071    void operator=(const MutLocFASTSlamParticle& mfp);
00072    
00073    ~MutLocFASTSlamParticle();
00074    
00075    void addFilter(int id);
00076    
00077    void addFeature();
00078    
00079    void clearAll();
00080    
00081    const bool idActive(const int id) const;
00082    
00083    string print() const;
00084    
00085    void updateStaticFeatures(EKFilterUnicycle2DIn& in);
00086    
00087    DCol getProbabilitiesOfDetection(Decimal mB, Decimal mD, Decimal ray);
00088  };
00089  
00093  class MutLocFASTSlamInput{
00094   public:
00096    int        numMeas;
00098    vector<Position> measure;
00100    Pose       myConf;
00102    vector<int>    hisIds;
00104    vector<Pose>   hisConf;
00106    vector<int>    hisPFIds;
00108    vector<PosiFeatures> hisPF;
00109    
00111    pair<bool,Decimal> actualTime;
00112    
00114    MutLocFASTSlamInput();
00115   
00117    ~MutLocFASTSlamInput();
00118    
00120    string print();
00121  };
00122  
00123  
00124  
00128  class MutLocFASTSlam{
00129   
00130   int _counterMeasUpdate;
00131   
00132   MutLocFASTSlamParticle* _particle;
00133   MutLocFASTSlamParticle* _particleNew;
00134   
00135   MutLocFASTSlamParticle _particle1[EKFILTERUNICYCLE2D_NUMPARTICLES];
00136   MutLocFASTSlamParticle _particle2[EKFILTERUNICYCLE2D_NUMPARTICLES];
00137   static const int _numPart = EKFILTERUNICYCLE2D_NUMPARTICLES;
00138   
00139   vector<int> _ekfsId;
00140   
00141   
00142   public:
00143    
00146    void step(MutLocFASTSlamInput &input);  //filtraggio di tipo Kalman
00147    
00149 //    virtual void reset()=0;
00150    
00154    virtual int getEstimate(Pose *best, int hisIds);
00155    
00159    virtual int getMeanEstimate(Pose *mean, int hisIds);
00160    
00164    virtual int getCovariance(MIPMatrix* cov){}
00165    
00170     virtual int getAllEstimates(vector<Pose> &all, vector<Decimal> &allMarks, int id);
00171    
00176     virtual int getAllFeatures(vector<Position> &all, vector<Decimal> &allMarks);
00177    
00179 //    virtual string print()=0;
00180  
00182    MutLocFASTSlam();
00183    
00185    ~MutLocFASTSlam();
00186    
00187   private:
00188    
00189    bool _initialized;
00190    
00191    bool _findId(int id);
00192    void _addId(int id);
00193    void _sysUpdate(EKFilterUnicycle2DIn &in);
00194    
00195    void _firstStep(MutLocFASTSlamInput &input);
00196    void _normalStep(MutLocFASTSlamInput &input);
00197    void _resampling();
00198    void _resampling2();
00199    
00200    void _rateParticle(MutLocFASTSlamParticle &p, int i, MutLocFASTSlamInput input);
00201    
00202  };
00203  
00204 };// end namespace MipAlgorithms
00205 
00206 #endif
00207 
00208 
00209 
00210 /* @} */
00211 
00212 
00213 
00214 
00215 
00216 
00217 
00218 
00219 
00220 
00221 
00222 
00223 
00224 
00225 
00226 
00227 
00228 
00229 
00230 
00231 
00232 
00233 

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