1 #ifndef JSK_FOOTSTEP_PLANNER_GRID_ASTAR_SOLVER_H_
2 #define JSK_FOOTSTEP_PLANNER_GRID_ASTAR_SOLVER_H_
5 #include <boost/unordered_map.hpp>
10 template <
class GraphT>
15 typedef typename GraphT::StateT
State;
19 typedef std::vector<typename SolverNode<State, GraphT>::Ptr>
Path;
20 typedef boost::unordered_map< StatePtr, SolverNodePtr >
SolveList;
25 std::vector<typename SolverNode<State, GraphT>::Ptr>
33 if (
verbose_) { std::cerr <<
"start" << std::endl; }
38 if (
verbose_) { std::cerr <<
"t " <<
p->indexX() <<
" - " <<
p->indexY(); }
39 if (
graph_->isGoal(target_node->getState())) {
40 if (
verbose_) { std::cerr <<
" -> g" << std::endl; }
41 std::vector<SolverNodePtr> result_path = target_node->getPathWithoutThis();
42 result_path.push_back(target_node);
45 std::vector<SolverNodePtr> nnodes = target_node->expand(target_node,
verbose_);
46 if (
verbose_) { std::cerr <<
" -> c "; }
48 for(
int i = 0;
i < nnodes.size();
i++) {
52 std::cerr <<
"a-" <<
i <<
" " << anode->getState()->indexX();
53 std::cerr <<
" - " << anode->getState()->indexY();
57 if(anode->getCost() < prev_cost) {
64 if(anode->getCost() < prev_cost) {
74 if (
i != nnodes.size() -1) {
80 if (
verbose_) { std::cerr << std::endl; }
83 return std::vector<SolverNodePtr>();
94 double min_cost = DBL_MAX;
96 for (
typename SolveList::const_iterator it =
open_list_map_.begin();
98 if (it->second->getSortValue() < min_cost) {
100 min_cost = it->second->getSortValue();
104 typename SolveList::const_iterator it
113 typename SolveList::const_iterator it
116 std::cerr <<
";;;; warn (duplicate adding to openlist) ;;;;" << std::endl;
120 .insert(
typename SolveList::value_type(node->getState(), node));
125 typename SolveList::const_iterator it
128 cost = it->second->getCost();
135 typename SolveList::const_iterator it
142 std::cerr <<
";;;; warn (fail remove) ;;;;" << std::endl;
150 std::cerr <<
";;;; warn (duplicate adding to closelist) ;;;;" << std::endl;
164 virtual bool getOpenList(std::vector<StatePtr> &lst, std::vector<float> &cost)
168 virtual bool getCloseList(std::vector<StatePtr> &lst, std::vector<float> &cost)