53 #define DEBUG_COND2(obj) (obj->isSelected())
57 #define DEBUG_COND_ZIPPER (ego->isSelected())
63 #define INVALID_TIME -1000
66 #define JM_CROSSING_GAP_DEFAULT 10
69 #define DIVERGENCE_MIN_WIDTH 2.5
94 if (foeConflictIndex >= 0) {
95 return foeExitLink->
myConflicts[foeConflictIndex].conflictSize;
106 return lengthBehindCrossing;
114 double length,
double foeVisibilityDistance,
bool keepClear,
156 const double dist = from.back().distanceTo2D(to.front());
162 myLateralShift = (from.back().distanceTo2D(to.front()) < dist) ? dist : -dist;
188 if (cc.from == foeFrom && cc.to == foeTo) {
199 const std::vector<MSLink*>& foeLinks,
200 const std::vector<MSLane*>& foeLanes,
201 MSLane* internalLaneBefore) {
211 for (
MSLane* foeLane : foeLanes) {
219 if (internalLaneBefore !=
nullptr) {
221 lane = internalLaneBefore;
233 for (
MSLane* foeLane : foeLanes) {
234 assert(foeLane->isInternal() || foeLane->isCrossing());
235 MSLink* viaLink = foeLane->getIncomingLanes().front().viaLink;
242 #ifdef MSLink_DEBUG_CROSSING_POINTS
245 if (lane !=
nullptr) {
246 const bool beforeInternalJunction = lane->
getLinkCont()[0]->getViaLaneOrLane()->getEdge().isInternal();
270 const CustomConflict* rcc = foeLane->getEntryLink()->getCustomConflict(lane);
271 bool haveIntersection =
false;
272 if (rcc ==
nullptr) {
277 const bool foeIsSecondPart = foeLane->getLogicalPredecessorLane()->isInternal();
280 if (foeIsSecondPart) {
281 foeStartPos -= foeLane->getLogicalPredecessorLane()->getLength();
283 const double foeEndPos = foeStartPos + foeConflictSize;
284 haveIntersection = ((foeStartPos > 0 && foeStartPos < foeLane->getLength())
285 || (foeEndPos > 0 && foeEndPos < foeLane->
getLength()));
287 if (haveIntersection) {
292 #ifdef MSLink_DEBUG_CROSSING_POINTS
293 std::cout <<
" " << lane->
getID() <<
" custom conflict with " << foeLane->getID() <<
" customReverse=" << (rcc !=
nullptr)
294 <<
" haveIntersection=" << haveIntersection
295 <<
" startPos=" << startPos <<
" conflictSize=" << conflictSize
296 <<
" lbc=" <<
myConflicts.back().lengthBehindCrossing
303 if (sameTarget && !beforeInternalJunction && !
contIntersect(lane, foeLane)) {
307 if (lane->
getShape().back().distanceTo2D(foeLane->getShape().back()) >= minDist) {
309 if (foeLane->getEntryLink()->isIndirect()) {
311 #ifdef MSLink_DEBUG_CROSSING_POINTS
312 std::cout <<
" " << lane->
getID() <<
" dummy merge with indirect" << foeLane->getID() <<
"\n";
316 #ifdef MSLink_DEBUG_CROSSING_POINTS
317 std::cout <<
" " << lane->
getID() <<
" dummy merge with " << foeLane->getID() <<
"\n";
324 #ifdef MSLink_DEBUG_CROSSING_POINTS
326 <<
" " << lane->
getID()
327 <<
" merges with " << foeLane->getID()
328 <<
" nextLane " << lane->
getLinkCont()[0]->getViaLaneOrLane()->getID()
329 <<
" dist1=" <<
myConflicts.back().lengthBehindCrossing
335 #ifdef MSLink_DEBUG_CROSSING_POINTS_DETAILS
336 std::cout <<
" intersections1=" <<
toString(intersections1) <<
"\n";
338 bool haveIntersection =
true;
339 if (intersections1.size() == 0) {
341 haveIntersection =
false;
342 }
else if (intersections1.size() > 1) {
343 std::sort(intersections1.begin(), intersections1.end());
345 std::vector<double> intersections2 = foeLane->getShape().intersectsAtLengths2D(lane->
getShape());
346 #ifdef MSLink_DEBUG_CROSSING_POINTS_DETAILS
347 std::cout <<
" intersections2=" <<
toString(intersections2) <<
"\n";
349 if (intersections2.size() == 0) {
350 intersections2.push_back(0);
351 }
else if (intersections2.size() > 1) {
352 std::sort(intersections2.begin(), intersections2.end());
354 double conflictSize = foeLane->getWidth();
356 if (haveIntersection) {
359 const double angle2 =
GeomHelper::naviDegree(foeLane->getShape().rotationAtOffset(intersections2.back()));
363 const double widthFactor = 1 /
MAX2(sin(
DEG2RAD(angleDiff)), 0.2) * 2 - 1;
365 conflictSize *= widthFactor;
368 intersections1.back() -= conflictSize / 2;
370 intersections1.back() =
MAX2(0.0, intersections1.back());
381 lane->
getLength() - intersections1.back(),
382 conflictSize, flag));
384 #ifdef MSLink_DEBUG_CROSSING_POINTS
386 <<
" intersection of " << lane->
getID()
388 <<
" with " << foeLane->getID()
389 <<
" totalLength=" << foeLane->getLength()
390 <<
" dist1=" <<
myConflicts.back().lengthBehindCrossing
391 <<
" widthFactor=" <<
myConflicts.back().conflictSize / foeLane->getWidth()
401 const MSLane*
const sibling = link->getViaLane();
402 if (sibling != lane && sibling !=
nullptr) {
404 if (lane->
getShape().front().distanceTo2D(sibling->
getShape().front()) >= minDist) {
414 lbcLane = lane->
getLength() - distToDivergence;
422 const int replacedIndex = (int)(it -
myFoeLanes.begin());
428 #ifdef MSLink_DEBUG_CROSSING_POINTS
429 std::cout <<
" adding same-origin foe" << sibling->
getID()
430 <<
" dist1=" <<
myConflicts.back().lengthBehindCrossing
437 for (
int i = 0; i < (int)
myFoeLanes.size(); i++) {
441 for (
int i2 = 0; i2 < (int)foeExitLink->
myFoeLanes.size(); i2++) {
450 #ifdef MSLink_DEBUG_CROSSING_POINTS
451 std::cout << lane->
getID() <<
" foeLane=" << foeLane->
getID() <<
" index=" << i <<
" foundIndex=" << foundIndex <<
"\n";
453 if (foundIndex < 0) {
465 const MSEdge* target = &(it->getLane()->getEdge());
469 if (target == myTarget) {
471 #ifdef MSLink_DEBUG_CROSSING_POINTS
472 std::cout <<
" sublaneFoeLink (same target): " << it->getViaLaneOrLane()->getID() <<
"\n";
477 #ifdef MSLink_DEBUG_CROSSING_POINTS
478 std::cout <<
" sublaneFoeLink2 (other target: " << it->getViaLaneOrLane()->getID() <<
"\n";
520 #ifdef MSLink_DEBUG_CROSSING_POINTS
521 std::cout <<
" recheck l1=" << item.first->getDescription() <<
" l2=" << item.second->getDescription() <<
"\n";
523 MSLink* link = item.first;
524 MSLink* foeExitLink = item.second;
527 int conflictIndex = -1;
528 for (
int i = 0; i < (int)link->
myFoeLanes.size(); i++) {
534 if (conflictIndex == -1) {
540 if (intersections1.size() == 0) {
541 #ifdef MSLink_DEBUG_CROSSING_POINTS
542 std::cout <<
" no intersection\n";
547 const double conflictSize2 = lane->
getWidth() * widthFactor;
548 std::sort(intersections1.begin(), intersections1.end());
549 intersections1.back() -= conflictSize2 / 2;
550 intersections1.back() =
MAX2(0.0, intersections1.back());
553 #ifdef MSLink_DEBUG_CROSSING_POINTS
554 std::cout <<
" ci=" << conflictIndex <<
" wf=" << widthFactor <<
" flag=" << ci.
flag <<
" flbc=" << foeExitLink->
myConflicts.back().lengthBehindCrossing <<
"\n";
562 double lbcSibling = 0;
576 lbcSibling += s[-1].distanceTo2D(s[-2]);
582 lbcLane += l[-1].distanceTo2D(l[-2]);
586 #ifdef MSLink_DEBUG_CROSSING_POINTS_DETAILS
587 std::cout <<
" sameSource=" << sameSource <<
" minDist=" << minDist <<
" backDist=" << l.back().distanceTo2D(s.back()) <<
"\n";
589 if (l.back().distanceTo2D(s.back()) > minDist) {
596 std::vector<double> distances = l.
distances(s);
597 #ifdef MSLink_DEBUG_CROSSING_POINTS
598 std::cout <<
" distances=" <<
toString(distances) <<
"\n";
600 assert(distances.size() == l.size() + s.size());
601 if (distances.back() > minDist && distances[l.size() - 1] > minDist) {
603 for (
int j = (
int)s.size() - 2; j >= 0; j--) {
604 const int i = j + (int)l.size();
605 const double segLength = s[j].distanceTo2D(s[j + 1]);
606 if (distances[i] > minDist) {
607 lbcSibling += segLength;
610 lbcSibling += segLength - (minDist - distances[i]) * segLength / (distances[i + 1] - distances[i]);
614 for (
int i = (
int)l.size() - 2; i >= 0; i--) {
615 const double segLength = l[i].distanceTo2D(l[i + 1]);
616 if (distances[i] > minDist) {
617 lbcLane += segLength;
620 lbcLane += segLength - (minDist - distances[i]) * segLength / (distances[i + 1] - distances[i]);
625 assert(lbcSibling >= -NUMERICAL_EPS);
626 assert(lbcLane >= -NUMERICAL_EPS);
628 const double distToDivergence1 = sibling->
getLength() - lbcSibling;
629 const double distToDivergence2 = lane->
getLength() - lbcLane;
630 const double distToDivergence =
MIN3(
631 MAX2(distToDivergence1, distToDivergence2),
633 #ifdef MSLink_DEBUG_CROSSING_POINTS
634 std::cout <<
" distToDivergence=" << distToDivergence
635 <<
" distTD1=" << distToDivergence1
636 <<
" distTD2=" << distToDivergence2
637 <<
" length=" << length
638 <<
" sibLength=" << sibLength
641 return distToDivergence;
647 if (foe->
getLinkCont()[0]->getViaLane() !=
nullptr) {
649 return intersections.size() > 0;
657 const bool setRequest,
const double arrivalSpeedBraking,
const SUMOTime waitingTime,
double dist,
double latOffset) {
659 #ifdef DEBUG_APPROACHING
663 std::cout <<
"'" << i->first->getID() <<
"'" << std::endl;
669 arrivalSpeedBraking, waitingTime, dist, approaching->
getSpeed(), latOffset));
676 #ifdef DEBUG_APPROACHING
680 std::cout <<
"'" << i->first->getID() <<
"'" << std::endl;
698 if ((*i)->isBlockingAnyone()) {
709 #ifdef DEBUG_APPROACHING
712 std::cout <<
"' Removing approaching vehicle '" << veh->
getID() <<
"'\nCurrently registered vehicles:" << std::endl;
714 std::cout <<
"'" << i->first->getID() <<
"'" << std::endl;
741 const double leaveSpeed,
const double vehicleLength)
const {
748 double impatience,
double decel,
SUMOTime waitingTime,
double posLat,
750 #ifdef MSLink_DEBUG_OPENED
765 assert(
myLane != foeLink->getLane());
766 for (
const auto& it : foeLink->myApproachingVehicles) {
770 ((posLat < foe->getLateralPositionOnLane() + it.second.latOffset &&
myLane->
getIndex() > foeLink->myLane->getIndex())
773 && (arrivalTime > it.second.arrivalTime
777 if (
blockedByFoe(foe, it.second, arrivalTime, leaveTime, arrivalSpeed, leaveSpeed,
false,
778 impatience, decel, waitingTime, ego)) {
779 #ifdef MSLink_DEBUG_OPENED
781 std::cout <<
SIMTIME <<
" blocked by " << foe->
getID() <<
" arrival=" << arrivalTime <<
" foeArrival=" << it.second.arrivalTime <<
"\n";
784 if (collectFoes ==
nullptr) {
785 #ifdef MSLink_DEBUG_OPENED
787 std::cout <<
" link=" <<
getViaLaneOrLane()->
getID() <<
" blocked by sublaneFoe=" << foe->
getID() <<
" foeLink=" << foeLink->getViaLaneOrLane()->getID() <<
" posLat=" << posLat <<
"\n";
792 collectFoes->push_back(it.first);
803 for (
const auto& it : foeLink->myApproachingVehicles) {
813 if (
blockedByFoe(foe, it.second, arrivalTime, leaveTime, arrivalSpeed, leaveSpeed,
false,
814 impatience, decel, waitingTime, ego)) {
815 #ifdef MSLink_DEBUG_OPENED
817 std::cout <<
SIMTIME <<
" blocked by sublane foe " << foe->
getID() <<
" arrival=" << arrivalTime <<
" foeArrival=" << it.second.arrivalTime <<
"\n";
820 if (collectFoes ==
nullptr) {
821 #ifdef MSLink_DEBUG_OPENED
823 std::cout <<
" link=" <<
getViaLaneOrLane()->
getID() <<
" blocked by sublaneFoe2=" << foe->
getID() <<
" foeLink=" << foeLink->getViaLaneOrLane()->getID() <<
" posLat=" << posLat <<
"\n";
828 collectFoes->push_back(it.first);
839 return collectFoes ==
nullptr || collectFoes->size() == 0;
846 #ifdef MSLink_DEBUG_OPENED
856 for (
const MSLink*
const link : foeLinks) {
858 if (link->haveRed()) {
862 #ifdef MSLink_DEBUG_OPENED
864 std::cout <<
" foeLink=" << link->getViaLaneOrLane()->getID() <<
" numApproaching=" << link->getApproaching().size() <<
"\n";
867 if (link->blockedAtTime(arrivalTime, leaveTime, arrivalSpeed, leaveSpeed,
myLane == link->getLane(),
868 impatience, decel, waitingTime, collectFoes, ego, lastWasContRed)) {
872 if (collectFoes !=
nullptr && collectFoes->size() > 0) {
881 bool sameTargetLane,
double impatience,
double decel,
SUMOTime waitingTime,
884 #ifdef MSLink_DEBUG_OPENED
889 std::stringstream stream;
891 <<
" foeVeh=" << it.first->getID() <<
" (below ignore speed)"
894 std::cout << stream.str();
905 &&
blockedByFoe(it.first, it.second, arrivalTime, leaveTime, arrivalSpeed, leaveSpeed, sameTargetLane,
906 impatience, decel, waitingTime, ego)) {
907 if (collectFoes ==
nullptr) {
910 collectFoes->push_back(it.first);
920 SUMOTime arrivalTime,
SUMOTime leaveTime,
double arrivalSpeed,
double leaveSpeed,
921 bool sameTargetLane,
double impatience,
double decel,
SUMOTime waitingTime,
923 #ifdef MSLink_DEBUG_OPENED
925 std::stringstream stream;
927 <<
" foeVeh=" << veh->
getID()
932 std::cout << stream.str();
939 assert(waitingTime > 0);
949 if (impatience > 0 && arrivalTime < avi.
arrivalTime) {
950 #ifdef MSLink_DEBUG_OPENED
954 foeArrivalTime = (
SUMOTime)((1. - impatience) * (double)avi.
arrivalTime + impatience * (
double)fatb);
955 #ifdef MSLink_DEBUG_OPENED
974 #ifdef MSLink_DEBUG_OPENED
976 std::stringstream stream;
977 stream <<
" imp=" << impatience <<
" fAT2=" << foeArrivalTime <<
" fASb=" << foeArrivalSpeedBraking <<
" lA=" << lookAhead <<
" egoAT=" << arrivalTime <<
" egoLT=" << leaveTime <<
" egoLS=" << leaveSpeed <<
"\n";
978 std::cout << stream.str();
983 if (sameTargetLane && (arrivalTime - avi.
leavingTime < lookAhead
986 #ifdef MSLink_DEBUG_OPENED
988 std::cout <<
" blocked (cannot follow)\n";
993 }
else if (foeArrivalTime > leaveTime + lookAhead) {
997 #ifdef MSLink_DEBUG_OPENED
999 std::cout <<
" blocked (cannot lead)\n";
1006 #ifdef MSLink_DEBUG_OPENED
1008 std::cout <<
" blocked (hard conflict)\n";
1025 if (arrivalTime - arrivalTime %
DELTA_T == foeArrivalTime - foeArrivalTime %
DELTA_T) {
1027 return foeArrivalTime;
1031 const double dt =
STEPS2TIME(foeArrivalTime - arrivalTime);
1032 const double d = dt * m;
1033 const double a = dt * d / 2;
1036 if (0.5 * v * v / m <= dist2) {
1038 std::cout <<
" dist=" << dist <<
" dist2=" << dist2 <<
" at=" <<
STEPS2TIME(arrivalTime) <<
" m=" << m <<
" d=" << d <<
" a=" << a <<
" canBrakeToStop\n";
1050 const double x = (sqrt(4 * (v - d) * (v - d) - 8 * m * a) * -0.5 - d + v) / m;
1052 #ifdef MSLink_DEBUG_OPENED
1053 const double x2 = (sqrt(4 * (v - d) * (v - d) - 8 * m * a) * 0.5 - d + v) / m;
1055 std::cout <<
SIMTIME <<
" dist=" << dist <<
" dist2=" << dist2 <<
" at=" <<
STEPS2TIME(arrivalTime) <<
" m=" << m <<
" d=" << d <<
" v=" << v <<
" a=" << a <<
" x=" << x <<
" x2=" << x2 <<
"\n";
1058 fasb = v - (dt + x) * m;
1066 if (link->blockedAtTime(arrivalTime, leaveTime, speed, speed,
myLane == link->getLane(), 0, decel, 0)) {
1071 if (lane->getVehicleNumberWithPartials() > 0) {
1079 std::pair<const SUMOVehicle*, const MSLink*>
1081 double closetDist = std::numeric_limits<double>::max();
1083 const MSLink* foeLink =
nullptr;
1085 for (
const auto& it : link->myApproachingVehicles) {
1088 return std::make_pair(
nullptr, wrapAround);
1089 }
else if (it.second.dist < closetDist) {
1090 closetDist = it.second.dist;
1091 if (it.second.willPass) {
1098 return std::make_pair(closest, foeLink);
1131 assert(pred2 !=
nullptr);
1133 assert(predLink !=
nullptr);
1157 assert(pred2 !=
nullptr);
1159 assert(predLink !=
nullptr);
1160 return predLink->
getState() == linkState;
1174 std::vector<std::pair<SUMOTime, const SUMOVehicle*> > toSort;
1176 toSort.push_back(std::make_pair(it.second.arrivalTime, it.first));
1178 std::sort(toSort.begin(), toSort.end());
1179 for (std::vector<std::pair<SUMOTime, const SUMOVehicle*> >::const_iterator it = toSort.begin(); it != toSort.end(); ++it) {
1202 while (lane !=
nullptr && lane->
isInternal()) {
1214 while (lane !=
nullptr && lane->
isInternal()) {
1229 double totalDist = 0.;
1230 bool foundCrossing =
false;
1231 while (via !=
nullptr) {
1237 foundCrossing =
true;
1244 if (foundCrossing) {
1255 for (foe_ix = 0; foe_ix != (int)
myFoeLanes.size(); ++foe_ix) {
1262 #ifdef MSLink_DEBUG_CROSSING_POINTS
1269 if (dist == -10000.) {
1273 #ifdef MSLink_DEBUG_CROSSING_POINTS
1275 <<
"' at distance " << dist <<
" (approach along '"
1322 const MSLink* link =
this;
1323 while (lane !=
nullptr) {
1333 const MSLink* link =
this;
1359 std::cout <<
SIMTIME <<
" getLeaderInfo link=" <<
getDescription() <<
" dist=" << dist <<
" isShadowLink=" << isShadowLink <<
"\n";
1367 std::cout <<
" ignore linkLeaders beyond red light\n";
1373 for (
int i = 0; i < (int)
myFoeLanes.size(); ++i) {
1377 double distToCrossing = dist -
myConflicts[i].getLengthBehindCrossing(
this);
1378 const double foeDistToCrossing = foeLane->
getLength() -
myConflicts[i].getFoeLengthBehindCrossing(foeExitLink);
1381 const double crossingWidth = (sameTarget || sameSource) ? 0 :
myConflicts[i].conflictSize;
1382 const double foeCrossingWidth = (sameTarget || sameSource) ? 0 :
myConflicts[i].getFoeConflictSize(foeExitLink);
1387 std::cout <<
" distToCrossing=" << distToCrossing <<
" foeLane=" << foeLane->
getID() <<
" cWidth=" << crossingWidth
1389 <<
" lbc=" <<
myConflicts[i].getLengthBehindCrossing(
this)
1390 <<
" flbc=" <<
myConflicts[i].getFoeLengthBehindCrossing(foeExitLink)
1391 <<
" cw=" << crossingWidth
1392 <<
" fcw=" << foeCrossingWidth
1393 <<
" contLane=" << contLane
1398 if (distToCrossing + crossingWidth < 0 && !sameTarget
1402 bool ignoreGreenCont =
false;
1403 bool foeIndirect =
false;
1408 if (entry !=
nullptr && entry->
haveGreen()
1409 && foeEntry !=
nullptr && foeEntry->
haveGreen()
1412 ignoreGreenCont =
true;
1417 std::cout <<
" ignore:noIntersection\n";
1431 const double leaderBackDist = foeDistToCrossing - leaderBack;
1432 const double l2 = ego !=
nullptr ? ego->
getLength() + 2 : 0;
1434 const bool pastTheCrossingPoint = leaderBackDist + foeCrossingWidth + sagitta < 0;
1438 const bool ignoreIndirectBicycleTurn = pastTheCrossingPoint && foeIsBicycleTurn;
1439 const bool cannotIgnore = ((contLane && !ignoreIndirectBicycleTurn) || sameTarget || sameSource) && ego !=
nullptr;
1440 const bool inTheWay = ((((!pastTheCrossingPoint && distToCrossing > 0) || (sameTarget && distToCrossing > leaderBackDist - leader->
getLength()))
1441 && enteredTheCrossingPoint
1449 std::cout <<
" candidate leader=" << leader->
getID()
1450 <<
" cannotIgnore=" << cannotIgnore
1451 <<
" fdtc=" << foeDistToCrossing
1452 <<
" lb=" << leaderBack
1453 <<
" lbd=" << leaderBackDist
1454 <<
" fcwidth=" << foeCrossingWidth
1456 <<
" sagitta=" << sagitta
1457 <<
" foePastCP=" << pastTheCrossingPoint
1458 <<
" foeEnteredCP=" << enteredTheCrossingPoint
1459 <<
" inTheWay=" << inTheWay
1460 <<
" willPass=" << willPass
1462 <<
" ignoreGreenCont=" << ignoreGreenCont
1463 <<
" foeIndirect=" << foeIndirect
1464 <<
" foeBikeTurn=" << foeIsBicycleTurn
1465 <<
" isOpposite=" << isOpposite <<
"\n";
1467 if (leader == ego) {
1471 if (!inTheWay && ignoreGreenCont) {
1473 std::cout <<
" ignoreGreenCont\n";
1479 && distToCrossing < -POSITION_EPS && !inTheWay
1480 && (ego ==
nullptr || !
MSGlobals::gComputeLC || distToCrossing < -ego->getVehicleType().getLength())) {
1482 std::cout <<
" ego entered conflict area\n";
1489 && leaderBack + leader->
getLength() < ego->getPositionOnLane() - ego->getLength()) {
1492 std::cout <<
" ego ahead of same-source foe\n";
1498 if ((!cannotIgnore || leader->
isStopped() || sameTarget)
1506 std::cout <<
" foe will not pass\n";
1521 && (!foeStrategicBlocked || sameInternalEdge)) {
1522 if (ego->getLane() == leader->
getLane()) {
1526 const double egoLatOffset = isShadowLink ? ego->getLatOffset(ego->getLaneChangeModel().getShadowLane()) : 0;
1527 const double posLat = ego->getLateralPositionOnLane() + egoLatOffset;
1529 if (foeLaneIsBidi) {
1531 posLatLeader = foeLane->
getWidth() - posLatLeader;
1533 const double latGap = (fabs(posLat - posLatLeader)
1538 <<
" sameSource=" << sameSource
1539 <<
" sameTarget=" << sameTarget
1540 <<
" foeLaneIsBidi=" << foeLaneIsBidi
1541 <<
" foeLane=" << foeLane->
getID()
1542 <<
" leader=" << leader->
getID()
1543 <<
" egoLane=" << ego->getLane()->getID()
1545 <<
" egoLat=" << posLat
1546 <<
" egoLatOffset=" << egoLatOffset
1547 <<
" leaderLat=" << posLatLeader
1548 <<
" leaderLatOffset=" << leader->
getLatOffset(foeLane)
1549 <<
" latGap=" << latGap
1550 <<
" maneuverDist=" << maneuverDist
1552 <<
" egoMaxSpeedLat=" << ego->getVehicleType().getMaxSpeedLat()
1563 if ((posLat > posLatLeader) == leaderFromRight) {
1566 std::cout <<
" ignored (same source) leaderFromRight=" << leaderFromRight <<
"\n";
1570 }
else if (sameTarget) {
1577 leaderFromRight = !leaderFromRight;
1579 if ((posLat > posLatLeader) == leaderFromRight
1583 && (ego->getLaneChangeModel().getSpeedLat() == 0
1584 || leaderFromRight == (ego->getLaneChangeModel().getSpeedLat() > latGap))) {
1586 std::cout <<
" ignored (different source) leaderFromRight=" << leaderFromRight <<
"\n";
1595 std::cout <<
" ignored oncoming bidi leader\n";
1605 bool fromLeft =
true;
1606 if (ego ==
nullptr) {
1609 gap = leaderBackDist;
1613 distToCrossing +=
myConflicts[i].conflictSize / 2;
1614 if (gap + foeCrossingWidth < 0) {
1621 fromLeft = foeDistToCrossing > 0.5 * foeLane->
getLength();
1622 }
else if ((contLane && !sameSource && !ignoreIndirectBicycleTurn) || isOpposite) {
1623 gap = -std::numeric_limits<double>::max();
1625 if (pastTheCrossingPoint && !sameTarget) {
1629 std::cout <<
" foePastCP ignored\n";
1633 double leaderBackDist2 = leaderBackDist;
1634 if (sameTarget && leaderBackDist2 < 0) {
1635 const double mismatch =
myConflicts[i].getFoeLengthBehindCrossing(foeExitLink) -
myConflicts[i].getLengthBehindCrossing(
this);
1637 leaderBackDist2 += mismatch;
1641 std::cout <<
" distToCrossing=" << distToCrossing <<
" leaderBack=" << leaderBack
1642 <<
" backDist=" << leaderBackDist
1643 <<
" backDist2=" << leaderBackDist2
1647 gap = distToCrossing - ego->getVehicleType().getMinGap() - leaderBackDist2 - foeCrossingWidth;
1652 const bool stopAsap = leader->
isFrontOnLane(foeLane) ? cannotIgnore : (sameTarget || sameSource);
1654 std::cout <<
" leader=" << leader->
getID() <<
" contLane=" << contLane <<
" cannotIgnore=" << cannotIgnore <<
" stopAsap=" << stopAsap <<
" gap=" << gap <<
"\n";
1663 result.emplace_back(leader, gap, stopAsap ? -1 : distToCrossing, llFlags, leader->
getLatOffset(foeLane));
1674 const double vehSideOffset = (foeDistToCrossing +
myLaneBefore->
getWidth() * 0.5 - vehWidth * 0.5
1680 result.emplace_back(
nullptr, -1, distToPeds);
1686 if (ego !=
nullptr) {
1694 const MSLane* foeLane = *it;
1698 if (leader == ego) {
1715 <<
" foeLane=" << foeLane->
getID()
1716 <<
" leader=" << leader->
getID()
1720 <<
" egoLat=" << posLat
1721 <<
" leaderLat=" << posLatLeader
1722 <<
" leaderLatOffset=" << leader->
getLatOffset(foeLane)
1724 <<
" foeIndex=" << foeLane->
getIndex()
1730 if ((posLat < posLatLeader && myInternalLaneBefore->
getIndex() > foeLane->
getIndex())
1733 std::cout <<
SIMTIME <<
" blocked by " << leader->
getID() <<
" (sublane split) foeLane=" << foeLane->
getID() <<
"\n";
1738 result.emplace_back(leader, gap, -1);
1754 double distToPeds = std::numeric_limits<double>::max();
1767 #ifdef DEBUG_WALKINGAREA
1773 <<
" inFront=" << inFront
1774 <<
" dist=" << dist <<
"\n";
1777 if (dist < ego->getVehicleType().getWidth() / 2 || inFront) {
1780 if (oncomingFactor > 0) {
1782 const double timeToStop = sqrt(dist) / 2;
1783 const double pedDist = p->
getMaxSpeed() *
MAX2(timeToStop,
TS) * oncomingFactor;
1784 dist =
MAX2(0.0, dist - pedDist);
1785 #ifdef DEBUG_WALKINGAREA
1787 std::cout <<
" timeToStop=" << timeToStop <<
" pedDist=" << pedDist <<
" factor=" << oncomingFactor <<
" dist2=" << dist <<
"\n";
1795 distToPeds =
MIN2(distToPeds, dist);
1796 if (collectBlockers !=
nullptr) {
1797 collectBlockers->push_back(p);
1801 if (distToPeds != std::numeric_limits<double>::max()) {
1803 result.emplace_back(
nullptr, -1, distToPeds);
1812 #ifdef DEBUG_WALKINGAREA
1814 std::cout <<
" angleDiff=" <<
RAD2DEG(angleDiff) <<
"\n";
1817 if (angleDiff <
DEG2RAD(75)) {
1828 #ifdef DEBUG_WALKINGAREA
1830 std::cout <<
" ped-angleDiff=" <<
RAD2DEG(angleDiff) <<
" res=" << cos(angleDiff) <<
"\n";
1833 if (angleDiff <=
DEG2RAD(90)) {
1835 return cos(angleDiff);
1845 const double dist = timeHorizon * p->
getMaxSpeed();
1847 const Position offset(cos(a) * dist, sin(a) * dist);
1854 if (direction == -1) {
1856 }
else if (direction == 1) {
1881 if (before !=
nullptr && after !=
nullptr) {
1883 if (link->getLane() == after) {
1901 throw ProcessError(
"Zipper junctions with more than two conflicting lanes are not supported (at junction '"
1909 <<
" dist=" << dist <<
" ignoring foes (arrival in " <<
STEPS2TIME(arrivalTime - now) <<
")\n")
1915 <<
" egoAT=" << arrivalTime
1917 <<
" brakeGap=" << brakeGap
1918 <<
" vSafe=" << vSafe
1919 <<
" numFoes=" << foes->size()
1923 for (
const auto& item : *foes) {
1938 <<
" ignoring foe=" << foe->
getID()
1940 <<
" foeDist=" << avi.
dist
1941 <<
" foeDist2=" << foeDist
1942 <<
" foeSpeed=" << avi.
speed
1944 <<
" deltaDist=" << foeDist - dist
1967 const double uEnd =
MIN2(uMax, uAccel);
1968 const double uAvg = (avi.
speed + uEnd) / 2;
1969 const double tf0 = foeDist /
MAX2(NUMERICAL_EPS, uAvg);
1970 const double tf =
MAX2(1.0, ceil((tf0) /
TS) *
TS);
1975 const double vEnd =
MIN3(vMax, vAccel,
MAX2(uEnd, vDecel));
1976 const double vAvg = (ego->
getSpeed() + vEnd) / 2;
1977 const double te0 = dist /
MAX2(NUMERICAL_EPS, vAvg);
1978 const double te =
MAX2(1.0, ceil((te0) /
TS) *
TS);
1985 const double deltaGap = gap + tf * uAvg - safeGap - vAvg * tf;
1986 const double a = 2 * deltaGap / (tf * tf);
1992 const double w =
MIN2(1.0, te / 10);
1994 const double vZipper =
MAX3(vFollow, ego->
getSpeed() -
ACCEL2SPEED(maxDecel), w * vSafeGap + (1 - w) * vFollow);
1996 vSafe =
MIN2(vSafe, vZipper);
1999 <<
" foeDist=" << foeDist
2000 <<
" foeSpeed=" << avi.
speed
2004 <<
" uAccel=" << uAccel
2008 <<
" safeGap=" << safeGap
2012 <<
" dg=" << deltaGap
2013 <<
" aSafeGap=" << a
2015 <<
" vAccel=" << vAccel
2016 <<
" vDecel=" << vDecel
2018 <<
" vSafeGap=" << vSafeGap
2019 <<
" vFollow=" << vFollow
2021 <<
" maxDecel=" << maxDecel
2022 <<
" vZipper=" << vZipper
2023 <<
" vSafe=" << vSafe
2034 followDist > leaderDist &&
2052 for (
const MSLink* link : cand->getLinkCont()) {
2063 return fabs(posLat2 - posLat) < (width + width2) / 2;
2084 if (
id == foe->
getID()) {
#define JM_CROSSING_GAP_DEFAULT
#define DIVERGENCE_MIN_WIDTH
#define DEBUG_COND_ZIPPER
#define WRITE_WARNING(msg)
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
const SVCPermissions SVCAll
all VClasses are allowed
@ SVC_BICYCLE
vehicle is a bicycle
const int VEHPARS_JUNCTIONMODEL_PARAMS_SET
LinkDirection
The different directions a link between two lanes may take (or a stream between two edges)....
@ PARTLEFT
The link is a partial left direction.
@ RIGHT
The link is a (hard) right direction.
@ LEFT
The link is a (hard) left direction.
@ STRAIGHT
The link is a straight direction.
@ PARTRIGHT
The link is a partial right direction.
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic,...
@ LINKSTATE_ALLWAY_STOP
This is an uncontrolled, all-way stop link.
@ LINKSTATE_STOP
This is an uncontrolled, minor link, has to stop.
@ LINKSTATE_TL_GREEN_MAJOR
The link has green light, may pass.
@ LINKSTATE_ZIPPER
This is an uncontrolled, zipper-merge link.
@ LINKSTATE_TL_OFF_BLINKING
The link is controlled by a tls which is off and blinks, has to brake.
@ LINKSTATE_TL_RED
The link has red light (must brake)
@ LINKSTATE_TL_GREEN_MINOR
The link has green light, has to brake.
@ LINKSTATE_TL_OFF_NOSIGNAL
The link is controlled by a tls which is off, not blinking, may pass.
@ SUMO_ATTR_JM_IGNORE_FOE_SPEED
@ SUMO_ATTR_JM_IGNORE_IDS
@ SUMO_ATTR_JM_IGNORE_TYPES
@ SUMO_ATTR_JM_IGNORE_FOE_PROB
@ SUMO_ATTR_JM_CROSSING_GAP
@ SUMO_ATTR_JM_TIMEGAP_MINOR
bool gDebugFlag1
global utility flags for debugging
const double INVALID_DOUBLE
invalid double
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static double naviDegree(const double angle)
static double angleDiff(const double angle1, const double angle2)
Returns the difference of the second angle to the first angle in radiants.
static double getMinAngleDiff(double angle1, double angle2)
Returns the minimum distance (clockwise/counter-clockwise) between both angles.
bool isStrategicBlocked() const
double getManeuverDist() const
Returns the remaining unblocked distance for the current maneuver. (only used by sublane model)
double getSpeedLat() const
return the lateral speed of the current lane change maneuver
virtual bool isSelected() const
whether this vehicle is selected in the GUI
double getLength() const
Returns the vehicle's length.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
bool isStopped() const
Returns whether the vehicle is at a stop.
double estimateSpeedAfterDistance(const double dist, const double v, const double accel) const
double getEmergencyDecel() const
Get the vehicle type's maximal phisically possible deceleration [m/s^2].
virtual double getSecureGap(const MSVehicle *const veh, const MSVehicle *const, const double speed, const double leaderSpeed, const double leaderMaxDecel) const
Returns the minimum gap to reserve if the leader is braking at maximum (>=0)
double getMaxAccel() const
Get the vehicle type's maximum acceleration [m/s^2].
double brakeGap(const double speed) const
Returns the distance the vehicle needs to halt including driver's reaction time tau (i....
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
virtual double followSpeed(const MSVehicle *const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle *const pred=0, const CalcReason usage=CalcReason::CURRENT) const =0
Computes the vehicle's follow speed (no dawdling)
A road/street connecting two junctions.
const std::set< MSTransportable *, ComparatorNumericalIdLess > & getPersons() const
Returns this edge's persons set.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
const MSJunction * getFromJunction() const
bool isInternal() const
return whether this edge is an internal edge
static double gLateralResolution
static bool gComputeLC
whether the simulationLoop is in the lane changing phase
static bool gLefthand
Whether lefthand-drive is being simulated.
static SUMOTime gIgnoreJunctionBlocker
static bool gSublane
whether sublane simulation is enabled (sublane model or continuous lanechanging)
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
The base class for an intersection.
AnyVehicleIterator is a structure, which manages the iteration through all vehicles on the lane,...
Representation of a lane in the micro simulation.
const std::vector< MSLink * > & getLinkCont() const
returns the container with all links !!!
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.
const MSLane * getNormalSuccessorLane() const
get normal lane following this internal lane, for normal lanes, the lane itself is returned
AnyVehicleIterator anyVehiclesEnd() const
end iterator for iterating over all vehicles touching this lane in downstream direction
const MSLink * getEntryLink() const
Returns the entry link if this is an internal lane, else nullptr.
const MSLink * getLinkTo(const MSLane *const) const
returns the link to the given lane or nullptr, if it is not connected
double getLength() const
Returns the lane's length.
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
int getIndex() const
Returns the lane's index.
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
MSEdge & getEdge() const
Returns the lane's edge.
double interpolateGeometryPosToLanePos(double geometryPos) const
AnyVehicleIterator anyVehiclesBegin() const
begin iterator for iterating over all vehicles touching this lane in downstream direction
MSLane * getOpposite() const
return the neighboring opposite direction lane for lane changing or nullptr
MSLane * getBidiLane() const
retrieve bidirectional lane or nullptr
const MSLane * getNormalPredecessorLane() const
get normal lane leading to this internal lane, for normal lanes, the lane itself is returned
double getWidth() const
Returns the lane's width.
virtual const PositionVector & getShape(bool) const
bool fromInternalLane() const
return whether the fromLane of this link is an internal lane
void writeApproaching(OutputDevice &od, const std::string fromLaneID) const
write information about all approaching vehicles to the given output device
double computeDistToDivergence(const MSLane *lane, const MSLane *sibling, double minDist, bool sameSource) const
compute point of divergence for geomatries with a common start or end
double getLengthBeforeCrossing(const MSLane *foeLane) const
Returns the internal length from the beginning of the link's internal lane before to the crossing wit...
LinkState getState() const
Returns the current state of the 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
SUMOTime myMesoTLSPenalty
penalty time at tls for mesoscopic simulation
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.
const bool myAmIndirect
whether this connection is an indirect turning movement
std::vector< MSLink * > mySublaneFoeLinks
double myGreenFraction
green fraction at tls for mesoscopic simulation
static const SUMOTime myLookaheadTime
ApproachInfos myApproachingVehicles
double myFoeVisibilityDistance
distance from which an approaching vehicle is able to see all relevant foes and may accelerate if the...
MSLink * computeParallelLink(int direction)
SVCPermissions myPermissions
who may drive on this link
int myIndex
The position within this respond.
bool myHasFoes
Whether any foe links exist.
MSLane * getViaLane() const
Returns the following inner lane.
void setApproaching(const SUMOVehicle *approaching, const SUMOTime arrivalTime, const double arrivalSpeed, const double leaveSpeed, const bool setRequest, const double arrivalSpeedBraking, const SUMOTime waitingTime, double dist, double latOffset)
Sets the information about an approaching vehicle.
const MSLane * myInternalLaneBefore
LinkState myState
The state of the link.
bool lastWasContState(LinkState linkState) const
whether this is a link past an internal junction where the entry to the junction currently has the gi...
void initParallelLinks()
initialize parallel links (to be called after all links are loaded)
void setTLState(LinkState state, SUMOTime t)
Sets the current tl-state.
static const SUMOTime myLookaheadTimeZipper
MSLane * getLane() const
Returns the connected lane.
MSLane * getViaLaneOrLane() const
return the via lane if it exists and the lane otherwise
std::vector< MSLink * > * myOffFoeLinks
bool isConflictEntryLink() const
return whether this link enters the conflict area (not a continuation link)
double myRadius
the turning radius for this link or doublemax for straight links
int getIndex() const
Returns the respond index (for visualization)
std::vector< const SUMOVehicle * > BlockingFoes
bool havePriority() const
Returns whether this link is a major link.
double myLength
The length of the link.
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 SUMOTrafficObject *ego) const
const LinkState myOffState
The state of the link when switching of traffic light control.
const 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.
static bool ignoreFoe(const SUMOTrafficObject *ego, const SUMOTrafficObject *foe)
bool isEntryLink() const
return whether the toLane of this link is an internal lane and fromLane is a normal lane
ApproachingVehicleInformation getApproaching(const SUMOVehicle *veh) const
const MSTrafficLightLogic * myLogic
the controlling logic or 0
@ CONFLICT_NO_INTERSECTION
@ CONFLICT_STOP_AT_INTERNAL_JUNCTION
static bool lateralOverlap(double posLat, double width, double posLat2, double width2)
check whether the given vehicle positions overlap laterally
std::vector< MSLink * > myFoeLinks
const MSLane * getLaneBefore() const
return the internalLaneBefore if it exists and the laneBefore otherwise
bool isInternalJunctionLink() const
return whether the fromLane and the toLane of this link are internal lanes
bool isExitLink() const
return whether the fromLane of this link is an internal lane and toLane is a normal lane
std::vector< const MSLane * > myFoeLanes
std::vector< LinkLeader > LinkLeaders
static std::set< std::pair< MSLink *, MSLink * > > myRecheck
links that need post processing after initialization (to deal with legacy networks)
void clearState()
Remove all approaching vehicles before quick-loading state.
bool willHaveBlockedFoe() const
MSLane * myLane
The lane behind the junction approached by this link.
static const double NO_INTERSECTION
LinkState getOffState() const
Returns the off-state for the link.
bool isInFront(const MSVehicle *ego, const PositionVector &egoPath, const Position &pPos) const
whether the given person is in front of the car
const int myTLIndex
the traffic light index
double getInternalLengthsAfter() const
Returns the cumulative length of all internal lanes after this link.
std::string getDescription() const
get string description for this link
static void recheckSetRequestInformation()
post-processing for legacy networks
bool hasFoes() const
Returns whether this link belongs to a junction where more than one edge is incoming.
LinkState myLastGreenState
The last green state of the link (minor or major)
static SUMOTime computeFoeArrivalTimeBraking(SUMOTime arrivalTime, const SUMOVehicle *foe, SUMOTime foeArrivalTime, double impatience, double dist, double &fasb)
compute arrival time if foe vehicle is braking for ego
double isOnComingPed(const MSVehicle *ego, const MSPerson *p) const
whether the given person is walking towards the car returned as a factor in [0, 1]
MSJunction * myJunction
the junction to which this link belongs
bool blockedAtTime(SUMOTime arrivalTime, SUMOTime leaveTime, double arrivalSpeed, double leaveSpeed, bool sameTargetLane, double impatience, double decel, SUMOTime waitingTime, BlockingFoes *collectFoes=nullptr, const SUMOTrafficObject *ego=nullptr, bool lastWasContRed=false) const
Returns the information whether this link is blocked Valid after the vehicles have set their requests...
const MSLink * getCorrespondingEntryLink() const
returns the corresponding entry link for exitLinks to a junction.
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.
void removeApproaching(const SUMOVehicle *veh)
removes the vehicle from myApproachingVehicles
bool contIntersect(const MSLane *lane, const MSLane *foe)
check if the lane intersects with a foe cont-lane
bool isExitLinkAfterInternalJunction() const
return whether the fromLane of this link is an internal lane and its incoming lane is also an interna...
LinkState getLastGreenState() const
Returns the last green state of the link.
std::pair< const SUMOVehicle *, const MSLink * > getFirstApproachingFoe(const MSLink *wrapAround) const
get the foe vehicle that is closest to the intersection or nullptr along with the foe link This funct...
std::vector< MSLink * > mySublaneFoeLinks2
MSLink * getParallelLink(int direction) const
return the link that is parallel to this lane or 0
void addCustomConflict(const MSLane *from, const MSLane *to, double startPos, double endPos)
const CustomConflict * getCustomConflict(const MSLane *foeLane) const
return CustomConflict with foeLane if it is defined
MSLane *const myInternalLane
The following junction-internal lane if used.
void addBlockedLink(MSLink *link)
double myLateralShift
lateral shift to be applied when passing this link
std::vector< ConflictInfo > myConflicts
double getInternalLengthsBefore() const
Returns the cumulative length of all internal lanes before this link.
const MSLane * myWalkingAreaFoe
walkingArea that must be checked when entering the intersection
static bool couldBrakeForLeader(double followDist, double leaderDist, const MSVehicle *follow, const MSVehicle *leader)
whether follower could stay behind leader (possibly by braking)
const ApproachInfos & getApproaching() const
return all approaching vehicles
const MSTrafficLightLogic * getTLLogic() const
Returns the TLS index.
bool opened(SUMOTime arrivalTime, double arrivalSpeed, double leaveSpeed, double vehicleLength, double impatience, double decel, SUMOTime waitingTime, double posLat=0, BlockingFoes *collectFoes=nullptr, bool ignoreRed=false, const SUMOTrafficObject *ego=nullptr) const
Returns the information whether the link may be passed.
std::vector< CustomConflict > myCustomConflicts
Position getFuturePosition(const MSPerson *p, double timeHorizon=1) const
return extrapolated position of the given person after the given time
const MSLane * myWalkingAreaFoeExit
walkingArea that must be checked when leaving the intersection
MSLane * myLaneBefore
The lane approaching this link.
@ LL_SAME_SOURCE
link leader is coming from the same (normal) lane
@ LL_SAME_TARGET
link leader is targeting the same outgoing lane
@ LL_IN_THE_WAY
vehicle is in the way
@ LL_FROM_LEFT
link leader is passing from left to right
SVCPermissions getPermissions() const
who may use this link
std::set< MSLink * > myBlockedFoeLinks
bool lastWasContMajor() const
whether this is a link past an internal junction which currently has priority
double getLengthsBeforeCrossing(const MSLane *foeLane) const
Returns the sum of the lengths along internal lanes following this link to the crossing with the give...
bool myHavePedestrianCrossingFoe
whether on of myFoeLanes is a crossing
SUMOTime myLastStateChange
The time of the last state change.
LinkDirection myDirection
An abstract (hopefully human readable) definition of the link's direction.
bool checkContOff() const
figure out whether the cont status remains in effect when switching off the tls
const MSLink * getCorrespondingExitLink() const
returns the corresponding exit link for entryLinks to a junction.
static bool unsafeMergeSpeeds(double leaderSpeed, double followerSpeed, double leaderDecel, double followerDecel)
return whether the given vehicles may NOT merge safely
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
double getZipperSpeed(const MSVehicle *ego, const double dist, double vSafe, SUMOTime arrivalTime, const BlockingFoes *foes) const
return the speed at which ego vehicle must approach the zipper link
MSLink * getOppositeDirectionLink() const
return the link that is the opposite entry link to this one
MSLink(MSLane *predLane, MSLane *succLane, MSLane *via, LinkDirection dir, LinkState state, double length, double foeVisibilityDistance, bool keepClear, MSTrafficLightLogic *logic, int tlLinkIdx, bool indirect)
Constructor for simulation which uses internal lanes.
std::vector< MSLane * > mySublaneFoeLanes
LinkDirection getDirection() const
Returns the direction the vehicle passing this link take.
bool keepClear() const
whether the junction after this link must be kept clear
const MSLane * getInternalLaneBefore() const
return myInternalLaneBefore (always 0 when compiled without internal lanes)
bool haveRed() const
Returns whether this link is blocked by a red (or redyellow) traffic light.
double getLength() const
Returns the length of this link.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
bool hasPersons() const
Returns whether persons are simulated.
virtual MSTransportableControl & getPersonControl()
Returns the person control.
virtual bool blockedAtDist(const SUMOTrafficObject *ego, 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
static const double SAFETY_GAP
The parent class for traffic light logics.
MSPModel * getMovementModel()
Returns the default movement model for this kind of transportables.
virtual double getAngle() const
return the current angle of the transportable
const MSVehicleType & getVehicleType() const
Returns the object's "vehicle" type.
Position getPosition(const double) const
Return current position (x/y, cartesian)
double getMaxSpeed() const
Returns the maximum speed (the minimum of desired and physical maximum speed)
Representation of a vehicle in the micro simulation.
bool willStop() const
Returns whether the vehicle will stop on the current edge.
SUMOTime getLastActionTime() const
Returns the time of the vehicle's last action point.
bool isActive() const
Returns whether the current simulation step is an action point for the vehicle.
SUMOTime getWaitingTime(const bool accumulated=false) const
Returns the SUMOTime waited (speed was lesser than 0.1m/s)
bool isFrontOnLane(const MSLane *lane) const
Returns the information whether the front of the vehicle is on the given lane.
MSAbstractLaneChangeModel & getLaneChangeModel()
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
double getBackPositionOnLane(const MSLane *lane) const
Get the vehicle's position relative to the given lane.
double getLatOffset(const MSLane *lane) const
Get the offset that that must be added to interpret myState.myPosLat for the given lane.
bool isBidiOn(const MSLane *lane) const
whether this vehicle is driving against lane
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
double getSpeed() const
Returns the vehicle's current speed.
bool ignoreRed(const MSLink *link, bool canBrake) const
decide whether a red (or yellow light) may be ignored
const MSLane * getLane() const
Returns the lane the vehicle is on.
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
double getAngle() const
Returns the vehicle's direction in radians.
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
double getMinGap() const
Get the free space in front of vehicles of this class.
const std::string & getID() const
Returns the name of the vehicle type.
double getLength() const
Get vehicle's length [m].
const MSCFModel & getCarFollowModel() const
Returns the vehicle type's car following model definition (const version)
const SUMOVTypeParameter & getParameter() const
const std::string & getID() const
Returns the id.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
virtual const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
A point in 2D or 3D with translation and scaling methods.
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position (in radians bet...
double length2D() const
Returns the length.
double rotationAtOffset(double pos) const
Returns the rotation at the given length.
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 ...
double distance2D(const Position &p, bool perpendicular=false) const
closest 2D-distance to point p (or -1 if perpendicular is true and the point is beyond this vector)
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
void move2side(double amount, double maxExtension=100)
move position vector to side using certain amount
double angleAt2D(int pos) const
get angle in certain position of position vector (in radians between -M_PI and M_PI)
PositionVector reverse() const
reverse position vector
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)
Representation of a vehicle, person, or container.
virtual double getSpeed() const =0
Returns the object's current speed.
virtual SumoRNG * getRNG() const =0
Returns the associated RNG for this object.
virtual const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
virtual bool isSelected() const =0
whether this object is selected in the GUI
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.
Representation of a vehicle.
virtual double getLateralPositionOnLane() const =0
Get the vehicle's lateral position on the lane.
Structure representing possible vehicle parameter.
bool wasSet(int what) const
Returns whether the given parameter was set.
pre-computed information for conflict points
double getLengthBehindCrossing(const MSLink *exitLink) const
double getFoeConflictSize(const MSLink *foeExitLink) const
int foeConflictIndex
the conflict from the perspective of the foe
double conflictSize
the length of the conflict space
double getFoeLengthBehindCrossing(const MSLink *foeExitLink) const
holds user defined conflict positions (must be interpreted for the correct exitLink)