51 #define DEBUG_COND2(obj) (obj->getID() == "train2")
54 #define DEBUG_COND_ZIPPER (ego->isSelected())
66 #define ZIPPER_ADAPT_TIME 10
68 #define JM_CROSSING_GAP_DEFAULT 10
71 #define DIVERGENCE_MIN_WIDTH 2.5
78 myLaneBefore(predLane),
87 myFoeVisibilityDistance(foeVisibilityDistance),
91 myKeepClear(keepClear),
93 myInternalLaneBefore(nullptr),
97 myWalkingAreaFoe(nullptr),
98 myWalkingAreaFoeExit(nullptr),
99 myHavePedestrianCrossingFoe(false),
100 myParallelRight(nullptr),
101 myParallelLeft(nullptr),
102 myJunction(nullptr) {
111 const double dist = from.back().distanceTo2D(to.front());
117 myLateralShift = (from.back().distanceTo2D(to.front()) < dist) ? dist : -dist;
132 const std::vector<MSLink*>& foeLinks,
133 const std::vector<MSLane*>& foeLanes,
134 MSLane* internalLaneBefore) {
144 for (std::vector<MSLane*>::const_iterator it_lane = foeLanes.begin(); it_lane != foeLanes.end(); ++it_lane) {
152 if (internalLaneBefore !=
nullptr) {
154 lane = internalLaneBefore;
160 #ifdef MSLink_DEBUG_CROSSING_POINTS
163 if (lane !=
nullptr) {
164 const bool beforeInternalJunction = lane->
getLinkCont()[0]->getViaLaneOrLane()->getEdge().isInternal();
169 for (std::vector<const MSLane*>::const_iterator it_lane =
myFoeLanes.begin(); it_lane !=
myFoeLanes.end(); ++it_lane) {
172 if (sameTarget && !beforeInternalJunction && !
contIntersect(lane, *it_lane)) {
175 const MSLane* sibling = *it_lane;
177 if (lane->
getShape().back().distanceTo2D(sibling->
getShape().back()) >= minDist) {
185 #ifdef MSLink_DEBUG_CROSSING_POINTS
187 <<
" " << lane->
getID()
188 <<
" merges with " << (*it_lane)->getID()
189 <<
" nextLane " << lane->
getLinkCont()[0]->getViaLaneOrLane()->getID()
197 #ifdef MSLink_DEBUG_CROSSING_POINTS_DETAILS
198 std::cout <<
" intersections1=" <<
toString(intersections1) <<
"\n";
200 bool haveIntersection =
true;
201 if (intersections1.size() == 0) {
202 intersections1.push_back(-10000.0);
203 haveIntersection =
false;
204 }
else if (intersections1.size() > 1) {
205 std::sort(intersections1.begin(), intersections1.end());
207 std::vector<double> intersections2 = (*it_lane)->getShape().intersectsAtLengths2D(lane->
getShape());
208 #ifdef MSLink_DEBUG_CROSSING_POINTS_DETAILS
209 std::cout <<
" intersections2=" <<
toString(intersections2) <<
"\n";
211 if (intersections2.size() == 0) {
212 intersections2.push_back(0);
213 }
else if (intersections2.size() > 1) {
214 std::sort(intersections2.begin(), intersections2.end());
216 if (haveIntersection) {
218 intersections1.back() -= (*it_lane)->getWidth() / 2;
219 intersections2.back() -= lane->
getWidth() / 2;
221 intersections1.back() =
MAX2(0.0, intersections1.back());
222 intersections2.back() =
MAX2(0.0, intersections2.back());
226 intersections2.back() = (*it_lane)->interpolateGeometryPosToLanePos(intersections2.back());
231 intersections1.back() = 0;
236 lane->
getLength() - intersections1.back(),
237 (*it_lane)->getLength() - intersections2.back()));
239 #ifdef MSLink_DEBUG_CROSSING_POINTS
241 <<
" intersection of " << lane->
getID()
243 <<
" with " << (*it_lane)->getID()
244 <<
" totalLength=" << (*it_lane)->getLength()
256 const MSLane* sibling = it->getViaLane();
257 if (sibling != lane && sibling !=
nullptr) {
259 if (lane->
getShape().front().distanceTo2D(sibling->
getShape().front()) >= minDist) {
268 #ifdef MSLink_DEBUG_CROSSING_POINTS
269 std::cout <<
" adding same-origin foe" << sibling->
getID()
282 const MSEdge* target = &(it->getLane()->getEdge());
286 if (target == myTarget) {
288 #ifdef MSLink_DEBUG_CROSSING_POINTS
289 std::cout <<
" sublaneFoeLink (same target): " << it->getViaLaneOrLane()->getID() <<
"\n";
294 #ifdef MSLink_DEBUG_CROSSING_POINTS
295 std::cout <<
" sublaneFoeLink2 (other target: " << it->getViaLaneOrLane()->getID() <<
"\n";
322 double lbcSibling = 0;
325 if (l.back().distanceTo2D(s.back()) > minDist) {
332 std::vector<double> distances = l.
distances(s);
333 #ifdef MSLink_DEBUG_CROSSING_POINTS
334 std::cout <<
" distances=" <<
toString(distances) <<
"\n";
336 assert(distances.size() == l.size() + s.size());
337 if (distances.back() > minDist && distances[l.size() - 1] > minDist) {
339 for (
int j = (
int)s.size() - 2; j >= 0; j--) {
340 const int i = j + (int)l.size();
341 const double segLength = s[j].distanceTo2D(s[j + 1]);
342 if (distances[i] > minDist) {
343 lbcSibling += segLength;
346 lbcSibling += segLength - (minDist - distances[i]) * segLength / (distances[i + 1] - distances[i]);
350 for (
int i = (
int)l.size() - 2; i >= 0; i--) {
351 const double segLength = l[i].distanceTo2D(l[i + 1]);
352 if (distances[i] > minDist) {
353 lbcLane += segLength;
356 lbcLane += segLength - (minDist - distances[i]) * segLength / (distances[i + 1] - distances[i]);
361 assert(lbcSibling >= -NUMERICAL_EPS);
362 assert(lbcLane >= -NUMERICAL_EPS);
364 const double distToDivergence1 = sibling->
getLength() - lbcSibling;
365 const double distToDivergence2 = lane->
getLength() - lbcLane;
366 const double distToDivergence =
MIN3(
367 MAX2(distToDivergence1, distToDivergence2),
369 #ifdef MSLink_DEBUG_CROSSING_POINTS
370 std::cout <<
" distToDivergence=" << distToDivergence
371 <<
" distTD1=" << distToDivergence1
372 <<
" distTD2=" << distToDivergence2
377 return distToDivergence;
383 if (foe->
getLinkCont()[0]->getViaLane() !=
nullptr) {
385 return intersections.size() > 0;
393 const bool setRequest,
const SUMOTime arrivalTimeBraking,
const double arrivalSpeedBraking,
const SUMOTime waitingTime,
double dist) {
395 #ifdef DEBUG_APPROACHING
399 std::cout <<
"'" << i->first->getID() <<
"'" << std::endl;
405 arrivalTimeBraking, arrivalSpeedBraking, waitingTime, dist, approaching->
getSpeed()));
412 #ifdef DEBUG_APPROACHING
416 std::cout <<
"'" << i->first->getID() <<
"'" << std::endl;
434 if ((*i)->isBlockingAnyone()) {
445 #ifdef DEBUG_APPROACHING
448 std::cout <<
"' Removing approaching vehicle '" << veh->
getID() <<
"'\nCurrently registered vehicles:" << std::endl;
450 std::cout <<
"'" << i->first->getID() <<
"'" << std::endl;
475 const double leaveSpeed,
const double vehicleLength)
const {
476 return arrivalTime +
TIME2STEPS((
getLength() + vehicleLength) /
MAX2(0.5 * (arrivalSpeed + leaveSpeed), NUMERICAL_EPS));
482 double impatience,
double decel,
SUMOTime waitingTime,
double posLat,
494 assert(
myLane != foeLink->getLane());
495 for (
const auto& it : foeLink->myApproachingVehicles) {
499 ((posLat < foe->getLateralPositionOnLane() &&
myLane->
getIndex() > foeLink->myLane->getIndex())
502 && (arrivalTime > it.second.arrivalTime
506 if (
blockedByFoe(foe, it.second, arrivalTime, leaveTime, arrivalSpeed, leaveSpeed,
false,
507 impatience, decel, waitingTime, ego)) {
508 #ifdef MSLink_DEBUG_OPENED
510 std::cout <<
SIMTIME <<
" blocked by " << foe->
getID() <<
" arrival=" << arrivalTime <<
" foeArrival=" << it.second.arrivalTime <<
"\n";
513 if (collectFoes ==
nullptr) {
514 #ifdef MSLink_DEBUG_OPENED
516 std::cout <<
" link=" <<
getViaLaneOrLane()->
getID() <<
" blocked by sublaneFoe=" << foe->
getID() <<
" foeLink=" << foeLink->getViaLaneOrLane()->getID() <<
" posLat=" << posLat <<
"\n";
521 collectFoes->push_back(it.first);
532 for (
const auto& it : foeLink->myApproachingVehicles) {
538 && (posLat * lhSign < foe->getLateralPositionOnLane() * lhSign))) {
539 if (
blockedByFoe(foe, it.second, arrivalTime, leaveTime, arrivalSpeed, leaveSpeed,
false,
540 impatience, decel, waitingTime, ego)) {
541 #ifdef MSLink_DEBUG_OPENED
543 std::cout <<
SIMTIME <<
" blocked by sublane foe " << foe->
getID() <<
" arrival=" << arrivalTime <<
" foeArrival=" << it.second.arrivalTime <<
"\n";
546 if (collectFoes ==
nullptr) {
549 collectFoes->push_back(it.first);
560 return collectFoes ==
nullptr || collectFoes->size() == 0;
566 #ifdef MSLink_DEBUG_OPENED
577 if (link->haveRed()) {
581 #ifdef MSLink_DEBUG_OPENED
583 std::cout <<
" foeLink=" << link->getViaLaneOrLane()->getID() <<
" numApproaching=" << link->getApproaching().size() <<
"\n";
586 if (link->blockedAtTime(arrivalTime, leaveTime, arrivalSpeed, leaveSpeed,
myLane == link->getLane(),
587 impatience, decel, waitingTime, collectFoes, ego)) {
591 if (collectFoes !=
nullptr && collectFoes->size() > 0) {
600 bool sameTargetLane,
double impatience,
double decel,
SUMOTime waitingTime,
603 #ifdef MSLink_DEBUG_OPENED
608 std::stringstream stream;
610 <<
" foeVeh=" << it.first->getID() <<
" (below ignore speed)"
613 std::cout << stream.str();
622 &&
blockedByFoe(it.first, it.second, arrivalTime, leaveTime, arrivalSpeed, leaveSpeed, sameTargetLane,
623 impatience, decel, waitingTime, ego)) {
624 if (collectFoes ==
nullptr) {
627 collectFoes->push_back(it.first);
637 SUMOTime arrivalTime,
SUMOTime leaveTime,
double arrivalSpeed,
double leaveSpeed,
638 bool sameTargetLane,
double impatience,
double decel,
SUMOTime waitingTime,
640 #ifdef MSLink_DEBUG_OPENED
642 std::stringstream stream;
644 <<
" foeVeh=" << veh->
getID()
649 std::cout << stream.str();
656 assert(waitingTime > 0);
671 #ifdef MSLink_DEBUG_OPENED
673 std::stringstream stream;
674 stream <<
" imp=" << impatience <<
" fATb=" << avi.
arrivalTimeBraking <<
" fAT2=" << foeArrivalTime <<
" lA=" << lookAhead <<
" egoAT=" << arrivalTime <<
" egoLT=" << leaveTime <<
"\n";
675 std::cout << stream.str();
680 if (sameTargetLane && (arrivalTime - avi.
leavingTime < lookAhead
683 #ifdef MSLink_DEBUG_OPENED
685 std::cout <<
" blocked (cannot follow)\n";
690 }
else if (foeArrivalTime > leaveTime + lookAhead) {
694 #ifdef MSLink_DEBUG_OPENED
696 std::cout <<
" blocked (cannot lead)\n";
703 #ifdef MSLink_DEBUG_OPENED
705 std::cout <<
" blocked (hard conflict)\n";
717 if (link->blockedAtTime(arrivalTime, leaveTime, speed, speed,
myLane == link->getLane(), 0, decel, 0)) {
722 if (lane->getVehicleNumberWithPartials() > 0) {
730 std::pair<const SUMOVehicle*, const MSLink*>
732 double closetDist = std::numeric_limits<double>::max();
734 const MSLink* foeLink =
nullptr;
736 for (
const auto& it : link->myApproachingVehicles) {
739 return std::make_pair(
nullptr, wrapAround);
740 }
else if (it.second.dist < closetDist) {
741 closetDist = it.second.dist;
742 if (it.second.willPass) {
749 return std::make_pair(closest, foeLink);
779 assert(pred2 !=
nullptr);
781 assert(predLink !=
nullptr);
798 assert(pred2 !=
nullptr);
800 assert(predLink !=
nullptr);
815 std::vector<std::pair<SUMOTime, const SUMOVehicle*> > toSort;
817 toSort.push_back(std::make_pair(it.second.arrivalTime, it.first));
819 std::sort(toSort.begin(), toSort.end());
820 for (std::vector<std::pair<SUMOTime, const SUMOVehicle*> >::const_iterator it = toSort.begin(); it != toSort.end(); ++it) {
844 while (lane !=
nullptr && lane->
isInternal()) {
856 while (lane !=
nullptr && lane->
isInternal()) {
871 double totalDist = 0.;
872 bool foundCrossing =
false;
873 while (via !=
nullptr) {
879 foundCrossing =
true;
897 for (foe_ix = 0; foe_ix != (int)
myFoeLanes.size(); ++foe_ix) {
904 #ifdef MSLink_DEBUG_CROSSING_POINTS
911 if (dist == -10000.) {
915 #ifdef MSLink_DEBUG_CROSSING_POINTS
917 <<
"' at distance " << dist <<
" (approach along '"
964 const MSLink* link =
nullptr;
965 while (lane !=
nullptr) {
975 const MSLink* link =
this;
1001 std::cout <<
SIMTIME <<
" getLeaderInfo link=" <<
getViaLaneOrLane()->
getID() <<
" dist=" << dist <<
" isShadowLink=" << isShadowLink <<
"\n";
1004 for (
int i = 0; i < (int)
myFoeLanes.size(); ++i) {
1011 const double crossingWidth = (sameTarget || sameSource) ? 0 : foeLane->
getWidth();
1017 std::cout <<
" distToCrossing=" << distToCrossing <<
" foeLane=" << foeLane->
getID() <<
" cWidth=" << crossingWidth
1021 <<
" contLane=" << contLane
1026 if (distToCrossing + crossingWidth < 0 && !sameTarget
1030 bool ignoreGreenCont =
false;
1034 if (entry !=
nullptr && entry->
haveGreen()
1035 && foeEntry !=
nullptr && foeEntry->
haveGreen()
1038 ignoreGreenCont =
true;
1052 const double leaderBackDist = foeDistToCrossing - leaderBack;
1053 const bool pastTheCrossingPoint = leaderBackDist + foeCrossingWidth < 0;
1056 const bool ignoreIndirectBicycleTurn = pastTheCrossingPoint && foeIsBicycleTurn;
1057 const bool cannotIgnore = ((contLane && !ignoreIndirectBicycleTurn) || sameTarget || sameSource) && ego !=
nullptr;
1058 const bool inTheWay = (((!pastTheCrossingPoint && distToCrossing > 0) || (sameTarget && distToCrossing > leaderBackDist - leader->
getLength()))
1063 std::cout <<
" candidate leader=" << leader->
getID()
1064 <<
" cannotIgnore=" << cannotIgnore
1065 <<
" fdtc=" << foeDistToCrossing
1066 <<
" lb=" << leaderBack
1067 <<
" lbd=" << leaderBackDist
1068 <<
" fcwidth=" << foeCrossingWidth
1069 <<
" foePastCP=" << pastTheCrossingPoint
1070 <<
" inTheWay=" << inTheWay
1073 <<
" ignoreGreenCont=" << ignoreGreenCont
1074 <<
" isOpposite=" << isOpposite <<
"\n";
1076 if (leader == ego) {
1080 if (ignoreGreenCont && !inTheWay) {
1084 if (distToCrossing < -POSITION_EPS && !inTheWay
1085 && (ego ==
nullptr || !
MSGlobals::gComputeLC || distToCrossing < -ego->getVehicleType().getLength())) {
1089 if ((!cannotIgnore || leader->
isStopped() || sameTarget)
1103 const double latGap = (fabs(posLat - posLatLeader)
1107 <<
" sameSource=" << sameSource
1108 <<
" sameTarget=" << sameTarget
1109 <<
" foeLane=" << foeLane->
getID()
1110 <<
" leader=" << leader->
getID()
1113 <<
" egoLat=" << posLat
1114 <<
" leaderLat=" << posLatLeader
1115 <<
" leaderLatOffset=" << leader->
getLatOffset(foeLane)
1116 <<
" latGap=" << latGap
1125 if ((posLat > posLatLeader) == leaderFromRight) {
1136 leaderFromRight = !leaderFromRight;
1138 if ((posLat > posLatLeader) == leaderFromRight
1156 bool fromLeft =
true;
1157 if (ego ==
nullptr) {
1160 gap = leaderBackDist;
1164 distToCrossing += foeLane->
getWidth() / 2;
1165 if (gap + foeCrossingWidth < 0) {
1172 fromLeft = foeDistToCrossing > 0.5 * foeLane->
getLength();
1173 }
else if ((contLane && !sameSource && !ignoreIndirectBicycleTurn) || isOpposite) {
1174 gap = -std::numeric_limits<double>::max();
1177 std::cout <<
" distToCrossing=" << distToCrossing <<
" leader back=" << leaderBack <<
" backDist=" << leaderBackDist
1182 if (leaderBackDist + foeCrossingWidth < 0 && !sameTarget) {
1191 gap = -std::numeric_limits<double>::max();
1197 const bool stopAsap = leader->
isFrontOnLane(foeLane) ? cannotIgnore : (sameTarget || sameSource);
1199 std::cout <<
" leader=" << leader->
getID() <<
" contLane=" << contLane <<
" cannotIgnore=" << cannotIgnore <<
" stopAsap=" << stopAsap <<
"\n";
1201 result.emplace_back(leader, gap, stopAsap ? -1 : distToCrossing, fromLeft, inTheWay);
1212 const double vehSideOffset = (foeDistToCrossing +
myLaneBefore->
getWidth() * 0.5 - vehWidth * 0.5
1218 result.emplace_back(
nullptr, -1, distToPeds);
1224 if (ego !=
nullptr) {
1232 const MSLane* foeLane = *it;
1236 if (leader == ego) {
1250 <<
" foeLane=" << foeLane->
getID()
1251 <<
" leader=" << leader->
getID()
1254 <<
" egoLat=" << posLat
1255 <<
" leaderLat=" << posLatLeader
1256 <<
" leaderLatOffset=" << leader->
getLatOffset(foeLane)
1258 <<
" foeIndex=" << foeLane->
getIndex()
1264 if ((posLat < posLatLeader && myInternalLaneBefore->
getIndex() > foeLane->
getIndex())
1267 std::cout <<
SIMTIME <<
" blocked by " << leader->
getID() <<
" (sublane split) foeLane=" << foeLane->
getID() <<
"\n";
1269 result.emplace_back(leader, gap, -1);
1285 double distToPeds = std::numeric_limits<double>::max();
1291 if (collectBlockers !=
nullptr) {
1292 collectBlockers->push_back(p);
1296 if (distToPeds != std::numeric_limits<double>::max()) {
1297 result.emplace_back(
nullptr, -1, distToPeds);
1305 if (direction == -1) {
1307 }
else if (direction == 1) {
1320 if (before !=
nullptr && after !=
nullptr) {
1322 if (link->getLane() == after) {
1340 throw ProcessError(
"Zipper junctions with more than two conflicting lanes are not supported (at junction '"
1344 const double secondsToArrival =
STEPS2TIME(arrivalTime - now);
1348 <<
" dist=" << dist <<
" ignoring foes (arrival in " <<
STEPS2TIME(arrivalTime - now) <<
")\n")
1354 <<
" egoAT=" << arrivalTime
1356 <<
" vSafe=" << vSafe
1357 <<
" numFoes=" << collectFoes->size()
1361 for (
const auto& item : *collectFoes) {
1376 <<
" ignoring foe=" << foe->
getID()
1378 <<
" foeDist=" << avi.
dist
1379 <<
" foeDist2=" << foeDist
1380 <<
" foeSpeed=" << avi.
speed
1382 <<
" deltaDist=" << foeDist - dist
1405 const double uEnd =
MIN2(uMax, uAccel);
1406 const double uAvg = (avi.
speed + uEnd) / 2;
1407 const double tf0 = foeDist /
MAX2(NUMERICAL_EPS, uAvg);
1408 const double tf =
MAX2(1.0, ceil((tf0) /
TS) *
TS);
1412 const double vEnd =
MIN3(vMax, vAccel, uEnd);
1413 const double vAvg = (ego->
getSpeed() + vEnd) / 2;
1414 const double te0 = dist /
MAX2(NUMERICAL_EPS, vAvg);
1415 const double te =
MAX2(1.0, ceil((te0) /
TS) *
TS);
1422 const double deltaGap = gap + tf * uAvg - safeGap - vAvg * tf;
1423 const double a = 2 * deltaGap / (tf * tf);
1429 const double w =
MIN2(1.0, te / 10);
1431 const double vZipper =
MAX3(vFollow, ego->
getSpeed() -
ACCEL2SPEED(maxDecel), w * vSafeGap + (1 - w) * vFollow);
1433 vSafe =
MIN2(vSafe, vZipper);
1436 <<
" foeDist=" << foeDist
1437 <<
" foeSpeed=" << avi.
speed
1441 <<
" uAccel=" << uAccel
1445 <<
" safeGap=" << safeGap
1449 <<
" dg=" << deltaGap
1450 <<
" aSafeGap=" << a
1452 <<
" vAccel=" << vAccel
1454 <<
" vSafeGap=" << vSafeGap
1455 <<
" vFollow=" << vFollow
1457 <<
" maxDecel=" << maxDecel
1458 <<
" vZipper=" << vZipper
1459 <<
" vSafe=" << vSafe
1470 followDist > leaderDist &&
1488 for (
const MSLink* link : cand->getLinkCont()) {
#define JM_CROSSING_GAP_DEFAULT
#define DIVERGENCE_MIN_WIDTH
#define ZIPPER_ADAPT_TIME
#define DEBUG_COND_ZIPPER
std::string time2string(SUMOTime t)
convert SUMOTime to string
@ SVC_BICYCLE
vehicle is a bicycle
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_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_FOE_PROB
@ SUMO_ATTR_JM_CROSSING_GAP
@ SUMO_ATTR_JM_TIMEGAP_MINOR
bool gDebugFlag1
global utility flags for debugging
const double INVALID_DOUBLE
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
bool isStrategicBlocked() const
double getSpeedLat() const
return the lateral speed of the current lane change maneuver
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
virtual double getSecureGap(const MSVehicle *const, 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 getEmergencyDecel() const
Get the vehicle type's maximal phisically possible 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 =0
Computes the vehicle's follow speed (no dawdling)
double getMaxAccel() const
Get the vehicle type's maximum acceleration [m/s^2].
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
A road/street connecting two junctions.
const std::set< MSTransportable * > & getPersons() const
Returns this edge's persons set.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
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 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.
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.
const PositionVector & getShape() const
Returns this lane's shape.
double interpolateGeometryPosToLanePos(double geometryPos) const
AnyVehicleIterator anyVehiclesBegin() const
begin iterator for iterating over all vehicles touching this lane in downstream direction
double getWidth() const
Returns the lane's width.
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
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.
std::vector< std::pair< double, double > > myLengthsBehindCrossing
std::vector< MSLink * > mySublaneFoeLinks
static const SUMOTime myLookaheadTime
ApproachInfos myApproachingVehicles
MSLink * computeParallelLink(int direction)
int myIndex
The position within this respond.
bool myHasFoes
Whether any foe links exist.
MSLane * getViaLane() const
Returns the following inner lane.
const MSLane * myInternalLaneBefore
LinkState myState
The state of the link.
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
bool isConflictEntryLink() const
return whether this link enters the conflict area (not a continuation link)
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.
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) const
Returns the information whether this link is blocked Valid after the vehicles have set their requests...
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
double getZipperSpeed(const MSVehicle *ego, const double dist, double vSafe, SUMOTime arrivalTime, BlockingFoes *collectFoes) const
return the speed at which ego vehicle must approach the zipper link
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.
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
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
void clearState()
Remove all approaching vehicles before quick-loading state.
bool willHaveBlockedFoe() const
MSLane * myLane
The lane behind the junction approached by this link.
bool lastWasContMajorGreen() const
whether this is a link past an internal junction which currently has green major
double getInternalLengthsAfter() const
Returns the cumulative length of all internal lanes after this link.
std::string getDescription() const
get string description for this link
bool hasFoes() const
Returns whether this link belongs to a junction where more than one edge is incoming.
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...
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
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
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
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.
MSLink(MSLane *predLane, MSLane *succLane, MSLane *via, LinkDirection dir, LinkState state, double length, double foeVisibilityDistance, bool keepClear, MSTrafficLightLogic *logic, int tlLinkIdx)
Constructor for simulation which uses internal lanes.
void setApproaching(const SUMOVehicle *approaching, const SUMOTime arrivalTime, const double arrivalSpeed, const double leaveSpeed, const bool setRequest, const SUMOTime arrivalTimeBraking, const double arrivalSpeedBraking, const SUMOTime waitingTime, double dist)
Sets the information about an approaching vehicle.
const MSLane * myWalkingAreaFoeExit
walkingArea that must be checked when leaving the intersection
MSLane * myLaneBefore
The lane approaching 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.
static const double ZIPPER_ADAPT_DIST
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
std::vector< MSLane * > mySublaneFoeLanes
LinkDirection getDirection() const
Returns the direction the vehicle passing this link take.
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 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 getSpeed() const
the current speed of the transportable
const MSVehicleType & getVehicleType() const
Returns the object's "vehicle" type.
Position getPosition(const double) const
Return current position (x/y, cartesian)
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.
SUMOTime getWaitingTime() const
Returns the SUMOTime waited (speed was lesser than 0.1m/s)
bool isActive() const
Returns whether the current simulation step is an action point for the vehicle.
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.
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
double getSpeed() const
Returns the vehicle's current speed.
const MSLane * getLane() const
Returns the lane the vehicle is on.
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
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.
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.
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
double length2D() const
Returns the 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 ...
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 ammount
PositionVector reverse() const
reverse position vector
static double rand(std::mt19937 *rng=nullptr)
Returns a random real number in [0, 1)
Representation of a vehicle, person, or container.
virtual std::mt19937 * getRNG() const =0
Returns the associated RNG for this object.
virtual double getSpeed() const =0
Returns the object's current speed.
virtual const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
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.