43 #include <boost/format.hpp> 48 int main(
int argc,
char** argv)
50 ros::init(argc, argv,
"sample_simple_graph");
51 std::cout <<
"usage: rosrun jsk_footstep_planner sample_astar config/map.txt" << std::endl;
56 const int depth = 1000;
57 for (
size_t d = 0;
d < depth;
d++) {
58 for (
size_t w = 0;
w < width;
w++) {
62 graph->findNode((boost::format(
"%lu_%lu") %
d % (w - 1)).
str())->addNeighbor(graph->findNode((boost::format(
"%lu_%lu") %
d % w).str()));
63 graph->findNode((boost::format(
"%lu_%lu") %
d % w).
str())->addNeighbor(graph->findNode((boost::format(
"%lu_%lu") %
d % (w - 1)).str()));
66 graph->findNode((boost::format(
"%lu_%lu") % (
d - 1) % w).
str())->addNeighbor(graph->findNode((boost::format(
"%lu_%lu") %
d % w).str()));
71 std::cout <<
"done building graph" << std::endl;
72 graph->setStartState(graph->findNode(
"0_0"));
73 graph->setGoalState(graph->findNode((boost::format(
"%lu_%lu") % (depth - 1) % (width - 1)).str()));
74 const int trials = 10;
77 for (
size_t i = 0; i < trials; i++) {
80 std::vector<SolverNode<SimpleNeighboredNode, SimpleNeighboredGraph>::Ptr>
path = solver->solve();
81 std::cout <<
"path: " << path.size() << std::endl;
84 std::cout <<
"braedth first time to solve:" << acc.
mean() << std::endl;
89 for (
size_t i = 0; i < trials; i++) {
92 std::vector<SolverNode<SimpleNeighboredNode, SimpleNeighboredGraph>::Ptr>
path = solver->solve();
93 std::cout <<
"path: " << path.size() << std::endl;
96 std::cout <<
"depth first time to solve:" << acc.
mean() << std::endl;
101 for (
size_t i = 0; i < trials; i++) {
104 std::vector<SolverNode<SimpleNeighboredNode, SimpleNeighboredGraph>::Ptr>
path = solver->solve();
105 std::cout <<
"path: " << path.size() << std::endl;
108 std::cout <<
"best first time to solve:" << acc.
mean() << std::endl;
112 std::vector<SolverNode<SimpleNeighboredNode, SimpleNeighboredGraph>::Ptr>
path = solver->solve();
113 std::cout <<
"number of nodes: " << graph->numNodes() << std::endl;
114 std::cout <<
"start node: " << graph->getStartState()->getName() << std::endl;
115 std::cout <<
"goal node: " << graph->getGoalState()->getName() << std::endl;
116 std::cout <<
"path: " << path.size() << std::endl;
117 for (
size_t i = 0; i < path.size(); i++) {
118 std::cout <<
" " << i <<
" - " << path[i]->getState()->getName() << std::endl;
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
int main(int argc, char **argv)