}
}
}
+ std::cerr << "finished 0, cost is " << final_path_cost << std::endl;
+ std::cout << rrts.json() << std::endl;
for (int i = 1; i < 5; i++) {
init_node.next();
RRTS rrts2;
}
}
}
+ std::cerr << "finished " << i << ", cost is " << final_path_cost;
+ std::cerr << std::endl;
+ std::cout << rrts2.json() << std::endl;
}
-
- {
- jvo["time"] = TDIFF();
- }
- {
- jvo["iterations"] = rrts.icnt();
- }
- {
- jvo["init"][0] = rrts.nodes().front().x();
- jvo["init"][1] = rrts.nodes().front().y();
- jvo["init"][2] = rrts.nodes().front().h();
- }
- {
- jvo["cost"] = final_path_cost;
- }
- {
- if (final_path.size() > 0) {
- jvo["goal"][0] = final_path.back().x();
- jvo["goal"][1] = final_path.back().y();
- jvo["goal"][2] = final_path.back().h();
- }
- unsigned int cu = 0;
- unsigned int co = 0;
- unsigned int pcnt = 0;
- for (auto n: final_path) {
- jvo["path"][pcnt][0] = n.x();
- jvo["path"][pcnt][1] = n.y();
- jvo["path"][pcnt][2] = n.h();
- if (n.t(RRTNodeType::cusp))
- cu++;
- if (n.t(RRTNodeType::connected))
- co++;
- pcnt++;
- }
- jvo["cusps-in-path"] = cu;
- jvo["connecteds-in-path"] = co;
- }
- {
- unsigned int gcnt = 0;
- for (auto g: rrts.goals()) {
- jvo["goals"][gcnt][0] = g.x();
- jvo["goals"][gcnt][1] = g.y();
- jvo["goals"][gcnt][2] = g.h();
- gcnt++;
- }
- }
- {
- unsigned int ocnt = 0;
- for (auto o: rrts.obstacles()) {
- unsigned int ccnt = 0;
- for (auto c: o.poly()) {
- jvo["obst"][ocnt][ccnt][0] = std::get<0>(c);
- jvo["obst"][ocnt][ccnt][1] = std::get<1>(c);
- ccnt++;
- }
- ocnt++;
- }
- }
- {
- jvo["nodes"] = (unsigned int) rrts.nodes().size();
- }
- //{
- // unsigned int ncnt = 0;
- // for (auto n: rrts.nodes()) {
- // jvo["nodes_x"][ncnt] = n.x();
- // jvo["nodes_y"][ncnt] = n.y();
- // //jvo["nodes_h"][ncnt] = n.h();
- // ncnt++;
- // }
- //}
- std::cout << jvo << std::endl;
return 0;
}