58 #define ZIPPER_ADAPT_TIME 10 60 #define JM_CROSSING_GAP_DEFAULT 10 67 myLaneBefore(predLane),
76 myFoeVisibilityDistance(foeVisibilityDistance),
80 myKeepClear(keepClear),
82 myInternalLaneBefore(0),
98 const double dist = from.back().distanceTo2D(to.front());
104 myLateralShift = (from.back().distanceTo2D(to.front()) < dist) ? dist : -dist;
116 const std::vector<MSLink*>& foeLinks,
117 const std::vector<MSLane*>& foeLanes,
118 MSLane* internalLaneBefore) {
128 for (std::vector<MSLane*>::const_iterator it_lane = foeLanes.begin(); it_lane != foeLanes.end(); ++it_lane) {
136 if (internalLaneBefore != 0) {
138 lane = internalLaneBefore;
144 #ifdef MSLink_DEBUG_CROSSING_POINTS 148 const bool beforeInternalJunction = lane->
getLinkCont()[0]->getViaLaneOrLane()->getEdge().isInternal();
153 for (std::vector<const MSLane*>::const_iterator it_lane =
myFoeLanes.begin(); it_lane !=
myFoeLanes.end(); ++it_lane) {
155 if (sameTarget && !beforeInternalJunction && !
contIntersect(lane, *it_lane)) {
159 #ifdef MSLink_DEBUG_CROSSING_POINTS 161 <<
" " << lane->
getID()
162 <<
" merges with " << (*it_lane)->getID()
163 <<
" nextLane " << lane->
getLinkCont()[0]->getViaLaneOrLane()->getID()
170 #ifdef MSLink_DEBUG_CROSSING_POINTS 173 bool haveIntersection =
true;
174 if (intersections1.size() == 0) {
175 intersections1.push_back(-10000.0);
176 haveIntersection =
false;
177 }
else if (intersections1.size() > 1) {
178 std::sort(intersections1.begin(), intersections1.end());
180 std::vector<double> intersections2 = (*it_lane)->getShape().intersectsAtLengths2D(lane->
getShape());
181 #ifdef MSLink_DEBUG_CROSSING_POINTS 184 if (intersections2.size() == 0) {
185 intersections2.push_back(0);
186 }
else if (intersections2.size() > 1) {
187 std::sort(intersections2.begin(), intersections2.end());
189 if (haveIntersection) {
191 intersections1.back() -= (*it_lane)->getWidth() / 2;
192 intersections2.back() -= lane->
getWidth() / 2;
195 intersections2.back() = (*it_lane)->interpolateGeometryPosToLanePos(intersections2.back());
200 intersections1.back() = 0;
205 lane->
getLength() - intersections1.back(),
206 (*it_lane)->getLength() - intersections2.back()));
208 #ifdef MSLink_DEBUG_CROSSING_POINTS 210 <<
" intersection of " << lane->
getID()
212 <<
" with " << (*it_lane)->getID()
213 <<
" totalLength=" << (*it_lane)->getLength()
225 const MSLane* sibling = it->getViaLane();
226 if (sibling != lane && sibling != 0) {
230 if (l.front().distanceTo2D(s.front()) >= minDist) {
234 double lbcSibling = 0;
236 if (l.back().distanceTo2D(s.back()) > minDist) {
243 std::vector<double> distances = l.
distances(s);
244 #ifdef MSLink_DEBUG_CROSSING_POINTS 245 std::cout <<
" distances=" <<
toString(distances) <<
"\n";
247 assert(distances.size() == l.size() + s.size());
248 if (distances.back() > minDist && distances[l.size() - 1] > minDist) {
250 for (
int j = (
int)s.size() - 2; j >= 0; j--) {
251 const int i = j + (int)l.size();
252 const double segLength = s[j].distanceTo2D(s[j + 1]);
253 if (distances[i] > minDist) {
254 lbcSibling += segLength;
257 lbcSibling += segLength - (minDist - distances[i]) * segLength / (distances[i + 1] - distances[i]);
261 for (
int i = (
int)l.size() - 2; i >= 0; i--) {
262 const double segLength = l[i].distanceTo2D(l[i + 1]);
263 if (distances[i] > minDist) {
264 lbcLane += segLength;
267 lbcLane += segLength - (minDist - distances[i]) * segLength / (distances[i + 1] - distances[i]);
275 const double distToDivergence1 = sibling->
getLength() - lbcSibling;
276 const double distToDivergence2 = lane->
getLength() - lbcLane;
277 const double distToDivergence =
MIN3(
278 MAX2(distToDivergence1, distToDivergence2),
282 lbcSibling =
MAX2(0.0, sibling->
getLength() - distToDivergence);
286 #ifdef MSLink_DEBUG_CROSSING_POINTS 287 std::cout <<
" distToDivergence=" << distToDivergence
288 <<
" distTD1=" << distToDivergence1
289 <<
" distTD2=" << distToDivergence2
293 std::cout <<
" adding same-origin foe" << sibling->
getID()
306 const MSEdge* target = &(it->getLane()->getEdge());
310 if (target == myTarget) {
321 for (MSLinkCont::const_iterator it = predLinks2.begin(); it != predLinks2.end(); ++it) {
322 const MSEdge* target = &((*it)->getLane()->getEdge());
337 return intersections.size() > 0;
346 const bool setRequest,
const SUMOTime arrivalTimeBraking,
const double arrivalSpeedBraking,
const SUMOTime waitingTime,
double dist) {
348 #ifdef DEBUG_APPROACHING 350 std::cout <<
SIMTIME <<
" Link ''" << (
myLaneBefore == 0 ?
"NULL" : myLaneBefore->
getID()) <<
"'->'" << (
myLane == 0 ?
"NULL" :
myLane->
getID()) <<
"' Adding approaching vehicle '" << approaching->
getID() <<
"'\nCurrently registered vehicles:" << std::endl;
352 std::cout <<
"'" << i->first->getID() <<
"'" << std::endl;
358 arrivalTimeBraking, arrivalSpeedBraking, waitingTime, dist)));
365 #ifdef DEBUG_APPROACHING 367 std::cout <<
SIMTIME <<
" Link ''" << (
myLaneBefore == 0 ?
"NULL" : myLaneBefore->
getID()) <<
"'->'" << (
myLane == 0 ?
"NULL" :
myLane->
getID()) <<
"' Adding approaching vehicle '" << approaching->
getID() <<
"'\nCurrently registered vehicles:" << std::endl;
369 std::cout <<
"'" << i->first->getID() <<
"'" << std::endl;
387 if ((*i)->isBlockingAnyone()) {
398 #ifdef DEBUG_APPROACHING 401 std::cout <<
"' Removing approaching vehicle '" << veh->
getID() <<
"'\nCurrently registered vehicles:" << std::endl;
403 std::cout <<
"'" << i->first->getID() <<
"'" << std::endl;
413 std::map<const SUMOVehicle*, ApproachingVehicleInformation>::const_iterator i =
myApproachingVehicles.find(veh);
424 const double leaveSpeed,
const double vehicleLength)
const {
431 double impatience,
double decel,
SUMOTime waitingTime,
double posLat,
432 std::vector<const SUMOVehicle*>* collectFoes,
bool ignoreRed,
const SUMOVehicle* ego)
const {
443 assert(
myLane != foeLink->getLane());
444 for (
auto& it : foeLink->myApproachingVehicles) {
448 ((posLat < foe->getLateralPositionOnLane() &&
myLane->
getIndex() > foeLink->myLane->getIndex())
451 && (arrivalTime > it.second.arrivalTime
455 if (
blockedByFoe(foe, it.second, arrivalTime, leaveTime, arrivalSpeed, leaveSpeed,
false,
456 impatience, decel, waitingTime, ego)) {
457 #ifdef MSLink_DEBUG_OPENED 459 std::cout <<
SIMTIME <<
" blocked by " << foe->
getID() <<
" arrival=" << arrivalTime <<
" foeArrival=" << it.second.arrivalTime <<
"\n";
462 if (collectFoes == 0) {
463 #ifdef MSLink_DEBUG_OPENED 465 std::cout <<
" link=" <<
getViaLaneOrLane()->
getID() <<
" blocked by sublaneFoe=" << foe->
getID() <<
" foeLink=" << foeLink->getViaLaneOrLane()->getID() <<
" posLat=" << posLat <<
"\n";
470 collectFoes->push_back(foe);
480 for (
auto& it : foeLink->myApproachingVehicles) {
486 && (posLat < foe->getLateralPositionOnLane()))) {
487 if (
blockedByFoe(foe, it.second, arrivalTime, leaveTime, arrivalSpeed, leaveSpeed,
false,
488 impatience, decel, waitingTime, ego)) {
489 #ifdef MSLink_DEBUG_OPENED 491 std::cout <<
SIMTIME <<
" blocked by sublane foe " << foe->
getID() <<
" arrival=" << arrivalTime <<
" foeArrival=" << it.second.arrivalTime <<
"\n";
494 if (collectFoes == 0) {
497 collectFoes->push_back(foe);
508 return collectFoes == 0 || collectFoes->size() == 0;
514 #ifdef MSLink_DEBUG_OPENED 522 if ((*i)->haveRed()) {
526 #ifdef MSLink_DEBUG_OPENED 528 std::cout <<
" foeLink=" << (*i)->getViaLaneOrLane()->getID() <<
" numApproaching=" << (*i)->getApproaching().size() <<
"\n";
531 if ((*i)->blockedAtTime(arrivalTime, leaveTime, arrivalSpeed, leaveSpeed,
myLane == (*i)->getLane(),
532 impatience, decel, waitingTime, collectFoes, ego)) {
536 if (collectFoes != 0 && collectFoes->size() > 0) {
545 bool sameTargetLane,
double impatience,
double decel,
SUMOTime waitingTime,
546 std::vector<const SUMOVehicle*>* collectFoes,
const SUMOVehicle* ego)
const {
548 #ifdef MSLink_DEBUG_OPENED 554 <<
" foeVeh=" << i->first->getID() <<
" (below ignore speed)" 565 &&
blockedByFoe(i->first, i->second, arrivalTime, leaveTime, arrivalSpeed, leaveSpeed, sameTargetLane,
566 impatience, decel, waitingTime, ego)) {
567 if (collectFoes == 0) {
570 collectFoes->push_back(i->first);
580 SUMOTime arrivalTime,
SUMOTime leaveTime,
double arrivalSpeed,
double leaveSpeed,
581 bool sameTargetLane,
double impatience,
double decel,
SUMOTime waitingTime,
583 #ifdef MSLink_DEBUG_OPENED 586 <<
" foeVeh=" << veh->
getID()
597 assert(waitingTime > 0);
612 #ifdef MSLink_DEBUG_OPENED 614 std::cout <<
" imp=" << impatience <<
" fATb=" << avi.
arrivalTimeBraking <<
" fAT2=" << foeArrivalTime <<
" lA=" << lookAhead <<
" egoAT=" << arrivalTime <<
" egoLT=" << leaveTime <<
"\n";
619 if (sameTargetLane && (arrivalTime - avi.
leavingTime < lookAhead
622 #ifdef MSLink_DEBUG_OPENED 624 std::cout <<
" blocked (cannot follow)\n";
629 }
else if (foeArrivalTime > leaveTime + lookAhead) {
633 #ifdef MSLink_DEBUG_OPENED 635 std::cout <<
" blocked (cannot lead)\n";
642 #ifdef MSLink_DEBUG_OPENED 644 std::cout <<
" blocked (hard conflict)\n";
661 assert(distLeft > 0);
672 if ((*i)->blockedAtTime(arrivalTime, leaveTime, speed, speed,
myLane == (*i)->getLane(), 0, decel, 0)) {
676 for (std::vector<const MSLane*>::const_iterator i =
myFoeLanes.begin(); i !=
myFoeLanes.end(); ++i) {
677 if ((*i)->getVehicleNumberWithPartials() > 0) {
725 assert(predLink != 0);
740 std::vector<std::pair<SUMOTime, const SUMOVehicle*> > toSort;
742 toSort.push_back(std::make_pair(it->second.arrivalTime, it->first));
744 std::sort(toSort.begin(), toSort.end());
745 for (std::vector<std::pair<SUMOTime, const SUMOVehicle*> >::const_iterator it = toSort.begin(); it != toSort.end(); ++it) {
796 double totalDist = 0.;
797 bool foundCrossing =
false;
804 foundCrossing =
true;
822 for (foe_ix = 0; foe_ix != (int)
myFoeLanes.size(); ++foe_ix) {
829 #ifdef MSLink_DEBUG_CROSSING_POINTS 836 if (dist == -10000.) {
840 #ifdef MSLink_DEBUG_CROSSING_POINTS 842 <<
"' at distance " << dist <<
" (approach along '" 914 for (
int i = 0; i < (int)
myFoeLanes.size(); ++i) {
920 const double crossingWidth = (sameTarget || sameSource) ? 0 : foeLane->
getWidth();
923 std::cout <<
" distToCrossing=" << distToCrossing <<
" foeLane=" << foeLane->
getID() <<
" cWidth=" << crossingWidth
928 const bool contLane = (foeLane->
getLinkCont()[0]->getViaLaneOrLane()->getEdge().isInternal() && !(
930 if (distToCrossing + crossingWidth < 0) {
944 const double leaderBackDist = foeDistToCrossing - leaderBack;
945 const bool pastTheCrossingPoint = leaderBackDist + foeCrossingWidth < 0;
946 const bool ignoreIndirectBicycleTurn = (pastTheCrossingPoint
949 const bool cannotIgnore = ((contLane && !ignoreIndirectBicycleTurn) || sameTarget || sameSource) && ego !=
nullptr;
953 std::cout <<
" candiate leader=" << leader->
getID()
954 <<
" cannotIgnore=" << cannotIgnore
955 <<
" fdtc=" << foeDistToCrossing
956 <<
" lb=" << leaderBack
957 <<
" lbd=" << leaderBackDist
958 <<
" fcwidth=" << foeCrossingWidth
959 <<
" foePastCP=" << pastTheCrossingPoint
960 <<
" inTheWay=" << inTheWay
961 <<
" willPass=" << foeLane->
getLinkCont()[0]->getApproaching(leader).willPass
963 <<
" isOpposite=" << isOpposite <<
"\n";
973 if ((!cannotIgnore || leader->
isStopped())
974 && !foeLane->
getLinkCont()[0]->getApproaching(leader).willPass
986 bool fromLeft =
true;
990 gap = leaderBackDist;
994 distToCrossing += foeLane->
getWidth() / 2;
995 if (gap + foeCrossingWidth < 0) {
1002 fromLeft = foeDistToCrossing > 0.5 * foeLane->
getLength();
1003 }
else if ((contLane && !sameSource && !ignoreIndirectBicycleTurn) || isOpposite) {
1007 std::cout <<
" distToCrossing=" << distToCrossing <<
" leader back=" << leaderBack <<
" backDist=" << leaderBackDist <<
"\n";
1009 if (leaderBackDist + foeCrossingWidth < 0) {
1017 std::cout <<
" leader=" << leader->
getID() <<
" contLane=" << contLane <<
" cannotIgnore=" << cannotIgnore <<
"\n";
1022 const bool stopAsap = leader->
isFrontOnLane(foeLane) ? cannotIgnore : (sameTarget || sameSource);
1023 result.push_back(
LinkLeader(leader, gap, stopAsap ? -1 : distToCrossing, fromLeft));
1034 const double vehSideOffset = (foeDistToCrossing +
myLaneBefore->
getWidth() * 0.5 - vehWidth * 0.5
1050 double distToPeds = std::numeric_limits<double>::max();
1052 for (std::set<MSTransportable*>::const_iterator it = persons.begin(); it != persons.end(); ++it) {
1055 if (collectBlockers != 0) {
1056 collectBlockers->push_back(p);
1065 const MSLane* foeLane = *it;
1069 if (leader == ego) {
1083 <<
" foeLane=" << foeLane->
getID()
1084 <<
" leader=" << leader->
getID()
1087 <<
" egoLat=" << posLat
1088 <<
" leaderLat=" << posLatLeader
1089 <<
" leaderLatOffset=" << leader->
getLatOffset(foeLane)
1091 <<
" foeIndex=" << foeLane->
getIndex()
1097 if ((posLat < posLatLeader && myInternalLaneBefore->
getIndex() > foeLane->
getIndex())
1100 std::cout <<
SIMTIME <<
" blocked by " << leader->
getID() <<
" (sublane split) foeLane=" << foeLane->
getID() <<
"\n";
1102 result.push_back(
LinkLeader(leader, gap, -1));
1134 if (direction == -1) {
1136 }
else if (direction == 1) {
1149 if (before != 0 && after != 0) {
1183 std::vector<const SUMOVehicle*>* collectFoes)
const {
1190 throw ProcessError(
"Zipper junctions with more than two conflicting lanes are not supported (at junction '" 1194 const double secondsToArrival =
STEPS2TIME(arrivalTime - now);
1208 const double vSafeOrig = vSafe;
1209 for (std::vector<const SUMOVehicle*>::const_iterator i = collectFoes->begin(); i != collectFoes->end(); ++i) {
1234 const double followInTime = vSafeOrig + (follow - vSafeOrig) /
MAX2((
double)1, secondsToArrival /
TS);
1235 vSafe =
MIN2(vSafe, followInTime);
1256 followDist > leaderDist &&
1274 for (
const MSLink* link : cand->getLinkCont()) {
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
bool gDebugFlag1
global utility flags for debugging
The link is a partial left direction.
static double gLateralResolution
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
bool contIntersect(const MSLane *lane, const MSLane *foe)
check if the lane intersects with a foe cont-lane
int myIndex
The position within this respond.
double getLength() const
Returns the vehicle's length.
MSEdge & getEdge() const
Returns the lane's edge.
Representation of a vehicle in the micro simulation.
bool blockedAtTime(SUMOTime arrivalTime, SUMOTime leaveTime, double arrivalSpeed, double leaveSpeed, bool sameTargetLane, double impatience, double decel, SUMOTime waitingTime, std::vector< const SUMOVehicle *> *collectFoes=0, const SUMOVehicle *ego=0) const
Returns the information whether this link is blocked Valid after the vehicles have set their requests...
double getJMParam(const SumoXMLAttr attr, const double defaultValue) const
Returns the named value from the map, or the default if it is not contained there.
MSLane * myLane
The lane behind the junction approached by this link.
void addBlockedLink(MSLink *link)
LinkState myState
The state of the link.
SUMOTime getWaitingTime() const
Returns the SUMOTime waited (speed was lesser than 0.1m/s)
LinkDirection getDirection() const
Returns the direction the vehicle passing this link take.
MSLane * getLane() const
Returns the connected lane.
double getLengthBeforeCrossing(const MSLane *foeLane) const
Returns the internal length from the beginning of the link's internal lane before to the crossing wit...
MSLane * getLane() const
Returns the lane the vehicle is on.
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
bool myHasFoes
Whether any foe links exist.
This is an uncontrolled, minor link, has to stop.
The base class for an intersection.
std::vector< MSLink * > mySublaneFoeLinks
const MSLane * getLaneBefore() const
return the internalLaneBefore if it exists and the laneBefore otherwise
SUMOTime myLastStateChange
The time of the last state change.
std::vector< MSLink * > myFoeLinks
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
MSLink * getCorrespondingExitLink() const
returns the corresponding exit link for entryLinks to a junction.
#define ZIPPER_ADAPT_TIME
void setTLState(LinkState state, SUMOTime t)
Sets the current tl-state.
AnyVehicleIterator is a structure, which manages the iteration through all vehicles on the lane...
std::string time2string(SUMOTime t)
LinkDirection myDirection
An abstract (hopefully human readable) definition of the link's direction.
double getZipperSpeed(const MSVehicle *ego, const double dist, double vSafe, SUMOTime arrivalTime, std::vector< const SUMOVehicle *> *collectFoes) const
return the speed at which ego vehicle must approach the zipper link
static const double ZIPPER_ADAPT_DIST
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
static const SUMOTime myLookaheadTime
double getLength() const
Returns the lane's length.
const PositionVector & getShape() const
Returns this lane's shape.
double myLateralShift
lateral shift to be applied when passing this link
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
std::vector< std::pair< double, double > > myLengthsBehindCrossing
bool hasFoes() const
Returns whether this link belongs to a junction where more than one edge is incoming.
bool checkContOff() const
figure out whether the cont status remains in effect when switching off the tls
const std::string & getID() const
Returns the id.
double getInternalLengthsBefore() const
Returns the cumulative length of all internal lanes before this link.
std::vector< double > distances(const PositionVector &s, bool perpendicular=false) const
distances of all my points to s and all of s points to myself
double getInternalLengthsAfter() const
Returns the cumulative length of all internal lanes after this link.
The link is controlled by a tls which is off, not blinking, may pass.
This is an uncontrolled, all-way stop link.
std::vector< MSLane * > mySublaneFoeLanes
double getWidth() const
Returns the lane's width.
void setApproaching(const SUMOVehicle *approaching, const SUMOTime arrivalTime, const double arrivalSpeed, const double leaveSpeed, const bool setRequest, const SUMOTime arrivalTimeBraking, const double arrivalSpeedBraking, const SUMOTime waitingTime, double dist)
Sets the information about an approaching vehicle.
bool isInternalJunctionLink() const
return whether the fromLane and the toLane of this link are internal lanes
This is an uncontrolled, zipper-merge link.
The link is a (hard) left direction.
MSAbstractLaneChangeModel & getLaneChangeModel()
MSLink * computeParallelLink(int direction)
MSLink * getParallelLink(int direction) const
return the link that is parallel to this lane or 0
bool isFrontOnLane(const MSLane *lane) const
Returns the information whether the front of the vehicle is on the given lane.
bool willHaveBlockedFoe() const
LinkDirection
The different directions a link between two lanes may take (or a stream between two edges)...
bool fromInternalLane() const
return whether the fromLane of this link is an internal lane
The link is a straight direction.
bool willStop() const
Returns whether the vehicle will stop on the current edge.
const MSLane * myInternalLaneBefore
bool lastWasContMajor() const
whether this is a link past an internal junction which currently has priority
A road/street connecting two junctions.
double getLatOffset(const MSLane *lane) const
Get the offset that that must be added to interpret myState.myPosLat for the given lane...
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
int getIndex() const
Returns the lane's index.
SUMOTime getLeaveTime(const SUMOTime arrivalTime, const double arrivalSpeed, const double leaveSpeed, const double vehicleLength) const
return the expected time at which the given vehicle will clear the link
MSLink * getEntryLink() const
Returns the entry link if this is an internal lane, else 0.
const MSCFModel & getCarFollowModel() const
Returns the vehicle type's car following model definition (const version)
MSLane * getViaLane() const
Returns the following inner lane.
virtual bool blockedAtDist(const MSLane *lane, double vehSide, double vehWidth, double oncomingGap, std::vector< const MSPerson *> *collectBlockers)
whether a pedestrian is blocking the crossing of lane for the given vehicle bondaries ...
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
void passedJunction(const MSVehicle *vehicle)
erase vehicle from myLinkLeaders
bool isExitLink() const
return whether the fromLane of this link is an internal lane and toLane is a normal lane ...
Representation of a vehicle.
bool opened(SUMOTime arrivalTime, double arrivalSpeed, double leaveSpeed, double vehicleLength, double impatience, double decel, SUMOTime waitingTime, double posLat=0, std::vector< const SUMOVehicle *> *collectFoes=0, bool ignoreRed=false, const SUMOVehicle *ego=0) const
Returns the information whether the link may be passed.
std::vector< MSLink * > mySublaneFoeLinks2
static bool unsafeMergeSpeeds(double leaderSpeed, double followerSpeed, double leaderDecel, double followerDecel)
return whether the given vehicles may NOT merge safely
static MSPModel * getModel()
double interpolateGeometryPosToLanePos(double geometryPos) const
ApproachingVehicleInformation getApproaching(const SUMOVehicle *veh) const
static const SUMOTime myLookaheadTimeZipper
static bool couldBrakeForLeader(double followDist, double leaderDist, const MSVehicle *follow, const MSVehicle *leader)
whether fllower could stay behind leader (possibly by braking)
bool isLeader(const MSVehicle *ego, const MSVehicle *foe, bool updateLeader=true) const
const std::set< MSTransportable * > & getPersons() const
Returns this edge's persons set.
void writeApproaching(OutputDevice &od, const std::string fromLaneID) const
write information about all approaching vehicles to the given output device
std::set< MSLink * > myBlockedFoeLinks
bool havePriority() const
Returns whether this link is a major link.
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic, in MSLink and GNEInternalLane.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
AnyVehicleIterator anyVehiclesEnd() const
end iterator for iterating over all vehicles touching this lane in downstream direction ...
The link is a (hard) right direction.
const MSLane * getInternalLaneBefore() const
return myInternalLaneBefore (always 0 when compiled without internal lanes)
AnyVehicleIterator anyVehiclesBegin() const
begin iterator for iterating over all vehicles touching this lane in downstream direction ...
double getLengthsBeforeCrossing(const MSLane *foeLane) const
Returns the sum of the lengths along internal lanes following this link to the crossing with the give...
std::vector< LinkLeader > LinkLeaders
std::vector< double > intersectsAtLengths2D(const PositionVector &other) const
For all intersections between this vector and other, return the 2D-length of the subvector from this ...
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
double getMinGap() const
Get the free space in front of vehicles of this class.
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
void initParallelLinks()
initialize parallel links (to be called after all links are loaded)
bool isInternal() const
return whether this edge is an internal edge
std::map< const SUMOVehicle *, ApproachingVehicleInformation, ComparatorIdLess > myApproachingVehicles
The link is a partial right direction.
const SUMOVTypeParameter & getParameter() const
double getLength() const
Returns the length of this link.
void move2side(double amount)
move position vector to side using certain ammount
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
bool isExitLinkAfterInternalJunction() const
return whether the fromLane of this link is an internal lane and its incoming lane is also an interna...
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
MSLink(MSLane *predLane, MSLane *succLane, MSLane *via, LinkDirection dir, LinkState state, double length, double foeVisibilityDistance, bool keepClear, MSTrafficLightLogic *logic, int tlLinkIdx)
Constructor for simulation which uses internal lanes.
static bool maybeOccupied(MSLane *lane)
returns whether the given lane may still be occupied by a vehicle currently on it ...
bool isLeader(const MSVehicle *ego, const MSVehicle *foe, bool updateLeader)
const MSLane * myWalkingAreaFoe
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
const MSTrafficLightLogic * myLogic
the controlling logic or 0
virtual Position getPosition() const
Return the Network coordinate of the transportable.
static MSLink * getConnectingLink(const MSLane &from, const MSLane &to)
Returns the link connecting both lanes Both lanes have to be non-internal; 0 may be returned if no co...
The link is controlled by a tls which is off and blinks, has to brake.
void passedJunction(const MSVehicle *vehicle) const
erase vehicle from myLinkLeaders of this links junction
const MSJunction * getFromJunction() const
MSLane * myLaneBefore
The lane approaching this link.
const std::map< const SUMOVehicle *, ApproachingVehicleInformation, ComparatorIdLess > & getApproaching() const
return all approaching vehicles
MSJunction * myJunction
the junction to which this link belongs
MSVehicle * getLastAnyVehicle() const
returns the last vehicle that is fully or partially on this lane
MSLane * getViaLaneOrLane() const
return the via lane if it exists and the lane otherwise
virtual double getLateralPositionOnLane() const =0
Get the vehicle's lateral position on the lane.
#define JM_CROSSING_GAP_DEFAULT
LinkLeaders getLeaderInfo(const MSVehicle *ego, double dist, std::vector< const MSPerson *> *collectBlockers=0, bool isShadowLink=false) const
Returns all potential link leaders (vehicles on foeLanes) Valid during the planMove() phase...
int getIndex() const
Returns the respond index (for visualization)
double getLength() const
Get vehicle's length [m].
static SUMOTime gIgnoreJunctionBlocker
const MSVehicleType & getVehicleType() const
double getBackPositionOnLane(const MSLane *lane) const
Get the vehicle's position relative to the given lane.
The parent class for traffic light logics.
Static storage of an output device and its base (abstract) implementation.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
MSLane *const myInternalLane
The following junction-internal lane if used.
static const double SAFETY_GAP
void removeApproaching(const SUMOVehicle *veh)
removes the vehicle from myApproachingVehicles
bool isStopped() const
Returns whether the vehicle is at a stop.
const double INVALID_DOUBLE
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
double getSpeed() const
Returns the vehicle's current speed.
virtual double followSpeed(const MSVehicle *const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle *const pred=0) const =0
Computes the vehicle's follow speed (no dawdling)
const std::string & getID() const
Returns the name of the vehicle.
Representation of a lane in the micro simulation.
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
virtual const std::string & getID() const =0
Get the vehicle's ID.
SumoXMLEdgeFunc getFunction() const
Returns the edge type (SumoXMLEdgeFunc)
bool haveRed() const
Returns whether this link is blocked by a red (or redyellow) traffic light.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
void setRequestInformation(int index, bool hasFoes, bool isCont, const std::vector< MSLink *> &foeLinks, const std::vector< MSLane *> &foeLanes, MSLane *internalLaneBefore=0)
Sets the request information.
std::vector< const MSLane * > myFoeLanes
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
MSLane * getParallelLane(int offset) const
Returns the lane with the given offset parallel to this one or 0 if it does not exist.
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...
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.