 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
51 #define DEBUG_COND_ZIPPER (ego->isSelected())
63 #define ZIPPER_ADAPT_TIME 10
65 #define JM_CROSSING_GAP_DEFAULT 10
68 #define DIVERGENCE_MIN_WIDTH 2.5
75 myLaneBefore(predLane),
84 myFoeVisibilityDistance(foeVisibilityDistance),
88 myKeepClear(keepClear),
90 myInternalLaneBefore(nullptr),
94 myWalkingAreaFoe(nullptr),
95 myWalkingAreaFoeExit(nullptr),
96 myHavePedestrianCrossingFoe(false),
97 myParallelRight(nullptr),
98 myParallelLeft(nullptr),
108 const double dist = from.back().distanceTo2D(to.front());
114 myLateralShift = (from.back().distanceTo2D(to.front()) < dist) ? dist : -dist;
126 const std::vector<MSLink*>& foeLinks,
127 const std::vector<MSLane*>& foeLanes,
128 MSLane* internalLaneBefore) {
138 for (std::vector<MSLane*>::const_iterator it_lane = foeLanes.begin(); it_lane != foeLanes.end(); ++it_lane) {
146 if (internalLaneBefore !=
nullptr) {
148 lane = internalLaneBefore;
154 #ifdef MSLink_DEBUG_CROSSING_POINTS
157 if (lane !=
nullptr) {
158 const bool beforeInternalJunction = lane->
getLinkCont()[0]->getViaLaneOrLane()->getEdge().isInternal();
163 for (std::vector<const MSLane*>::const_iterator it_lane =
myFoeLanes.begin(); it_lane !=
myFoeLanes.end(); ++it_lane) {
166 if (sameTarget && !beforeInternalJunction && !
contIntersect(lane, *it_lane)) {
170 #ifdef MSLink_DEBUG_CROSSING_POINTS
172 <<
" " << lane->
getID()
173 <<
" merges with " << (*it_lane)->getID()
174 <<
" nextLane " << lane->
getLinkCont()[0]->getViaLaneOrLane()->getID()
181 #ifdef MSLink_DEBUG_CROSSING_POINTS
184 bool haveIntersection =
true;
185 if (intersections1.size() == 0) {
186 intersections1.push_back(-10000.0);
187 haveIntersection =
false;
188 }
else if (intersections1.size() > 1) {
189 std::sort(intersections1.begin(), intersections1.end());
191 std::vector<double> intersections2 = (*it_lane)->getShape().intersectsAtLengths2D(lane->
getShape());
192 #ifdef MSLink_DEBUG_CROSSING_POINTS
195 if (intersections2.size() == 0) {
196 intersections2.push_back(0);
197 }
else if (intersections2.size() > 1) {
198 std::sort(intersections2.begin(), intersections2.end());
200 if (haveIntersection) {
202 intersections1.back() -= (*it_lane)->getWidth() / 2;
203 intersections2.back() -= lane->
getWidth() / 2;
205 intersections1.back() =
MAX2(0.0, intersections1.back());
206 intersections2.back() =
MAX2(0.0, intersections2.back());
210 intersections2.back() = (*it_lane)->interpolateGeometryPosToLanePos(intersections2.back());
215 intersections1.back() = 0;
220 lane->
getLength() - intersections1.back(),
221 (*it_lane)->getLength() - intersections2.back()));
223 #ifdef MSLink_DEBUG_CROSSING_POINTS
225 <<
" intersection of " << lane->
getID()
227 <<
" with " << (*it_lane)->getID()
228 <<
" totalLength=" << (*it_lane)->getLength()
240 const MSLane* sibling = it->getViaLane();
241 if (sibling != lane && sibling !=
nullptr) {
245 if (l.front().distanceTo2D(s.front()) >= minDist) {
249 double lbcSibling = 0;
251 if (l.back().distanceTo2D(s.back()) > minDist) {
258 std::vector<double> distances = l.
distances(s);
259 #ifdef MSLink_DEBUG_CROSSING_POINTS
260 std::cout <<
" distances=" <<
toString(distances) <<
"\n";
262 assert(distances.size() == l.size() + s.size());
263 if (distances.back() > minDist && distances[l.size() - 1] > minDist) {
265 for (
int j = (
int)s.size() - 2; j >= 0; j--) {
266 const int i = j + (int)l.size();
267 const double segLength = s[j].distanceTo2D(s[j + 1]);
268 if (distances[i] > minDist) {
269 lbcSibling += segLength;
272 lbcSibling += segLength - (minDist - distances[i]) * segLength / (distances[i + 1] - distances[i]);
276 for (
int i = (
int)l.size() - 2; i >= 0; i--) {
277 const double segLength = l[i].distanceTo2D(l[i + 1]);
278 if (distances[i] > minDist) {
279 lbcLane += segLength;
282 lbcLane += segLength - (minDist - distances[i]) * segLength / (distances[i + 1] - distances[i]);
290 const double distToDivergence1 = sibling->
getLength() - lbcSibling;
291 const double distToDivergence2 = lane->
getLength() - lbcLane;
292 const double distToDivergence =
MIN3(
293 MAX2(distToDivergence1, distToDivergence2),
297 lbcSibling =
MAX2(0.0, sibling->
getLength() - distToDivergence);
301 #ifdef MSLink_DEBUG_CROSSING_POINTS
302 std::cout <<
" distToDivergence=" << distToDivergence
303 <<
" distTD1=" << distToDivergence1
304 <<
" distTD2=" << distToDivergence2
308 std::cout <<
" adding same-origin foe" << sibling->
getID()
321 const MSEdge* target = &(it->getLane()->getEdge());
325 if (target == myTarget) {
327 #ifdef MSLink_DEBUG_CROSSING_POINTS
328 std::cout <<
" sublaneFoeLink (same target): " << it->getViaLaneOrLane()->getID() <<
"\n";
333 #ifdef MSLink_DEBUG_CROSSING_POINTS
334 std::cout <<
" sublaneFoeLink2 (other target: " << it->getViaLaneOrLane()->getID() <<
"\n";
342 for (MSLinkCont::const_iterator it = predLinks2.begin(); it != predLinks2.end(); ++it) {
343 const MSEdge* target = &((*it)->getLane()->getEdge());
356 if (foe->
getLinkCont()[0]->getViaLane() !=
nullptr) {
358 return intersections.size() > 0;
366 const bool setRequest,
const SUMOTime arrivalTimeBraking,
const double arrivalSpeedBraking,
const SUMOTime waitingTime,
double dist) {
368 #ifdef DEBUG_APPROACHING
372 std::cout <<
"'" << i->first->getID() <<
"'" << std::endl;
378 arrivalTimeBraking, arrivalSpeedBraking, waitingTime, dist, approaching->
getSpeed()));
385 #ifdef DEBUG_APPROACHING
389 std::cout <<
"'" << i->first->getID() <<
"'" << std::endl;
407 if ((*i)->isBlockingAnyone()) {
418 #ifdef DEBUG_APPROACHING
421 std::cout <<
"' Removing approaching vehicle '" << veh->
getID() <<
"'\nCurrently registered vehicles:" << std::endl;
423 std::cout <<
"'" << i->first->getID() <<
"'" << std::endl;
444 const double leaveSpeed,
const double vehicleLength)
const {
451 double impatience,
double decel,
SUMOTime waitingTime,
double posLat,
463 assert(
myLane != foeLink->getLane());
464 for (
const auto& it : foeLink->myApproachingVehicles) {
468 ((posLat < foe->getLateralPositionOnLane() &&
myLane->
getIndex() > foeLink->myLane->getIndex())
471 && (arrivalTime > it.second.arrivalTime
475 if (
blockedByFoe(foe, it.second, arrivalTime, leaveTime, arrivalSpeed, leaveSpeed,
false,
476 impatience, decel, waitingTime, ego)) {
477 #ifdef MSLink_DEBUG_OPENED
479 std::cout <<
SIMTIME <<
" blocked by " << foe->
getID() <<
" arrival=" << arrivalTime <<
" foeArrival=" << it.second.arrivalTime <<
"\n";
482 if (collectFoes ==
nullptr) {
483 #ifdef MSLink_DEBUG_OPENED
485 std::cout <<
" link=" <<
getViaLaneOrLane()->
getID() <<
" blocked by sublaneFoe=" << foe->
getID() <<
" foeLink=" << foeLink->getViaLaneOrLane()->getID() <<
" posLat=" << posLat <<
"\n";
490 collectFoes->push_back(it.first);
501 for (
const auto& it : foeLink->myApproachingVehicles) {
507 && (posLat * lhSign < foe->getLateralPositionOnLane() * lhSign))) {
508 if (
blockedByFoe(foe, it.second, arrivalTime, leaveTime, arrivalSpeed, leaveSpeed,
false,
509 impatience, decel, waitingTime, ego)) {
510 #ifdef MSLink_DEBUG_OPENED
512 std::cout <<
SIMTIME <<
" blocked by sublane foe " << foe->
getID() <<
" arrival=" << arrivalTime <<
" foeArrival=" << it.second.arrivalTime <<
"\n";
515 if (collectFoes ==
nullptr) {
518 collectFoes->push_back(it.first);
529 return collectFoes ==
nullptr || collectFoes->size() == 0;
535 #ifdef MSLink_DEBUG_OPENED
546 if ((*i)->haveRed()) {
550 #ifdef MSLink_DEBUG_OPENED
552 std::cout <<
" foeLink=" << (*i)->getViaLaneOrLane()->getID() <<
" numApproaching=" << (*i)->getApproaching().size() <<
"\n";
555 if ((*i)->blockedAtTime(arrivalTime, leaveTime, arrivalSpeed, leaveSpeed,
myLane == (*i)->getLane(),
556 impatience, decel, waitingTime, collectFoes, ego)) {
560 if (collectFoes !=
nullptr && collectFoes->size() > 0) {
569 bool sameTargetLane,
double impatience,
double decel,
SUMOTime waitingTime,
572 #ifdef MSLink_DEBUG_OPENED
577 std::stringstream stream;
579 <<
" foeVeh=" << it.first->getID() <<
" (below ignore speed)"
582 std::cout << stream.str();
591 &&
blockedByFoe(it.first, it.second, arrivalTime, leaveTime, arrivalSpeed, leaveSpeed, sameTargetLane,
592 impatience, decel, waitingTime, ego)) {
593 if (collectFoes ==
nullptr) {
596 collectFoes->push_back(it.first);
606 SUMOTime arrivalTime,
SUMOTime leaveTime,
double arrivalSpeed,
double leaveSpeed,
607 bool sameTargetLane,
double impatience,
double decel,
SUMOTime waitingTime,
609 #ifdef MSLink_DEBUG_OPENED
611 std::stringstream stream;
613 <<
" foeVeh=" << veh->
getID()
618 std::cout << stream.str();
625 assert(waitingTime > 0);
640 #ifdef MSLink_DEBUG_OPENED
642 std::stringstream stream;
643 stream <<
" imp=" << impatience <<
" fATb=" << avi.
arrivalTimeBraking <<
" fAT2=" << foeArrivalTime <<
" lA=" << lookAhead <<
" egoAT=" << arrivalTime <<
" egoLT=" << leaveTime <<
"\n";
644 std::cout << stream.str();
649 if (sameTargetLane && (arrivalTime - avi.
leavingTime < lookAhead
652 #ifdef MSLink_DEBUG_OPENED
654 std::cout <<
" blocked (cannot follow)\n";
659 }
else if (foeArrivalTime > leaveTime + lookAhead) {
663 #ifdef MSLink_DEBUG_OPENED
665 std::cout <<
" blocked (cannot lead)\n";
672 #ifdef MSLink_DEBUG_OPENED
674 std::cout <<
" blocked (hard conflict)\n";
686 if ((*i)->blockedAtTime(arrivalTime, leaveTime, speed, speed,
myLane == (*i)->getLane(), 0, decel, 0)) {
690 for (std::vector<const MSLane*>::const_iterator i =
myFoeLanes.begin(); i !=
myFoeLanes.end(); ++i) {
691 if ((*i)->getVehicleNumberWithPartials() > 0) {
699 std::pair<const SUMOVehicle*, const MSLink*>
701 double closetDist = std::numeric_limits<double>::max();
703 const MSLink* foeLink =
nullptr;
705 for (
const auto& it : link->myApproachingVehicles) {
706 if (it.second.dist < closetDist) {
707 closetDist = it.second.dist;
708 if (it.second.willPass) {
715 return std::make_pair(closest, foeLink);
759 assert(predLink != 0);
774 std::vector<std::pair<SUMOTime, const SUMOVehicle*> > toSort;
776 toSort.push_back(std::make_pair(it.second.arrivalTime, it.first));
778 std::sort(toSort.begin(), toSort.end());
779 for (std::vector<std::pair<SUMOTime, const SUMOVehicle*> >::const_iterator it = toSort.begin(); it != toSort.end(); ++it) {
803 while (lane !=
nullptr && lane->
isInternal()) {
815 while (lane !=
nullptr && lane->
isInternal()) {
830 double totalDist = 0.;
831 bool foundCrossing =
false;
832 while (via !=
nullptr) {
838 foundCrossing =
true;
856 for (foe_ix = 0; foe_ix != (int)
myFoeLanes.size(); ++foe_ix) {
863 #ifdef MSLink_DEBUG_CROSSING_POINTS
870 if (dist == -10000.) {
874 #ifdef MSLink_DEBUG_CROSSING_POINTS
876 <<
"' at distance " << dist <<
" (approach along '"
930 while (lane !=
nullptr) {
960 std::cout <<
SIMTIME <<
" getLeaderInfo link=" <<
getViaLaneOrLane()->
getID() <<
" dist=" << dist <<
" isShadowLink=" << isShadowLink <<
"\n";
963 for (
int i = 0; i < (int)
myFoeLanes.size(); ++i) {
969 const double crossingWidth = (sameTarget || sameSource) ? 0 : foeLane->
getWidth();
972 std::cout <<
" distToCrossing=" << distToCrossing <<
" foeLane=" << foeLane->
getID() <<
" cWidth=" << crossingWidth
979 const bool contLane = (foeLane->
getLinkCont()[0]->getViaLaneOrLane()->getEdge().isInternal() && !(
981 if (distToCrossing + crossingWidth < 0
996 const double leaderBackDist = foeDistToCrossing - leaderBack;
997 const bool pastTheCrossingPoint = leaderBackDist + foeCrossingWidth < 0;
998 const bool ignoreIndirectBicycleTurn = (pastTheCrossingPoint
1001 const bool cannotIgnore = ((contLane && !ignoreIndirectBicycleTurn) || sameTarget || sameSource) && ego !=
nullptr;
1005 std::cout <<
" candiate leader=" << leader->
getID()
1006 <<
" cannotIgnore=" << cannotIgnore
1007 <<
" fdtc=" << foeDistToCrossing
1008 <<
" lb=" << leaderBack
1009 <<
" lbd=" << leaderBackDist
1010 <<
" fcwidth=" << foeCrossingWidth
1011 <<
" foePastCP=" << pastTheCrossingPoint
1012 <<
" inTheWay=" << inTheWay
1013 <<
" willPass=" << foeLane->
getLinkCont()[0]->getApproaching(leader).willPass
1015 <<
" isOpposite=" << isOpposite <<
"\n";
1017 if (leader == ego) {
1022 && (ego ==
nullptr || !
MSGlobals::gComputeLC || distToCrossing < -ego->getVehicleType().getLength())) {
1026 if ((!cannotIgnore || leader->
isStopped() || sameTarget)
1027 && !foeLane->
getLinkCont()[0]->getApproaching(leader).willPass
1039 bool fromLeft =
true;
1040 if (ego ==
nullptr) {
1043 gap = leaderBackDist;
1047 distToCrossing += foeLane->
getWidth() / 2;
1048 if (gap + foeCrossingWidth < 0) {
1055 fromLeft = foeDistToCrossing > 0.5 * foeLane->
getLength();
1056 }
else if ((contLane && !sameSource && !ignoreIndirectBicycleTurn) || isOpposite) {
1060 std::cout <<
" distToCrossing=" << distToCrossing <<
" leader back=" << leaderBack <<
" backDist=" << leaderBackDist
1065 if (leaderBackDist + foeCrossingWidth < 0) {
1079 const bool stopAsap = leader->
isFrontOnLane(foeLane) ? cannotIgnore : (sameTarget || sameSource);
1081 std::cout <<
" leader=" << leader->
getID() <<
" contLane=" << contLane <<
" cannotIgnore=" << cannotIgnore <<
" stopAsap=" << stopAsap <<
"\n";
1083 result.push_back(
LinkLeader(leader, gap, stopAsap ? -1 : distToCrossing, fromLeft));
1094 const double vehSideOffset = (foeDistToCrossing +
myLaneBefore->
getWidth() * 0.5 - vehWidth * 0.5
1105 if (ego !=
nullptr) {
1113 const MSLane* foeLane = *it;
1117 if (leader == ego) {
1131 <<
" foeLane=" << foeLane->
getID()
1132 <<
" leader=" << leader->
getID()
1135 <<
" egoLat=" << posLat
1136 <<
" leaderLat=" << posLatLeader
1137 <<
" leaderLatOffset=" << leader->
getLatOffset(foeLane)
1139 <<
" foeIndex=" << foeLane->
getIndex()
1145 if ((posLat < posLatLeader && myInternalLaneBefore->
getIndex() > foeLane->
getIndex())
1148 std::cout <<
SIMTIME <<
" blocked by " << leader->
getID() <<
" (sublane split) foeLane=" << foeLane->
getID() <<
"\n";
1150 result.push_back(
LinkLeader(leader, gap, -1));
1167 double distToPeds = std::numeric_limits<double>::max();
1173 if (collectBlockers !=
nullptr) {
1174 collectBlockers->push_back(p);
1178 if (distToPeds != std::numeric_limits<double>::max()) {
1207 if (direction == -1) {
1209 }
else if (direction == 1) {
1222 if (before !=
nullptr && after !=
nullptr) {
1245 throw ProcessError(
"Zipper junctions with more than two conflicting lanes are not supported (at junction '"
1249 const double secondsToArrival =
STEPS2TIME(arrivalTime - now);
1253 <<
" dist=" << dist <<
" ignoring foes (arrival in " <<
STEPS2TIME(arrivalTime - now) <<
")\n")
1259 <<
" egoAT=" << arrivalTime
1261 <<
" vSafe=" << vSafe
1262 <<
" numFoes=" << collectFoes->size()
1266 for (
const auto& item : *collectFoes) {
1281 <<
" ignoring foe=" << foe->
getID()
1283 <<
" foeDist=" << avi.
dist
1284 <<
" foeDist2=" << foeDist
1285 <<
" foeSpeed=" << avi.
speed
1287 <<
" deltaDist=" << foeDist - dist
1310 const double uEnd =
MIN2(uMax, uAccel);
1311 const double uAvg = (avi.
speed + uEnd) / 2;
1313 const double tf =
MAX2(1.0, ceil((tf0) /
TS) *
TS);
1317 const double vEnd =
MIN3(vMax, vAccel, uEnd);
1318 const double vAvg = (ego->
getSpeed() + vEnd) / 2;
1320 const double te =
MAX2(1.0, ceil((te0) /
TS) *
TS);
1327 const double deltaGap = gap + tf * uAvg - safeGap - vAvg * tf;
1328 const double a = 2 * deltaGap / (tf * tf);
1334 const double w =
MIN2(1.0, te / 10);
1336 const double vZipper =
MAX3(vFollow, ego->
getSpeed() -
ACCEL2SPEED(maxDecel), w * vSafeGap + (1 - w) * vFollow);
1338 vSafe =
MIN2(vSafe, vZipper);
1341 <<
" foeDist=" << foeDist
1342 <<
" foeSpeed=" << avi.
speed
1346 <<
" uAccel=" << uAccel
1350 <<
" safeGap=" << safeGap
1354 <<
" dg=" << deltaGap
1355 <<
" aSafeGap=" << a
1357 <<
" vAccel=" << vAccel
1359 <<
" vSafeGap=" << vSafeGap
1360 <<
" vFollow=" << vFollow
1362 <<
" maxDecel=" << maxDecel
1363 <<
" vZipper=" << vZipper
1364 <<
" vSafe=" << vSafe
1375 followDist > leaderDist &&
1393 for (
const MSLink* link : cand->getLinkCont()) {
bool hasFoes() const
Returns whether this link belongs to a junction where more than one edge is incoming.
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.
LinkDirection getDirection() const
Returns the direction the vehicle passing this link take.
bool isConflictEntryLink() const
return whether this link enters the conflict area (not a continuation link)
bool havePriority() const
Returns whether this link is a major link.
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.
MSLink * computeParallelLink(int direction)
double getMaxAccel() const
Get the vehicle type's maximum acceleration [m/s^2].
MSLane * getViaLaneOrLane() const
return the via lane if it exists and the lane otherwise
const std::set< MSTransportable * > & getPersons() const
Returns this edge's persons set.
ApproachInfos myApproachingVehicles
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 getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
#define ZIPPER_ADAPT_TIME
Representation of a lane in the micro simulation.
bool isStopped() const
Returns whether the vehicle is at a stop.
bool isActive() const
Returns whether the current simulation step is an action point for the vehicle.
virtual std::mt19937 * getRNG() const =0
Returns the associated RNG for this vehicle.
@ LINKSTATE_TL_OFF_BLINKING
The link is controlled by a tls which is off and blinks, has to brake.
bool myHasFoes
Whether any foe links exist.
bool lastWasContMajor() const
whether this is a link past an internal junction which currently has priority
The base class for an intersection.
Static storage of an output device and its base (abstract) implementation.
MSLane *const myInternalLane
The following junction-internal lane if used.
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 ...
static bool gComputeLC
whether the simulationLoop is in the lane changing phase
@ LINKSTATE_TL_OFF_NOSIGNAL
The link is controlled by a tls which is off, not blinking, may pass.
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.
double getLatOffset(const MSLane *lane) const
Get the offset that that must be added to interpret myState.myPosLat for the given lane.
LinkState myState
The state of the link.
bool isExitLink() const
return whether the fromLane of this link is an internal lane and toLane is a normal lane
static const double ZIPPER_ADAPT_DIST
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)
virtual const std::string & getID() const =0
Get the vehicle's ID.
static bool unsafeMergeSpeeds(double leaderSpeed, double followerSpeed, double leaderDecel, double followerDecel)
return whether the given vehicles may NOT merge safely
@ LINKDIR_PARTRIGHT
The link is a partial right direction.
std::vector< const SUMOVehicle * > BlockingFoes
static const double SAFETY_GAP
static MSLink * getConnectingLink(const MSLane &from, const MSLane &to)
Returns the link connecting both lanes Both lanes have to be non-internal; 0 may be returned if no co...
double getLength() const
Returns the vehicle's length.
bool blockedByFoe(const SUMOVehicle *veh, const ApproachingVehicleInformation &avi, SUMOTime arrivalTime, SUMOTime leaveTime, double arrivalSpeed, double leaveSpeed, bool sameTargetLane, double impatience, double decel, SUMOTime waitingTime, const SUMOVehicle *ego) const
Representation of a vehicle.
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
@ SVC_BICYCLE
vehicle is a bicycle
bool hasPersons() const
Returns whether persons are simulated.
MSLane * myLaneBefore
The lane approaching this link.
double getLengthsBeforeCrossing(const MSLane *foeLane) const
Returns the sum of the lengths along internal lanes following this link to the crossing with the give...
LinkDirection
The different directions a link between two lanes may take (or a stream between two edges)....
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
#define DEBUG_COND_ZIPPER
MSLink * getParallelLink(int direction) const
return the link that is parallel to this lane or 0
void initParallelLinks()
initialize parallel links (to be called after all links are loaded)
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
int getIndex() const
Returns the respond index (for visualization)
MSAbstractLaneChangeModel & getLaneChangeModel()
bool isEntryLink() const
return whether the toLane of this link is an internal lane and fromLane is a normal lane
@ SUMO_ATTR_JM_IGNORE_FOE_PROB
@ SUMO_ATTR_JM_TIMEGAP_MINOR
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
static double gLateralResolution
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
@ SUMO_ATTR_JM_IGNORE_FOE_SPEED
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
@ LINKDIR_RIGHT
The link is a (hard) right direction.
bool isInternal() const
return whether this edge is an internal edge
std::string getDescription() const
get string description for this link
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
double getInternalLengthsBefore() const
Returns the cumulative length of all internal lanes before this link.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
const MSJunction * getFromJunction() const
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic,...
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
@ LINKDIR_STRAIGHT
The link is a straight direction.
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
MSLane * getLane() const
Returns the connected lane.
double interpolateGeometryPosToLanePos(double geometryPos) const
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.
bool myHavePedestrianCrossingFoe
whether on of myFoeLanes is a crossing
const MSCFModel & getCarFollowModel() const
Returns the vehicle type's car following model definition (const version)
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
void writeApproaching(OutputDevice &od, const std::string fromLaneID) const
write information about all approaching vehicles to the given output device
const MSLane * myWalkingAreaFoe
walkingArea that must be checked when entering the intersection
bool lefthand() const
return whether the network was built for lefthand traffic
SUMOTime getLastActionTime() const
Returns the time of the vehicle's last action point.
void setTLState(LinkState state, SUMOTime t)
Sets the current tl-state.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
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 SUMOVehicle *ego=nullptr) const
Returns the information whether the link may be passed.
const MSLane * getInternalLaneBefore() const
return myInternalLaneBefore (always 0 when compiled without internal lanes)
@ LINKSTATE_ZIPPER
This is an uncontrolled, zipper-merge link.
std::vector< LinkLeader > LinkLeaders
double getLength() const
Returns the lane's length.
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
static SUMOTime gIgnoreJunctionBlocker
MSJunction * myJunction
the junction to which this link belongs
LinkDirection myDirection
An abstract (hopefully human readable) definition of the link's direction.
double myLateralShift
lateral shift to be applied when passing this link
virtual double getLateralPositionOnLane() const =0
Get the vehicle's lateral position on the lane.
std::string time2string(SUMOTime t)
std::vector< MSLink * > mySublaneFoeLinks2
bool contIntersect(const MSLane *lane, const MSLane *foe)
check if the lane intersects with a foe cont-lane
double getMinGap() const
Get the free space in front of vehicles of this class.
A road/street connecting two junctions.
@ LINKDIR_LEFT
The link is a (hard) left direction.
The parent class for traffic light logics.
void addBlockedLink(MSLink *link)
std::vector< std::pair< double, double > > myLengthsBehindCrossing
Position getPosition(const double) const
Return current position (x/y, cartesian)
static const SUMOTime myLookaheadTimeZipper
double getInternalLengthsAfter() const
Returns the cumulative length of all internal lanes after this link.
bool blockedAtTime(SUMOTime arrivalTime, SUMOTime leaveTime, double arrivalSpeed, double leaveSpeed, bool sameTargetLane, double impatience, double decel, SUMOTime waitingTime, BlockingFoes *collectFoes=nullptr, const SUMOVehicle *ego=nullptr) const
Returns the information whether this link is blocked Valid after the vehicles have set their requests...
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
const MSLane * myWalkingAreaFoeExit
walkingArea that must be checked when leaving the intersection
AnyVehicleIterator anyVehiclesEnd() const
end iterator for iterating over all vehicles touching this lane in downstream direction
void removeApproaching(const SUMOVehicle *veh)
removes the vehicle from myApproachingVehicles
std::set< MSLink * > myBlockedFoeLinks
double getLengthBeforeCrossing(const MSLane *foeLane) const
Returns the internal length from the beginning of the link's internal lane before to the crossing wit...
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
bool willHaveBlockedFoe() const
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
MSLane * getLane() const
Returns the lane the vehicle is on.
bool isInternalJunctionLink() const
return whether the fromLane and the toLane of this link are internal lanes
MSEdge & getEdge() const
Returns the lane's edge.
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
bool haveRed() const
Returns whether this link is blocked by a red (or redyellow) traffic light.
@ SUMO_ATTR_JM_CROSSING_GAP
bool willStop() const
Returns whether the vehicle will stop on the current edge.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
const PositionVector & getShape() const
Returns this lane's shape.
SUMOTime myLastStateChange
The time of the last state change.
std::vector< MSLink * > myFoeLinks
MSLink * getCorrespondingExitLink() const
returns the corresponding exit link for entryLinks to a junction.
const MSLane * myInternalLaneBefore
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
std::vector< const MSLane * > myFoeLanes
double getLength() const
Returns the length of this link.
virtual double getSpeed() const
the current speed of the transportable
std::pair< const SUMOVehicle *, const MSLink * > getFirstApproachingFoe() const
get the foe vehicle that is closest to the intersection or nullptr along with the foe link
const MSVehicleType & getVehicleType() const
Returns the vehicle's type.
double getLength() const
Get vehicle's length [m].
static const SUMOTime myLookaheadTime
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
MSLink(MSLane *predLane, MSLane *succLane, MSLane *via, LinkDirection dir, LinkState state, double length, double foeVisibilityDistance, bool keepClear, MSTrafficLightLogic *logic, int tlLinkIdx)
Constructor for simulation which uses internal lanes.
static bool couldBrakeForLeader(double followDist, double leaderDist, const MSVehicle *follow, const MSVehicle *leader)
whether follower could stay behind leader (possibly by braking)
const double INVALID_DOUBLE
const SUMOVTypeParameter & getParameter() const
bool checkContOff() const
figure out whether the cont status remains in effect when switching off the tls
double getEmergencyDecel() const
Get the vehicle type's maximal phisically possible deceleration [m/s^2].
const std::string & getID() const
Returns the name of the vehicle.
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.
bool isStrategicBlocked() const
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
#define DIVERGENCE_MIN_WIDTH
double getBackPositionOnLane(const MSLane *lane) const
Get the vehicle's position relative to the given lane.
MSLane * myLane
The lane behind the junction approached by this link.
double getWidth() const
Returns the lane's width.
const MSTrafficLightLogic * myLogic
the controlling logic or 0
static MSPModel * getModel()
SUMOTime getWaitingTime() const
Returns the SUMOTime waited (speed was lesser than 0.1m/s)
@ LINKSTATE_ALLWAY_STOP
This is an uncontrolled, all-way stop link.
std::vector< MSLane * > mySublaneFoeLanes
bool gDebugFlag1
global utility flags for debugging
double getSpeed() const
Returns the vehicle's current speed.
std::vector< MSLink * > mySublaneFoeLinks
bool fromInternalLane() const
return whether the fromLane of this link is an internal lane
bool isFrontOnLane(const MSLane *lane) const
Returns the information whether the front of the vehicle is on the given lane.
const MSLane * getLaneBefore() const
return the internalLaneBefore if it exists and the laneBefore otherwise
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
double estimateSpeedAfterDistance(const double dist, const double v, const double accel) const
#define JM_CROSSING_GAP_DEFAULT
const ApproachInfos & getApproaching() const
return all approaching vehicles
@ LINKDIR_PARTLEFT
The link is a partial left direction.
const std::string & getID() const
Returns the id.
bool isExitLinkAfterInternalJunction() const
return whether the fromLane of this link is an internal lane and its incoming lane is also an interna...
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)
AnyVehicleIterator is a structure, which manages the iteration through all vehicles on the lane,...
int getIndex() const
Returns the lane's index.
double getJMParam(const SumoXMLAttr attr, const double defaultValue) const
Returns the named value from the map, or the default if it is not contained there.
MSLane * getViaLane() const
Returns the following inner lane.
void move2side(double amount, double maxExtension=100)
move position vector to side using certain ammount
int myIndex
The position within this respond.
virtual double getSpeed() const =0
Returns the vehicle's current speed.
MSLink * getEntryLink() const
Returns the entry link if this is an internal lane, else 0.
AnyVehicleIterator anyVehiclesBegin() const
begin iterator for iterating over all vehicles touching this lane in downstream direction
@ LINKSTATE_STOP
This is an uncontrolled, minor link, has to stop.
Representation of a vehicle in the micro simulation.