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 __PA_FIL_BFL_RR_BEAR_ONLY_H_ 00035 #define __PA_FIL_BFL_RR_BEAR_ONLY_H_ 00036 00037 #include <filter/bootstrapfilter.h> 00038 00039 #include <model/systemmodel.h> 00040 #include <model/measurementmodel.h> 00041 #include "time.h" 00042 00043 #include <iostream> 00044 #include <fstream> 00045 00046 #include <pdf/conditionalpdf.h> 00047 #include <pdf/gaussian.h> 00048 #include "PaFilBFL.h" 00049 00050 using namespace MatrixWrapper; 00051 using namespace BFL; 00052 using namespace std; 00053 using namespace MipBaselib; 00054 //Pose _bestParticlePose; 00055 //Decimal _bestParticleProb; 00056 00057 00058 namespace MipAlgorithms { 00059 00061 class NonlinearMobileRobRelRelBearOnlyPdf : public ConditionalPdf<MatrixWrapper::ColumnVector, MatrixWrapper::ColumnVector> { 00062 public: 00065 NonlinearMobileRobRelRelBearOnlyPdf( const Gaussian& additiveNoise); 00066 00068 virtual ~NonlinearMobileRobRelRelBearOnlyPdf(); 00069 00070 // implement this virtual function for system model of a particle filter 00071 virtual bool SampleFrom (Sample<MatrixWrapper::ColumnVector>& one_sample, int method=DEFAULT, void * args=NULL) const; 00072 00073 private: 00074 Gaussian _additiveNoise; 00075 }; 00076 00077 00079 class NonlinearMeasurementRelRelBearOnlyPdf : public ConditionalPdf<MatrixWrapper::ColumnVector, MatrixWrapper::ColumnVector> { 00080 public: 00083 NonlinearMeasurementRelRelBearOnlyPdf( const Gaussian& measNoise); 00084 00086 virtual ~NonlinearMeasurementRelRelBearOnlyPdf(); 00087 00088 // implement this virtual function for measurement model of a particle filter 00089 virtual Probability ProbabilityGet(const MatrixWrapper::ColumnVector& measurement) const; 00090 00091 private: 00092 Gaussian _measNoise; 00093 }; 00094 00095 00099 class PaFilBFLRelRelBearOnly : public PaFilBFL{ 00100 public: 00101 00103 PaFilBFLRelRelBearOnly(PaFilBFLPar par); 00104 00106 ~PaFilBFLRelRelBearOnly(); 00107 00110 void step(MutLocFilInput &input); 00111 00113 void reset(); 00114 00116 string print(); 00117 00118 private: 00119 // Timer: 00120 Timer timer_measures; 00121 Decimal iniTime; 00122 00123 int iteration; 00124 00125 PaFilBFLPar _par; 00126 00127 NonlinearMobileRobRelRelBearOnlyPdf* _sys_pdf; 00128 SystemModel<ColumnVector>* _sys_model; 00129 00130 NonlinearMeasurementRelRelBearOnlyPdf* _meas_pdf; 00131 MeasurementModel<ColumnVector, ColumnVector>* _meas_model; 00132 00133 Pose _myPrevConf; 00134 Pose _myCurrConf; 00135 Pose _myOdometry; 00136 00137 Pose _hisPrevConf; 00138 Pose _hisCurrConf; 00139 Pose _hisOdometry; 00140 00141 Decimal _myOdometryNorm; 00142 Decimal _hisOdometryNorm; 00143 00144 void _normalStep(MutLocFilInput &input); 00145 00146 void _firstStep(MutLocFilInput &input); 00147 00148 void _computeHisOdometry(MutLocFilInput &input); 00149 00150 }; 00151 } 00152 00153 #endif 00154 00155 00156 00157 00158 00159