jvo["init"][0] = p.root()->x();
jvo["init"][1] = p.root()->y();
jvo["init"][2] = p.root()->h();
+ jvo["goal"][0] = jvi["goal"][0].asFloat();
+ jvo["goal"][1] = jvi["goal"][1].asFloat();
+ jvo["goal"][2] = jvi["goal"][2].asFloat();
+
+ if (jvi["goals"] != Json::nullValue) {
+ for (auto g: jvi["goals"]) {
+ p.goals().push_back(new RRTNode(
+ g[0].asFloat(),
+ g[1].asFloat(),
+ g[2].asFloat()
+ ));
+ }
+ }
+
+ if (jvi["slot"] != Json::nullValue) {
+ jvo["slot"] = jvi["slot"];
+ }
+
std::vector<CircleObstacle> co;
std::vector<SegmentObstacle> so;
p.HMIN = p.root()->x();
p.ocost(p.root());
p.ocost(p.goal());
- ParallelSlot ps = ParallelSlot();
- if (
- jvi["slot"] != Json::nullValue &&
- jvi["slot"]["polygon"] != Json::nullValue
- ) {
- for (auto xy: jvi["slot"]["polygon"]) {
- ps.slot().add_bnode(new RRTNode(
- xy[0].asFloat(),
- xy[1].asFloat()
- ));
- }
- for (auto e: ps.slot().frame())
- so.push_back(SegmentObstacle(e->init(), e->goal()));
- }
-#ifdef USE_SLOTPLANNER
- TSTART();
- if (ps.slot().bnodes().size() > 0)
- ps.fip(co, so);
- TEND();
- jvo["ppse"] = ELAPSED;
- TPRINT("ParallelSlot");
-#endif
- if (ps.slot().bnodes().size() > 0) {
- ps.setAll();
- //if (ps.getMidd() != nullptr)
- // p.setSamplingInfo(ps.getSamplingInfo());
- }
- if (ps.cusp().size() > 0) {
- p.goal(ps.getMidd());
- p.slot_cusp(ps.cusp().front()); // use first found solution
- p.goals(ps.goals());
- jvo["midd"][0] = p.goal()->x();
- jvo["midd"][1] = p.goal()->y();
- jvo["midd"][2] = p.goal()->h();
- jvo["goal"][0] = p.slot_cusp().back()->x();
- jvo["goal"][1] = p.slot_cusp().back()->y();
- jvo["goal"][2] = p.slot_cusp().back()->h();
- } else {
- jvo["goal"][0] = p.goal()->x();
- jvo["goal"][1] = p.goal()->y();
- jvo["goal"][2] = p.goal()->h();
- }
- TSTART();
- std::cerr << "Slot Info:" << std::endl;
- if (ps.slotSide() == LEFT)
- std::cerr << "- LEFT" << std::endl;
- else
- std::cerr << "- RIGHT" << std::endl;
- if (ps.slotType() == PARALLEL)
- std::cerr << "- PARALLEL" << std::endl;
- else
- std::cerr << "- PERPENDICULAR" << std::endl;
#ifdef USE_LOADF
std::vector<RRTNode *> steered;
for (auto jn: jvi["traj"][0]) {
p.tlog(p.findt());
}
}
- if (p.goal_found() && ps.slotType() == PARALLEL)
- p.tlog(p.findt(p.slot_cusp().back()));
#elif defined USE_PTHREAD
bool gf = false;
RRTNode *ron = nullptr;
jvo["traj"][j][i][4] = n->s();
i++;
}
+ if (j == p.tlog().size() - 1) {
+ i = 0;
+ for (auto n: traj) {
+ jvo["path"][i][0] = n->x();
+ jvo["path"][i][1] = n->y();
+ jvo["path"][i][2] = n->h();
+ i++;
+ }
+ }
j++;
}
+ jvo["goals"][0][0] = p.tlog()[p.tlog().size() - 1].front()->x();
+ jvo["goals"][0][1] = p.tlog()[p.tlog().size() - 1].front()->y();
+ jvo["goals"][0][2] = p.tlog()[p.tlog().size() - 1].front()->h();
#ifdef JSONLOGEDGES
i = 0;
j = 0;