56#define DEBUG_COND2(obj) (obj->isSelected())
61#define DEBUG_COND_ZIPPER (ego->isSelected())
67#define INVALID_TIME -1000
70#define JM_CROSSING_GAP_DEFAULT 10
73#define DIVERGENCE_MIN_WIDTH 2.5
98 if (foeConflictIndex >= 0) {
99 return foeExitLink->
myConflicts[foeConflictIndex].conflictSize;
110 return lengthBehindCrossing;
118 double length,
double foeVisibilityDistance,
bool keepClear,
163 const double dist = from.back().distanceTo2D(to.front());
169 myLateralShift = (from.back().distanceTo2D(to.front()) < dist) ? dist : -dist;
203 if (cc.from == foeFrom && cc.to == foeTo) {
214 const std::vector<MSLink*>& foeLinks,
215 const std::vector<MSLane*>& foeLanes,
216 MSLane* internalLaneBefore) {
226 for (
MSLane* foeLane : foeLanes) {
234 if (internalLaneBefore !=
nullptr) {
236 lane = internalLaneBefore;
248 for (
MSLane* foeLane : foeLanes) {
249 assert(foeLane->isInternal() || foeLane->isCrossing());
250 MSLink* viaLink = foeLane->getIncomingLanes().front().viaLink;
257#ifdef MSLink_DEBUG_CROSSING_POINTS
260 if (lane !=
nullptr) {
261 const bool beforeInternalJunction = lane->
getLinkCont()[0]->getViaLaneOrLane()->getEdge().isInternal();
285 const CustomConflict* rcc = foeLane->getEntryLink()->getCustomConflict(lane);
286 bool haveIntersection =
false;
287 if (rcc ==
nullptr) {
292 const bool foeIsSecondPart = foeLane->getLogicalPredecessorLane()->isInternal();
295 if (foeIsSecondPart) {
296 foeStartPos -= foeLane->getLogicalPredecessorLane()->getLength();
298 const double foeEndPos = foeStartPos + foeConflictSize;
299 haveIntersection = ((foeStartPos > 0 && foeStartPos < foeLane->getLength())
300 || (foeEndPos > 0 && foeEndPos < foeLane->
getLength()));
302 if (haveIntersection) {
307#ifdef MSLink_DEBUG_CROSSING_POINTS
308 std::cout <<
" " << lane->
getID() <<
" custom conflict with " << foeLane->getID() <<
" customReverse=" << (rcc !=
nullptr)
309 <<
" haveIntersection=" << haveIntersection
310 <<
" startPos=" << startPos <<
" conflictSize=" << conflictSize
311 <<
" lbc=" <<
myConflicts.back().lengthBehindCrossing
318 if (sameTarget && !beforeInternalJunction && !
contIntersect(lane, foeLane)) {
322 if (lane->
getShape().back().distanceTo2D(foeLane->getShape().back()) >= minDist) {
324 if (foeLane->getEntryLink()->isIndirect()) {
326#ifdef MSLink_DEBUG_CROSSING_POINTS
327 std::cout <<
" " << lane->
getID() <<
" dummy merge with indirect" << foeLane->getID() <<
"\n";
331#ifdef MSLink_DEBUG_CROSSING_POINTS
332 std::cout <<
" " << lane->
getID() <<
" dummy merge with " << foeLane->getID() <<
"\n";
339#ifdef MSLink_DEBUG_CROSSING_POINTS
341 <<
" " << lane->
getID()
342 <<
" merges with " << foeLane->getID()
343 <<
" nextLane " << lane->
getLinkCont()[0]->getViaLaneOrLane()->getID()
344 <<
" dist1=" <<
myConflicts.back().lengthBehindCrossing
350#ifdef MSLink_DEBUG_CROSSING_POINTS_DETAILS
351 std::cout <<
" intersections1=" <<
toString(intersections1) <<
"\n";
353 bool haveIntersection =
true;
354 if (intersections1.size() == 0) {
356 haveIntersection =
false;
357 }
else if (intersections1.size() > 1) {
358 std::sort(intersections1.begin(), intersections1.end());
360 std::vector<double> intersections2 = foeLane->getShape().intersectsAtLengths2D(lane->
getShape());
361#ifdef MSLink_DEBUG_CROSSING_POINTS_DETAILS
362 std::cout <<
" intersections2=" <<
toString(intersections2) <<
"\n";
364 if (intersections2.size() == 0) {
365 intersections2.push_back(0);
366 }
else if (intersections2.size() > 1) {
367 std::sort(intersections2.begin(), intersections2.end());
371 if (!haveIntersection && foeLane->getLinkCont()[0]->getViaLane() !=
nullptr) {
372 const Position waitPos = foeLane->getShape().back();
376 intersections1.clear();
377 intersections2.clear();
379 intersections2.push_back(foeLane->getShape().length());
380 haveIntersection =
true;
381#ifdef MSLink_DEBUG_CROSSING_POINTS_DETAILS
382 std::cout <<
" link=" <<
myIndex <<
" " <<
getDescription() <<
" almostIntersection with foeLane " << foeLane->getID() <<
" offset=" << intersections1.back() <<
"\n";
387 double conflictSize = foeLane->getWidth();
389 if (haveIntersection) {
392 const double angle2 =
GeomHelper::naviDegree(foeLane->getShape().rotationAtOffset(intersections2.back()));
396 const double widthFactor = 1 /
MAX2(sin(
DEG2RAD(angleDiff)), 0.2) * 2 - 1;
398 conflictSize *= widthFactor;
401 intersections1.back() -= conflictSize / 2;
403 intersections1.back() =
MAX2(0.0, intersections1.back());
412 if (foeLane->isCrossing()) {
419 lane->
getLength() - intersections1.back(),
420 conflictSize, flag));
422#ifdef MSLink_DEBUG_CROSSING_POINTS
424 <<
" intersection of " << lane->
getID()
426 <<
" with " << foeLane->getID()
427 <<
" totalLength=" << foeLane->getLength()
428 <<
" dist1=" <<
myConflicts.back().lengthBehindCrossing
429 <<
" widthFactor=" <<
myConflicts.back().conflictSize / foeLane->getWidth()
439 const MSLane*
const sibling = link->getViaLane();
440 if (sibling != lane && sibling !=
nullptr) {
442 if (lane->
getShape().front().distanceTo2D(sibling->
getShape().front()) >= minDist) {
452 lbcLane = lane->
getLength() - distToDivergence;
460 const int replacedIndex = (int)(it -
myFoeLanes.begin());
466#ifdef MSLink_DEBUG_CROSSING_POINTS
467 std::cout <<
" adding same-origin foe" << sibling->
getID()
468 <<
" dist1=" <<
myConflicts.back().lengthBehindCrossing
471 const MSLane*
const siblingCont = sibling->
getLinkCont().front()->getViaLaneOrLane();
475 const double lengthBehindDivergence =
MAX2(0.0, lane->
getLength() - maxCommonLength);
481#ifdef MSLink_DEBUG_CROSSING_POINTS
482 std::cout <<
" adding same-origin foeContinuation" << siblingCont->
getID()
483 <<
" dist1=" <<
myConflicts.back().lengthBehindCrossing
491 for (
int i = 0; i < (int)
myFoeLanes.size(); i++) {
495 for (
int i2 = 0; i2 < (int)foeExitLink->
myFoeLanes.size(); i2++) {
504#ifdef MSLink_DEBUG_CROSSING_POINTS
505 std::cout << lane->
getID() <<
" foeLane=" << foeLane->
getID() <<
" index=" << i <<
" foundIndex=" << foundIndex <<
"\n";
507 if (foundIndex < 0) {
519 const MSEdge* target = &(it->getLane()->getEdge());
523 if (target == myTarget) {
525#ifdef MSLink_DEBUG_CROSSING_POINTS
526 std::cout <<
" sublaneFoeLink (same target): " << it->getViaLaneOrLane()->
getID() <<
"\n";
531#ifdef MSLink_DEBUG_CROSSING_POINTS
532 std::cout <<
" sublaneFoeLink2 (other target: " << it->getViaLaneOrLane()->getID() <<
"\n";
574#ifdef MSLink_DEBUG_CROSSING_POINTS
575 std::cout <<
" recheck l1=" << item.first->getDescription() <<
" l2=" << item.second->getDescription() <<
"\n";
577 MSLink*
const link = item.first;
578 MSLink*
const foeExitLink = item.second;
581 int conflictIndex = -1;
582 for (
int i = 0; i < (int)link->
myFoeLanes.size(); i++) {
588 if (conflictIndex == -1) {
600#ifdef MSLink_DEBUG_CROSSING_POINTS
601 std::cout <<
" siblingContinuation: distToDivergence=" << distToDivergence <<
" lbcSibCont=" << lbcSibCont <<
"\n";
602 std::cout <<
" conflictIndex=" << conflictIndex <<
" foeLane=" << foeLane->
getID() <<
" foeExitLink=" << foeExitLink->
getDescription() <<
" intLane=" << intLane->
getID() <<
"\n";
613 if (intersections1.size() == 0) {
614#ifdef MSLink_DEBUG_CROSSING_POINTS
615 std::cout <<
" no intersection\n";
620 const double conflictSize2 = lane->
getWidth() * widthFactor;
621 std::sort(intersections1.begin(), intersections1.end());
622 intersections1.back() -= conflictSize2 / 2;
623 intersections1.back() =
MAX2(0.0, intersections1.back());
626#ifdef MSLink_DEBUG_CROSSING_POINTS
627 std::cout <<
" ci=" << conflictIndex <<
" wf=" << widthFactor <<
" flag=" << ci.
flag <<
" flbc=" << foeExitLink->
myConflicts.back().lengthBehindCrossing <<
"\n";
635 double lbcSibling = 0;
649 lbcSibling += s[-1].distanceTo2D(s[-2]);
655 lbcLane += l[-1].distanceTo2D(l[-2]);
659#ifdef MSLink_DEBUG_CROSSING_POINTS_DETAILS
660 std::cout <<
" sameSource=" << sameSource <<
" lane=" << lane->
getID() <<
" sib=" << sibling->
getID() <<
" minDist=" << minDist <<
" backDist=" << l.back().distanceTo2D(s.back()) <<
"\n";
662 if (l.back().distanceTo2D(s.back()) > minDist) {
669 std::vector<double> distances = l.
distances(s);
670#ifdef MSLink_DEBUG_CROSSING_POINTS
671 std::cout <<
" distances=" <<
toString(distances) <<
"\n";
673 assert(distances.size() == l.size() + s.size());
674 if (distances.back() > minDist && distances[l.size() - 1] > minDist) {
676 for (
int j = (
int)s.size() - 2; j >= 0; j--) {
677 const int i = j + (int)l.size();
678 const double segLength = s[j].distanceTo2D(s[j + 1]);
679 if (distances[i] > minDist) {
680 lbcSibling += segLength;
683 lbcSibling += segLength - (minDist - distances[i]) * segLength / (distances[i + 1] - distances[i]);
687 for (
int i = (
int)l.size() - 2; i >= 0; i--) {
688 const double segLength = l[i].distanceTo2D(l[i + 1]);
689 if (distances[i] > minDist) {
690 lbcLane += segLength;
693 lbcLane += segLength - (minDist - distances[i]) * segLength / (distances[i + 1] - distances[i]);
698 assert(lbcSibling >= -NUMERICAL_EPS);
699 assert(lbcLane >= -NUMERICAL_EPS);
701 const double distToDivergence1 = sibling->
getLength() + siblingPredLength - lbcSibling;
702 const double distToDivergence2 = lane->
getLength() - lbcLane;
703 const double distToDivergence =
MIN3(
704 MAX2(distToDivergence1, distToDivergence2),
706#ifdef MSLink_DEBUG_CROSSING_POINTS
707 std::cout <<
" distToDivergence=" << distToDivergence
708 <<
" distTD1=" << distToDivergence1
709 <<
" distTD2=" << distToDivergence2
710 <<
" length=" << length
711 <<
" sibLength=" << sibLength
714 return distToDivergence;
720 if (foe->
getLinkCont()[0]->getViaLane() !=
nullptr) {
722 return intersections.size() > 0;
730 const bool setRequest,
const double arrivalSpeedBraking,
const SUMOTime waitingTime,
double dist,
double latOffset) {
732#ifdef DEBUG_APPROACHING
736 std::cout <<
" curApproaching=";
738 std::cout << i->first->getID() <<
" ";
756 arrivalSpeedBraking, waitingTime, dist, approaching->
getSpeed(), latOffset));
762 const bool setRequest,
const double arrivalSpeedBraking,
const SUMOTime waitingTime,
double dist,
double latOffset) {
771 arrivalSpeedBraking, waitingTime, dist, approaching->
getSpeed(), latOffset);
776 setApproaching(approaching, arrivalTime, arrivalSpeed, leaveSpeed, setRequest, arrivalSpeedBraking, waitingTime, dist, latOffset);
782#ifdef DEBUG_APPROACHING
786 std::cout <<
" curApproaching=";
788 std::cout << i->first->getID() <<
" ";
810#ifdef DEBUG_APPROACHING
814 std::cout <<
" curApproaching=";
816 std::cout << i->first->getID() <<
" ";
835#ifdef DEBUG_APPROACHING
838 std::cout <<
"' Removing approaching person '" << person->
getID() <<
"'\nCurrently registered persons:" << std::endl;
840 std::cout <<
"'" << i->first->getID() <<
"'" << std::endl;
878 const double leaveSpeed,
const double vehicleLength)
const {
885 double impatience,
double decel,
SUMOTime waitingTime,
double posLat,
887#ifdef MSLink_DEBUG_OPENED
902 assert(
myLane != foeLink->getLane());
903 for (
const auto& it : foeLink->myApproachingVehicles) {
907 ((posLat < foe->getLateralPositionOnLane() + it.second.latOffset &&
myLane->
getIndex() > foeLink->myLane->getIndex())
910 && (arrivalTime > it.second.arrivalTime
914 if (
blockedByFoe(foe, it.second, arrivalTime, leaveTime, arrivalSpeed, leaveSpeed,
false,
915 impatience, decel, waitingTime, ego)) {
916#ifdef MSLink_DEBUG_OPENED
918 std::cout <<
SIMTIME <<
" blocked by " << foe->
getID() <<
" arrival=" << arrivalTime <<
" foeArrival=" << it.second.arrivalTime <<
"\n";
921 if (collectFoes ==
nullptr) {
922#ifdef MSLink_DEBUG_OPENED
924 std::cout <<
" link=" <<
getViaLaneOrLane()->
getID() <<
" blocked by sublaneFoe=" << foe->
getID() <<
" foeLink=" << foeLink->getViaLaneOrLane()->getID() <<
" posLat=" << posLat <<
"\n";
929 collectFoes->push_back(it.first);
940 for (
const auto& it : foeLink->myApproachingVehicles) {
950 if (
blockedByFoe(foe, it.second, arrivalTime, leaveTime, arrivalSpeed, leaveSpeed,
false,
951 impatience, decel, waitingTime, ego)) {
952#ifdef MSLink_DEBUG_OPENED
954 std::cout <<
SIMTIME <<
" blocked by sublane foe " << foe->
getID() <<
" arrival=" << arrivalTime <<
" foeArrival=" << it.second.arrivalTime <<
"\n";
957 if (collectFoes ==
nullptr) {
958#ifdef MSLink_DEBUG_OPENED
960 std::cout <<
" link=" <<
getViaLaneOrLane()->
getID() <<
" blocked by sublaneFoe2=" << foe->
getID() <<
" foeLink=" << foeLink->getViaLaneOrLane()->getID() <<
" posLat=" << posLat <<
"\n";
965 collectFoes->push_back(it.first);
972#ifdef MSLink_DEBUG_OPENED
989 return collectFoes ==
nullptr || collectFoes->size() == 0;
1005 if (ego ==
nullptr) {
1008 double maxOncomingWidth = 0;
1011 maxOncomingWidth =
MAX2(maxOncomingWidth, foe->getVehicleType().getWidth());
1015 if (ego->
getVehicleType().
getWidth() + maxOncomingWidth + MSGlobals::gLateralResolution < myLane->getWidth()) {
1018 }
else if (maxOncomingWidth > 0) {
1028 double maxOncomingWidth = 0;
1029 if (ili.viaLink->blockedAtTime(arrivalTime, leaveTime, arrivalSpeed, leaveSpeed,
false, 0, decel, 0,
1033 maxOncomingWidth =
MAX2(maxOncomingWidth, foe->getVehicleType().getWidth());
1035 if (ego->
getVehicleType().
getWidth() + maxOncomingWidth + MSGlobals::gLateralResolution < myLane->getWidth()) {
1046 for (
const MSLink*
const link : foeLinks) {
1048 if (link->haveRed()) {
1052#ifdef MSLink_DEBUG_OPENED
1054 std::cout <<
SIMTIME <<
" foeLink=" << link->getViaLaneOrLane()->getID() <<
" numApproaching=" << link->getApproaching().size() <<
"\n";
1055 if (link->getLane()->isCrossing()) {
1056 std::cout <<
SIMTIME <<
" approachingPersons=" << (link->myApproachingPersons ==
nullptr ?
"NULL" :
toString(link->myApproachingPersons->size())) <<
"\n";
1060 if (link->blockedAtTime(arrivalTime, leaveTime, arrivalSpeed, leaveSpeed,
myLane == link->getLane(),
1061 impatience, decel, waitingTime, collectFoes, ego, lastWasContRed, dist)) {
1065 if (collectFoes !=
nullptr && collectFoes->size() > 0) {
1074 bool sameTargetLane,
double impatience,
double decel,
SUMOTime waitingTime,
1077#ifdef MSLink_DEBUG_OPENED
1082 std::stringstream stream;
1084 <<
" foeVeh=" << it.first->getID() <<
" (below ignore speed)"
1087 std::cout << stream.str();
1098 &&
blockedByFoe(it.first, it.second, arrivalTime, leaveTime, arrivalSpeed, leaveSpeed, sameTargetLane,
1099 impatience, decel, waitingTime, ego)) {
1100 if (collectFoes ==
nullptr) {
1103 collectFoes->push_back(it.first);
1108 const SUMOTime lookAhead = (ego ==
nullptr
1112#ifdef MSLink_DEBUG_OPENED
1114 std::cout <<
SIMTIME <<
": " << ego->
getID() <<
" check person " << it.first->getID() <<
" aTime=" << arrivalTime <<
" foeATime=" << it.second.arrivalTime
1115 <<
" lTime=" << leaveTime <<
" foeLTime=" << it.second.leavingTime
1116 <<
" dist=" << dist <<
"\n";
1124 && !((arrivalTime > it.second.leavingTime + lookAhead) || (leaveTime + lookAhead < it.second.arrivalTime))) {
1125 if (ego ==
nullptr) {
1135#ifdef MSLink_DEBUG_OPENED
1137 std::cout <<
SIMTIME <<
": " << ego->
getID() <<
" conflict with person " << it.first->getID() <<
" aTime=" << arrivalTime <<
" foeATime=" << it.second.arrivalTime <<
" dist=" << dist <<
" bGap=" << cfm.brakeGap(ego->
getSpeed(), cfm.getMaxDecel(), 0) <<
"\n";
1140 if (dist > cfm.brakeGap(ego->
getSpeed(), cfm.getMaxDecel(), 0)) {
1141#ifdef MSLink_DEBUG_OPENED
1143 std::cout <<
SIMTIME <<
": " << ego->
getID() <<
" blocked by person " << it.first->getID() <<
"\n";
1146 if (collectFoes ==
nullptr) {
1149 collectFoes->push_back(it.first);
1161 SUMOTime arrivalTime,
SUMOTime leaveTime,
double arrivalSpeed,
double leaveSpeed,
1162 bool sameTargetLane,
double impatience,
double decel,
SUMOTime waitingTime,
1164#ifdef MSLink_DEBUG_OPENED
1166 std::stringstream stream;
1168 <<
" foeVeh=" << veh->
getID()
1173 std::cout << stream.str();
1180 assert(waitingTime > 0);
1181#ifdef MSLink_DEBUG_OPENED
1183 std::stringstream stream;
1184 stream <<
" foeDist=" << avi.
dist
1187 <<
" wait=" << waitingTime
1189 std::cout << stream.str();
1194 if (waitingTime > avi.
waitingTime + actionDelta) {
1203 if (impatience > 0 && arrivalTime < avi.
arrivalTime) {
1204#ifdef MSLink_DEBUG_OPENED
1208 foeArrivalTime = (
SUMOTime)((1. - impatience) * (double)avi.
arrivalTime + impatience * (
double)fatb);
1209#ifdef MSLink_DEBUG_OPENED
1228#ifdef MSLink_DEBUG_OPENED
1230 std::stringstream stream;
1231 stream <<
" imp=" << impatience <<
" fAT2=" << foeArrivalTime <<
" fASb=" << foeArrivalSpeedBraking <<
" lA=" << lookAhead <<
" egoAT=" << arrivalTime <<
" egoLT=" << leaveTime <<
" egoLS=" << leaveSpeed <<
"\n";
1232 std::cout << stream.str();
1237 if (sameTargetLane && (arrivalTime - avi.
leavingTime < lookAhead
1240#ifdef MSLink_DEBUG_OPENED
1242 std::cout <<
" blocked (cannot follow)\n";
1247 }
else if (foeArrivalTime > leaveTime + lookAhead) {
1251#ifdef MSLink_DEBUG_OPENED
1253 std::cout <<
" blocked (cannot lead)\n";
1260#ifdef MSLink_DEBUG_OPENED
1262 std::cout <<
" blocked (hard conflict)\n";
1279 if (arrivalTime - arrivalTime %
DELTA_T == foeArrivalTime - foeArrivalTime %
DELTA_T) {
1281#ifdef MSLink_DEBUG_OPENED
1283 std::cout <<
" foeAT before egoAT\n";
1286 return foeArrivalTime;
1288 if (arrivalTime %
DELTA_T > 0) {
1293 const double dt =
STEPS2TIME(foeArrivalTime - arrivalTime);
1294 const double d = dt * m;
1295 const double a = dt * d / 2;
1298#ifdef MSLink_DEBUG_OPENED
1300 std::cout <<
" dist=" << dist <<
" dist2=" << dist2
1303 <<
" dt=" << dt <<
" v=" << v <<
" m=" << m <<
" d=" << d <<
" a=" << a <<
"\n";
1306 if (0.5 * v * v / m <= dist2) {
1307#ifdef MSLink_DEBUG_OPENED
1309 std::cout <<
" canBrakeToStop\n";
1322 const double x = (sqrt(4 * (v - d) * (v - d) - 8 * m * a) * -0.5 - d + v) / m;
1324#ifdef MSLink_DEBUG_OPENED
1325 const double x2 = (sqrt(4 * (v - d) * (v - d) - 8 * m * a) * 0.5 - d + v) / m;
1327 std::cout <<
SIMTIME <<
" dist=" << dist <<
" dist2=" << dist2 <<
" at=" <<
STEPS2TIME(arrivalTime) <<
" m=" << m <<
" d=" << d <<
" v=" << v <<
" a=" << a <<
" x=" << x <<
" x2=" << x2 <<
"\n";
1330 fasb = v - (dt + x) * m;
1338 if (link->blockedAtTime(arrivalTime, leaveTime, speed, speed,
myLane == link->getLane(), 0, decel, 0)) {
1343 if (lane->getVehicleNumberWithPartials() > 0) {
1351std::pair<const SUMOVehicle*, const MSLink*>
1353 double closetDist = std::numeric_limits<double>::max();
1355 const MSLink* foeLink =
nullptr;
1357 for (
const auto& it : link->myApproachingVehicles) {
1360 return std::make_pair(
nullptr, wrapAround);
1361 }
else if (it.second.dist < closetDist) {
1362 closetDist = it.second.dist;
1363 if (it.second.willPass) {
1370 return std::make_pair(closest, foeLink);
1412 assert(pred2 !=
nullptr);
1414 assert(predLink !=
nullptr);
1438 assert(pred2 !=
nullptr);
1440 assert(predLink !=
nullptr);
1441 return predLink->
getState() == linkState;
1455 std::vector<std::pair<SUMOTime, const SUMOVehicle*> > toSort;
1457 toSort.push_back(std::make_pair(it.second.arrivalTime, it.first));
1459 std::sort(toSort.begin(), toSort.end(), [](
const std::pair<SUMOTime, const SUMOVehicle*>& a,
const std::pair<SUMOTime, const SUMOVehicle*>& b) {
1460 return a.first < b.first || (a.first == b.first && a.second->getNumericalID() < b.second->getNumericalID());
1462 for (std::vector<std::pair<SUMOTime, const SUMOVehicle*> >::const_iterator it = toSort.begin(); it != toSort.end(); ++it) {
1485 while (lane !=
nullptr && lane->
isInternal()) {
1497 while (lane !=
nullptr && lane->
isInternal()) {
1512 double totalDist = 0.;
1513 bool foundCrossing =
false;
1514 while (via !=
nullptr) {
1520 foundCrossing =
true;
1527 if (foundCrossing) {
1538 for (foe_ix = 0; foe_ix != (int)
myFoeLanes.size(); ++foe_ix) {
1545#ifdef MSLink_DEBUG_CROSSING_POINTS
1552 if (dist == -10000.) {
1556#ifdef MSLink_DEBUG_CROSSING_POINTS
1558 <<
"' at distance " << dist <<
" (approach along '"
1605 const MSLink* link =
this;
1606 while (lane !=
nullptr) {
1616 const MSLink* link =
this;
1642 std::cout <<
SIMTIME <<
" getLeaderInfo link=" <<
getDescription() <<
" dist=" << dist <<
" isShadowLink=" << isShadowLink <<
"\n";
1650 std::cout <<
" ignore linkLeaders beyond red light\n";
1658 for (
int i = 0; i < (int)
myFoeLanes.size(); ++i) {
1666 double distToCrossing = dist -
myConflicts[i].getLengthBehindCrossing(
this);
1667 const double foeDistToCrossing = foeLane->
getLength() -
myConflicts[i].getFoeLengthBehindCrossing(foeExitLink);
1670 const double crossingWidth = (sameTarget || sameSource) ? 0 :
myConflicts[i].conflictSize;
1671 const double foeCrossingWidth = (sameTarget || sameSource) ? 0 :
myConflicts[i].getFoeConflictSize(foeExitLink);
1676 std::cout <<
" distToCrossing=" << distToCrossing <<
" foeLane=" << foeLane->
getID() <<
" cWidth=" << crossingWidth
1679 <<
" lbc=" <<
myConflicts[i].getLengthBehindCrossing(
this)
1680 <<
" flbc=" <<
myConflicts[i].getFoeLengthBehindCrossing(foeExitLink)
1681 <<
" cw=" << crossingWidth
1682 <<
" fcw=" << foeCrossingWidth
1683 <<
" contLane=" << contLane
1688 if (distToCrossing + crossingWidth < 0 && !sameTarget
1691 std::cout <<
" ignore:egoBeyondCrossingPoint\n";
1695 bool ignoreGreenCont =
false;
1696 bool foeIndirect =
false;
1701 if (entry !=
nullptr && entry->
haveGreen()
1702 && foeEntry !=
nullptr && foeEntry->
haveGreen()
1705 ignoreGreenCont =
true;
1710 std::cout <<
" ignore:noIntersection\n";
1724 const double leaderBackDist = foeDistToCrossing - leaderBack;
1725 const double l2 = ego !=
nullptr ? ego->
getLength() + 2 : 0;
1727 const bool pastTheCrossingPoint = leaderBackDist + foeCrossingWidth + sagitta < 0;
1731 const bool ignoreIndirectBicycleTurn = pastTheCrossingPoint && foeIsBicycleTurn;
1732 const bool cannotIgnore = ((contLane && !ignoreIndirectBicycleTurn) || sameTarget || (sameSource && !
MSGlobals::gComputeLC)) && ego !=
nullptr;
1733 const bool inTheWay = ((((!pastTheCrossingPoint && distToCrossing > 0) || (sameTarget && distToCrossing > leaderBackDist - leader->
getLength()))
1734 && (enteredTheCrossingPoint || (sameSource && !enteredTheCrossingPoint && foeDistToCrossing < distToCrossing))
1742 std::cout <<
" candidate leader=" << leader->
getID()
1743 <<
" cannotIgnore=" << cannotIgnore
1744 <<
" fdtc=" << foeDistToCrossing
1745 <<
" lb=" << leaderBack
1746 <<
" lbd=" << leaderBackDist
1747 <<
" fcwidth=" << foeCrossingWidth
1749 <<
" sagitta=" << sagitta
1750 <<
" foePastCP=" << pastTheCrossingPoint
1751 <<
" foeEnteredCP=" << enteredTheCrossingPoint
1752 <<
" inTheWay=" << inTheWay
1753 <<
" willPass=" << willPass
1755 <<
" ignoreGreenCont=" << ignoreGreenCont
1756 <<
" foeIndirect=" << foeIndirect
1757 <<
" foeBikeTurn=" << foeIsBicycleTurn
1758 <<
" isOpposite=" << isOpposite <<
"\n";
1760 if (leader == ego) {
1764 if (!inTheWay && ignoreGreenCont) {
1766 std::cout <<
" ignoreGreenCont\n";
1772 && distToCrossing < -POSITION_EPS && !inTheWay
1775 std::cout <<
" ego entered conflict area\n";
1785 std::cout <<
" ego ahead of same-source foe\n";
1791 if ((!cannotIgnore || leader->
isStopped() || sameTarget)
1800 std::cout <<
" foe will not pass\n";
1815 && (!foeStrategicBlocked || sameInternalEdge)) {
1823 if (foeLaneIsBidi) {
1825 posLatLeader = foeLane->
getWidth() - posLatLeader;
1827 const double latGap = (fabs(posLat - posLatLeader)
1832 <<
" sameSource=" << sameSource
1833 <<
" sameTarget=" << sameTarget
1834 <<
" foeLaneIsBidi=" << foeLaneIsBidi
1835 <<
" foeLane=" << foeLane->
getID()
1836 <<
" leader=" << leader->
getID()
1839 <<
" egoLat=" << posLat
1840 <<
" egoLatOffset=" << egoLatOffset
1841 <<
" leaderLat=" << posLatLeader
1842 <<
" leaderLatOffset=" << leader->
getLatOffset(foeLane)
1843 <<
" latGap=" << latGap
1844 <<
" maneuverDist=" << maneuverDist
1857 if ((posLat > posLatLeader) == leaderFromRight) {
1860 std::cout <<
" ignored (same source) leaderFromRight=" << leaderFromRight <<
"\n";
1864 }
else if (sameTarget) {
1871 leaderFromRight = !leaderFromRight;
1874 std::cout <<
" leaderFromRight=" << leaderFromRight <<
"\n";
1876 if ((posLat > posLatLeader) == leaderFromRight
1883 std::cout <<
" ignored (different source) leaderFromRight=" << leaderFromRight <<
"\n";
1892 std::cout <<
" ignored oncoming bidi leader\n";
1902 bool fromLeft =
true;
1903 if (ego ==
nullptr) {
1906 gap = leaderBackDist;
1910 distToCrossing +=
myConflicts[i].conflictSize / 2;
1911 if (gap + foeCrossingWidth < 0) {
1918 fromLeft = foeDistToCrossing > 0.5 * foeLane->
getLength();
1919 }
else if ((contLane && !sameSource && !ignoreIndirectBicycleTurn) || isOpposite) {
1920 gap = -std::numeric_limits<double>::max();
1922 if (pastTheCrossingPoint && !sameTarget) {
1926 std::cout <<
" foePastCP ignored\n";
1930 double leaderBackDist2 = leaderBackDist;
1931 if (sameTarget && leaderBackDist2 < 0) {
1932 const double mismatch =
myConflicts[i].getFoeLengthBehindCrossing(foeExitLink) -
myConflicts[i].getLengthBehindCrossing(
this);
1934 leaderBackDist2 += mismatch;
1938 std::cout <<
" distToCrossing=" << distToCrossing <<
" leaderBack=" << leaderBack
1939 <<
" backDist=" << leaderBackDist
1940 <<
" backDist2=" << leaderBackDist2
1949 const bool stopAsap = ((leader->
isFrontOnLane(foeLane) ? cannotIgnore : (sameTarget || sameSource))
1952 std::cout <<
" leader=" << leader->
getID() <<
" contLane=" << contLane <<
" cannotIgnore=" << cannotIgnore <<
" stopAsap=" << stopAsap <<
" gap=" << gap <<
"\n";
1961 result.emplace_back(leader, gap, stopAsap ? -1 : distToCrossing, llFlags, leader->
getLatOffset(foeLane));
1978 result.emplace_back(
nullptr, -1, distToPeds);
1984 const double timeToEnterCrossing = distToCrossing /
MAX2(ego->
getSpeed(), 1.0);
1988 std::cout <<
SIMTIME <<
": " << ego->
getID() <<
" breaking for approaching person " << item.first->getID()
1992 result.emplace_back(
nullptr, -1, distToPeds);
2008 if (ego !=
nullptr) {
2016 const MSLane* foeLane = *it;
2020 if (leader == ego) {
2037 <<
" foeLane=" << foeLane->
getID()
2038 <<
" leader=" << leader->
getID()
2042 <<
" egoLat=" << posLat
2043 <<
" leaderLat=" << posLatLeader
2044 <<
" leaderLatOffset=" << leader->
getLatOffset(foeLane)
2046 <<
" foeIndex=" << foeLane->
getIndex()
2052 if ((posLat < posLatLeader && myInternalLaneBefore->
getIndex() > foeLane->
getIndex())
2055 std::cout <<
SIMTIME <<
" blocked by " << leader->
getID() <<
" (sublane split) foeLane=" << foeLane->
getID() <<
"\n";
2076 double distToPeds = std::numeric_limits<double>::max();
2089#ifdef DEBUG_WALKINGAREA
2095 <<
" inFront=" << inFront
2096 <<
" dist=" << dist <<
"\n";
2099 if (dist < ego->getVehicleType().getWidth() / 2 || inFront) {
2102 if (oncomingFactor > 0) {
2104 const double timeToStop = sqrt(dist) / 2;
2105 const double pedDist = p->
getMaxSpeed() *
MAX2(timeToStop,
TS) * oncomingFactor;
2106 dist =
MAX2(0.0, dist - pedDist);
2107#ifdef DEBUG_WALKINGAREA
2109 std::cout <<
" timeToStop=" << timeToStop <<
" pedDist=" << pedDist <<
" factor=" << oncomingFactor <<
" dist2=" << dist <<
"\n";
2117 distToPeds =
MIN2(distToPeds, dist);
2118 if (collectBlockers !=
nullptr) {
2119 collectBlockers->push_back(p);
2123 if (distToPeds != std::numeric_limits<double>::max()) {
2125 result.emplace_back(
nullptr, -1, distToPeds);
2134#ifdef DEBUG_WALKINGAREA
2136 std::cout <<
" angleDiff=" <<
RAD2DEG(angleDiff) <<
"\n";
2139 if (angleDiff <
DEG2RAD(75)) {
2150#ifdef DEBUG_WALKINGAREA
2152 std::cout <<
" ped-angleDiff=" <<
RAD2DEG(angleDiff) <<
" res=" << cos(angleDiff) <<
"\n";
2155 if (angleDiff <=
DEG2RAD(90)) {
2157 return cos(angleDiff);
2167 const double dist = timeHorizon * p->
getMaxSpeed();
2169 const Position offset(cos(a) * dist, sin(a) * dist);
2176 if (direction == -1) {
2178 }
else if (direction == 1) {
2203 if (before !=
nullptr && after !=
nullptr) {
2205 if (link->getLane() == after) {
2228 <<
" dist=" << dist <<
" bGap=" << brakeGap <<
" ignoring foes (arrival in " <<
STEPS2TIME(arrivalTime - now) <<
")\n")
2234 <<
" egoAT=" << arrivalTime
2236 <<
" brakeGap=" << brakeGap
2237 <<
" vSafe=" << vSafe
2238 <<
" numFoes=" << foes->size()
2241 const bool uniqueFoeLink =
myFoeLinks.size() == 1;
2243 for (
const auto& item : *foes) {
2244 if (!item->isVehicle()) {
2250 if (uniqueFoeLink) {
2255 aviPtr = fl->getApproachingPtr(foe);
2256 if (aviPtr !=
nullptr) {
2261 if (aviPtr ==
nullptr) {
2276 <<
" ignoring foe=" << foe->
getID()
2278 <<
" foeDist=" << avi.
dist
2279 <<
" foeDist2=" << foeDist
2280 <<
" foeSpeed=" << avi.
speed
2282 <<
" deltaDist=" << foeDist - dist
2305 const double uEnd =
MIN2(uMax, uAccel);
2306 const double uAvg = (avi.
speed + uEnd) / 2;
2307 const double tf0 = foeDist /
MAX2(NUMERICAL_EPS, uAvg);
2308 const double tf =
MAX2(1.0, ceil((tf0) /
TS) *
TS);
2313 const double vEnd =
MIN3(vMax, vAccel,
MAX2(uEnd, vDecel));
2314 const double vAvg = (ego->
getSpeed() + vEnd) / 2;
2315 const double te0 = dist /
MAX2(NUMERICAL_EPS, vAvg);
2316 const double te =
MAX2(1.0, ceil((te0) /
TS) *
TS);
2327 const double w =
MIN2(1.0, te / 10);
2331 vSafe =
MIN2(vSafe, vZipper);
2334 <<
" foeDist=" << foeDist
2335 <<
" foeSpeed=" << avi.
speed
2339 <<
" uAccel=" << uAccel
2346 <<
" aSafeGap=" << a
2348 <<
" vAccel=" << vAccel
2349 <<
" vDecel=" << vDecel
2351 <<
" vSafeGap=" << vSafeGap
2352 <<
" vFollow=" << vFollow
2354 <<
" maxDecel=" << maxDecel
2355 <<
" vZipper=" << vZipper
2356 <<
" vSafe=" << vSafe
2367 followDist > leaderDist &&
2385 for (
const MSLink* link : cand->getLinkCont()) {
2396 return fabs(posLat2 - posLat) < (width + width2) / 2;
2417 if (
id == foe->
getID()) {
2431std::pair<const SUMOVehicle* const, const MSLink::ApproachingVehicleInformation>
2434 double minDist = std::numeric_limits<double>::max();
2437 if (apprIt->second.dist < minDist) {
2438 minDist = apprIt->second.dist;
2463 if (item.second.dist <
SPEED2DIST(item.first->getSpeed())) {
#define JM_CROSSING_GAP_DEFAULT
#define DIVERGENCE_MIN_WIDTH
#define DEBUG_COND_ZIPPER
#define WRITE_WARNINGF(...)
#define WRITE_WARNING(msg)
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
constexpr SUMOTime TIME2STEPS(double x)
const SVCPermissions SVCAll
all VClasses are allowed
@ SVC_BICYCLE
vehicle is a bicycle
const long long 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_STOPLINE_CROSSING_GAP
@ SUMO_ATTR_JM_STOPSIGN_WAIT
@ SUMO_ATTR_JM_IGNORE_IDS
@ SUMO_ATTR_JM_IGNORE_TYPES
@ SUMO_ATTR_JM_ALLWAYSTOP_WAIT
@ 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
#define DEBUGOUT(cond, msg)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static const double INVALID_OFFSET
a value to signify offsets outside the range of [0, Line.length()]
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)
MSLane * getShadowLane() const
Returns the lane the vehicle's shadow is on during continuous/sublane lane change.
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 physically possible deceleration [m/s^2].
static double avoidArrivalAccel(double dist, double time, double speed, double maxDecel)
Computes the acceleration needed to arrive not before the given time.
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)
virtual double getHeadwayTime() const
Get the driver's desired headway [s].
A road/street connecting two junctions.
int getPriority() const
Returns the priority of the edge.
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 * getToJunction() const
const MSJunction * getFromJunction() const
bool isRoundabout() 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 int gNumSimThreads
how many threads to use for simulation
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.
SumoXMLNodeType getType() const
return the type of this Junction
AnyVehicleIterator is a structure, which manages the iteration through all vehicles on the lane,...
Representation of a lane in the micro simulation.
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
int getVehicleNumber() const
Returns the number of vehicles on this lane (for which this lane is responsible)
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
std::vector< MSVehicle * > VehCont
Container for vehicles.
SVCPermissions getPermissions() const
Returns the vehicle class permissions for this lane.
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
MSLane * getCanonicalPredecessorLane() const
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.
MSLane * getLogicalPredecessorLane() const
get the most likely predecessor lane (sorted using by_connections_to_sorter). The result is cached in...
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
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
MSLane * getBidiLane() const
retrieve bidirectional lane or nullptr
virtual const PositionVector & getShape(bool) const
MSEdge & getEdge() const
Returns the lane's edge.
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.
const std::vector< MSLink * > & getLinkCont() const
returns the container with all links !!!
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 getLengthBeforeCrossing(const MSLane *foeLane) const
Returns the internal length from the beginning of the link's internal lane before to the crossing wit...
const MSLane * getInternalLaneBefore() const
return myInternalLaneBefore (always 0 when compiled without internal lanes)
LinkState getState() const
Returns the current state of the link.
void setApproachingPerson(const MSPerson *approaching, const SUMOTime arrivalTime, const SUMOTime leaveTime)
Sets the information about an approaching person (only for a pedestrian crossing)
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.
double myDistToFoePedCrossing
distance from the stop line to the first pedestrian crossing or maxdouble
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.
const ApproachInfos & getApproaching() const
return all approaching vehicles
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
void removeApproachingPerson(const MSPerson *person)
removes the person from myApproachingPersons
const ApproachingVehicleInformation * getApproachingPtr(const SUMOVehicle *veh) const
MSLane * getLane() const
Returns the connected lane.
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, double dist=-1) const
Returns the information whether the link may be passed.
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)
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
void updateApproaching(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)
like setApproaching but overwrites an existing entry in place (no erase and insert)
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)
std::map< const MSPerson *, ApproachingPersonInformation > PersonApproachInfos
bool isEntryLink() const
return whether the toLane of this link is an internal lane and fromLane is a normal lane
const MSLane * getLaneBefore() const
return the internalLaneBefore if it exists and the laneBefore otherwise
ApproachingVehicleInformation getApproaching(const SUMOVehicle *veh) const
const MSTrafficLightLogic * myLogic
the controlling logic or 0
@ CONFLICT_NO_INTERSECTION
@ CONFLICT_SIBLING_CONTINUATION
@ 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
bool isInternalJunctionLink() const
return whether the fromLane and the toLane of this link are internal lanes
double computeDistToDivergence(const MSLane *lane, const MSLane *sibling, double minDist, bool sameSource, double siblingPredLength=0) const
compute point of divergence for geomatries with a common start or end
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.
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
MSLane * getViaLane() const
Returns the following inner lane.
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.
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, double dist=-1) const
Returns the information whether this link is blocked Valid after the vehicles have set their requests...
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]
std::pair< const SUMOVehicle *const, const ApproachingVehicleInformation > getClosest() const
get the closest vehicle approaching this link
void updateDistToFoePedCrossing(double dist)
add information about another pedestrian crossing
MSJunction * myJunction
the junction to which this link belongs
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
bool railSignalWasPassed() const
whether this link is for a railsignal that was passed in this step
MSLink * getParallelLink(int direction) const
return the link that is parallel to this link or 0
MSLane * getViaLaneOrLane() const
return the via lane if it exists and the lane otherwise
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.
std::vector< const SUMOTrafficObject * > BlockingFoes
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)
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
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.
PersonApproachInfos * myApproachingPersons
LinkDirection myDirection
An abstract (hopefully human readable) definition of the link's direction.
const MSTrafficLightLogic * getTLLogic() const
Returns the TLS index.
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
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.
void setTLLogic(const MSTrafficLightLogic *logic)
Sets the currently active tlLogic.
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 vehCenter, 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.
Position getPosition(const double) const override
Return current position (x/y, cartesian)
double getMaxSpeed() const override
Returns the maximum speed (the minimum of desired and physical maximum speed)
const MSVehicleType & getVehicleType() const override
Returns the object's "vehicle" type.
virtual double getAngle() const override
return the current angle of the transportable
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.
const MSLane * getLane() const
Returns the lane the vehicle is on.
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.
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
bool ignoreRed(const MSLink *link, bool canBrake) const
decide whether a red (or yellow light) may be ignored
double getPositionOnLane() const
Get the vehicle's position along the lane.
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.
const std::string & getID() const
Returns the name of the vehicle type.
double getMinGap() const
Get the free space in front of vehicles of this class.
double getMaxSpeedLat() const
Get vehicle's maximum lateral speed [m/s].
const MSCFModel & getCarFollowModel() const
Returns the vehicle type's car following model definition (const version)
double getLength() const
Get vehicle's length [m].
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 ATTR_TYPE &attr, const T &val, const bool isNull=false, const bool escape=false)
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)
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
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 const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
virtual double getSpeed() const =0
Returns the object's current speed.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
virtual SumoRNG * getRNG() const =0
Returns the associated RNG for this object.
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.
virtual SUMOTime getLastActionTime() const =0
virtual double getBrakeGap(bool delayed=false) const =0
get distance for coming to a stop (used for rerouting checks)
Structure representing possible vehicle parameter.
bool wasSet(long long int what) const
Returns whether the given parameter was set.
A scoped lock which only triggers on condition.
std::vector< std::string > getVector()
return vector of strings
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
double lengthBehindCrossing
length of internal lane after the crossing point
holds user defined conflict positions (must be interpreted for the correct exitLink)