6 #ifndef DMP_GRAPH_SEARCH_H 7 #define DMP_GRAPH_SEARCH_H 9 #include <boost/heap/d_ary_heap.hpp> 13 #include <unordered_map> 21 bool operator()(T a1, T a2)
const 23 double f1 = a1->g + a1->h;
24 double f2 = a2->g + a2->h;
25 if( ( f1 >= f2 - 0.000001) && (f1 <= f2 +0.000001) )
35 using StatePtr = std::shared_ptr<State>;
36 using priorityQueue = boost::heap::d_ary_heap<StatePtr, boost::heap::mutable_<true>,
37 boost::heap::arity<2>, boost::heap::compare< compare_state<StatePtr> >>;
53 double g = std::numeric_limits<double>::infinity();
67 State(
int id,
int x,
int y,
int z)
68 : id(id), x(x), y(y), z(z)
92 GraphSearch(
const int8_t* cMap,
int xDim,
int yDim,
double eps = 1,
double cweight = 0.1,
bool verbose =
false);
104 GraphSearch(
const int8_t* cMap,
int xDim,
int yDim,
int zDim,
double eps = 1,
double cweight = 0.1,
bool verbose =
false);
117 double plan(
int xStart,
int yStart,
int xGoal,
int yGoal, std::vector<bool> in_region = std::vector<bool>());
131 double plan(
int xStart,
int yStart,
int zStart,
int xGoal,
int yGoal,
int zGoal, std::vector<bool> in_region = std::vector<bool>());
134 std::vector<StatePtr> getPath()
const;
137 std::vector<StatePtr> getOpenSet()
const;
140 std::vector<StatePtr> getCloseSet()
const;
143 std::vector<StatePtr> getAllSet()
const;
147 double plan(StatePtr& currNode_ptr,
int start_id,
int goal_id);
149 void getSucc(
const StatePtr& curr, std::vector<int>& succ_ids, std::vector<double>& succ_costs);
151 std::vector<StatePtr> recoverPath(StatePtr node,
int id);
154 int coordToId(
int x,
int y)
const;
156 int coordToId(
int x,
int y,
int z)
const;
159 bool isFree(
int x,
int y)
const;
161 bool isFree(
int x,
int y,
int z)
const;
164 double getHeur(
int x,
int y)
const;
166 double getHeur(
int x,
int y,
int z)
const;
169 int xDim_, yDim_, zDim_;
176 const int8_t val_free_ = 0;
177 const int8_t val_occ_ = 100;
178 int xGoal_, yGoal_, zGoal_;
183 std::vector<StatePtr> hm_;
184 std::vector<bool> seen_;
185 std::vector<bool> in_region_;
187 std::vector<StatePtr> path_;
189 std::vector<std::vector<int>> ns_;
GraphSearch class.
Definition: graph_search.h:79
double h
heuristic cost
Definition: graph_search.h:55
priorityQueue::handle_type heapkey
pointer to heap location
Definition: graph_search.h:50
double eps_
weight of heuristic
Definition: graph_search.h:171
int x
Coord.
Definition: graph_search.h:45
Definition: graph_search.h:15
Node of the graph in graph search.
Definition: graph_search.h:40
State(int id, int x, int y, int z)
3D constructor
Definition: graph_search.h:67
double cweight_
weight of distance map
Definition: graph_search.h:173
Heap element comparison.
Definition: graph_search.h:19
int id
ID.
Definition: graph_search.h:43
State(int id, int x, int y)
2D constructor
Definition: graph_search.h:62