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 * Class OGMReflectProb 00008 * 00009 * 00010 */ 00011 00012 #pragma once 00013 00014 #ifndef __MORAVEC__AND__ELFES_85__ 00015 #define __MORAVEC__AND__ELFES_85__ 00016 00017 #include "binMap.h" 00018 #include "robotTypes.h" 00019 #include "occupancyGridMap.h" 00020 00021 ///represents the occupation probability of a cell in a grid occupancy map 00022 typedef struct cell{ 00023 float occ; 00024 float total; 00025 float val; 00026 //float val2; 00027 cell():occ(0),total(0),val(50.0f)//,val2(50.0f) 00028 {}; 00029 }cell; 00030 00031 static cell nullcell; 00032 00033 /** 00034 * @brief Implements an ocupancy grid map using a counting model 00035 */ 00036 00037 class OGMReflectProb: public occupancyGridMap{ 00038 00039 /////////////////////////////////////////////////////////////////////// 00040 //------------------------- Attributes ------------------------------ 00041 /////////////////////////////////////////////////////////////////////// 00042 00043 00044 00045 private: 00046 00047 int totalsize; 00048 cell* cells; // Data cell array 00049 float step; 00050 00051 //--------------------------------------------------------------------- 00052 /////////////////////////////////////////////////////////////////////// 00053 00054 /////////////////////////////////////////////////////////////////////// 00055 //------------------------- Methods -------------------------------- 00056 /////////////////////////////////////////////////////////////////////// 00057 00058 public: 00059 /// Default Constructor 00060 OGMReflectProb(); 00061 /// Constructor with size in meters and related to real coordinates 00062 OGMReflectProb(float w, float h, float res, float x, float y); 00063 /// Destructor 00064 virtual ~OGMReflectProb(); 00065 00066 /// Initializes with size in meters and related to real coordinates 00067 void initialize(float w, float h, float res, float x, float y); 00068 /// clone method 00069 OGMReflectProb* clone() const; 00070 00071 /// assigment operator 00072 gridMapInterface& operator=(const gridMapInterface&); 00073 00074 /// return the occupancy probability of the cell 00075 float getValue(int x, int y) const; 00076 /// Resets the occupation probability for the total map 00077 void reset(); 00078 00079 /// Updates the occupancy grid using the new data 00080 void update(const rangeSensorData& rsData, const pose& rpos, float disp=0); 00081 00082 /// save a map to disk 00083 int saveMapToFile(const char* file) const; 00084 /// load a map from disk 00085 int loadMapFromFile(const char* file); 00086 00087 private: 00088 00089 /// copy constructor 00090 OGMReflectProb(const OGMReflectProb&); 00091 /// Returns the occupation probability for a cell 00092 cell& get(int x, int y) ; 00093 00094 //--------------------------------------------------------------------- 00095 /////////////////////////////////////////////////////////////////////// 00096 }; 00097 00098 inline float OGMReflectProb::getValue(int x, int y) const{ 00099 int idx(y*width+x); 00100 return (idx >=0 && idx < totalsize)? cells[idx].val : 50.0f; 00101 }; 00102 00103 inline cell& OGMReflectProb::get(int x, int y) { 00104 int idx(y*width+x); 00105 return (idx >=0 && idx < totalsize)? cells[idx]: nullcell; 00106 }; 00107 00108 inline OGMReflectProb* OGMReflectProb::clone() const {return new OGMReflectProb(*this);}; 00109 00110 #endif