MRXT: The Multi-Robot eXploration Tool
Multi-Robot autonomous exploration and mapping simulator.
|
00001 /* 00002 * 00003 * Author: Miguel Julia <mjulia@umh.es> 00004 * 00005 * Date: 2008 00006 * 00007 * Abstract Class SLAM Filter 00008 * 00009 * 00010 */ 00011 00012 #pragma once 00013 #ifndef __SLAM_FILTER__ 00014 #define __SLAM_FILTER__ 00015 00016 #include "slamInterface.h" 00017 #include "robotBase.h" 00018 #include "matFuns.h" 00019 00020 /** 00021 * @brief Implement common attributes and methods for slam algorithms 00022 * 00023 */ 00024 00025 class vslamFilter: public slamInterface{ 00026 00027 Q_OBJECT 00028 00029 signals: 00030 00031 void slamUpdated(); 00032 00033 /////////////////////////////////////////////////////////////////////// 00034 //------------------------- Attributes ------------------------------ 00035 /////////////////////////////////////////////////////////////////////// 00036 protected: 00037 00038 int nBots; /// number of robots 00039 00040 float th_high; /// deslocalization threshold 00041 float th_low; /// localization threshold 00042 00043 float width; /// real width 00044 float height; /// real height 00045 float resolution; /// grip map resolution 00046 int gmwidth; /// grid map width 00047 int gmheight; /// grid map height 00048 float xorigin; /// x position in real coordinates of grid map origin 00049 float yorigin; /// y position in real coordinates of grid map origin 00050 00051 robotBase** rbase; /// pointers to robots bases 00052 bool* robotsEnabled; 00053 worldModelInterface* scene; /// pointer to world model 00054 00055 bool* badlocalized; /// localization state for each robot (well localized / bad localized) 00056 00057 char* logstr; /// name for log results file 00058 00059 bool displayomap; /// flag that indicates if the occupancy map must be displayed 00060 bool displayppmap; /// flag that indicates if the occupancy map must be displayed 00061 bool displayipmap; /// flag that indicates if the occupancy map must be displayed 00062 bool displayposes; /// flag that indicates if the position of the robot for each particle must be displayed 00063 bool displayfeatures; /// flag that indicates if the features must be displayed 00064 bool saveAviFile; 00065 00066 float alfa1; /// odometry params 00067 float alfa2; /// odometry params 00068 float alfa3; /// odometry params 00069 float alfa4; /// odometry params 00070 float drifttrans; /// odometry params 00071 00072 int gmtype; /// gridmap algorithm 00073 int vmtype; /// visual map implementation 00074 bool perfectMatching; /// type of data association 00075 int nmarks; /// num of landmarks to reserve 00076 00077 char* windowName; 00078 //--------------------------------------------------------------------- 00079 /////////////////////////////////////////////////////////////////////// 00080 00081 /////////////////////////////////////////////////////////////////////// 00082 //------------------------- Methods -------------------------------- 00083 /////////////////////////////////////////////////////////////////////// 00084 00085 public: 00086 00087 /// Constructor 00088 vslamFilter(); 00089 /// Destructor 00090 virtual ~vslamFilter(); 00091 /// Constructor 00092 vslamFilter(int nrobots, ConfigFile& configFile); 00093 00094 ///initializer 00095 void initialize(int nrobots, ConfigFile& configfile); 00096 00097 /// sets the pointer to a robot base object 00098 void setRobotBase(int robot, robotBase& rbase); 00099 /// sets the world model 00100 void setWorldModel(worldModelInterface& scene); 00101 00102 /// return the number of robots 00103 int getNumRobots() const; 00104 /// returns the width of the map 00105 float getWidth() const; 00106 /// return the height of the map 00107 float getHeight() const; 00108 /// return the x position of the origin of grid map in real coordinates 00109 float getXOrigin() const; 00110 /// return the y position of the origin of grid map in real coordinates 00111 float getYOrigin() const; 00112 /// returns the resolution of the gridmap 00113 float getResolution() const; 00114 /// returns the width in cells of the grid map 00115 int getGMWidth() const; 00116 /// returns the height in cells of the grid map 00117 int getGMHeight() const; 00118 00119 /// sets the high uncertainty threshold for the localization state 00120 void setHighThreshold(float thb); 00121 /// sets the low uncertainty threshold for the localization state 00122 void setLowThreshold(float tha); 00123 /// return the current state of localization of the robot 00124 bool getLoc(int robot) const; 00125 00126 /// returns the current simulation time 00127 float getTime() const; 00128 /// returns the period of the simulation time step 00129 float getSampleTime() const; 00130 00131 /// returns a copy of the current occupancy map 00132 virtual gridMapInterface* getOMap() = 0; 00133 /// returns a copy of the current visual map 00134 virtual visualMap* getVMap() = 0; 00135 /// return a copy of the current precise pose map 00136 virtual binMap* getPreMap() = 0; 00137 /// returns a copy of the current imprecise pose map 00138 virtual binMap* getImpMap() = 0; 00139 00140 /// returns the current pose of the robot 00141 virtual pose getPos(int robot) = 0 ; 00142 /// returns the current cell of the robot 00143 virtual point getCell(int robot) = 0 ; 00144 /// returns the matrix that represents the covariance of the position of the robot 00145 virtual matrix getCovariance(int robot) const = 0 ; 00146 /// returns the matrix that represents the covariance of robots and marks 00147 virtual Ematrix getGlobalCovariance() const = 0 ; 00148 /// returns a measure of the dispersion of the robot 00149 virtual float getDisp(int robot) const = 0; 00150 00151 /// sets the name of the log file 00152 void setLogName(const char*); 00153 /// sets the name of the gridmap file 00154 void setGridMapName(const char*){}; 00155 00156 void setWindowName(const char*); 00157 00158 void disableRobotBase(int r); 00159 00160 virtual QPixmap* getPixmap()=0; 00161 virtual QImage* getQImage()=0; 00162 00163 00164 protected: 00165 00166 /// set up for the execution thread 00167 virtual int setup()=0; 00168 /// primary execution loop 00169 virtual void execute()=0; 00170 /// called before stopping 00171 virtual void onStop()=0; 00172 00173 /// updates precise poses map 00174 void updatePPMap(const point& rpos, binMap& ppmap, float disp, bool badloc); 00175 /// updates imprecise poses map 00176 void updateIPMap(const point& rpos, binMap& ipmap, float disp, bool badloc); 00177 00178 /// returns a likely evolution of the robot pose using the odometry model 00179 pose odometryModel(const pose& lastOdo, const pose& deltaOdo, const pose& lastPose); 00180 00181 00182 00183 //--------------------------------------------------------------------- 00184 /////////////////////////////////////////////////////////////////////// 00185 }; 00186 00187 inline void vslamFilter::setRobotBase(int robot, robotBase& rb) {rbase[robot] = &rb;}; 00188 inline void vslamFilter::setWorldModel (worldModelInterface& s) {scene = &s;}; 00189 inline int vslamFilter::getNumRobots() const {return nBots;}; 00190 inline float vslamFilter::getWidth() const {return width;}; 00191 inline float vslamFilter::getHeight() const {return height;}; 00192 inline float vslamFilter::getXOrigin() const {return xorigin;}; 00193 inline float vslamFilter::getYOrigin() const {return yorigin;}; 00194 inline int vslamFilter::getGMWidth() const {return gmwidth;}; 00195 inline int vslamFilter::getGMHeight() const {return gmheight;}; 00196 inline float vslamFilter::getResolution() const {return resolution;}; 00197 inline void vslamFilter::setHighThreshold(float thb) {th_high = thb;}; 00198 inline void vslamFilter::setLowThreshold(float tha) {th_low = tha;}; 00199 inline bool vslamFilter::getLoc(int robot) const {return (robot<nBots)? badlocalized[robot] : 0;}; 00200 inline float vslamFilter::getTime() const {return scene->getTime();}; 00201 inline float vslamFilter::getSampleTime() const {return scene->getSampleTime();}; 00202 00203 #endif