MRXT: The Multi-Robot eXploration Tool
Multi-Robot autonomous exploration and mapping simulator.
|
00001 #pragma once 00002 #ifndef __PATH__PLANNING__FUNS___ 00003 #define __PATH__PLANNING__FUNS___ 00004 00005 #include "robotTypes.h" 00006 #include "binMap.h" 00007 #include "gridMapInterface.h" 00008 00009 #define VHMOV 100 00010 #define DMOV 142 00011 #define COSTOCC 100 00012 #define COSTOBS 1000 00013 00014 00015 //typedef struct ocell{ 00016 // unsigned short x; 00017 // unsigned short y; 00018 // short th; // 0, 45, 90, 135, 180, 225, 270, 315 00019 //}ocell; 00020 00021 /// Cost cell struct used for path planning with heuristics 00022 typedef struct costCellH{ 00023 long int F; 00024 long int G; 00025 long int H; 00026 bool closed; 00027 bool open; 00028 void* parent; 00029 }costCellH; 00030 00031 /// Cost cell struct used for path planning 00032 typedef struct costCell{ 00033 long int C; 00034 void* parent; 00035 bool closed; 00036 bool open; 00037 costCell():C(999999999L),parent(0){} 00038 }costCell; 00039 00040 //class costMap{ 00041 //private: 00042 // costCell* data; 00043 // std::vector<ocell>* closedlist; 00044 // int step; 00045 // int angles; 00046 // long maxcost; 00047 //public: 00048 // costMap(costCell* d, int s, int ang, std::vector<ocell>* cl, long max): data(d), closedlist(cl), step(s), angles(ang), maxcost(max){}; 00049 // //costMap* createPolicy(const ocell& target, const gridMapInterface& omap); 00050 // virtual ~costMap(){if (data){ delete[] data; delete closedlist;}}; 00051 // long getCost(int i, int j){ 00052 // long min=data[j*step+i*angles].C; 00053 // for (int a = 1; a < angles; a++){ 00054 // int idx = j*step+i*angles+a; 00055 // if (data[idx].C<min) min = data[idx].C; 00056 // } 00057 // return min; 00058 // } 00059 // int getPath(const ocell& dest, std::vector<ocell>& resultpath){ 00060 // resultpath.clear(); 00061 // const ocell* p = &dest; 00062 // while (p!=0){ 00063 // resultpath.push_back(*p); 00064 // long idxnext = p->y*step+p->x*angles+p->th; 00065 // p = (ocell*) data[idxnext].parent; 00066 // } 00067 // resultpath.pop_back(); 00068 00069 // return resultpath.size(); 00070 // } 00071 // long getMaxCost(){return maxcost;}; 00072 //}; 00073 00074 00075 /** 00076 * @brief Stores the cost to reach each cell of the map 00077 */ 00078 class costMapSimple{ 00079 private: 00080 costCell* data; 00081 std::vector<point>* closedlist; 00082 int step; 00083 long maxcost; 00084 public: 00085 costMapSimple(costCell* d, int s, std::vector<point>* cl, long max): data(d), closedlist(cl), step(s), maxcost(max){}; 00086 //costMapSimple* createPolicy(const point& target, const gridMapInterface& omap); 00087 virtual ~costMapSimple(){if (data){ delete[] data; delete closedlist;}}; 00088 long getCost(int i, int j){ 00089 return data[j*step+i].C; 00090 } 00091 int getPath(const point& dest, std::vector<point>& resultpath){ 00092 resultpath.clear(); 00093 const point* p = &dest; 00094 while (p!=0){ 00095 resultpath.push_back(*p); 00096 long idxnext = p->y*step+p->x; 00097 p = (point*) data[idxnext].parent; 00098 } 00099 resultpath.pop_back(); 00100 00101 return resultpath.size(); 00102 } 00103 long getMaxCost(){return maxcost;}; 00104 }; 00105 00106 //const int avancex[8] = {1, 1, 0, -1, -1, -1, 0, 1}; 00107 //const int avancey[8] = {0, 1, 1, 1, 0, -1, -1, -1}; 00108 00109 int AStarGrid(const point& origin, const point& target, const gridMapInterface& omap, std::vector<point>& resultpath, bool trackUnknown); 00110 00111 int DijkstraGrid(const point& origin, const binMap& objectives, const gridMapInterface& omap, std::vector<point>& resultpath, int inflaterad); 00112 00113 costMapSimple* createCostMap(const point& origin, const binMap& objectives, const gridMapInterface& omap, std::vector<point>& reachable, int inflaterad); 00114 00115 //int DijkstraGridWithHeading(const ocell& origin, const binMap& objectives, const gridMapInterface& omap, std::vector<ocell>& resultpath); 00116 00117 //costMap* createCostMapOri(const ocell& origin, const binMap& objectives, const gridMapInterface& omap, std::vector<ocell>& reachable); 00118 00119 //costMap* createPolicy(const ocell& target, const gridMapInterface& omap); 00120 00121 #endif