}
// other
-void ParallelSlot::fip()
+void ParallelSlot::fip(
+ std::vector<CircleObstacle>& co,
+ std::vector<SegmentObstacle>& so
+)
{
// see https://courses.cs.washington.edu/courses/cse326/03su/homework/hw3/bfs.html
// RRTNode.s() works as iteration level
int i = 0;
c = B->move(CC, -i * di * 0.01 / CC->diag_radi());
while (!this->slot().collide(c->frame())) {
- q.push(c);
+ bool end = false;
+ std::vector<RRTEdge *> eds = c->frame();
+ for (auto o: co)
+ if (o.collide(eds))
+ end = true;
+ for (auto o: so)
+ if (o.collide(eds))
+ end = true;
+ for (auto e: eds)
+ delete e;
+ if (!end)
+ q.push(c);
c = B->move(CC, -i * di * 0.01 / CC->diag_radi());
i += 1;
}
if (this->isInside(c)) {
goto createcuspandfinish;
} else if (c->s() < 9) {
- BicycleCar *cc = this->flnc(c);
+ BicycleCar *cc = this->flnc(c, co, so);
cc->s(c->s() + 1);
cc->bcparent(c);
q.push(cc);
this->cusp().push_back(cusp);
}
-BicycleCar *ParallelSlot::flnc(BicycleCar *B)
+BicycleCar *ParallelSlot::flnc(
+ BicycleCar *B,
+ std::vector<CircleObstacle>& co,
+ std::vector<SegmentObstacle>& so
+)
{
RRTNode *cc;
if (this->slotSide() == LEFT) {
delete p;
i += 10;
p = B->move(cc, i * this->DH());
+ bool end = false;
+ std::vector<RRTEdge *> eds = p->frame();
+ for (auto o: co)
+ if (o.collide(eds))
+ end = true;
+ for (auto o: so)
+ if (o.collide(eds))
+ end = true;
+ for (auto e: eds)
+ delete e;
+ if (end)
+ break;
}
i -= 10;
p = B->move(cc, i * this->DH());
delete p;
i += 1;
p = B->move(cc, i * this->DH());
+ bool end = false;
+ std::vector<RRTEdge *> eds = p->frame();
+ for (auto o: co)
+ if (o.collide(eds))
+ end = true;
+ for (auto o: so)
+ if (o.collide(eds))
+ end = true;
+ for (auto e: eds)
+ delete e;
+ if (end)
+ break;
}
delete p;
return B->move(cc, (i - 1) * this->DH());
// other
/** BFS to _Find Init Pose_. */
- void fip();
+ void fip(
+ std::vector<CircleObstacle>& co,
+ std::vector<SegmentObstacle>& so
+ );
/** _Find Init Pose by Reverse_ approach, see Vorobieva2015
@param B Last pose of vehicle when it is parked.
@param B Find from?
*/
- BicycleCar *flnc(BicycleCar *B);
+ BicycleCar *flnc(
+ BicycleCar *B,
+ std::vector<CircleObstacle>& co,
+ std::vector<SegmentObstacle>& so
+ );
RRTNode *fposecenter();
/** Recursive function to find out the moves */
bool flast(