RelPaFil.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 
00032 /* @{ */
00033 
00034 #ifndef __REL_PA_FIL_H_
00035 #define __REL_PA_FIL_H_
00036 
00037 #include "MutLoc.h"
00038 
00039 namespace MipAlgorithms{
00043  class RelParticle {
00044   public:
00046    Decimal weight;
00048    Pose p;
00049    
00051    RelParticle(){
00052    }
00053    
00055    RelParticle ( Pose a, Decimal w){
00056     p=a;
00057     weight=w;
00058     }
00059    
00061    RelParticle(const RelParticle &A){
00062     p     = A.p;
00063     weight= A.weight;
00064    }
00065    
00067    void operator= (const RelParticle &A){
00068     p     = A.p;
00069     weight= A.weight;
00070    }
00071    
00073    string print(){
00074     stringstream s;
00075     s << "weight:" << this -> weight << endl << "Pose:" << this -> p.print();
00076     return s.str();
00077    }
00078  };
00079 }; // end namespace MipAlgorithms
00080 
00081 
00082 namespace MipAlgorithms{
00087  class RelPaFilParams{
00088   public:
00090    int numPart; 
00092    Decimal sigma_xx;
00094    Decimal sigma_yy;
00096    Decimal sigma_thetatheta;
00098    Decimal severity_xx;
00100    Decimal severity_yy;
00102    Decimal severity_thetatheta;
00104    int factor;
00106    int hisId;
00108    RelParticleFilterType type;
00110    int tempo_in;
00112    RelPaFilParams(){
00113    }
00114    
00116    RelPaFilParams( int N, Decimal sx , Decimal sy, Decimal sth, Decimal sev_x , Decimal sev_y, Decimal sev_th, int fac, int hId, RelParticleFilterType ty, int tmp){
00117     sigma_xx     = sx;
00118     sigma_yy    = sy;
00119     sigma_thetatheta = sth;
00120     severity_xx = sev_x;
00121     severity_yy = sev_y;
00122     severity_thetatheta = sev_th;
00123     numPart    = N;
00124     factor   = fac;
00125     hisId  = hId;
00126     type  = ty;
00127     tempo_in = tmp; 
00128    }
00129  
00131    RelPaFilParams(const RelPaFilParams &A){
00132     sigma_xx     = A.sigma_xx;
00133     sigma_yy    =  A.sigma_yy;
00134     sigma_thetatheta = A.sigma_thetatheta;
00135     severity_xx = A.severity_xx;
00136     severity_yy = A.severity_yy;
00137     severity_thetatheta = A.severity_thetatheta;
00138     numPart    = A.numPart;
00139     factor  = A.factor;
00140     hisId  = A.hisId;
00141     type  = A.type;  
00142     tempo_in = A.tempo_in; 
00143    }
00144  
00146    void operator= (const RelPaFilParams &A){
00147     sigma_xx      = A.sigma_xx;
00148     sigma_yy     =  A.sigma_yy;
00149     sigma_thetatheta = A.sigma_thetatheta;
00150     severity_xx = A.severity_xx;
00151     severity_yy = A.severity_yy;
00152     severity_thetatheta = A.severity_thetatheta;
00153     numPart     = A.numPart;
00154     factor  = A.factor;
00155     hisId  = A.hisId;
00156     type  = A.type;
00157     tempo_in = A.tempo_in;
00158    } 
00159    
00161    string print(){
00162     stringstream s;
00163     s << "Stampa RelPaFilParams: " << endl;
00164     s << "sigma_xx = " << sigma_xx << endl;
00165     s << "sigma_yy = " << sigma_yy << endl;
00166     s << "sigma_thetatheta = " << sigma_thetatheta << endl;
00167     s << "severity_xx = " << severity_xx << endl;
00168     s << "severity_yy = " << severity_yy << endl;
00169     s << "severity_thetatheta = " << severity_thetatheta << endl;
00170     s << "numPart = " << numPart << endl;
00171     s << "factor = " << factor << endl;
00172     s << "hisId = " << hisId << endl;
00173     s << "tempo_corrente = " << tempo_in << endl;
00174     if (type==ABS) s << "type = ABS" << endl;
00175     else  s << "type = REL" << endl;
00176     return s.str();
00177    }
00178  };
00179 };
00180 
00181 
00182 namespace MipAlgorithms{
00186  class RelPaFilVariables{
00187   public:
00189    int step;
00191    vector<RelParticle> map;
00193    Pose Ixi_tmeno1;
00195    Pose Jxj_tmeno1;
00197    Pose bestIxJ_mean;
00199    Pose bestIxJ_winner;
00201    int bestRelParticle;
00203    Pose myLastConf;
00205    Pose hisLastConf;
00206    
00207    
00209    RelPaFilVariables (){
00210     step = 0;
00211     Ixi_tmeno1 = Pose (); 
00212     Jxj_tmeno1 = Pose (); 
00213     bestIxJ_mean = Pose ();
00214     bestIxJ_winner = Pose ();
00215     bestRelParticle=0;
00216     myLastConf = Pose();  
00217     hisLastConf = Pose(); 
00218    }
00219    
00221    RelPaFilVariables(const RelPaFilVariables &A){
00222     //un nuovo oggetto parFilVariables coi campi uguali
00223     step  = A.step;
00224     Ixi_tmeno1 = A.Ixi_tmeno1;
00225     Jxj_tmeno1 = A.Jxj_tmeno1;
00226     bestIxJ_mean = A.bestIxJ_mean;
00227     bestIxJ_winner = A.bestIxJ_winner;
00228     bestRelParticle = A.bestRelParticle;
00229     myLastConf = A.myLastConf;  
00230     hisLastConf = A.hisLastConf; 
00231     map = A.map; //Rivedere!!!!!!!!!
00232     }
00233    
00235    RelPaFilVariables operator=(RelPaFilVariables &A){
00236     step  = A.step;
00237     Ixi_tmeno1 = A.Ixi_tmeno1;
00238     Jxj_tmeno1 = A.Jxj_tmeno1;
00239     bestIxJ_mean = A.bestIxJ_mean;
00240     bestIxJ_winner = A.bestIxJ_winner;
00241     bestRelParticle = A.bestRelParticle;
00242     myLastConf = A.myLastConf;  
00243     hisLastConf = A.hisLastConf;
00244    }
00245    
00247    ~RelPaFilVariables(){
00248     //RelParticle.clear();
00249     map.clear();
00250    }
00251    
00253    string print(){
00254     stringstream s;
00255     s << endl;
00256     s << "Step: " << step << endl;
00257     s << "Ixi_tmeno1 = " << Ixi_tmeno1.print() << endl;
00258     s << "Jxj_tmeno1 = " << Jxj_tmeno1.print() << endl;
00259     s << "bestIxJ_mean = " << bestIxJ_mean.print() << endl;
00260     s << "bestIxJ_winner = " << bestIxJ_winner.print() << endl;
00261     s << "bestRelParticle = " << bestRelParticle << endl;
00262     s << "myLastConf = " << myLastConf.print() << endl; 
00263     s << "hisLastConf = " << hisLastConf.print() << endl;
00264     return s.str();
00265    }
00266  };
00267 };// end namespace MipAlgorithms
00268 
00269 
00270 
00271 namespace MipAlgorithms{
00275  class RelParticleFilter : public MutLocFilter{
00276   public:
00277    
00278    //costruttori
00280    RelParticleFilter(){
00281    }
00282  
00284    RelParticleFilter(RelPaFilParams in){
00285     par = in;
00286     var = (RelPaFilVariables*) new RelPaFilVariables();
00287     init();
00288    }
00289    
00290    //metodi virtuali della classe genitore
00292    void step(MutLocFilInput &input);
00293    
00295    void reset(){} //qua dobbiamo eliminare i risultati delle operazioni fatte
00296    
00298    void getInternalEstimate(MutLocFilInput &input, vector<RelParticle> &last_map);
00299    
00301    void getInternalEstimate_abs(MutLocFilInput &input, vector<RelParticle> &last_map);
00302    
00304    void getInternalEstimate_rel(MutLocFilInput &input, vector<RelParticle> &last_map);
00305    
00308    int getEstimate(Pose* best);
00309    
00312    int getAllEstimates(vector<Pose> &all, vector<Decimal> &allMarks);
00313    
00315    void updateVar(MutLocFilInput &input, vector<RelParticle> &last_map, int &caso);
00316    
00318    string print();
00319  
00321    void reset(RelPaFilParams inPar){
00322     assert(initialized());
00323     par = inPar;
00324     var->step = 0;
00325     var->Ixi_tmeno1 = Pose();
00326     var->Jxj_tmeno1 = Pose();
00327     var->map.clear();
00328    }
00329    
00331    int getStep(){
00332     assert(initialized());
00333     return var->step;
00334    }
00335  
00337    Pose getIxi(){
00338     assert(initialized());
00339     return var->Ixi_tmeno1;
00340    }
00341    
00343    Pose getJxj(){
00344     assert(initialized());
00345     return var->Jxj_tmeno1;
00346    }
00347    
00349    void ComputeWeights (MutLocFilInput &input, int &caso);
00350    
00352    void ComputeWeights_abs (MutLocFilInput &input, int &caso);
00353    
00355    void ComputeWeights_rel (MutLocFilInput &input, int &caso);
00356    
00359    vector<RelParticle> Resample();
00360    
00362    void OutputPerformance (MutLocFilInput &input) ;
00363    
00364   protected:
00366    RelPaFilParams par;
00368    RelPaFilVariables *var;
00369    
00370   private:
00372    void CreateMap_abs(MutLocFilInput &input);
00373    
00375    void CreateMap_rel(MutLocFilInput &input);
00376    
00378    void PropagateMap(MutLocFilInput &input, int &caso);
00379    
00381    void PropagateMap_abs(MutLocFilInput &input, int &caso);
00382    
00384    void PropagateMap_rel(MutLocFilInput &input, int &caso);
00385    
00388    Pose* gaussPose(int &factor);
00389    
00391    void normalStep(MutLocFilInput &input);
00392    
00394    void firstStep(MutLocFilInput &input);
00395    
00397    void NormalizeWeights(int &caso);
00398  };
00399 };// end namespace MipAlgorithms
00400 
00401 
00402 #endif
00403 
00404 
00405 
00406 
00407 
00408 

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