MRXT: The Multi-Robot eXploration Tool
Multi-Robot autonomous exploration and mapping simulator.
|
00001 00002 /* 00003 * 00004 * Author: Miguel Julia <mjulia@umh.es> 00005 * 00006 * Date: 2008 00007 * 00008 * Class RBPFilter 00009 * 00010 * 00011 */ 00012 #pragma once 00013 #ifndef __RAO_BLACKWELLIZED_PARTILCE_FILTER__ 00014 #define __RAO_BLACKWELLIZED_PARTILCE_FILTER__ 00015 00016 #include "particle.h" 00017 #include "ClMutex.h" 00018 #include "robotBase.h" 00019 #include "matFuns.h" 00020 #include "vslamFilter.h" 00021 00022 /** 00023 * @brief Implements an slam algorithm consisting on a rao-blackwellized particle filter 00024 * 00025 */ 00026 class RBPFilter: public vslamFilter{ 00027 00028 /////////////////////////////////////////////////////////////////////// 00029 //------------------------- Attributes ------------------------------ 00030 /////////////////////////////////////////////////////////////////////// 00031 private: 00032 00033 int M; /// number of particles 00034 00035 particle* p; /// particles data structure 00036 particle* newp; /// last particles 00037 int index; /// most probable particle 00038 00039 float* dispRobot; /// measure of uncertainty for each robot 00040 pose** odoData; /// odometry values 00041 pose** lastOdoData; /// last odometry values 00042 rangeSensorData** rsData; /// captured range sensor data 00043 landmarksData** lmData; /// captured features 00044 00045 ClMutex sampling; /// sampling syncronization mutual exclusion 00046 ClMutex closing; /// run/stop control 00047 bool endSlam; /// stop condition 00048 00049 bool onlyonegridmap; /// flag to use only one grid map instead of one per particle 00050 gridMapInterface* omap; /// a common occupancy grid for all particles 00051 binMap* ppmap; /// a common precise pose binMap for all particles 00052 binMap* ipmap; /// a common imprecise pose binMap for all particles 00053 00054 matrix Identity3; /// 3x3 identity matrix 00055 00056 float mahTh; 00057 00058 //--------------------------------------------------------------------- 00059 /////////////////////////////////////////////////////////////////////// 00060 00061 /////////////////////////////////////////////////////////////////////// 00062 //------------------------- Methods -------------------------------- 00063 /////////////////////////////////////////////////////////////////////// 00064 00065 public: 00066 00067 /// Constructor 00068 RBPFilter(); 00069 /// Destructor 00070 virtual ~RBPFilter(); 00071 /// Constructor 00072 RBPFilter(int nrobots, ConfigFile& configFile); 00073 00074 ///initializer 00075 void initialize(int nrobots, ConfigFile& configfile); 00076 00077 /// returns a copy of the current occupancy map 00078 gridMapInterface* getOMap(); 00079 /// returns a copy of the current visual map 00080 visualMap* getVMap(); 00081 /// return a copy of the current precise pose map 00082 binMap* getPreMap(); 00083 /// returns a copy of the current imprecise pose map 00084 binMap* getImpMap(); 00085 00086 /// returns the current pose of the robot 00087 pose getPos(int robot) ; 00088 /// returns the current cell of the robot 00089 point getCell(int robot) ; 00090 /// returns the matrix that represents the covariance of the position of the robot 00091 matrix getCovariance(int robot) const; 00092 /// returns the matrix that represents the covariance of robots and marks 00093 Ematrix getGlobalCovariance() const; 00094 /// returns a measure of the dispersion of the robot 00095 float getDisp(int robot) const; 00096 00097 QImage* getQImage(){return 0;}; 00098 00099 QPixmap* getPixmap(); 00100 00101 00102 private: 00103 00104 /// set up for the execution thread 00105 int setup(); 00106 /// primary execution loop 00107 void execute(); 00108 /// called before stopping 00109 void onStop(); 00110 00111 /// updates fast slam filter 00112 void fastSlam(int robot, const landmarksData& lmData, const pose& lastOdo, const pose& odo); 00113 /// updates one particle of the RBPF 00114 void updateParticle(int robot, const landmarksData& lmData, const pose& lastOdo, const pose& deltaOdo, int i); 00115 /// performs the resampling step 00116 double resample(); 00117 /// updates the occupancy, precise poses and imprecises poses maps 00118 void updateAll(const rangeSensorData& rsData, int robot); 00119 00120 /// evaluates the uncertainty on the position of each robot 00121 void evalDisp(int r); 00122 00123 /// jacobian, this is to update the EKF of each feature 00124 matrix jacobian(const pose& pos); 00125 00126 void drawPoses (IplImage& im, float xorigin, float yorigin, float resolution); 00127 00128 //--------------------------------------------------------------------- 00129 /////////////////////////////////////////////////////////////////////// 00130 }; 00131 00132 inline float RBPFilter::getDisp(int robot) const {return (robot<nBots)? dispRobot[robot] : 0;}; 00133 00134 #endif