51 #define DEBUG_COND_ZIPPER (ego->isSelected()) 63 #define ZIPPER_ADAPT_TIME 10 65 #define JM_CROSSING_GAP_DEFAULT 10 68 #define DIVERGENCE_MIN_WIDTH 2.5 75 myLaneBefore(predLane),
84 myFoeVisibilityDistance(foeVisibilityDistance),
88 myKeepClear(keepClear),
90 myInternalLaneBefore(nullptr),
94 myWalkingAreaFoe(nullptr),
95 myWalkingAreaFoeExit(nullptr),
96 myHavePedestrianCrossingFoe(false),
97 myParallelRight(nullptr),
98 myParallelLeft(nullptr),
108 const double dist = from.back().distanceTo2D(to.front());
114 myLateralShift = (from.back().distanceTo2D(to.front()) < dist) ? dist : -dist;
126 const std::vector<MSLink*>& foeLinks,
127 const std::vector<MSLane*>& foeLanes,
128 MSLane* internalLaneBefore) {
138 for (std::vector<MSLane*>::const_iterator it_lane = foeLanes.begin(); it_lane != foeLanes.end(); ++it_lane) {
146 if (internalLaneBefore !=
nullptr) {
148 lane = internalLaneBefore;
154 #ifdef MSLink_DEBUG_CROSSING_POINTS 157 if (lane !=
nullptr) {
158 const bool beforeInternalJunction = lane->
getLinkCont()[0]->getViaLaneOrLane()->getEdge().isInternal();
163 for (std::vector<const MSLane*>::const_iterator it_lane =
myFoeLanes.begin(); it_lane !=
myFoeLanes.end(); ++it_lane) {
166 if (sameTarget && !beforeInternalJunction && !
contIntersect(lane, *it_lane)) {
170 #ifdef MSLink_DEBUG_CROSSING_POINTS 172 <<
" " << lane->
getID()
173 <<
" merges with " << (*it_lane)->getID()
174 <<
" nextLane " << lane->
getLinkCont()[0]->getViaLaneOrLane()->getID()
181 #ifdef MSLink_DEBUG_CROSSING_POINTS 184 bool haveIntersection =
true;
185 if (intersections1.size() == 0) {
186 intersections1.push_back(-10000.0);
187 haveIntersection =
false;
188 }
else if (intersections1.size() > 1) {
189 std::sort(intersections1.begin(), intersections1.end());
191 std::vector<double> intersections2 = (*it_lane)->getShape().intersectsAtLengths2D(lane->
getShape());
192 #ifdef MSLink_DEBUG_CROSSING_POINTS 195 if (intersections2.size() == 0) {
196 intersections2.push_back(0);
197 }
else if (intersections2.size() > 1) {
198 std::sort(intersections2.begin(), intersections2.end());
200 if (haveIntersection) {
202 intersections1.back() -= (*it_lane)->getWidth() / 2;
203 intersections2.back() -= lane->
getWidth() / 2;
205 intersections1.back() =
MAX2(0.0, intersections1.back());
206 intersections2.back() =
MAX2(0.0, intersections2.back());
210 intersections2.back() = (*it_lane)->interpolateGeometryPosToLanePos(intersections2.back());
215 intersections1.back() = 0;
220 lane->
getLength() - intersections1.back(),
221 (*it_lane)->getLength() - intersections2.back()));
223 #ifdef MSLink_DEBUG_CROSSING_POINTS 225 <<
" intersection of " << lane->
getID()
227 <<
" with " << (*it_lane)->getID()
228 <<
" totalLength=" << (*it_lane)->getLength()
240 const MSLane* sibling = it->getViaLane();
241 if (sibling != lane && sibling !=
nullptr) {
245 if (l.front().distanceTo2D(s.front()) >= minDist) {
249 double lbcSibling = 0;
251 if (l.back().distanceTo2D(s.back()) > minDist) {
258 std::vector<double> distances = l.
distances(s);
259 #ifdef MSLink_DEBUG_CROSSING_POINTS 260 std::cout <<
" distances=" <<
toString(distances) <<
"\n";
262 assert(distances.size() == l.size() + s.size());
263 if (distances.back() > minDist && distances[l.size() - 1] > minDist) {
265 for (
int j = (
int)s.size() - 2; j >= 0; j--) {
266 const int i = j + (int)l.size();
267 const double segLength = s[j].distanceTo2D(s[j + 1]);
268 if (distances[i] > minDist) {
269 lbcSibling += segLength;
272 lbcSibling += segLength - (minDist - distances[i]) * segLength / (distances[i + 1] - distances[i]);
276 for (
int i = (
int)l.size() - 2; i >= 0; i--) {
277 const double segLength = l[i].distanceTo2D(l[i + 1]);
278 if (distances[i] > minDist) {
279 lbcLane += segLength;
282 lbcLane += segLength - (minDist - distances[i]) * segLength / (distances[i + 1] - distances[i]);
290 const double distToDivergence1 = sibling->
getLength() - lbcSibling;
291 const double distToDivergence2 = lane->
getLength() - lbcLane;
292 const double distToDivergence =
MIN3(
293 MAX2(distToDivergence1, distToDivergence2),
297 lbcSibling =
MAX2(0.0, sibling->
getLength() - distToDivergence);
301 #ifdef MSLink_DEBUG_CROSSING_POINTS 302 std::cout <<
" distToDivergence=" << distToDivergence
303 <<
" distTD1=" << distToDivergence1
304 <<
" distTD2=" << distToDivergence2
308 std::cout <<
" adding same-origin foe" << sibling->
getID()
321 const MSEdge* target = &(it->getLane()->getEdge());
325 if (target == myTarget) {
327 #ifdef MSLink_DEBUG_CROSSING_POINTS 328 std::cout <<
" sublaneFoeLink (same target): " << it->getViaLaneOrLane()->getID() <<
"\n";
333 #ifdef MSLink_DEBUG_CROSSING_POINTS 334 std::cout <<
" sublaneFoeLink2 (other target: " << it->getViaLaneOrLane()->getID() <<
"\n";
342 for (MSLinkCont::const_iterator it = predLinks2.begin(); it != predLinks2.end(); ++it) {
343 const MSEdge* target = &((*it)->getLane()->getEdge());
356 if (foe->
getLinkCont()[0]->getViaLane() !=
nullptr) {
358 return intersections.size() > 0;
366 const bool setRequest,
const SUMOTime arrivalTimeBraking,
const double arrivalSpeedBraking,
const SUMOTime waitingTime,
double dist) {
368 #ifdef DEBUG_APPROACHING 370 std::cout <<
SIMTIME <<
" Link ''" << (
myLaneBefore == 0 ?
"NULL" : myLaneBefore->
getID()) <<
"'->'" << (
myLane == 0 ?
"NULL" :
myLane->
getID()) <<
"' Adding approaching vehicle '" << approaching->
getID() <<
"'\nCurrently registered vehicles:" << std::endl;
372 std::cout <<
"'" << i->first->getID() <<
"'" << std::endl;
378 arrivalTimeBraking, arrivalSpeedBraking, waitingTime, dist));
385 #ifdef DEBUG_APPROACHING 387 std::cout <<
SIMTIME <<
" Link ''" << (
myLaneBefore == 0 ?
"NULL" : myLaneBefore->
getID()) <<
"'->'" << (
myLane == 0 ?
"NULL" :
myLane->
getID()) <<
"' Adding approaching vehicle '" << approaching->
getID() <<
"'\nCurrently registered vehicles:" << std::endl;
389 std::cout <<
"'" << i->first->getID() <<
"'" << std::endl;
407 if ((*i)->isBlockingAnyone()) {
418 #ifdef DEBUG_APPROACHING 421 std::cout <<
"' Removing approaching vehicle '" << veh->
getID() <<
"'\nCurrently registered vehicles:" << std::endl;
423 std::cout <<
"'" << i->first->getID() <<
"'" << std::endl;
444 const double leaveSpeed,
const double vehicleLength)
const {
451 double impatience,
double decel,
SUMOTime waitingTime,
double posLat,
452 std::vector<const SUMOVehicle*>* collectFoes,
bool ignoreRed,
const SUMOVehicle* ego)
const {
463 assert(
myLane != foeLink->getLane());
464 for (
auto& it : foeLink->myApproachingVehicles) {
468 ((posLat < foe->getLateralPositionOnLane() &&
myLane->
getIndex() > foeLink->myLane->getIndex())
471 && (arrivalTime > it.second.arrivalTime
475 if (
blockedByFoe(foe, it.second, arrivalTime, leaveTime, arrivalSpeed, leaveSpeed,
false,
476 impatience, decel, waitingTime, ego)) {
477 #ifdef MSLink_DEBUG_OPENED 479 std::cout <<
SIMTIME <<
" blocked by " << foe->
getID() <<
" arrival=" << arrivalTime <<
" foeArrival=" << it.second.arrivalTime <<
"\n";
482 if (collectFoes ==
nullptr) {
483 #ifdef MSLink_DEBUG_OPENED 485 std::cout <<
" link=" <<
getViaLaneOrLane()->
getID() <<
" blocked by sublaneFoe=" << foe->
getID() <<
" foeLink=" << foeLink->getViaLaneOrLane()->getID() <<
" posLat=" << posLat <<
"\n";
490 collectFoes->push_back(foe);
501 for (
auto& it : foeLink->myApproachingVehicles) {
507 && (posLat * lhSign < foe->getLateralPositionOnLane() * lhSign))) {
508 if (
blockedByFoe(foe, it.second, arrivalTime, leaveTime, arrivalSpeed, leaveSpeed,
false,
509 impatience, decel, waitingTime, ego)) {
510 #ifdef MSLink_DEBUG_OPENED 512 std::cout <<
SIMTIME <<
" blocked by sublane foe " << foe->
getID() <<
" arrival=" << arrivalTime <<
" foeArrival=" << it.second.arrivalTime <<
"\n";
515 if (collectFoes ==
nullptr) {
518 collectFoes->push_back(foe);
529 return collectFoes ==
nullptr || collectFoes->size() == 0;
535 #ifdef MSLink_DEBUG_OPENED 543 if ((*i)->haveRed()) {
547 #ifdef MSLink_DEBUG_OPENED 549 std::cout <<
" foeLink=" << (*i)->getViaLaneOrLane()->getID() <<
" numApproaching=" << (*i)->getApproaching().size() <<
"\n";
552 if ((*i)->blockedAtTime(arrivalTime, leaveTime, arrivalSpeed, leaveSpeed,
myLane == (*i)->getLane(),
553 impatience, decel, waitingTime, collectFoes, ego)) {
557 if (collectFoes !=
nullptr && collectFoes->size() > 0) {
566 bool sameTargetLane,
double impatience,
double decel,
SUMOTime waitingTime,
567 std::vector<const SUMOVehicle*>* collectFoes,
const SUMOVehicle* ego)
const {
569 #ifdef MSLink_DEBUG_OPENED 575 <<
" foeVeh=" << it.first->getID() <<
" (below ignore speed)" 586 &&
blockedByFoe(it.first, it.second, arrivalTime, leaveTime, arrivalSpeed, leaveSpeed, sameTargetLane,
587 impatience, decel, waitingTime, ego)) {
588 if (collectFoes ==
nullptr) {
591 collectFoes->push_back(it.first);
601 SUMOTime arrivalTime,
SUMOTime leaveTime,
double arrivalSpeed,
double leaveSpeed,
602 bool sameTargetLane,
double impatience,
double decel,
SUMOTime waitingTime,
604 #ifdef MSLink_DEBUG_OPENED 607 <<
" foeVeh=" << veh->
getID()
618 assert(waitingTime > 0);
633 #ifdef MSLink_DEBUG_OPENED 635 std::cout <<
" imp=" << impatience <<
" fATb=" << avi.
arrivalTimeBraking <<
" fAT2=" << foeArrivalTime <<
" lA=" << lookAhead <<
" egoAT=" << arrivalTime <<
" egoLT=" << leaveTime <<
"\n";
640 if (sameTargetLane && (arrivalTime - avi.
leavingTime < lookAhead
643 #ifdef MSLink_DEBUG_OPENED 645 std::cout <<
" blocked (cannot follow)\n";
650 }
else if (foeArrivalTime > leaveTime + lookAhead) {
654 #ifdef MSLink_DEBUG_OPENED 656 std::cout <<
" blocked (cannot lead)\n";
663 #ifdef MSLink_DEBUG_OPENED 665 std::cout <<
" blocked (hard conflict)\n";
678 if (veh ==
nullptr) {
682 assert(distLeft > 0);
693 if ((*i)->blockedAtTime(arrivalTime, leaveTime, speed, speed,
myLane == (*i)->getLane(), 0, decel, 0)) {
697 for (std::vector<const MSLane*>::const_iterator i =
myFoeLanes.begin(); i !=
myFoeLanes.end(); ++i) {
698 if ((*i)->getVehicleNumberWithPartials() > 0) {
746 assert(predLink != 0);
761 std::vector<std::pair<SUMOTime, const SUMOVehicle*> > toSort;
763 toSort.push_back(std::make_pair(it.second.arrivalTime, it.first));
765 std::sort(toSort.begin(), toSort.end());
766 for (std::vector<std::pair<SUMOTime, const SUMOVehicle*> >::const_iterator it = toSort.begin(); it != toSort.end(); ++it) {
790 while (lane !=
nullptr && lane->
isInternal()) {
802 while (lane !=
nullptr && lane->
isInternal()) {
817 double totalDist = 0.;
818 bool foundCrossing =
false;
819 while (via !=
nullptr) {
825 foundCrossing =
true;
843 for (foe_ix = 0; foe_ix != (int)
myFoeLanes.size(); ++foe_ix) {
850 #ifdef MSLink_DEBUG_CROSSING_POINTS 857 if (dist == -10000.) {
861 #ifdef MSLink_DEBUG_CROSSING_POINTS 863 <<
"' at distance " << dist <<
" (approach along '" 917 while (lane !=
nullptr) {
947 std::cout <<
SIMTIME <<
" getLeaderInfo link=" <<
getViaLaneOrLane()->
getID() <<
" dist=" << dist <<
" isShadowLink=" << isShadowLink <<
"\n";
950 for (
int i = 0; i < (int)
myFoeLanes.size(); ++i) {
956 const double crossingWidth = (sameTarget || sameSource) ? 0 : foeLane->
getWidth();
959 std::cout <<
" distToCrossing=" << distToCrossing <<
" foeLane=" << foeLane->
getID() <<
" cWidth=" << crossingWidth
966 const bool contLane = (foeLane->
getLinkCont()[0]->getViaLaneOrLane()->getEdge().isInternal() && !(
968 if (distToCrossing + crossingWidth < 0
983 const double leaderBackDist = foeDistToCrossing - leaderBack;
984 const bool pastTheCrossingPoint = leaderBackDist + foeCrossingWidth < 0;
985 const bool ignoreIndirectBicycleTurn = (pastTheCrossingPoint
988 const bool cannotIgnore = ((contLane && !ignoreIndirectBicycleTurn) || sameTarget || sameSource) && ego !=
nullptr;
992 std::cout <<
" candiate leader=" << leader->
getID()
993 <<
" cannotIgnore=" << cannotIgnore
994 <<
" fdtc=" << foeDistToCrossing
995 <<
" lb=" << leaderBack
996 <<
" lbd=" << leaderBackDist
997 <<
" fcwidth=" << foeCrossingWidth
998 <<
" foePastCP=" << pastTheCrossingPoint
999 <<
" inTheWay=" << inTheWay
1000 <<
" willPass=" << foeLane->
getLinkCont()[0]->getApproaching(leader).willPass
1002 <<
" isOpposite=" << isOpposite <<
"\n";
1004 if (leader == ego) {
1013 if ((!cannotIgnore || leader->
isStopped() || sameTarget)
1014 && !foeLane->
getLinkCont()[0]->getApproaching(leader).willPass
1026 bool fromLeft =
true;
1027 if (ego ==
nullptr) {
1030 gap = leaderBackDist;
1034 distToCrossing += foeLane->
getWidth() / 2;
1035 if (gap + foeCrossingWidth < 0) {
1042 fromLeft = foeDistToCrossing > 0.5 * foeLane->
getLength();
1043 }
else if ((contLane && !sameSource && !ignoreIndirectBicycleTurn) || isOpposite) {
1047 std::cout <<
" distToCrossing=" << distToCrossing <<
" leader back=" << leaderBack <<
" backDist=" << leaderBackDist
1052 if (leaderBackDist + foeCrossingWidth < 0) {
1066 const bool stopAsap = leader->
isFrontOnLane(foeLane) ? cannotIgnore : (sameTarget || sameSource);
1068 std::cout <<
" leader=" << leader->
getID() <<
" contLane=" << contLane <<
" cannotIgnore=" << cannotIgnore <<
" stopAsap=" << stopAsap <<
"\n";
1070 result.push_back(
LinkLeader(leader, gap, stopAsap ? -1 : distToCrossing, fromLeft));
1081 const double vehSideOffset = (foeDistToCrossing +
myLaneBefore->
getWidth() * 0.5 - vehWidth * 0.5
1092 if (ego !=
nullptr) {
1100 const MSLane* foeLane = *it;
1104 if (leader == ego) {
1118 <<
" foeLane=" << foeLane->
getID()
1119 <<
" leader=" << leader->
getID()
1122 <<
" egoLat=" << posLat
1123 <<
" leaderLat=" << posLatLeader
1124 <<
" leaderLatOffset=" << leader->
getLatOffset(foeLane)
1126 <<
" foeIndex=" << foeLane->
getIndex()
1132 if ((posLat < posLatLeader && myInternalLaneBefore->
getIndex() > foeLane->
getIndex())
1135 std::cout <<
SIMTIME <<
" blocked by " << leader->
getID() <<
" (sublane split) foeLane=" << foeLane->
getID() <<
"\n";
1137 result.push_back(
LinkLeader(leader, gap, -1));
1154 double distToPeds = std::numeric_limits<double>::max();
1160 if (collectBlockers !=
nullptr) {
1161 collectBlockers->push_back(p);
1165 if (distToPeds != std::numeric_limits<double>::max()) {
1194 if (direction == -1) {
1196 }
else if (direction == 1) {
1209 if (before !=
nullptr && after !=
nullptr) {
1226 std::vector<const SUMOVehicle*>* collectFoes)
const {
1232 throw ProcessError(
"Zipper junctions with more than two conflicting lanes are not supported (at junction '" 1236 const double secondsToArrival =
STEPS2TIME(arrivalTime - now);
1240 <<
" dist=" << dist <<
" ignoring foes (arrival in " <<
STEPS2TIME(arrivalTime - now) <<
")\n";
1246 <<
" egoAT=" << arrivalTime
1248 <<
" vSafe=" << vSafe
1249 <<
" numFoes=" << collectFoes->size()
1253 for (std::vector<const SUMOVehicle*>::const_iterator i = collectFoes->begin(); i != collectFoes->end(); ++i) {
1268 <<
" ignoring foe=" << foe->
getID()
1270 <<
" foeDist=" << avi.
dist 1271 <<
" foeDist2=" << foeDist
1274 <<
" deltaDist=" << foeDist - dist
1297 const double uEnd =
MIN2(uMax, uAccel);
1298 const double uAvg = (foe->
getSpeed() + uEnd) / 2;
1300 const double tf =
MAX2(1.0, ceil((tf0) /
TS) *
TS);
1304 const double vEnd =
MIN3(vMax, vAccel, uEnd);
1305 const double vAvg = (ego->
getSpeed() + vEnd) / 2;
1307 const double te =
MAX2(1.0, ceil((te0) / TS) * TS);
1314 const double deltaGap = gap + tf * uAvg - safeGap - vAvg * tf;
1315 const double a = 2 * deltaGap / (tf * tf);
1321 const double w =
MIN2(1.0, te / 10);
1323 const double vZipper =
MAX3(vFollow, ego->
getSpeed() -
ACCEL2SPEED(maxDecel), w * vSafeGap + (1 - w) * vFollow);
1325 vSafe =
MIN2(vSafe, vZipper);
1328 <<
" foeDist=" << foeDist
1333 <<
" uAccel=" << uAccel
1337 <<
" safeGap=" << safeGap
1341 <<
" dg=" << deltaGap
1342 <<
" aSafeGap=" << a
1344 <<
" vAccel=" << vAccel
1346 <<
" vSafeGap=" << vSafeGap
1347 <<
" vFollow=" << vFollow
1349 <<
" maxDecel=" << maxDecel
1350 <<
" vZipper=" << vZipper
1351 <<
" vSafe=" << vSafe
1362 followDist > leaderDist &&
1380 for (
const MSLink* link : cand->getLinkCont()) {
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
bool gDebugFlag1
global utility flags for debugging
The link is a partial left direction.
static double gLateralResolution
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
bool contIntersect(const MSLane *lane, const MSLane *foe)
check if the lane intersects with a foe cont-lane
int myIndex
The position within this respond.
double getLength() const
Returns the vehicle's length.
#define DIVERGENCE_MIN_WIDTH
MSEdge & getEdge() const
Returns the lane's edge.
Representation of a vehicle in the micro simulation.
bool blockedAtTime(SUMOTime arrivalTime, SUMOTime leaveTime, double arrivalSpeed, double leaveSpeed, bool sameTargetLane, double impatience, double decel, SUMOTime waitingTime, std::vector< const SUMOVehicle *> *collectFoes=0, const SUMOVehicle *ego=0) const
Returns the information whether this link is blocked Valid after the vehicles have set their requests...
double getJMParam(const SumoXMLAttr attr, const double defaultValue) const
Returns the named value from the map, or the default if it is not contained there.
MSLane * myLane
The lane behind the junction approached by this link.
void addBlockedLink(MSLink *link)
LinkState myState
The state of the link.
SUMOTime getWaitingTime() const
Returns the SUMOTime waited (speed was lesser than 0.1m/s)
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.
LinkDirection getDirection() const
Returns the direction the vehicle passing this link take.
MSLane * getLane() const
Returns the connected lane.
virtual const std::string & getID() const =0
Get the vehicle's ID.
bool myHavePedestrianCrossingFoe
whether on of myFoeLanes is a crossing
double getLengthBeforeCrossing(const MSLane *foeLane) const
Returns the internal length from the beginning of the link's internal lane before to the crossing wit...
MSLane * getLane() const
Returns the lane the vehicle is on.
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
bool myHasFoes
Whether any foe links exist.
This is an uncontrolled, minor link, has to stop.
The base class for an intersection.
std::vector< MSLink * > mySublaneFoeLinks
static bool gComputeLC
whether the simulationLoop is in the lane changing phase
const MSLane * getLaneBefore() const
return the internalLaneBefore if it exists and the laneBefore otherwise
std::map< const SUMOVehicle *, const ApproachingVehicleInformation, ComparatorNumericalIdLess > myApproachingVehicles
SUMOTime myLastStateChange
The time of the last state change.
std::vector< MSLink * > myFoeLinks
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
MSLink * getCorrespondingExitLink() const
returns the corresponding exit link for entryLinks to a junction.
#define ZIPPER_ADAPT_TIME
void setTLState(LinkState state, SUMOTime t)
Sets the current tl-state.
AnyVehicleIterator is a structure, which manages the iteration through all vehicles on the lane...
std::string time2string(SUMOTime t)
LinkDirection myDirection
An abstract (hopefully human readable) definition of the link's direction.
double getZipperSpeed(const MSVehicle *ego, const double dist, double vSafe, SUMOTime arrivalTime, std::vector< const SUMOVehicle *> *collectFoes) const
return the speed at which ego vehicle must approach the zipper link
static const double ZIPPER_ADAPT_DIST
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
static const SUMOTime myLookaheadTime
SUMOTime getLastActionTime() const
Returns the time of the vehicle's last action point.
double getLength() const
Returns the lane's length.
const PositionVector & getShape() const
Returns this lane's shape.
double myLateralShift
lateral shift to be applied when passing this link
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
std::vector< std::pair< double, double > > myLengthsBehindCrossing
bool hasFoes() const
Returns whether this link belongs to a junction where more than one edge is incoming.
bool checkContOff() const
figure out whether the cont status remains in effect when switching off the tls
const MSLane * myWalkingAreaFoeExit
walkingArea that must be checked when leaving the intersection
std::string getDescription() const
get string description for this link
const std::string & getID() const
Returns the id.
double getInternalLengthsBefore() const
Returns the cumulative length of all internal lanes before this link.
virtual double getSpeed() const
the current speed of the transportable
std::vector< double > distances(const PositionVector &s, bool perpendicular=false) const
distances of all my points to s and all of s points to myself
double getInternalLengthsAfter() const
Returns the cumulative length of all internal lanes after this link.
The link is controlled by a tls which is off, not blinking, may pass.
This is an uncontrolled, all-way stop link.
std::vector< MSLane * > mySublaneFoeLanes
MSLane * getParallelLane(int offset, bool includeOpposite=true) const
Returns the lane with the given offset parallel to this one or 0 if it does not exist.
double getWidth() const
Returns the lane's width.
void setApproaching(const SUMOVehicle *approaching, const SUMOTime arrivalTime, const double arrivalSpeed, const double leaveSpeed, const bool setRequest, const SUMOTime arrivalTimeBraking, const double arrivalSpeedBraking, const SUMOTime waitingTime, double dist)
Sets the information about an approaching vehicle.
bool isInternalJunctionLink() const
return whether the fromLane and the toLane of this link are internal lanes
This is an uncontrolled, zipper-merge link.
The link is a (hard) left direction.
MSAbstractLaneChangeModel & getLaneChangeModel()
MSLink * computeParallelLink(int direction)
MSLink * getParallelLink(int direction) const
return the link that is parallel to this lane or 0
bool isFrontOnLane(const MSLane *lane) const
Returns the information whether the front of the vehicle is on the given lane.
bool willHaveBlockedFoe() const
LinkDirection
The different directions a link between two lanes may take (or a stream between two edges)...
bool fromInternalLane() const
return whether the fromLane of this link is an internal lane
The link is a straight direction.
double getMaxAccel() const
Get the vehicle type's maximum acceleration [m/s^2].
bool willStop() const
Returns whether the vehicle will stop on the current edge.
const MSLane * myInternalLaneBefore
bool lastWasContMajor() const
whether this is a link past an internal junction which currently has priority
A road/street connecting two junctions.
double getLatOffset(const MSLane *lane) const
Get the offset that that must be added to interpret myState.myPosLat for the given lane...
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
int getIndex() const
Returns the lane's index.
SUMOTime getLeaveTime(const SUMOTime arrivalTime, const double arrivalSpeed, const double leaveSpeed, const double vehicleLength) const
return the expected time at which the given vehicle will clear the link
virtual std::mt19937 * getRNG() const =0
Returns the associated RNG for this vehicle.
MSLink * getEntryLink() const
Returns the entry link if this is an internal lane, else 0.
const MSCFModel & getCarFollowModel() const
Returns the vehicle type's car following model definition (const version)
MSLane * getViaLane() const
Returns the following inner lane.
virtual bool blockedAtDist(const MSLane *lane, double vehSide, double vehWidth, double oncomingGap, std::vector< const MSPerson *> *collectBlockers)
whether a pedestrian is blocking the crossing of lane for the given vehicle bondaries ...
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
bool isExitLink() const
return whether the fromLane of this link is an internal lane and toLane is a normal lane ...
virtual double getSecureGap(const double speed, const double leaderSpeed, const double leaderMaxDecel) const
Returns the minimum gap to reserve if the leader is braking at maximum (>=0)
Representation of a vehicle.
bool opened(SUMOTime arrivalTime, double arrivalSpeed, double leaveSpeed, double vehicleLength, double impatience, double decel, SUMOTime waitingTime, double posLat=0, std::vector< const SUMOVehicle *> *collectFoes=0, bool ignoreRed=false, const SUMOVehicle *ego=0) const
Returns the information whether the link may be passed.
std::vector< MSLink * > mySublaneFoeLinks2
static bool unsafeMergeSpeeds(double leaderSpeed, double followerSpeed, double leaderDecel, double followerDecel)
return whether the given vehicles may NOT merge safely
static MSPModel * getModel()
double interpolateGeometryPosToLanePos(double geometryPos) const
ApproachingVehicleInformation getApproaching(const SUMOVehicle *veh) const
static const SUMOTime myLookaheadTimeZipper
static bool couldBrakeForLeader(double followDist, double leaderDist, const MSVehicle *follow, const MSVehicle *leader)
whether fllower could stay behind leader (possibly by braking)
double getEmergencyDecel() const
Get the vehicle type's maximal phisically possible deceleration [m/s^2].
const std::set< MSTransportable * > & getPersons() const
Returns this edge's persons set.
void writeApproaching(OutputDevice &od, const std::string fromLaneID) const
write information about all approaching vehicles to the given output device
void move2side(double amount, double maxExtension=100)
move position vector to side using certain ammount
std::set< MSLink * > myBlockedFoeLinks
bool isConflictEntryLink() const
return whether this link enters the conflict area (not a continuation link)
void checkWalkingAreaFoe(const MSVehicle *ego, const MSLane *foeLane, std::vector< const MSPerson *> *collectBlockers, LinkLeaders &result) const
check for persons on walkingarea in the path of ego vehicle
bool havePriority() const
Returns whether this link is a major link.
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic, in MSLink and GNEInternalLane.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
AnyVehicleIterator anyVehiclesEnd() const
end iterator for iterating over all vehicles touching this lane in downstream direction ...
The link is a (hard) right direction.
const MSLane * getInternalLaneBefore() const
return myInternalLaneBefore (always 0 when compiled without internal lanes)
AnyVehicleIterator anyVehiclesBegin() const
begin iterator for iterating over all vehicles touching this lane in downstream direction ...
double getLengthsBeforeCrossing(const MSLane *foeLane) const
Returns the sum of the lengths along internal lanes following this link to the crossing with the give...
std::vector< LinkLeader > LinkLeaders
std::vector< double > intersectsAtLengths2D(const PositionVector &other) const
For all intersections between this vector and other, return the 2D-length of the subvector from this ...
bool isEntryLink() const
return whether the toLane of this link is an internal lane and fromLane is a normal lane ...
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
double getMinGap() const
Get the free space in front of vehicles of this class.
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
void initParallelLinks()
initialize parallel links (to be called after all links are loaded)
const std::map< const SUMOVehicle *, const ApproachingVehicleInformation, ComparatorNumericalIdLess > & getApproaching() const
return all approaching vehicles
bool isInternal() const
return whether this edge is an internal edge
The link is a partial right direction.
const SUMOVTypeParameter & getParameter() const
bool lefthand() const
return whether the network was built for lefthand traffic
double getLength() const
Returns the length of this link.
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
bool isExitLinkAfterInternalJunction() const
return whether the fromLane of this link is an internal lane and its incoming lane is also an interna...
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
MSLink(MSLane *predLane, MSLane *succLane, MSLane *via, LinkDirection dir, LinkState state, double length, double foeVisibilityDistance, bool keepClear, MSTrafficLightLogic *logic, int tlLinkIdx)
Constructor for simulation which uses internal lanes.
static bool maybeOccupied(MSLane *lane)
returns whether the given lane may still be occupied by a vehicle currently on it ...
const MSLane * myWalkingAreaFoe
walkingArea that must be checked when entering the intersection
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
const MSTrafficLightLogic * myLogic
the controlling logic or 0
bool isActive() const
Returns whether the current simulation step is an action point for the vehicle.
static MSLink * getConnectingLink(const MSLane &from, const MSLane &to)
Returns the link connecting both lanes Both lanes have to be non-internal; 0 may be returned if no co...
The link is controlled by a tls which is off and blinks, has to brake.
const MSJunction * getFromJunction() const
MSLane * myLaneBefore
The lane approaching this link.
bool isStrategicBlocked() const
MSJunction * myJunction
the junction to which this link belongs
MSVehicle * getLastAnyVehicle() const
returns the last vehicle that is fully or partially on this lane
MSLane * getViaLaneOrLane() const
return the via lane if it exists and the lane otherwise
virtual double getLateralPositionOnLane() const =0
Get the vehicle's lateral position on the lane.
#define JM_CROSSING_GAP_DEFAULT
LinkLeaders getLeaderInfo(const MSVehicle *ego, double dist, std::vector< const MSPerson *> *collectBlockers=0, bool isShadowLink=false) const
Returns all potential link leaders (vehicles on foeLanes) Valid during the planMove() phase...
int getIndex() const
Returns the respond index (for visualization)
double getLength() const
Get vehicle's length [m].
static SUMOTime gIgnoreJunctionBlocker
#define DEBUG_COND_ZIPPER
const MSVehicleType & getVehicleType() const
Returns the vehicle's type.
double getBackPositionOnLane(const MSLane *lane) const
Get the vehicle's position relative to the given lane.
double estimateSpeedAfterDistance(const double dist, const double v, const double accel) const
The parent class for traffic light logics.
Static storage of an output device and its base (abstract) implementation.
Position getPosition(const double) const
Return current position (x/y, cartesian)
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
MSLane *const myInternalLane
The following junction-internal lane if used.
static const double SAFETY_GAP
void removeApproaching(const SUMOVehicle *veh)
removes the vehicle from myApproachingVehicles
bool isStopped() const
Returns whether the vehicle is at a stop.
const double INVALID_DOUBLE
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
double getSpeed() const
Returns the vehicle's current speed.
virtual double followSpeed(const MSVehicle *const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle *const pred=0) const =0
Computes the vehicle's follow speed (no dawdling)
const std::string & getID() const
Returns the name of the vehicle.
Representation of a lane in the micro simulation.
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
bool blockedByFoe(const SUMOVehicle *veh, const ApproachingVehicleInformation &avi, SUMOTime arrivalTime, SUMOTime leaveTime, double arrivalSpeed, double leaveSpeed, bool sameTargetLane, double impatience, double decel, SUMOTime waitingTime, const SUMOVehicle *ego) const
bool haveRed() const
Returns whether this link is blocked by a red (or redyellow) traffic light.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
void setRequestInformation(int index, bool hasFoes, bool isCont, const std::vector< MSLink *> &foeLinks, const std::vector< MSLane *> &foeLanes, MSLane *internalLaneBefore=0)
Sets the request information.
std::vector< const MSLane * > myFoeLanes
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
bool hasApproachingFoe(SUMOTime arrivalTime, SUMOTime leaveTime, double speed, double decel) const
Returns the information whether a vehicle is approaching on one of the link's foe streams...