MRXT: The Multi-Robot eXploration Tool
Multi-Robot autonomous exploration and mapping simulator.
include/architecture/slam/mapdata/gridMapInterface.h
00001 /*
00002 *
00003 * Author: Miguel Julia <mjulia@umh.es> 
00004 * 
00005 * Date:   2009
00006 * 
00007 * Class gridMapInterface
00008 *
00009 
00010 *
00011 */
00012 
00013 #pragma once
00014 #ifndef __GRID__MAP__ITERFACE__
00015 #define __GRID__MAP__ITERFACE__
00016 
00017 #include "binMap.h"
00018 #include "robotTypes.h"
00019 #include "matFuns.h"
00020 #include "rangeSensorData.h"
00021 #include <opencv2/opencv.hpp>
00022 #include <loki/Factory.h>
00023 #include <loki/Typelist.h>
00024 #include <loki/Functor.h>
00025 
00026 /**
00027 * @brief Interface to grid map algorithm class
00028 *
00029 */
00030 
00031 class gridMapInterface
00032 {
00033 ///////////////////////////////////////////////////////////////////////
00034 //-------------------------  Methods  --------------------------------
00035 ///////////////////////////////////////////////////////////////////////
00036 
00037 public:
00038 
00039         virtual ~gridMapInterface(){};
00040 
00041         /// Initializes with size in meters and related to real coordinates
00042         virtual void initialize(float width, float height, float resolution, float xorigin, float yorigin)=0;
00043         /// clone method
00044         virtual gridMapInterface* clone() const=0;
00045         /// assigment operator
00046         virtual gridMapInterface& operator=(const gridMapInterface&)=0;
00047 
00048         /// return the occupancy probability of the cell
00049         virtual float getValue(int x, int y) const=0;
00050         /// return the occupancy probability of the cell
00051         virtual float getValue(int x, int y, int range) const=0;
00052         /// Resets the occupation probability for the total map
00053         virtual void reset()=0;
00054         /// Updates the occupancy grid using the new data
00055         virtual void update(const rangeSensorData& rsData, const pose& rpos, float disp)=0;
00056 
00057         /// sets the x real coordinates of pixel(0,0)
00058         virtual void setXOrigin(float xori)=0;
00059         /// sets the y real coordinates of pixel(0,0)
00060         virtual void setYOrigin(float yori)=0;
00061         /// sets the grid map resolution in meters
00062         virtual void setResolution(float res)=0;
00063         
00064         /// returns the width of the grid map
00065         virtual int getWidth() const=0;
00066         /// returns the height of the grid map
00067         virtual int getHeight() const=0;
00068         /// returns the width of the grid map
00069         virtual float getRealWidth() const=0;
00070         /// returns the height of the grid map
00071         virtual float getRealHeight() const=0;
00072         /// returns the x real coordinates of pixel(0,0)
00073         virtual float getXOrigin() const=0;
00074         /// returns the y real coordinates of pixel(0,0)
00075         virtual float getYOrigin() const=0;
00076         /// returns the grid map resolution in meters
00077         virtual float getResolution() const=0;
00078         
00079         /// Returns a binMap of the frontiers
00080         virtual int frontiers(binMap& frontiers) const=0;
00081         /// Returns a binMap of the frontiers inside the given zone
00082         virtual int frontiersIn(const binMap& zone, binMap& frontiers) const=0;
00083         /// Evaluates the expected safe zone viewed from a given point
00084         virtual void esz(int x, int y, binMap& esz, int dilaterad, int size) const=0;
00085         /// Looks for gateways in a given zone
00086         virtual void gateways(const binMap& esz, binMap& gateways) const=0;
00087         virtual void clearUnconnect(binMap& vz,int x, int y) const=0;
00088         /// Return the occupied cells
00089         virtual void occupiedCells(binMap& occupied, int dilateRad = 1) const=0;
00090         
00091         /// true if the cell is free
00092         virtual bool isfree(int x, int y) const=0;
00093         /// true if the cell is occupied
00094         virtual bool isoccupied(int x, int y) const=0;
00095         /// true if the cell is unknown
00096         virtual bool isunknown(int x, int y) const=0;
00097         /// true if the cell is frontier
00098         virtual bool isfrontier(int x, int y) const=0;
00099         
00100         /// true if all cells in a given square mask of radius rad are free (Totally free)
00101         virtual bool isfree(int x, int y, int rad) const=0;     
00102         /// true if all cells in a diamond 1px mask of radius rad are free (Totally free)
00103         virtual bool isfreeD(int x, int y) const=0;     
00104         /// true if a cell in a given square mask of radius rad is occupied (Partially occupied)
00105         virtual bool isoccupied(int x, int y, int rad) const=0;
00106         /// true if a cell in a given square mask of radius rad is unknown (Partially unknown)
00107         virtual bool isunknown(int x, int y, int size) const=0;
00108         
00109         /// Save function
00110         virtual void saveMapAsImage(const char* file) const=0;
00111         /// Get the map as a new opencv image
00112         virtual IplImage* getMapAsImage() const=0;
00113         /// Show binMap
00114         virtual void showMap(const char* windowname)const =0;
00115 
00116         /// returns an array of points of size points for a line that joins point (x1,y1) and point x2,y2)
00117         virtual point* getLine(int x1, int y1, int x2, int y2, int& points) const=0;
00118 
00119         /// save a map to disk
00120         virtual int saveMapToFile(const char* file) const = 0;
00121         /// load a map from disk
00122         virtual int loadMapFromFile(const char* file) = 0;
00123 
00124         virtual int countAccessible(const point* p, int numpoints, binMap& accessible) const=0;
00125 
00126         virtual point toCell(float x, float y) const=0;
00127         virtual pointf toCoords(int x, int y) const=0;
00128 //--------------------------------------------------------------------- 
00129 ///////////////////////////////////////////////////////////////////////
00130 };
00131 
00132 typedef Loki::Functor<gridMapInterface*, LOKI_TYPELIST_5(float,float,float,float,float)> gridMapCreator;
00133 typedef Loki::SingletonHolder< Loki::Factory< gridMapInterface, int, LOKI_TYPELIST_5(float,float,float,float,float)> > gridMapFactory;
00134 
00135 
00136 #endif
00137 
 All Classes Functions Variables Typedefs