96#define DEBUG_COND (isSelected())
97#define DEBUG_COND2(obj) ((obj != nullptr && (obj)->isSelected()))
143 for (
auto p : persons) {
172 if (nextIsMyVehicles()) {
173 if (myI1 != myI1End) {
175 }
else if (myI3 != myI3End) {
189 if (nextIsMyVehicles()) {
190 if (myI1 != myI1End) {
191 return myLane->myVehicles[myI1];
192 }
else if (myI3 != myI3End) {
193 return myLane->myTmpVehicles[myI3];
195 assert(myI2 == myI2End);
199 return myLane->myPartialVehicles[myI2];
207 if (
DEBUG_COND2(myLane)) std::cout <<
SIMTIME <<
" AnyVehicleIterator::nextIsMyVehicles lane=" << myLane->getID()
209 <<
" myI1End=" << myI1End
211 <<
" myI2End=" << myI2End
213 <<
" myI3End=" << myI3End
216 if (myI1 == myI1End && myI3 == myI3End) {
217 if (myI2 != myI2End) {
223 if (myI2 == myI2End) {
226 MSVehicle* cand = myI1 == myI1End ? myLane->myTmpVehicles[myI3] : myLane->myVehicles[myI1];
229 <<
" veh1=" << cand->
getID()
230 <<
" isTmp=" << (myI1 == myI1End)
231 <<
" veh2=" << myLane->myPartialVehicles[myI2]->getID()
233 <<
" pos2=" << myLane->myPartialVehicles[myI2]->getPositionOnLane(myLane)
236 if (cand->
getPositionOnLane() < myLane->myPartialVehicles[myI2]->getPositionOnLane(myLane)) {
239 return !myDownstream;
251#pragma warning(disable: 4355)
257 int index,
bool isRampAccel,
258 const std::string& type,
289 mySimulationTask(*this, 0),
294 assert(
myRNGs.size() > 0);
296 if (outlineShape.size() > 0) {
364 veh->addReminder(rem);
377 veh->removeReminder(rem);
389 std::cout <<
SIMTIME <<
" setPartialOccupation. lane=" <<
getID() <<
" veh=" << v->
getID() <<
"\n";
409 std::cout <<
SIMTIME <<
" resetPartialOccupation. lane=" <<
getID() <<
" veh=" << v->
getID() <<
"\n";
429 std::cout <<
SIMTIME <<
" setManeuverReservation. lane=" <<
getID() <<
" veh=" << v->
getID() <<
"\n";
440 std::cout <<
SIMTIME <<
" resetManeuverReservation(): lane=" <<
getID() <<
" veh=" << v->
getID() <<
"\n";
485 if (leader ==
nullptr) {
490 leader = leaderInfo.first;
496 if (leader ==
nullptr) {
502 if (leaderBack >= frontGapNeeded) {
503 pos =
MIN2(pos, leaderBack - frontGapNeeded);
529 if (missingRearGap > 0) {
530 if (minPos + missingRearGap <= maxPos) {
537 return isInsertionSuccess(&veh, mspeed, minPos + missingRearGap, posLat,
true, notification);
548 const double speed = leader->
getSpeed();
550 if (leaderPos >= frontGapNeeded) {
560 MSLane::VehCont::iterator predIt =
myVehicles.begin();
571 double speed = mspeed;
572 if (leader !=
nullptr) {
577 double frontMax = maxPos;
578 if (leader !=
nullptr) {
581 frontMax =
MIN2(maxPos, leaderRearPos - frontGapNeeded);
589 if (frontMax > minPos && backMin + POSITION_EPS < frontMax) {
591 if (
isInsertionSuccess(&veh, speed, backMin + POSITION_EPS, posLat,
true, notification)) {
640 if (last !=
nullptr) {
692 bool patchSpeed =
true;
709 for (
int i = 0; i < 10; i++) {
764 for (
int i = 0; i < 10; i++) {
791#ifdef DEBUG_EXTRAPOLATE_DEPARTPOS
800 double dist = speed *
STEPS2TIME(relevantDelay);
802 if (leaderInfo.first !=
nullptr) {
806 dist =
MIN2(dist, leaderInfo.second - frontGapNeeded);
818 if (nspeed < speed) {
820 speed =
MIN2(nspeed, speed);
822 }
else if (speed > 0) {
829 if (emergencyBrakeGap <= dist) {
837 if (errorMsg !=
"") {
838 WRITE_ERRORF(
TL(
"Vehicle '%' will not be able to depart on lane '%' with speed % (%), time=%."),
851 double speed,
double pos,
double posLat,
bool patchSpeed,
856 WRITE_WARNINGF(
TL(
"Invalid departPos % given for vehicle '%', time=%. Inserting at lane end instead."),
861#ifdef DEBUG_INSERTION
863 std::cout <<
"\nIS_INSERTION_SUCCESS\n"
865 <<
" veh '" << aVehicle->
getID()
868 <<
" speed=" << speed
869 <<
" patchSpeed=" << patchSpeed
878 std::vector<MSLane*>::const_iterator ri = bestLaneConts.begin();
881 const bool isRail = aVehicle->
isRail();
888#ifdef DEBUG_INSERTION
893#ifdef DEBUG_INSERTION
895 std::cout <<
" foe of driveway " + dw->
getID() +
" has occupied edges " +
toString(occupied) <<
"\n";
901#ifdef DEBUG_INSERTION
908#ifdef DEBUG_INSERTION
910 std::cout <<
" bidi-lane occupied\n";
916 double backLength = aVehicle->
getLength() - pos;
920 while (backLength > 0 && bidi !=
nullptr) {
922#ifdef DEBUG_INSERTION
924 std::cout <<
" bidi-lane furtherLanes occupied\n";
931 bidi = pred ==
nullptr ? nullptr : pred->
getBidiLane();
935 MSLink* firstRailSignal =
nullptr;
936 double firstRailSignalDist = -1;
944 if (nextStop.
lane ==
this) {
945 std::stringstream msg;
946 double distToStop, safeSpeed;
948 msg <<
"scheduled waypoint on lane '" <<
myID <<
"' too close";
952 msg <<
"scheduled stop on lane '" <<
myID <<
"' too close";
969#ifdef DEBUG_INSERTION
971 std::cout <<
SIMTIME <<
" isInsertionSuccess lane=" <<
getID()
972 <<
" veh=" << aVehicle->
getID()
974 <<
" posLat=" << posLat
975 <<
" patchSpeed=" << patchSpeed
976 <<
" speed=" << speed
977 <<
" nspeed=" << nspeed
978 <<
" leaders=" << leaders.
toString()
979 <<
" failed (@700)!\n";
984#ifdef DEBUG_INSERTION
986 std::cout <<
SIMTIME <<
" speed = " << speed <<
" nspeed = " << nspeed <<
" leaders=" << leaders.
toString() <<
"\n";
993 MSLane* currentLane =
this;
996 while ((seen < dist || (isRail && firstRailSignal ==
nullptr)) && ri != bestLaneConts.end()) {
998 std::vector<MSLink*>::const_iterator link =
succLinkSec(*aVehicle, nRouteSuccs, *currentLane, bestLaneConts);
1030 if (isRail && firstRailSignal ==
nullptr) {
1031 std::string constraintInfo;
1032 bool isInsertionOrder;
1034 setParameter((isInsertionOrder ?
"insertionOrder" :
"insertionConstraint:")
1035 + aVehicle->
getID(), constraintInfo);
1036#ifdef DEBUG_INSERTION
1038 std::cout <<
" insertion constraint at link " << (*link)->getDescription() <<
" not cleared \n";
1046 if (firstRailSignal ==
nullptr && (*link)->
getTLLogic() !=
nullptr) {
1047 firstRailSignal = *link;
1048 firstRailSignalDist = seen;
1050 nextLane = (*link)->getViaLaneOrLane();
1052 cfModel.
getMaxDecel(), 0, posLat,
nullptr,
false, aVehicle)
1053 || (*link)->railSignalWasPassed()
1054 || !(*link)->havePriority()
1057 std::string errorMsg =
"";
1058 const LinkState state = (*link)->getState();
1064 errorMsg =
"unpriorised junction too close";
1065 }
else if ((*link)->getTLLogic() !=
nullptr && !(*link)->getTLLogic()->getsMajorGreen((*link)->getTLIndex())) {
1067 errorMsg =
"tlLogic '" + (*link)->getTLLogic()->
getID() +
"' link " +
toString((*link)->getTLIndex()) +
" never switches to 'G'";
1071 const double remaining = seen - laneStopOffset;
1075#ifdef DEBUG_INSERTION
1077 std::cout <<
SIMTIME <<
" isInsertionSuccess lane=" <<
getID()
1078 <<
" veh=" << aVehicle->
getID()
1079 <<
" patchSpeed=" << patchSpeed
1080 <<
" speed=" << speed
1081 <<
" remaining=" << remaining
1085 <<
" failed (@926)!\n";
1090#ifdef DEBUG_INSERTION
1092 std::cout <<
"trying insertion before minor link: "
1093 <<
"insertion speed = " << speed <<
" dist=" << dist
1102 bool dummyReq =
true;
1103#ifdef DEBUG_INSERTION
1105 std::cout <<
"checking linkLeader for lane '" << nextLane->
getID() <<
"'\n";
1109 double nSpeed = speed;
1111#ifdef DEBUG_INSERTION
1116#ifdef DEBUG_INSERTION
1118 std::cout <<
" linkLeader nSpeed=" << nSpeed <<
" failed (@1058)!\n";
1125 if (nextLane !=
nullptr) {
1130#ifdef DEBUG_INSERTION
1132 std::cout <<
" nextLane=" << nextLane->
getID() <<
" occupiedBidi\n";
1143 if (nextStop.
lane == nextLane) {
1144 std::stringstream msg;
1145 msg <<
"scheduled stop on lane '" << nextStop.
lane->
getID() <<
"' too close";
1146 const double distToStop = seen + nextStop.
pars.
endPos;
1158 const double nextLaneSpeed = nextLane->
safeInsertionSpeed(aVehicle, seen, nextLeaders, speed);
1159#ifdef DEBUG_INSERTION
1161 std::cout <<
SIMTIME <<
" leader on lane '" << nextLane->
getID() <<
"': " << nextLeaders.
toString() <<
" nspeed=" << nextLaneSpeed <<
"\n";
1166#ifdef DEBUG_INSERTION
1168 std::cout <<
" isInsertionSuccess lane=" <<
getID()
1169 <<
" veh=" << aVehicle->
getID()
1171 <<
" posLat=" << posLat
1172 <<
" patchSpeed=" << patchSpeed
1173 <<
" speed=" << speed
1174 <<
" nspeed=" << nextLaneSpeed
1175 <<
" nextLane=" << nextLane->
getID()
1176 <<
" lead=" << nextLeaders.
toString()
1177 <<
" failed (@641)!\n";
1188 if (freeSpeed < speed) {
1189 if (patchSpeedSpecial) {
1195 WRITE_WARNINGF(
TL(
"Vehicle '%' is inserted too fast and will violate the speed limit on a lane '%', time=%."),
1210 if ((*link)->hasApproachingFoe(arrivalTime, leaveTime, speed, cfModel.
getMaxDecel())) {
1218 currentLane = nextLane;
1219 if ((*link)->getViaLane() ==
nullptr) {
1228 for (
int i = 0; i < followers.
numSublanes(); ++i) {
1229 const MSVehicle* follower = followers[i].first;
1230 if (follower !=
nullptr) {
1232 if (followers[i].second < backGapNeeded
1236#ifdef DEBUG_INSERTION
1238 std::cout <<
SIMTIME <<
" isInsertionSuccess lane=" <<
getID()
1239 <<
" veh=" << aVehicle->
getID()
1241 <<
" posLat=" << posLat
1242 <<
" speed=" << speed
1243 <<
" nspeed=" << nspeed
1244 <<
" follower=" << follower->
getID()
1245 <<
" backGapNeeded=" << backGapNeeded
1246 <<
" gap=" << followers[i].second
1247 <<
" failure (@719)!\n";
1260#ifdef DEBUG_INSERTION
1265 if (shadowLane !=
nullptr) {
1267 for (
int i = 0; i < shadowFollowers.
numSublanes(); ++i) {
1268 const MSVehicle* follower = shadowFollowers[i].first;
1269 if (follower !=
nullptr) {
1271 if (shadowFollowers[i].second < backGapNeeded
1275#ifdef DEBUG_INSERTION
1278 <<
" isInsertionSuccess shadowlane=" << shadowLane->
getID()
1279 <<
" veh=" << aVehicle->
getID()
1281 <<
" posLat=" << posLat
1282 <<
" speed=" << speed
1283 <<
" nspeed=" << nspeed
1284 <<
" follower=" << follower->
getID()
1285 <<
" backGapNeeded=" << backGapNeeded
1286 <<
" gap=" << shadowFollowers[i].second
1287 <<
" failure (@812)!\n";
1297 if (veh !=
nullptr) {
1304#ifdef DEBUG_INSERTION
1307 <<
" isInsertionSuccess shadowlane=" << shadowLane->
getID()
1308 <<
" veh=" << aVehicle->
getID()
1310 <<
" posLat=" << posLat
1311 <<
" speed=" << speed
1312 <<
" nspeed=" << nspeed
1313 <<
" leader=" << veh->
getID()
1314 <<
" gapNeeded=" << gapNeeded
1316 <<
" failure (@842)!\n";
1328 if (missingRearGap > 0
1331#ifdef DEBUG_INSERTION
1334 <<
" isInsertionSuccess lane=" <<
getID()
1335 <<
" veh=" << aVehicle->
getID()
1337 <<
" posLat=" << posLat
1338 <<
" speed=" << speed
1339 <<
" nspeed=" << nspeed
1340 <<
" missingRearGap=" << missingRearGap
1341 <<
" failure (@728)!\n";
1348 speed =
MAX2(0.0, speed);
1352#ifdef DEBUG_INSERTION
1355 <<
" isInsertionSuccess lane=" <<
getID()
1356 <<
" veh=" << aVehicle->
getID()
1358 <<
" posLat=" << posLat
1359 <<
" speed=" << speed
1360 <<
" nspeed=" << nspeed
1361 <<
" failed (@733)!\n";
1368 if (extraReservation > 0) {
1369 std::stringstream msg;
1370 msg <<
"too many lane changes required on lane '" <<
myID <<
"'";
1373 if (distToStop >= 0) {
1375#ifdef DEBUG_INSERTION
1377 std::cout <<
"\nIS_INSERTION_SUCCESS\n"
1378 <<
SIMTIME <<
" veh=" << aVehicle->
getID() <<
" bestLaneOffset=" << bestLaneOffset <<
" bestLaneDist=" << aVehicle->
getBestLaneDist() <<
" extraReservation=" << extraReservation
1379 <<
" distToStop=" << distToStop <<
" v=" << speed <<
" v2=" << stopSpeed <<
"\n";
1391 return v->getPositionOnLane() >= pos;
1393#ifdef DEBUG_INSERTION
1396 <<
" isInsertionSuccess lane=" <<
getID()
1397 <<
" veh=" << aVehicle->
getID()
1399 <<
" posLat=" << posLat
1400 <<
" speed=" << speed
1401 <<
" nspeed=" << nspeed
1428 return v->getPositionOnLane() >= pos;
1435 double nspeed = speed;
1436#ifdef DEBUG_INSERTION
1438 std::cout <<
SIMTIME <<
" safeInsertionSpeed veh=" << veh->
getID() <<
" speed=" << speed <<
"\n";
1443 if (leader !=
nullptr) {
1450#ifdef DEBUG_INSERTION
1461 nspeed =
MIN2(nspeed,
1463#ifdef DEBUG_INSERTION
1465 std::cout <<
" leader=" << leader->
getID() <<
" bPos=" << leader->
getBackPositionOnLane(
this) <<
" gap=" << gap <<
" nspeed=" << nspeed <<
"\n";
1480 int freeSublanes = 1;
1485 while (freeSublanes > 0 && veh !=
nullptr) {
1486#ifdef DEBUG_PLAN_MOVE
1489 std::cout <<
" getLastVehicleInformation lane=" <<
getID() <<
" minPos=" << minPos <<
" veh=" << veh->
getID() <<
" pos=" << veh->
getPositionOnLane(
this) <<
"\n";
1494 freeSublanes = leaderTmp.
addLeader(veh,
true, vehLatOffset);
1495#ifdef DEBUG_PLAN_MOVE
1497 std::cout <<
" latOffset=" << vehLatOffset <<
" newLeaders=" << leaderTmp.
toString() <<
"\n";
1503 if (ego ==
nullptr && minPos == 0) {
1511#ifdef DEBUG_PLAN_MOVE
1540 int freeSublanes = 1;
1542 while (freeSublanes > 0 && veh !=
nullptr) {
1543#ifdef DEBUG_PLAN_MOVE
1545 std::cout <<
" veh=" << veh->
getID() <<
" pos=" << veh->
getPositionOnLane(
this) <<
" maxPos=" << maxPos <<
"\n";
1552#ifdef DEBUG_PLAN_MOVE
1554 std::cout <<
" veh=" << veh->
getID() <<
" latOffset=" << vehLatOffset <<
"\n";
1557 freeSublanes = followerTmp.
addLeader(veh,
true, vehLatOffset);
1561 if (ego ==
nullptr && maxPos == std::numeric_limits<double>::max()) {
1566#ifdef DEBUG_PLAN_MOVE
1589 double cumulatedVehLength = 0.;
1593 VehCont::reverse_iterator veh =
myVehicles.rbegin();
1596#ifdef DEBUG_PLAN_MOVE
1600 <<
" planMovements() lane=" <<
getID()
1608#ifdef DEBUG_PLAN_MOVE
1610 std::cout <<
" plan move for: " << (*veh)->getID();
1614#ifdef DEBUG_PLAN_MOVE
1616 std::cout <<
" leaders=" << leaders.
toString() <<
"\n";
1619 (*veh)->planMove(t, leaders, cumulatedVehLength);
1620 cumulatedVehLength += (*veh)->getVehicleType().getLengthWithGap();
1629 veh->setApproachingForAllLinks();
1638 bool nextToConsiderIsPartial;
1641 while (moreReservationsAhead || morePartialVehsAhead) {
1642 if ((!moreReservationsAhead || (*vehRes)->getPositionOnLane(
this) <= veh->
getPositionOnLane())
1643 && (!morePartialVehsAhead || (*vehPart)->getPositionOnLane(
this) <= veh->
getPositionOnLane())) {
1649 if (moreReservationsAhead && !morePartialVehsAhead) {
1650 nextToConsiderIsPartial =
false;
1651 }
else if (morePartialVehsAhead && !moreReservationsAhead) {
1652 nextToConsiderIsPartial =
true;
1654 assert(morePartialVehsAhead && moreReservationsAhead);
1656 nextToConsiderIsPartial = (*vehPart)->getPositionOnLane(
this) > (*vehRes)->getPositionOnLane(
this);
1659 if (nextToConsiderIsPartial) {
1660 const double latOffset = (*vehPart)->getLatOffset(
this);
1661#ifdef DEBUG_PLAN_MOVE
1663 std::cout <<
" partial ahead: " << (*vehPart)->getID() <<
" latOffset=" << latOffset <<
"\n";
1667 && !(*vehPart)->getLaneChangeModel().isChangingLanes())) {
1668 ahead.
addLeader(*vehPart,
false, latOffset);
1673 const double latOffset = (*vehRes)->getLatOffset(
this);
1674#ifdef DEBUG_PLAN_MOVE
1676 std::cout <<
" reservation ahead: " << (*vehRes)->getID() <<
" latOffset=" << latOffset <<
"\n";
1679 ahead.
addLeader(*vehRes,
false, latOffset);
1690#ifdef DEBUG_COLLISIONS
1692 std::vector<const MSVehicle*> all;
1694 all.push_back(*last);
1696 std::cout <<
SIMTIME <<
" detectCollisions stage=" << stage <<
" lane=" <<
getID() <<
":\n"
1699 <<
" all=" <<
toString(all) <<
"\n"
1708 std::set<const MSVehicle*, ComparatorNumericalIdLess> toRemove;
1709 std::set<const MSVehicle*, ComparatorNumericalIdLess> toTeleport;
1712#ifdef DEBUG_JUNCTION_COLLISIONS
1714 std::cout <<
SIMTIME <<
" detect junction Collisions stage=" << stage <<
" lane=" <<
getID() <<
":\n"
1721 const std::vector<const MSLane*>& foeLanes =
myLinks.front()->getFoeLanes();
1728 for (
const MSLane*
const foeLane : foeLanes) {
1729#ifdef DEBUG_JUNCTION_COLLISIONS
1731 std::cout <<
" foeLane " << foeLane->getID()
1732 <<
" foeVehs=" <<
toString(foeLane->myVehicles)
1733 <<
" foePart=" <<
toString(foeLane->myPartialVehicles) <<
"\n";
1738 const MSVehicle*
const victim = *it_veh;
1739 if (victim == collider) {
1743#ifdef DEBUG_JUNCTION_COLLISIONS
1746 <<
" bound=" << colliderBoundary <<
" foeBound=" << victim->
getBoundingBox()
1769 foeLane->handleCollisionBetween(timestep, stage, victim, collider, -1, 0, toRemove, toTeleport);
1778 if (
myLinks.front()->getWalkingAreaFoe() !=
nullptr) {
1781 if (
myLinks.front()->getWalkingAreaFoeExit() !=
nullptr) {
1789#ifdef DEBUG_PEDESTRIAN_COLLISIONS
1791 std::cout <<
SIMTIME <<
" detect pedestrian collisions stage=" << stage <<
" lane=" <<
getID() <<
"\n";
1805#ifdef DEBUG_PEDESTRIAN_COLLISIONS
1808 <<
" dist=" << leader.second <<
" jammed=" << (leader.first ==
nullptr ? false : leader.first->isJammed()) <<
"\n";
1811 if (leader.first != 0 && leader.second < length && !leader.first->isJammed()) {
1816 const double gap = leader.second - length;
1827 VehCont::reverse_iterator lastVeh =
myVehicles.rend() - 1;
1828 for (VehCont::reverse_iterator pred =
myVehicles.rbegin(); pred != lastVeh; ++pred) {
1829 VehCont::reverse_iterator veh = pred + 1;
1840 double high = (*veh)->getPositionOnLane(
this);
1841 double low = (*veh)->getBackPositionOnLane(
this);
1849 if (*veh == *veh2 && !(*veh)->isRail()) {
1852 if ((*veh)->getLane() == (*veh2)->getLane() ||
1853 (*veh)->getLane() == (*veh2)->getBackLane() ||
1854 (*veh)->getBackLane() == (*veh2)->getLane()) {
1858 double low2 =
myLength - (*veh2)->getPositionOnLane(bidiLane);
1859 double high2 =
myLength - (*veh2)->getBackPositionOnLane(bidiLane);
1865 if (!(high < low2 || high2 < low)) {
1866#ifdef DEBUG_COLLISIONS
1868 std::cout <<
SIMTIME <<
" bidi-collision veh=" << (*veh)->getID() <<
" bidiVeh=" << (*veh2)->getID()
1869 <<
" vehFurther=" <<
toString((*veh)->getFurtherLanes())
1870 <<
" high=" << high <<
" low=" << low <<
" high2=" << high2 <<
" low2=" << low2 <<
"\n";
1899 if (lead == follow) {
1914 for (std::set<const MSVehicle*, ComparatorNumericalIdLess>::iterator it = toRemove.begin(); it != toRemove.end(); ++it) {
1918 if (toTeleport.count(veh) > 0) {
1930 SUMOTime timestep,
const std::string& stage,
1931 std::set<const MSVehicle*, ComparatorNumericalIdLess>& toRemove,
1932 std::set<const MSVehicle*, ComparatorNumericalIdLess>& toTeleport) {
1934#ifdef DEBUG_PEDESTRIAN_COLLISIONS
1936 std::cout <<
SIMTIME <<
" detect pedestrian junction collisions stage=" << stage <<
" lane=" <<
getID() <<
" foeLane=" << foeLane->
getID() <<
"\n";
1940 for (std::vector<MSTransportable*>::const_iterator it_p = persons.begin(); it_p != persons.end(); ++it_p) {
1941#ifdef DEBUG_PEDESTRIAN_COLLISIONS
1943 std::cout <<
" collider=" << collider->
getID()
1944 <<
" ped=" << (*it_p)->getID()
1945 <<
" jammed=" << (*it_p)->isJammed()
1946 <<
" colliderBoundary=" << colliderBoundary
1947 <<
" pedBoundary=" << (*it_p)->getBoundingBox()
1951 if ((*it_p)->isJammed()) {
1954 if (colliderBoundary.
overlapsWith((*it_p)->getBoundingBox())
1956 std::string collisionType =
"junctionPedestrian";
1958 collisionType =
"crossing";
1960 collisionType =
"walkingarea";
1971 std::set<const MSVehicle*, ComparatorNumericalIdLess>& toRemove,
1972 std::set<const MSVehicle*, ComparatorNumericalIdLess>& toTeleport)
const {
1979 if (collider == victim) {
1985 const bool bothOpposite = victimOpposite && colliderOpposite;
2001 }
else if (colliderOpposite) {
2005#ifdef DEBUG_COLLISIONS
2008 <<
" thisLane=" <<
getID()
2009 <<
" collider=" << collider->
getID()
2010 <<
" victim=" << victim->
getID()
2011 <<
" colOpposite=" << colliderOpposite
2012 <<
" vicOpposite=" << victimOpposite
2015 <<
" colPos=" << colliderPos
2016 <<
" vicBack=" << victimBack
2020 <<
" minGapFactor=" << minGapFactor
2029 if (gap < -NUMERICAL_EPS) {
2034 if (latGap + NUMERICAL_EPS > 0) {
2040 double gapDelta = 0;
2041 const MSVehicle* otherLaneVeh = collider->
getLane() ==
this ? victim : collider;
2046 if (&cand->getEdge() == &
getEdge()) {
2047 gapDelta =
getLength() - cand->getLength();
2052 if (gap + gapDelta >= 0) {
2060 && victim->
getLane() !=
this) {
2064#ifdef DEBUG_COLLISIONS
2066 std::cout <<
SIMTIME <<
" detectedCollision gap=" << gap <<
" latGap=" << latGap <<
"\n";
2078 double gap,
double latGap, std::set<const MSVehicle*, ComparatorNumericalIdLess>& toRemove,
2079 std::set<const MSVehicle*, ComparatorNumericalIdLess>& toTeleport)
const {
2083 std::string collisionType;
2084 std::string collisionText;
2086 collisionType =
"frontal";
2087 collisionText =
TL(
"frontal collision");
2089 collisionType =
"side";
2090 collisionText =
TL(
"side collision");
2092 collisionType =
"junction";
2093 collisionText =
TL(
"junction collision");
2095 collisionType =
"collision";
2096 collisionText =
TL(
"collision");
2103 std::string prefix =
TLF(
"Vehicle '%'; % with vehicle '%", collider->
getID(), collisionText, victim->
getID());
2108 std::string dummyError;
2114 double victimSpeed = victim->
getSpeed();
2115 double colliderSpeed = collider->
getSpeed();
2118 if (collisionAngle < 45) {
2120 colliderSpeed =
MIN2(colliderSpeed, victimSpeed);
2121 }
else if (collisionAngle < 135) {
2160 prefix =
TLF(
"Teleporting vehicle '%'; % with vehicle '%", collider->
getID(), collisionText, victim->
getID());
2161 toRemove.insert(collider);
2162 toTeleport.insert(collider);
2165 prefix =
TLF(
"Removing % participants: vehicle '%', vehicle '%", collisionText, collider->
getID(), victim->
getID());
2166 bool removeCollider =
true;
2167 bool removeVictim =
true;
2171 toRemove.insert(victim);
2173 if (removeCollider) {
2174 toRemove.insert(collider);
2176 if (!removeVictim) {
2177 if (!removeCollider) {
2178 prefix =
TLF(
"Keeping remote-controlled % participants: vehicle '%', vehicle '%", collisionText, collider->
getID(), victim->
getID());
2180 prefix =
TLF(
"Removing % participant: vehicle '%', keeping remote-controlled vehicle '%", collisionText, collider->
getID(), victim->
getID());
2182 }
else if (!removeCollider) {
2183 prefix =
TLF(
"Keeping remote-controlled % participant: vehicle '%', removing vehicle '%", collisionText, collider->
getID(), victim->
getID());
2200#ifdef DEBUG_COLLISIONS
2202 toRemove.erase(collider);
2203 toTeleport.erase(collider);
2206 toRemove.erase(victim);
2207 toTeleport.erase(victim);
2215 double gap,
const std::string& collisionType,
2216 std::set<const MSVehicle*, ComparatorNumericalIdLess>& toRemove,
2217 std::set<const MSVehicle*, ComparatorNumericalIdLess>& toTeleport)
const {
2221 std::string prefix =
TLF(
"Vehicle '%'", collider->
getID());
2226 std::string dummyError;
2231 double colliderSpeed = collider->
getSpeed();
2232 const double victimStopPos = victim->
getEdgePos();
2250 prefix =
TLF(
"Teleporting vehicle '%' after", collider->
getID());
2251 toRemove.insert(collider);
2252 toTeleport.insert(collider);
2255 prefix =
TLF(
"Removing vehicle '%' after", collider->
getID());
2256 bool removeCollider =
true;
2258 if (!removeCollider) {
2259 prefix =
TLF(
"Keeping remote-controlled vehicle '%' after", collider->
getID());
2261 toRemove.insert(collider);
2272 WRITE_WARNING(prefix +
TLF(
" collision with person '%', lane='%', gap=%, time=%, stage=%.",
2275 WRITE_WARNING(prefix +
TLF(
" collision with person '%', lane='%', time=%, stage=%.",
2281#ifdef DEBUG_COLLISIONS
2283 toRemove.erase(collider);
2284 toTeleport.erase(collider);
2300 if (&further->getEdge() == victimBidi) {
2328#ifdef DEBUG_EXEC_MOVE
2330 std::cout <<
SIMTIME <<
" veh " << veh->
getID() <<
" has arrived." << std::endl;
2335 }
else if (target !=
nullptr && moved) {
2355 WRITE_WARNINGF(
TL(
"Removing vehicle '%' after breaking down, lane='%', time=%."),
2366 WRITE_WARNINGF(
TL(
"Teleporting vehicle '%'; beyond end of lane, target lane='%', time=%."),
2374 WRITE_WARNINGF(
TL(
"Removing vehicle '%' after earlier collision, lane='%', time=%."),
2379 WRITE_WARNINGF(
TL(
"Teleporting vehicle '%' after earlier collision, lane='%', time=%."),
2383 if (firstNotStopped ==
nullptr && !(*i)->
isStopped() && (*i)->getLane() ==
this) {
2384 firstNotStopped = *i;
2390 if (firstNotStopped ==
nullptr && !(*i)->
isStopped() && (*i)->getLane() ==
this) {
2391 firstNotStopped = *i;
2399 i = VehCont::reverse_iterator(
myVehicles.erase(i.base()));
2401 if (firstNotStopped !=
nullptr) {
2405 const bool wrongLane = !
appropriate(firstNotStopped);
2407 && firstNotStopped->
succEdge(1) !=
nullptr
2410 const bool r1 = ttt > 0 && firstNotStopped->
getWaitingTime() > ttt && !disconnected
2418 const bool r4 = !r1 && !r2 && !r3 && tttb > 0
2422 if (r1 || r2 || r3 || r4 || r5) {
2424 const bool minorLink = !wrongLane && (link !=
myLinks.end()) && !((*link)->havePriority());
2425 std::string reason = (wrongLane ?
" (wrong lane" : (minorLink ?
" (yield" :
" (jam"));
2432 reason =
" (blocked";
2434 WRITE_WARNINGF(
"Teleporting vehicle '%'; waited too long" + reason
2435 + (r2 ?
", highway" :
"")
2436 + (r3 ?
", disconnected" :
"")
2437 + (r4 ?
", bidi" :
"")
2438 + (r5 ?
", railSignal" :
"")
2442 }
else if (minorLink) {
2507 const MSLane* firstInternal =
this;
2509 while (pred !=
nullptr && pred->
isInternal()) {
2510 firstInternal = pred;
2514 return firstInternal;
2521 const DictType::iterator it =
myDict.lower_bound(
id);
2522 if (it ==
myDict.end() || it->first !=
id) {
2524 myDict.emplace_hint(it,
id, ptr);
2533 const DictType::iterator it =
myDict.find(
id);
2534 if (it ==
myDict.end()) {
2544 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
2553 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
2554 into.push_back((*i).first);
2559template<
class RTREE>
void
2561 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
2565 const float cmin[2] = {(float) b.
xmin(), (float) b.
ymin()};
2566 const float cmax[2] = {(float) b.
xmax(), (float) b.
ymax()};
2567 into.Insert(cmin, cmax, l);
2571template void MSLane::fill<NamedRTree>(
NamedRTree& into);
2592 return (link !=
myLinks.end());
2602 assert(veh->getLane() ==
this);
2616#ifdef DEBUG_VEHICLE_CONTAINER
2636 std::cout <<
"sortManeuverReservations on lane " <<
getID()
2731std::vector<MSLink*>::const_iterator
2733 const MSLane& succLinkSource,
const std::vector<MSLane*>& conts) {
2736 if (nRouteEdge ==
nullptr) {
2738 return succLinkSource.
myLinks.end();
2742 assert(succLinkSource.
myLinks.size() == 1);
2745 return succLinkSource.
myLinks.begin();
2756 if (nRouteSuccs < (
int)conts.size()) {
2758 for (std::vector<MSLink*>::const_iterator link = succLinkSource.
myLinks.begin(); link != succLinkSource.
myLinks.end(); ++link) {
2759 if ((*link)->getLane() !=
nullptr && (*link)->getLane()->myEdge == nRouteEdge
2760 && (*link)->getLane()->allowsVehicleClass(veh.
getVClass())
2761 && ((*link)->getViaLane() ==
nullptr || (*link)->getViaLane()->allowsVehicleClass(veh.
getVClass()))) {
2763 if ((*link)->getLane() == conts[nRouteSuccs]) {
2770 return succLinkSource.
myLinks.end();
2773#ifdef DEBUG_NO_CONNECTION
2775 WRITE_WARNING(
"Could not find connection between lane " + succLinkSource.
getID() +
" and lane " + conts[nRouteSuccs]->getID() +
2778 return succLinkSource.
myLinks.end();
2786 if ((internal && l->getViaLane() == target) || (!internal && l->getLane() == target)) {
2797 if (l->getLane() == target) {
2798 return l->getViaLane();
2810 const MSLane* internal =
this;
2812 assert(lane !=
nullptr);
2816 assert(lane !=
nullptr);
2829 while (first !=
nullptr) {
2870 assert(remVehicle->
getLane() ==
this);
2872 if (remVehicle == *it) {
2907 }
else if (!approachingEdge->
isInternal() && warnMultiCon) {
2910 WRITE_WARNINGF(
TL(
"Lane '%' is approached multiple times from edge '%'. This may cause collisions."),
2919 std::map<MSEdge*, std::vector<MSLane*> >::const_iterator i =
myApproachingLanes.find(edge);
2923 const std::vector<MSLane*>& lanes = (*i).second;
2924 return std::find(lanes.begin(), lanes.end(), lane) != lanes.end();
2935 const MSVehicle* v = followerInfo.first;
2950 return MIN2(maxSpeed * maxSpeed * 0.5 / minDecel,
2955std::pair<MSVehicle* const, double>
2956MSLane::getLeader(
const MSVehicle* veh,
const double vehPos,
const std::vector<MSLane*>& bestLaneConts,
double dist,
bool checkTmpVehicles)
const {
2964 if (checkTmpVehicles) {
2973 std::cout << std::setprecision(
gPrecision) <<
" getLeader lane=" <<
getID() <<
" ego=" << veh->
getID() <<
" egoPos=" << vehPos <<
" pred=" << pred->
getID() <<
" predPos=" << pred->
getPositionOnLane() <<
"\n";
2989 std::cout <<
" getLeader lane=" <<
getID() <<
" ego=" << veh->
getID() <<
" egoPos=" << vehPos
3006 if (bestLaneConts.size() > 0) {
3014 std::cout <<
" getLeader lane=" <<
getID() <<
" seen=" << seen <<
" dist=" << dist <<
"\n";
3018 return std::pair<MSVehicle* const, double>(
static_cast<MSVehicle*
>(
nullptr), -1);
3022 return std::make_pair(
static_cast<MSVehicle*
>(
nullptr), -1);
3027std::pair<MSVehicle* const, double>
3029 const std::vector<MSLane*>& bestLaneConts,
bool considerCrossingFoes)
const {
3032 std::cout <<
" getLeaderOnConsecutive lane=" <<
getID() <<
" ego=" << veh.
getID() <<
" seen=" << seen <<
" dist=" << dist <<
" conts=" <<
toString(bestLaneConts) <<
"\n";
3036 return std::make_pair(
static_cast<MSVehicle*
>(
nullptr), -1);
3051 return std::pair<MSVehicle* const, double>(pred, gap);
3059 const MSLane* nextLane =
this;
3063 std::vector<MSLink*>::const_iterator link =
succLinkSec(veh, view, *nextLane, bestLaneConts);
3069 if ((*link)->getLane() == nextEdge->
getLanes().front()) {
3078 std::cout <<
" cannot continue after nextLane=" << nextLane->
getID() <<
"\n";
3085 const bool laneChanging = veh.
getLane() !=
this;
3088 if (linkLeaders.size() > 0) {
3089 std::pair<MSVehicle*, double> result;
3090 double shortestGap = std::numeric_limits<double>::max();
3091 for (
auto ll : linkLeaders) {
3092 double gap = ll.vehAndGap.second;
3094 if (lVeh !=
nullptr) {
3101 <<
" isLeader=" << veh.
isLeader(*link, lVeh, ll.vehAndGap.second)
3102 <<
" gap=" << ll.vehAndGap.second
3103 <<
" gap+brakeing=" << gap
3108 if (!considerCrossingFoes && !ll.sameTarget()) {
3112 if (lVeh !=
nullptr && !laneChanging && !veh.
isLeader(*link, lVeh, ll.vehAndGap.second)) {
3115 if (gap < shortestGap) {
3120 ll.vehAndGap.second =
MAX2(seen - nextLane->
getLength(), ll.distToCrossing);
3122 result = ll.vehAndGap;
3125 if (shortestGap != std::numeric_limits<double>::max()) {
3128 std::cout <<
" found linkLeader after nextLane=" << nextLane->
getID() <<
"\n";
3135 bool nextInternal = (*link)->getViaLane() !=
nullptr;
3136 nextLane = (*link)->getViaLaneOrLane();
3137 if (nextLane ==
nullptr) {
3142 if (leader !=
nullptr) {
3145 std::cout <<
" found leader " << leader->
getID() <<
" on nextLane=" << nextLane->
getID() <<
"\n";
3150 return std::make_pair(leader, leaderDist);
3157 if (!nextInternal) {
3160 }
while (seen <= dist || nextLane->
isInternal());
3164 return std::make_pair(
static_cast<MSVehicle*
>(
nullptr), -1);
3168std::pair<MSVehicle* const, double>
3172 std::cout <<
SIMTIME <<
" getCriticalLeader. lane=" <<
getID() <<
" veh=" << veh.
getID() <<
"\n";
3176 std::pair<MSVehicle*, double> result = std::make_pair(
static_cast<MSVehicle*
>(
nullptr), -1);
3177 double safeSpeed = std::numeric_limits<double>::max();
3182 const MSLane* nextLane =
this;
3186 std::vector<MSLink*>::const_iterator link =
succLinkSec(veh, view, *nextLane, bestLaneConts);
3203 for (MSLink::LinkLeaders::const_iterator it = linkLeaders.begin(); it != linkLeaders.end(); ++it) {
3204 const MSVehicle* leader = (*it).vehAndGap.first;
3205 if (leader !=
nullptr && leader != result.first) {
3209 double tmpSpeed = safeSpeed;
3210 veh.
adaptToJunctionLeader((*it).vehAndGap, seen,
nullptr, nextLane, tmpSpeed, tmpSpeed, (*it).distToCrossing);
3213 std::cout <<
" linkLeader=" << leader->
getID() <<
" gap=" << result.second <<
" tmpSpeed=" << tmpSpeed <<
" safeSpeed=" << safeSpeed <<
"\n";
3216 if (tmpSpeed < safeSpeed) {
3217 safeSpeed = tmpSpeed;
3218 result = (*it).vehAndGap;
3222 bool nextInternal = (*link)->getViaLane() !=
nullptr;
3223 nextLane = (*link)->getViaLaneOrLane();
3224 if (nextLane ==
nullptr) {
3228 if (leader !=
nullptr && leader != result.first) {
3231 if (tmpSpeed < safeSpeed) {
3232 safeSpeed = tmpSpeed;
3233 result = std::make_pair(leader, gap);
3244 if (!nextInternal) {
3247 }
while (seen <= dist || nextLane->
isInternal());
3257 for (MSEdgeVector::iterator i = pred.begin(); i != pred.end();) {
3266 if (pred.size() != 0) {
3268 MSEdge* best = *pred.begin();
3300 if (&(cand.lane->getEdge()) == &fromEdge) {
3325#ifdef DEBUG_LANE_SORTER
3341 std::vector<MSLink*> candidateLinks =
myLinks;
3344 MSLane* best = (*candidateLinks.begin())->getViaLaneOrLane();
3345#ifdef DEBUG_LANE_SORTER
3346 std::cout <<
"\nBest successor lane for lane '" <<
myID <<
"': '" << best->
getID() <<
"'" << std::endl;
3356 if (pred ==
nullptr) {
3364const std::vector<std::pair<const MSLane*, const MSEdge*> >
3366 std::vector<std::pair<const MSLane*, const MSEdge*> > result;
3368 assert(link->getLane() !=
nullptr);
3369 result.push_back(std::make_pair(link->getLane(), link->getViaLane() ==
nullptr ?
nullptr : &link->getViaLane()->getEdge()));
3374std::vector<const MSLane*>
3376 std::vector<const MSLane*> result = {};
3378 for (std::vector<MSLane*>::const_iterator it_lane = (*it).second.begin(); it_lane != (*it).second.end(); ++it_lane) {
3379 if (!((*it_lane)->isInternal())) {
3380 result.push_back(*it_lane);
3404 for (std::vector<MSLink*>::const_iterator i =
myLinks.begin(); i !=
myLinks.end(); ++i) {
3405 if ((*i)->getLane()->isCrossing()) {
3406 return (
int)(i -
myLinks.begin());
3422 if (cand->getLane() == bidi) {
3423 sum += (brutto ? cand->getVehicleType().getLengthWithGap() : cand->getVehicleType().getLength());
3425 sum +=
myLength - cand->getBackPositionOnLane(
this);
3469 wtime += (*i)->getWaitingSeconds();
3484 v += veh->getSpeed();
3506 v += veh->getSpeed();
3525 if (vehs.size() == 0) {
3529 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
3530 double sv = (*i)->getHarmonoise_NoiseEmissions();
3531 ret += (double) pow(10., (sv / 10.));
3564 myLaneDir(e->getLanes()[0]->
getShape().angleAt2D(0)) {
3575 if (ae1 !=
nullptr && ae1->size() != 0) {
3585 if (ae2 !=
nullptr && ae2->size() != 0) {
3605 myLaneDir(targetLane->
getShape().angleAt2D(0)) {}
3623#ifdef DEBUG_LANE_SORTER
3624 std::cout <<
"\nincoming_lane_priority sorter()\n"
3625 <<
"noninternal predecessor for lane '" << laneInfo1.
lane->
getID()
3626 <<
"': '" << noninternal1->
getID() <<
"'\n"
3627 <<
"noninternal predecessor for lane '" << laneInfo2.
lane->
getID()
3628 <<
"': '" << noninternal2->
getID() <<
"'\n";
3636 bool priorized1 =
true;
3637 bool priorized2 =
true;
3639#ifdef DEBUG_LANE_SORTER
3640 std::cout <<
"FoeLinks of '" << noninternal1->
getID() <<
"'" << std::endl;
3643#ifdef DEBUG_LANE_SORTER
3644 std::cout << foeLink->getLaneBefore()->getID() << std::endl;
3646 if (foeLink == link2) {
3652#ifdef DEBUG_LANE_SORTER
3653 std::cout <<
"FoeLinks of '" << noninternal2->
getID() <<
"'" << std::endl;
3656#ifdef DEBUG_LANE_SORTER
3657 std::cout << foeLink->getLaneBefore()->getID() << std::endl;
3660 if (foeLink == link1) {
3668 if (priorized1 != priorized2) {
3682 myLaneDir(sourceLane->
getShape().angleAt2D(0)) {}
3688 if (target2 ==
nullptr) {
3691 if (target1 ==
nullptr) {
3695#ifdef DEBUG_LANE_SORTER
3696 std::cout <<
"\noutgoing_lane_priority sorter()\n"
3697 <<
"noninternal successors for lane '" << myLane->
getID()
3698 <<
"': '" << target1->
getID() <<
"' and "
3699 <<
"'" << target2->
getID() <<
"'\n";
3706 if (priority1 != priority2) {
3707 return priority1 > priority2;
3733 if (link->getApproaching().size() > 0) {
3742 const bool toRailJunction =
myLinks.size() > 0 && (
3745 const bool hasVehicles =
myVehicles.size() > 0;
3754 if (toRailJunction) {
3756 if (link->getApproaching().size() > 0) {
3759 for (
auto item : link->getApproaching()) {
3769 if (item.second.latOffset != 0) {
3840 bool allSublanes,
double searchDist,
MinorLinkMode mLinkMode)
const {
3849 std::cout <<
SIMTIME <<
" getFollowers lane=" <<
getID() <<
" ego=" << ego->
getID()
3850 <<
" backOffset=" << backOffset <<
" pos=" << egoPos
3851 <<
" allSub=" << allSublanes <<
" searchDist=" << searchDist <<
" ignoreMinor=" << mLinkMode
3852 <<
" egoLatDist=" << egoLatDist
3853 <<
" getOppositeLeaders=" << getOppositeLeaders
3869 std::cout <<
SIMTIME <<
" getFollowers lane=" <<
getID() <<
" ego=" << ego->
getID()
3895 std::cout <<
" (1) added veh=" << veh->
getID() <<
" latOffset=" << latOffset <<
" result=" << result.
toString() <<
"\n";
3902 std::cout <<
" result.numFreeSublanes=" << result.
numFreeSublanes() <<
"\n";
3910 if (searchDist == -1) {
3914 std::cout <<
" computed searchDist=" << searchDist <<
"\n";
3918 std::set<const MSEdge*> egoFurther;
3920 egoFurther.insert(&further->getEdge());
3933 std::vector<MSLane::IncomingLaneInfo> newFound;
3935 while (toExamine.size() != 0) {
3936 for (std::vector<MSLane::IncomingLaneInfo>::iterator it = toExamine.begin(); it != toExamine.end(); ++it) {
3937 MSLane* next = (*it).lane;
3943 std::cout <<
" next=" << next->
getID() <<
" seen=" << (*it).length <<
" first=" << first.
toString() <<
" firstFront=" << firstFront.
toString() <<
" backOffset=" << backOffset <<
"\n";
3947 if (backOffset + (*it).length - next->
getLength() < 0
3948 && egoFurther.count(&next->
getEdge()) != 0
3954 for (
const auto& ll : linkLeaders) {
3955 if (ll.vehAndGap.first !=
nullptr) {
3956 const bool bidiFoe = (*it).viaLink->getLane() == ll.vehAndGap.first->getLane()->getNormalPredecessorLane()->getBidiLane();
3957 const bool egoIsLeader = !bidiFoe && ll.vehAndGap.first->isLeader((*it).viaLink, ego, ll.vehAndGap.second);
3960 const double gap = (egoIsLeader
3961 ? -ll.vehAndGap.second - ll.vehAndGap.first->getVehicleType().getLengthWithGap() - ego->
getVehicleType().
getMinGap()
3966 std::cout <<
SIMTIME <<
" ego=" << ego->
getID() <<
" link=" << (*it).viaLink->getViaLaneOrLane()->getID()
3968 <<
" gap=" << ll.vehAndGap.second <<
" dtC=" << ll.distToCrossing
3969 <<
" bidiFoe=" << bidiFoe
3970 <<
" egoIsLeader=" << egoIsLeader <<
" gap2=" << gap
3984 const MSVehicle* v = first[i] == ego ? firstFront[i] : first[i];
3987 if (v !=
nullptr && v != ego) {
3994 agap = (*it).length - next->
getLength() + backOffset;
4001 std::cout <<
" agap1=" << agap <<
"\n";
4005 if (agap > 0 && differentEdge) {
4008 if (!getOppositeLeaders) {
4013 if (v !=
nullptr && v != ego) {
4019 }
else if (differentEdge && result.
hasVehicle(v)) {
4029 if (!(*it).viaLink->havePriority() && egoFurther.count(&(*it).lane->getEdge()) == 0
4035 agap =
MAX2(agap, 0.0);
4046 if ((*it).length < searchDist) {
4047 const std::vector<MSLane::IncomingLaneInfo>& followers = next->
getIncomingLanes();
4048 for (std::vector<MSLane::IncomingLaneInfo>::const_iterator j = followers.begin(); j != followers.end(); ++j) {
4049 if (visited.find((*j).lane) == visited.end() && (((*j).viaLink->havePriority() && !(*j).viaLink->isTurnaround())
4052 visited.insert((*j).lane);
4054 ili.
lane = (*j).lane;
4055 ili.
length = (*j).length + (*it).length;
4057 newFound.push_back(ili);
4063 swap(newFound, toExamine);
4075 bool oppositeDirection)
const {
4094 const MSLane* nextLane =
this;
4099 bool nextInternal =
false;
4100 if (oppositeDirection) {
4101 if (view >= (
int)bestLaneConts.size()) {
4104 nextLane = bestLaneConts[view];
4106 std::vector<MSLink*>::const_iterator link =
succLinkSec(*ego, view, *nextLane, bestLaneConts);
4112 if (linkLeaders.size() > 0) {
4122 std::cout <<
" linkleader=" << veh->
getID() <<
" gap=" << ll.
vehAndGap.second <<
" leaderOffset=" << ll.
latOffset <<
" flags=" << ll.
llFlags <<
"\n";
4139 nextInternal = (*link)->getViaLane() !=
nullptr;
4140 nextLane = (*link)->getViaLaneOrLane();
4141 if (nextLane ==
nullptr) {
4149 std::cout <<
SIMTIME <<
" getLeadersOnConsecutive lane=" <<
getID() <<
" nextLane=" << nextLane->
getID() <<
" leaders=" << leaders.
toString() <<
"\n";
4154 for (
int i = 0; i < iMax; ++i) {
4156 if (veh !=
nullptr) {
4173 if (!nextInternal) {
4187#ifdef DEBUG_SURROUNDING
4189 std::cout <<
" addLeaders lane=" <<
getID() <<
" veh=" << vehicle->
getID() <<
" vehPos=" << vehPos <<
" opposite=" << opposite <<
"\n";
4193 for (
int i = 0; i < aheadSamePos.
numSublanes(); ++i) {
4195 if (veh !=
nullptr && veh != vehicle) {
4197#ifdef DEBUG_SURROUNDING
4208 double speed = vehicle->
getSpeed();
4216#ifdef DEBUG_SURROUNDING
4218 std::cout <<
" aborting forward search. dist=" << dist <<
" seen=" << seen <<
"\n";
4223#ifdef DEBUG_SURROUNDING
4225 std::cout <<
" add consecutive before=" << result.
toString() <<
" seen=" << seen <<
" dist=" << dist;
4230#ifdef DEBUG_SURROUNDING
4232 std::cout <<
" upstreamOpposite=" <<
toString(bestLaneConts);
4240#ifdef DEBUG_SURROUNDING
4242 std::cout <<
" after=" << result.
toString() <<
"\n";
4258 std::cout <<
SIMTIME <<
" getPartialBehind lane=" <<
getID() <<
" ego=" << ego->
getID() <<
" found=" << veh->
getID() <<
"\n";
4289 assert(checkedLanes !=
nullptr);
4290 if (checkedLanes->find(
this) != checkedLanes->end()) {
4291#ifdef DEBUG_SURROUNDING
4292 std::cout <<
"Skipping previously scanned lane: " <<
getID() << std::endl;
4294 return std::set<MSVehicle*>();
4297 (*checkedLanes)[
this] = std::make_pair(
MAX2(0.0, startPos - upstreamDist),
MIN2(startPos + downstreamDist,
getLength()));
4299#ifdef DEBUG_SURROUNDING
4300 std::cout <<
"Scanning on lane " <<
myID <<
"(downstr. " << downstreamDist <<
", upstr. " << upstreamDist <<
", startPos " << startPos <<
"): " << std::endl;
4303 if (startPos < upstreamDist) {
4306 MSLane* incoming = incomingInfo.lane;
4307#ifdef DEBUG_SURROUNDING
4308 std::cout <<
"Checking on incoming: " << incoming->
getID() << std::endl;
4309 if (checkedLanes->find(incoming) != checkedLanes->end()) {
4310 std::cout <<
"Skipping previous: " << incoming->
getID() << std::endl;
4314 foundVehicles.insert(newVehs.begin(), newVehs.end());
4318 if (
getLength() < startPos + downstreamDist) {
4322#ifdef DEBUG_SURROUNDING
4323 std::cout <<
"Checking on outgoing: " << l->getViaLaneOrLane()->getID() << std::endl;
4325 std::set<MSVehicle*> newVehs = l->getViaLaneOrLane()->getSurroundingVehicles(0.0, downstreamDist - (
myLength - startPos), upstreamDist, checkedLanes);
4326 foundVehicles.insert(newVehs.begin(), newVehs.end());
4329#ifdef DEBUG_SURROUNDING
4330 std::cout <<
"On lane (2) " <<
myID <<
": \nFound vehicles: " << std::endl;
4332 std::cout << v->getID() <<
" pos = " << v->getPositionOnLane() << std::endl;
4335 return foundVehicles;
4341 std::set<MSVehicle*> res;
4344 if (!vehs.empty()) {
4346 if (veh->getPositionOnLane() >= a) {
4347 if (veh->getBackPositionOnLane() > b) {
4359std::vector<const MSJunction*>
4362 std::vector<const MSJunction*> junctions;
4364 junctions.insert(junctions.end(), l->getJunction());
4370std::vector<const MSLink*>
4372#ifdef DEBUG_SURROUNDING
4373 std::cout <<
"getUpcoming links on lane '" <<
getID() <<
"' with pos=" << pos
4374 <<
" range=" << range << std::endl;
4377 std::vector<const MSLink*> links;
4380 const MSLane* lane =
this;
4383 std::vector<MSLane*>::const_iterator contLanesIt = contLanes.begin();
4387 const MSLink* link =
nullptr;
4389 assert(*contLanesIt ==
nullptr);
4391 links.insert(links.end(), link);
4396 assert(*(contLanesIt + 1) == lane);
4398 while (++contLanesIt != contLanes.end()) {
4402#ifdef DEBUG_SURROUNDING
4403 std::cout <<
"Distance until end of lane '" << lane->
getID() <<
"' is " << dist <<
"." << std::endl;
4409 if (link !=
nullptr) {
4410 links.insert(links.end(), link);
4412 lane = *contLanesIt;
4435std::pair<MSVehicle* const, double>
4442 std::cout <<
" getFollower lane=" <<
getID() <<
" egoPos=" << egoPos <<
" pred=" << pred->
getID() <<
" predPos=" << pred->
getPositionOnLane(
this) <<
"\n";
4450 if (dist > 0 && backOffset > dist) {
4451 return std::make_pair(
nullptr, -1);
4455 return std::make_pair(
const_cast<MSVehicle*
>(result.first), result.second);
4458std::pair<MSVehicle* const, double>
4460#ifdef DEBUG_OPPOSITE
4462 <<
" ego=" << ego->
getID()
4466 <<
" oppositeDir=" << oppositeDir
4474 std::pair<MSVehicle* const, double> result =
getFollower(ego, egoPos + egoLength, dist, mLinkMode);
4475 if (result.first !=
nullptr) {
4477 if (result.first->getLaneChangeModel().isOpposite()) {
4478 result.second -= result.first->getVehicleType().getLength();
4486std::pair<MSVehicle* const, double>
4488#ifdef DEBUG_OPPOSITE
4490 <<
" ego=" << ego->
getID()
4500 std::pair<MSVehicle*, double> result =
getLeader(ego, vehPos, std::vector<MSLane*>());
4503 while (result.first ==
nullptr && dist > 0) {
4508 if (next ==
nullptr) {
4512 result = next->
getLeader(ego, vehPos, std::vector<MSLane*>());
4514 if (result.first !=
nullptr) {
4515 if (result.first->getLaneChangeModel().isOpposite()) {
4516 result.second -= result.first->getVehicleType().getLength();
4518 if (result.second > POSITION_EPS) {
4520 return std::make_pair(
static_cast<MSVehicle*
>(
nullptr), -1);
4530 const std::string action = oc.
getString(option);
4531 if (action ==
"none") {
4533 }
else if (action ==
"warn") {
4535 }
else if (action ==
"teleport") {
4537 }
else if (action ==
"remove") {
4618#ifdef DEBUG_INSERTION
4620 std::cout <<
SIMTIME <<
" check for pedestrians on lane=" <<
getID() <<
" pos=" << pos <<
"\n";
4625 if (leader.first != 0) {
4631#ifdef DEBUG_INSERTION
4633 <<
" isInsertionSuccess lane=" <<
getID()
4634 <<
" veh=" << aVehicle->
getID()
4637 <<
" patchSpeed=" << patchSpeed
4638 <<
" speed=" << speed
4639 <<
" stopSpeed=" << stopSpeed
4640 <<
" pedestrianLeader=" << leader.first->getID()
4641 <<
" failed (@796)!\n";
4647 double backLength = aVehicle->
getLength() - pos;
4651 const MSLane* cur =
this;
4652 while (backLength > 0 && prev !=
nullptr) {
4656 if (foe->isCrossing() && (foe->hasPedestrians() ||
4657 (foe->getIncomingLanes()[0].viaLink->getApproachingPersons() !=
nullptr
4658 && foe->getIncomingLanes()[0].viaLink->getApproachingPersons()->size() > 0))) {
4659#ifdef DEBUG_INSERTION
4661 <<
" isInsertionSuccess lane=" <<
getID()
4662 <<
" veh=" << aVehicle->
getID()
4664 <<
" backCrossing=" << foe->getID()
4666 <<
" approaching=" << foe->getIncomingLanes()[0].viaLink->getApproachingPersons()->size()
4667 <<
" failed (@4550)!\n";
4685 const int numRNGs = oc.
getInt(
"thread-rngs");
4686 const bool random = oc.
getBool(
"random");
4687 int seed = oc.
getInt(
"seed");
4689 for (
int i = 0; i < numRNGs; i++) {
4723 myLinks.front()->getFoeLanes().size() > 0
4724 ||
myLinks.front()->getWalkingAreaFoe() !=
nullptr
4725 ||
myLinks.front()->getWalkingAreaFoeExit() !=
nullptr);
4738 foundStopped =
true;
4739 const double lastBrakeGap = last->getCarFollowModel().brakeGap(last->getSpeed());
4740 const double ret = last->getBackPositionOnLane() + lastBrakeGap - lengths;
4744 lengths += last->getVehicleType().getLengthWithGap() * (last->getVehicleType().getWidth() + last->getVehicleType().getMinGapLat()) /
getWidth();
4746 lengths += last->getVehicleType().getLengthWithGap();
std::vector< MSEdge * > MSEdgeVector
std::pair< const MSVehicle *, double > CLeaderDist
std::pair< const MSPerson *, double > PersonDist
ConstMSEdgeVector::const_iterator MSRouteIterator
#define WRITE_WARNINGF(...)
#define WRITE_ERRORF(...)
#define WRITE_WARNING(msg)
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
const SVCPermissions SVCAll
all VClasses are allowed
bool isRailway(SVCPermissions permissions)
Returns whether an edge with the given permissions is a (exclusive) railway edge.
bool isRailwayOrShared(SVCPermissions permissions)
Returns whether an edge with the given permissions is a railway edge or a shared road/rail edge.
long long int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
@ AIRCRAFT
render as aircraft
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_SHIP
is an arbitrary ship
@ SVC_RAIL_CLASSES
classes which drive on tracks
@ SVC_BICYCLE
vehicle is a bicycle
const int STOP_DURATION_SET
@ GIVEN
The speed is given.
@ RANDOM
The lateral position is chosen randomly.
@ RIGHT
At the rightmost side of the lane.
@ GIVEN
The position is given.
@ DEFAULT
No information given; use default.
@ LEFT
At the leftmost side of the lane.
@ FREE
A free lateral position is chosen.
@ CENTER
At the center of the lane.
@ RANDOM_FREE
If a fixed number of random choices fails, a free lateral position is chosen.
@ RANDOM
A random position is chosen.
@ GIVEN
The position is given.
@ DEFAULT
No information given; use default.
@ STOP
depart position is endPos of first stop
@ FREE
A free position is chosen.
@ SPLIT_FRONT
depart position for a split vehicle is in front of the continuing vehicle
@ BASE
Back-at-zero position.
@ LAST
Insert behind the last vehicle as close as possible to still allow the specified departSpeed....
@ RANDOM_FREE
If a fixed number of random choices fails, a free position is chosen.
DepartSpeedDefinition
Possible ways to choose the departure speed.
@ RANDOM
The speed is chosen randomly.
@ MAX
The maximum safe speed is used.
@ GIVEN
The speed is given.
@ LIMIT
The maximum lane speed is used (speedLimit)
@ DEFAULT
No information given; use default.
@ DESIRED
The maximum lane speed is used (speedLimit * speedFactor)
@ LAST
The speed of the last vehicle. Fallback to DepartSpeedDefinition::DESIRED if there is no vehicle on t...
@ AVG
The average speed on the lane. Fallback to DepartSpeedDefinition::DESIRED if there is no vehicle on t...
@ SPLIT
The departure is triggered by a train split.
InsertionCheck
different checking levels for vehicle insertion
@ SUMO_TAG_LINK
Link information for state-saving.
@ SUMO_TAG_APPROACHING
Link-approaching vehicle information for state-saving.
@ SUMO_TAG_VIEWSETTINGS_VEHICLES
@ SUMO_TAG_LANE
begin/end of the description of a single lane
@ STRAIGHT
The link is a straight 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_MAJOR
This is an uncontrolled, major link, may pass.
@ LINKSTATE_STOP
This is an uncontrolled, minor link, has to stop.
@ LINKSTATE_EQUAL
This is an uncontrolled, right-before-left link.
@ LINKSTATE_DEADEND
This is a dead end link.
@ LINKSTATE_ZIPPER
This is an uncontrolled, zipper-merge link.
@ LINKSTATE_MINOR
This is an uncontrolled, minor link, has to brake.
@ SUMO_ATTR_JM_STOPLINE_CROSSING_GAP
@ SUMO_ATTR_ARRIVALSPEEDBRAKING
@ SUMO_ATTR_STATE
The state of a link.
int gPrecision
the precision for floating point outputs
double roundDecimal(double x, int precision)
round to the given number of decimal digits
bool gDebugFlag1
global utility flags for debugging
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
std::string joinNamedToString(const std::set< T *, C > &ns, const T_BETWEEN &between)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
A class that stores a 2D geometrical boundary.
double ymin() const
Returns minimum y-coordinate.
double xmin() const
Returns minimum x-coordinate.
Boundary & grow(double by)
extends the boundary by the given amount
double ymax() const
Returns maximum y-coordinate.
double xmax() const
Returns maximum x-coordinate.
static double angleDiff(const double angle1, const double angle2)
Returns the difference of the second angle to the first angle in radiants.
static double sum(double val)
Computes the resulting noise.
MESegment * getSegmentForEdge(const MSEdge &e, double pos=0)
Get the segment for a given edge at a given position.
A single mesoscopic segment (cell)
void setSpeed(double newSpeed, SUMOTime currentTime, double jamThresh=DO_NOT_PATCH_JAM_THRESHOLD, int qIdx=-1)
reset mySpeed and patch the speed of all vehicles in it. Also set/recompute myJamThreshold
MESegment * getNextSegment() const
Returns the following segment on the same edge (0 if it is the last).
Container & getContainer()
virtual double getExtraReservation(int bestLaneOffset, double neighExtraDist=0) const
bool hasBlueLight() const
MSLane * getShadowLane() const
Returns the lane the vehicle's shadow is on during continuous/sublane lane change.
bool isChangingLanes() const
return true if the vehicle currently performs a lane change maneuver
The base class for microscopic and mesoscopic vehicles.
double getImpatience() const
Returns this vehicles impatience.
const MSEdge * succEdge(int nSuccs) const
Returns the nSuccs'th successor of edge the vehicle is currently at.
virtual double getArrivalPos() const
Returns this vehicle's desired arrivalPos for its current route (may change on reroute)
int getInsertionChecks() const
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
double getChosenSpeedFactor() const
Returns the precomputed factor by which the driver wants to be faster than the speed limit.
const SUMOVehicleParameter::Stop * getNextStopParameter() const
return parameters for the next stop (SUMOVehicle Interface)
bool isJumping() const
Returns whether the vehicle is perform a jump.
const MSRouteIterator & getCurrentRouteEdge() const
Returns an iterator pointing to the current edge in this vehicles route.
double getLength() const
Returns the vehicle's length.
bool isParking() const
Returns whether the vehicle is parking.
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
bool hasDeparted() const
Returns whether this vehicle has already departed.
double basePos(const MSEdge *edge) const
departure position where the vehicle fits fully onto the edge (if possible)
bool hasStops() const
Returns whether the vehicle has to stop somewhere.
const MSStop & getNextStop() const
SUMOVehicleClass getVClass() const
Returns the vehicle's access class.
NumericalID getNumericalID() const
return the numerical ID which is only for internal usage
const MSRoute & getRoute() const
Returns the current route.
int getRoutePosition() const
return index of edge within route
SUMOTime getDepartDelay() const
Returns the depart delay.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
bool isStopped() const
Returns whether the vehicle is at a stop.
MSDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists, nullptr otherwise.
The car-following model abstraction.
double getCollisionMinGapFactor() const
Get the factor of minGap that must be maintained to avoid a collision event.
double getEmergencyDecel() const
Get the vehicle type's maximal physically possible deceleration [m/s^2].
virtual double freeSpeed(const MSVehicle *const veh, double speed, double seen, double maxSpeed, const bool onInsertion=false, const CalcReason usage=CalcReason::CURRENT) const
Computes the vehicle's safe speed without a leader.
virtual double insertionFollowSpeed(const MSVehicle *const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle *const pred=0) const
Computes the vehicle's safe speed (no dawdling) This method is used during the insertion stage....
@ FUTURE
the return value is used for calculating future speeds
virtual double getSecureGap(const MSVehicle *const veh, const MSVehicle *const, const double speed, const double leaderSpeed, const double leaderMaxDecel) const
Returns the minimum gap to reserve if the leader is braking at maximum (>=0)
double brakeGap(const double speed) const
Returns the distance the vehicle needs to halt including driver's reaction time tau (i....
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
double stopSpeed(const MSVehicle *const veh, const double speed, double gap, const CalcReason usage=CalcReason::CURRENT) const
Computes the vehicle's safe speed for approaching a non-moving obstacle (no dawdling)
virtual double insertionStopSpeed(const MSVehicle *const veh, double speed, double gap) const
Computes the vehicle's safe speed for approaching an obstacle at insertion without constraints due to...
std::string toString() const
print a debugging representation
int addFollower(const MSVehicle *veh, const MSVehicle *ego, double gap, double latOffset=0, int sublane=-1)
A device which collects info on the vehicle trip (mainly on departure and arrival)
static const MSDriveWay * getDepartureDriveway(const SUMOVehicle *veh, bool init=false)
bool foeDriveWayOccupied(bool store, const SUMOVehicle *ego, MSEdgeVector &occupied) const
whether any of myFoes is occupied (vehicles that are the target of a join must be ignored)
void gotActive(MSLane *l)
Informs the control that the given lane got active.
void checkCollisionForInactive(MSLane *l)
trigger collision checking for inactive lane
void needsVehicleIntegration(MSLane *const l)
A road/street connecting two junctions.
void changeLanes(SUMOTime t) const
Performs lane changing on this edge.
bool isCrossing() const
return whether this edge is a pedestrian crossing
int getPriority() const
Returns the priority of the edge.
const std::set< MSTransportable *, ComparatorNumericalIdLess > & getPersons() const
Returns this edge's persons set.
bool isWalkingArea() const
return whether this edge is walking area
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
const MSEdge * getNormalSuccessor() const
if this edge is an internal edge, return its first normal successor, otherwise the edge itself
const std::vector< MSLane * > * allowedLanes(const MSEdge &destination, SUMOVehicleClass vclass=SVC_IGNORING, bool ignoreTransientPermissions=false) const
Get the allowed lanes to reach the destination-edge.
const MSEdge * getBidiEdge() const
return opposite superposable/congruent edge, if it exist and 0 else
bool isNormal() const
return whether this edge is an internal edge
std::vector< MSTransportable * > getSortedPersons(SUMOTime timestep, bool includeRiding=false) const
Returns this edge's persons sorted by pos.
void recalcCache()
Recalculates the cached values.
bool hasLaneChanger() const
const MSJunction * getToJunction() const
const MSJunction * getFromJunction() const
bool isInternal() const
return whether this edge is an internal edge
bool isVaporizing() const
Returns whether vehicles on this edge shall be vaporized.
MSLane * parallelLane(const MSLane *const lane, int offset, bool includeOpposite=true) const
Returns the lane with the given offset parallel to the given lane one or 0 if it does not exist.
const std::string & getEdgeType() const
Returns the type of the edge.
const MSEdgeVector & getPredecessors() const
static SUMOTime gTimeToTeleportDisconnected
static SUMOTime gTimeToGridlockHighways
static double gGridlockHighwaysSpeed
static bool gRemoveGridlocked
static SUMOTime gTimeToTeleportBidi
static MELoop * gMesoNet
mesoscopic simulation infrastructure
static double gLateralResolution
static SUMOTime gTimeToTeleportRSDeadlock
static bool gClearState
whether the simulation is in the process of clearing state (MSNet::clearState)
static bool gComputeLC
whether the simulationLoop is in the lane changing phase
static bool gEmergencyInsert
static int gNumSimThreads
how many threads to use for simulation
static SUMOTime gIgnoreJunctionBlocker
static bool gSublane
whether sublane simulation is enabled (sublane model or continuous lanechanging)
static SUMOTime gLaneChangeDuration
static bool gUnitTests
whether unit tests are being run
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
static SUMOTime gTimeToGridlock
void retractDescheduleDeparture(const SUMOVehicle *veh)
reverts a previous call to descheduleDeparture (only needed for departPos="random_free")
void descheduleDeparture(const SUMOVehicle *veh)
stops trying to emit the given vehicle (and delete it)
The base class for an intersection.
SumoXMLNodeType getType() const
return the type of this Junction
AnyVehicleIterator is a structure, which manages the iteration through all vehicles on the lane,...
bool nextIsMyVehicles() const
AnyVehicleIterator & operator++()
const MSVehicle * operator*()
void add(const MSLane *const l) const
Adds the given object to the container.
std::set< const Named * > & myObjects
The container.
const PositionVector & myShape
Sorts edges by their angle relative to the given edge (straight comes first)
by_connections_to_sorter(const MSEdge *const e)
constructor
int operator()(const MSEdge *const e1, const MSEdge *const e2) const
comparing operator
Sorts lanes (IncomingLaneInfos) by their priority or, if this doesn't apply, wrt. the angle differenc...
incoming_lane_priority_sorter(const MSLane *targetLane)
constructor
int operator()(const IncomingLaneInfo &lane1, const IncomingLaneInfo &lane2) const
comparing operator
Sorts lanes (their origin link) by the priority of their noninternal target edges or,...
outgoing_lane_priority_sorter(const MSLane *sourceLane)
constructor
int operator()(const MSLink *link1, const MSLink *link2) const
comparing operator
int operator()(MSVehicle *v1, MSVehicle *v2) const
Comparing operator.
Sorts vehicles by their position (descending)
int operator()(MSVehicle *v1, MSVehicle *v2) const
Comparing operator.
Representation of a lane in the micro simulation.
void addApproachingLane(MSLane *lane, bool warnMultiCon)
void loadState(const std::vector< SUMOVehicle * > &vehs)
Loads the state of this segment with the given parameters.
bool detectCollisionBetween(SUMOTime timestep, const std::string &stage, MSVehicle *collider, MSVehicle *victim, std::set< const MSVehicle *, ComparatorNumericalIdLess > &toRemove, std::set< const MSVehicle *, ComparatorNumericalIdLess > &toTeleport) const
detect whether there is a collision between the two vehicles
static SUMOTime myIntermodalCollisionStopTime
MFXSynchQue< MSVehicle *, std::vector< MSVehicle * > > myVehBuffer
Buffer for vehicles that moved from their previous lane onto this one. Integrated after all vehicles ...
SVCPermissions myPermissions
The vClass permissions for this lane.
MSLane * myLogicalPredecessorLane
static void initCollisionAction(const OptionsCont &oc, const std::string &option, CollisionAction &myAction)
std::set< const MSBaseVehicle * > myParkingVehicles
bool checkForPedestrians(const MSVehicle *aVehicle, double &speed, double &dist, double pos, bool patchSpeed) const
check whether pedestrians on this lane interfere with vehicle insertion
std::pair< MSVehicle *const, double > getFollower(const MSVehicle *ego, double egoPos, double dist, MinorLinkMode mLinkMode) const
Find follower vehicle for the given ego vehicle (which may be on the opposite direction lane)
static double myDefaultDepartSpeed
std::pair< const MSPerson *, double > nextBlocking(double minPos, double minRight, double maxLeft, double stopTime=0, bool bidi=false) const
This is just a wrapper around MSPModel::nextBlocking. You should always check using hasPedestrians be...
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.
double myRightSideOnEdge
the combined width of all lanes with lower index on myEdge
const StopOffset & getLaneStopOffsets() const
Returns vehicle class specific stopOffsets.
virtual void removeParking(MSBaseVehicle *veh)
remove parking vehicle. This must be syncrhonized when running with GUI
virtual ~MSLane()
Destructor.
bool insertVehicle(MSVehicle &v)
Tries to insert the given vehicle.
bool mySpeedModified
Whether the current speed limit is set by a variable speed sign (VSS), TraCI or a MSCalibrator.
const MSLeaderInfo getFirstVehicleInformation(const MSVehicle *ego, double latOffset, bool onlyFrontOnLane, double maxPos=std::numeric_limits< double >::max(), bool allowCached=true) const
analogue to getLastVehicleInformation but in the upstream direction
virtual void integrateNewVehicles()
Insert buffered vehicle into the real lane.
double myLength
Lane length [m].
bool isApproachedFrom(MSEdge *const edge)
double getNettoOccupancy() const
Returns the netto (excluding minGaps) occupancy of this lane during the last step (including minGaps)
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
int getCrossingIndex() const
return the index of the link to the next crossing if this is walkingArea, else -1
PositionVector myShape
The shape of the lane.
PositionVector * myOutlineShape
the outline of the lane (optional)
std::map< long long, SVCPermissions > myPermissionChanges
const std::map< SUMOVehicleClass, double > * myRestrictions
The vClass speed restrictions for this lane.
virtual void incorporateVehicle(MSVehicle *veh, double pos, double speed, double posLat, const MSLane::VehCont::iterator &at, MSMoveReminder::Notification notification=MSMoveReminder::NOTIFICATION_DEPARTED)
Inserts the vehicle into this lane, and informs it about entering the network.
void initRestrictions()
initialized vClass-specific speed limits
std::vector< MSMoveReminder * > myMoveReminders
This lane's move reminder.
bool hasApproaching() const
void addParking(MSBaseVehicle *veh)
add parking vehicle. This should only used during state loading
VehCont myTmpVehicles
Container for lane-changing vehicles. After completion of lane-change- process, the containers will b...
static DepartSpeedDefinition myDefaultDepartSpeedDefinition
MSLane(const std::string &id, double maxSpeed, double friction, double length, MSEdge *const edge, int numericalID, const PositionVector &shape, double width, SVCPermissions permissions, SVCPermissions changeLeft, SVCPermissions changeRight, int index, bool isRampAccel, const std::string &type, const PositionVector &outlineShape)
Constructor.
double getDepartSpeed(const MSVehicle &veh, bool &patchSpeed)
MSLeaderInfo myFollowerInfo
followers on all sublanes as seen by vehicles on consecutive lanes (cached)
const MSLane * getNormalSuccessorLane() const
get normal lane following this internal lane, for normal lanes, the lane itself is returned
int getVehicleNumber() const
Returns the number of vehicles on this lane (for which this lane is responsible)
static SUMOTime myCollisionStopTime
static CollisionAction myCollisionAction
the action to take on collisions
MSLane * myCanonicalSuccessorLane
Main successor lane,.
SVCPermissions myChangeLeft
The vClass permissions for changing from this lane.
void getLeadersOnConsecutive(double dist, double seen, double speed, const MSVehicle *ego, const std::vector< MSLane * > &bestLaneConts, MSLeaderDistanceInfo &result, bool oppositeDirection=false) const
Returns the immediate leaders and the distance to them (as getLeaderOnConsecutive but for the sublane...
std::vector< IncomingLaneInfo > myIncomingLanes
All direct predecessor lanes.
AnyVehicleIterator anyVehiclesEnd() const
end iterator for iterating over all vehicles touching this lane in downstream direction
static void insertIDs(std::vector< std::string > &into)
Adds the ids of all stored lanes into the given vector.
bool hadPermissionChanges() const
void sortPartialVehicles()
sorts myPartialVehicles
double myFrictionCoefficient
Lane-wide friction coefficient [0..1].
MSVehicle * getFirstAnyVehicle() const
returns the first vehicle that is fully or partially on this lane
const MSLink * getEntryLink() const
Returns the entry link if this is an internal lane, else nullptr.
int getVehicleNumberWithPartials() const
Returns the number of vehicles on this lane (including partial occupators)
static bool myCheckJunctionCollisions
static void clear()
Clears the dictionary.
virtual void resetManeuverReservation(MSVehicle *v)
Unregisters a vehicle, which previously registered for maneuvering into this lane.
SVCPermissions myOriginalPermissions
The original vClass permissions for this lane (before temporary modifications)
MSEdge *const myEdge
The lane's edge, for routing only.
double myNettoVehicleLengthSum
The current length of all vehicles on this lane, excluding their minGaps.
static std::vector< MSLink * >::const_iterator succLinkSec(const SUMOVehicle &veh, int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane * > &conts)
void detectPedestrianJunctionCollision(const MSVehicle *collider, const PositionVector &colliderBoundary, const MSLane *foeLane, SUMOTime timestep, const std::string &stage, std::set< const MSVehicle *, ComparatorNumericalIdLess > &toRemove, std::set< const MSVehicle *, ComparatorNumericalIdLess > &toTeleport)
detect whether a vehicle collids with pedestrians on the junction
double getMissingRearGap(const MSVehicle *leader, double backOffset, double leaderSpeed) const
return by how much further the leader must be inserted to avoid rear end collisions
double myMaxSpeed
Lane-wide speed limit [m/s].
void saveState(OutputDevice &out)
Saves the state of this lane into the given stream.
void markRecalculateBruttoSum()
Set a flag to recalculate the brutto (including minGaps) occupancy of this lane (used if mingap is ch...
const MSLink * getLinkTo(const MSLane *const) const
returns the link to the given lane or nullptr, if it is not connected
int myRightmostSublane
the index of the rightmost sublane of this lane on myEdge
void setChangeRight(SVCPermissions permissions)
Sets the permissions for changing to the right neighbour lane.
const bool myIsRampAccel
whether this lane is an acceleration lane
virtual void planMovements(const SUMOTime t)
Compute safe velocities for all vehicles based on positions and speeds from the last time step....
static void saveRNGStates(OutputDevice &out)
save random number generator states to the given output device
SUMOTime myFollowerInfoTime
time step for which myFollowerInfo was last updated
MSLeaderInfo myLeaderInfo
leaders on all sublanes as seen by approaching vehicles (cached)
bool isInsertionSuccess(MSVehicle *vehicle, double speed, double pos, double posLat, bool recheckNextLanes, MSMoveReminder::Notification notification)
Tries to insert the given vehicle with the given state (speed and pos)
void forceVehicleInsertion(MSVehicle *veh, double pos, MSMoveReminder::Notification notification, double posLat=0)
Inserts the given vehicle at the given position.
double getVehicleStopOffset(const MSVehicle *veh) const
Returns vehicle class specific stopOffset for the vehicle.
static void initCollisionOptions(const OptionsCont &oc)
int myNumericalID
Unique numerical ID (set on reading by netload)
VehCont myVehicles
The lane's vehicles. This container holds all vehicles that have their front (longitudinally) and the...
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
MSLeaderInfo getPartialBeyond() const
get all vehicles that are inlapping from consecutive edges
std::vector< MSVehicle * > VehCont
Container for vehicles.
bool checkFailure(const MSVehicle *aVehicle, double &speed, double &dist, const double nspeed, const bool patchSpeed, const std::string errorMsg, InsertionCheck check) const
static DictType myDict
Static dictionary to associate string-ids with objects.
static void fill(RTREE &into)
Fills the given RTree with lane instances.
double safeInsertionSpeed(const MSVehicle *veh, double seen, const MSLeaderInfo &leaders, double speed)
return the maximum safe speed for insertion behind leaders (a negative value indicates that safe inse...
std::vector< const MSJunction * > getUpcomingJunctions(double pos, double range, const std::vector< MSLane * > &contLanes) const
Returns all upcoming junctions within given range along the given (non-internal) continuation lanes m...
void addIncomingLane(MSLane *lane, MSLink *viaLink)
bool isWalkingArea() const
const MSEdge * getNextNormal() const
Returns the lane's follower if it is an internal lane, the edge of the lane otherwise.
void addLink(MSLink *link)
Delayed initialization.
std::set< MSVehicle * > getVehiclesInRange(const double a, const double b) const
Returns all vehicles on the lane overlapping with the interval [a,b].
void enteredByLaneChange(MSVehicle *v)
double getDepartPosLat(const MSVehicle &veh)
std::pair< MSVehicle *const, double > getOppositeLeader(const MSVehicle *ego, double dist, bool oppositeDir, MinorLinkMode mLinkMode=MinorLinkMode::FOLLOW_NEVER) const
SVCPermissions getPermissions() const
Returns the vehicle class permissions for this lane.
LinkState getIncomingLinkState() const
get the state of the link from the logical predecessor to this lane
void updateLengthSum()
updated current vehicle length sum (delayed to avoid lane-order-dependency)
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
static const long CHANGE_PERMISSIONS_PERMANENT
virtual void addMoveReminder(MSMoveReminder *rem, bool addToVehicles=true)
Add a move-reminder to move-reminder container.
MSLane * getCanonicalPredecessorLane() const
void resetPermissions(long long transientID)
bool isPriorityCrossing() const
MSVehicle * getLastFullVehicle() const
returns the last vehicle for which this lane is responsible or 0
static void loadRNGState(int index, const std::string &state)
load random number generator state for the given rng index
const std::string myLaneType
the type of this lane
VehCont myManeuverReservations
The vehicles which registered maneuvering into the lane within their current action step....
const MSJunction * getToJunction() const
void addLeaders(const MSVehicle *vehicle, double vehPos, MSLeaderDistanceInfo &result, bool oppositeDirection=false)
get leaders for ego on the given lane
static double myCheckJunctionCollisionMinGap
double getLength() const
Returns the lane's length.
double myBruttoVehicleLengthSum
The current length of all vehicles on this lane, including their minGaps.
bool mayContinue(const MSVehicle *veh) const
whether the route of the give vehicle might be extended on insertion
const PositionVector & getShape() const
Returns this lane's shape.
static bool isFrontalCollision(const MSVehicle *collider, const MSVehicle *victim)
detect frontal collisions
void setChangeLeft(SVCPermissions permissions)
Sets the permissions for changing to the left neighbour lane.
std::vector< const MSLink * > getUpcomingLinks(double pos, double range, const std::vector< MSLane * > &contLanes) const
Returns all upcoming links within given range along the given (non-internal) continuation lanes measu...
const MSLane * getFirstInternalInConnection(double &offset) const
Returns 0 if the lane is not internal. Otherwise the first part of the connection (sequence of intern...
const MSJunction * getFromJunction() const
static int getNumRNGs()
return the number of RNGs
void handleCollisionBetween(SUMOTime timestep, const std::string &stage, const MSVehicle *collider, const MSVehicle *victim, double gap, double latGap, std::set< const MSVehicle *, ComparatorNumericalIdLess > &toRemove, std::set< const MSVehicle *, ComparatorNumericalIdLess > &toTeleport) const
take action upon collision
double getMaximumBrakeDist() const
compute maximum braking distance on this lane
static CollisionAction myIntermodalCollisionAction
const MSLane * getInternalFollowingLane(const MSLane *const) const
returns the internal lane leading to the given lane or nullptr, if there is none
static std::vector< SumoRNG > myRNGs
virtual void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
std::pair< MSVehicle *const, double > getCriticalLeader(double dist, double seen, double speed, const MSVehicle &veh) const
Returns the most dangerous leader and the distance to him.
StopOffset myLaneStopOffset
const MSLeaderInfo getLastVehicleInformation(const MSVehicle *ego, double latOffset, double minPos=0, bool allowCached=true) const
Returns the last vehicles on the lane.
static void initRNGs(const OptionsCont &oc)
initialize rngs
std::pair< MSVehicle *const, double > getLeaderOnConsecutive(double dist, double seen, double speed, const MSVehicle &veh, const std::vector< MSLane * > &bestLaneConts, bool considerCrossingFoes=true) const
Returns the immediate leader and the distance to him.
std::set< MSVehicle * > getSurroundingVehicles(double startPos, double downstreamDist, double upstreamDist, std::shared_ptr< LaneCoverageInfo > checkedLanes) const
Returns all vehicles closer than downstreamDist along the road network starting on the given position...
bool myRecalculateBruttoSum
Flag to recalculate the occupancy (including minGaps) after a change in minGap.
virtual void removeMoveReminder(MSMoveReminder *rem)
Remove a move-reminder from move-reminder container.
void clearState()
Remove all vehicles before quick-loading state.
MSLane * myCanonicalPredecessorLane
Similar to LogicalPredecessorLane,.
bool myNeedsCollisionCheck
whether a collision check is currently needed
bool isLinkEnd(std::vector< MSLink * >::const_iterator &i) const
bool allowsVehicleClass(SUMOVehicleClass vclass) const
virtual double setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
void setBidiLane(MSLane *bidyLane)
Adds the (overlapping) reverse direction lane to this lane.
double getRightSideOnEdge() const
std::pair< MSVehicle *const, double > getOppositeFollower(const MSVehicle *ego) const
bool hasPedestrians() const
whether the lane has pedestrians on it
const std::vector< std::pair< const MSLane *, const MSEdge * > > getOutgoingViaLanes() const
get the list of outgoing lanes
MSVehicle * getPartialBehind(const MSVehicle *ego) const
void setLaneStopOffset(const StopOffset &stopOffset)
Set vehicle class specific stopOffsets.
double myBruttoVehicleLengthSumToRemove
The length of all vehicles that have left this lane in the current step (this lane,...
void leftByLaneChange(MSVehicle *v)
MSLane * getCanonicalSuccessorLane() const
std::vector< StopWatch< std::chrono::nanoseconds > > myStopWatch
void setPermissions(SVCPermissions permissions, long long transientID)
Sets the permissions to the given value. If a transientID is given, the permissions are recored as te...
const double myWidth
Lane width [m].
bool lastInsertion(MSVehicle &veh, double mspeed, double posLat, bool patchSpeed)
inserts vehicle as close as possible to the last vehicle on this lane (or at the end of the lane if t...
void changeLanes(const SUMOTime time)
double getOppositePos(double pos) const
return the corresponding position on the opposite lane
SVCPermissions myChangeRight
const double myLengthGeometryFactor
precomputed myShape.length / myLength
virtual void executeMovements(const SUMOTime t)
Executes planned vehicle movements with regards to right-of-way.
const std::set< const MSBaseVehicle * > & getParkingVehicles() const
retrieve the parking vehicles (see GUIParkingArea)
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
double getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
AnyVehicleIterator anyVehiclesUpstreamEnd() const
end iterator for iterating over all vehicles touching this lane in upstream direction
int myIndex
The lane index.
double getMeanSpeedBike() const
get the mean speed of all bicycles on this lane
void updateLeaderInfo(const MSVehicle *veh, VehCont::reverse_iterator &vehPart, VehCont::reverse_iterator &vehRes, MSLeaderInfo &ahead) const
This updates the MSLeaderInfo argument with respect to the given MSVehicle. All leader-vehicles on th...
double getWaitingSeconds() const
Returns the overall waiting time on this lane.
bool hasUnsafeLink() const
whether any link from this lane is unsafe
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
virtual void detectCollisions(SUMOTime timestep, const std::string &stage)
Check if vehicles are too close.
std::vector< MSLink * > myLinks
MSVehicle * getLastAnyVehicle() const
returns the last vehicle that is fully or partially on this lane
VehCont myPartialVehicles
The lane's partial vehicles. This container holds all vehicles that are partially on this lane but wh...
void sortManeuverReservations()
sorts myManeuverReservations
MinorLinkMode
determine whether/how getFollowers looks upstream beyond minor links
void setMaxSpeed(const double val, const bool modified=true, const double jamThreshold=-1)
Sets a new maximum speed for the lane (used by TraCI, MSLaneSpeedTrigger (VSS) and MSCalibrator)
AnyVehicleIterator anyVehiclesUpstreamBegin() const
begin iterator for iterating over all vehicles touching this lane in upstream direction
std::vector< const MSLane * > getNormalIncomingLanes() const
get the list of all direct (disregarding internal predecessors) non-internal predecessor lanes of thi...
virtual void resetPartialOccupation(MSVehicle *v)
Removes the information about a vehicle lapping into this lane.
void setOpposite(MSLane *oppositeLane)
Adds a neighbor to this lane.
AnyVehicleIterator anyVehiclesBegin() const
begin iterator for iterating over all vehicles touching this lane in downstream direction
double getHarmonoise_NoiseEmissions() const
Returns the sum of last step noise emissions.
std::pair< MSVehicle *const, double > getLeader(const MSVehicle *veh, const double vehPos, const std::vector< MSLane * > &bestLaneConts, double dist=-1, bool checkTmpVehicles=false) const
Returns the immediate leader of veh and the distance to veh starting on this lane.
void handleIntermodalCollisionBetween(SUMOTime timestep, const std::string &stage, const MSVehicle *collider, const MSTransportable *victim, double gap, const std::string &collisionType, std::set< const MSVehicle *, ComparatorNumericalIdLess > &toRemove, std::set< const MSVehicle *, ComparatorNumericalIdLess > &toTeleport) const
static bool myExtrapolateSubstepDepart
MSLane * getOpposite() const
return the neighboring opposite direction lane for lane changing or nullptr
void setLength(double val)
Sets a new length for the lane (used by TraCI only)
std::map< MSEdge *, std::vector< MSLane * > > myApproachingLanes
All direct internal and direct (disregarding internal predecessors) non-internal predecessor lanes of...
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
bool mustCheckJunctionCollisions() const
whether this lane must check for junction collisions
virtual void setManeuverReservation(MSVehicle *v)
Registers the lane change intentions (towards this lane) for the given vehicle.
virtual void setJunctionApproaches() const
Register junction approaches for all vehicles after velocities have been planned.
MSLane * getBidiLane() const
retrieve bidirectional lane or nullptr
static double myCollisionMinGapFactor
SUMOTime myLeaderInfoTime
time step for which myLeaderInfo was last updated
@ COLLISION_ACTION_TELEPORT
@ COLLISION_ACTION_REMOVE
virtual const PositionVector & getShape(bool) const
MSLane * getParallelOpposite() const
return the opposite direction lane of this lanes edge or nullptr
std::map< std::string, MSLane * > DictType
definition of the static dictionary type
double getFractionalVehicleLength(bool brutto) const
return length of fractional vehicles on this lane
MSEdge & getEdge() const
Returns the lane's edge.
double getSpaceTillLastStanding(const MSVehicle *ego, bool &foundStopped) const
return the empty space up to the last standing vehicle or the empty space on the whole lane if no veh...
const MSLane * getNormalPredecessorLane() const
get normal lane leading to this internal lane, for normal lanes, the lane itself is returned
virtual bool appropriate(const MSVehicle *veh) const
MSLeaderDistanceInfo getFollowersOnConsecutive(const MSVehicle *ego, double backOffset, bool allSublanes, double searchDist=-1, MinorLinkMode mLinkMode=FOLLOW_ALWAYS) const
return the sublane followers with the largest missing rear gap among all predecessor lanes (within di...
double getWidth() const
Returns the lane's width.
const std::vector< MSLink * > & getLinkCont() const
returns the container with all links !!!
bool freeInsertion(MSVehicle &veh, double speed, double posLat, MSMoveReminder::Notification notification=MSMoveReminder::NOTIFICATION_DEPARTED)
Tries to insert the given vehicle on any place.
MSVehicle * getFirstFullVehicle() const
returns the first vehicle for which this lane is responsible or 0
double getMeanSpeed() const
Returns the mean speed on this lane.
double myNettoVehicleLengthSumToRemove
The length of all vehicles that have left this lane in the current step (this lane,...
void setFrictionCoefficient(double val)
Sets a new friction coefficient for the lane [to be later (used by TraCI and MSCalibrator)].
static CollisionAction getCollisionAction()
saves leader/follower vehicles and their distances relative to an ego vehicle
virtual std::string toString() const
print a debugging representation
CLeaderDist getClosest() const
return vehicle with the smalles gap
virtual int addLeader(const MSVehicle *veh, double gap, double latOffset=0, int sublane=-1)
bool hasVehicle(const MSVehicle *veh) const
whether the given vehicle is part of this leaderInfo
void setSublaneOffset(int offset)
set number of sublanes by which to shift positions
int numFreeSublanes() const
virtual int addLeader(const MSVehicle *veh, bool beyond, double latOffset=0.)
virtual std::string toString() const
print a debugging representation
int getSublaneOffset() const
const std::vector< const MSLane * > & getFoeLanes() const
LinkState getState() const
Returns the current state of the link.
MSJunction * getJunction() const
MSLane * getLane() const
Returns the connected lane.
bool hasFoeCrossing() const
const std::vector< MSLink * > & getFoeLinks() const
std::vector< LinkLeader > LinkLeaders
double getInternalLengthsAfter() const
Returns the cumulative length of all internal lanes after this link.
const MSTrafficLightLogic * getTLLogic() const
Returns the TLS index.
Something on a lane to be noticed about vehicle movement.
Notification
Definition of a vehicle state.
@ NOTIFICATION_ARRIVED
The vehicle arrived at its destination (is deleted)
@ NOTIFICATION_TELEPORT_ARRIVED
The vehicle was teleported out of the net.
@ NOTIFICATION_DEPARTED
The vehicle has departed (was inserted into the network)
@ NOTIFICATION_VAPORIZED_VAPORIZER
The vehicle got vaporized with a vaporizer.
@ NOTIFICATION_VAPORIZED_BREAKDOWN
The vehicle got removed via stationfinder device.
@ NOTIFICATION_VAPORIZED_COLLISION
The vehicle got removed by a collision.
@ NOTIFICATION_LOAD_STATE
The vehicle has been loaded from a state file.
@ NOTIFICATION_TELEPORT
The vehicle is being teleported.
The simulated network and simulation perfomer.
@ COLLISION
The vehicle is involved in a collision.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
static const std::string STAGE_MOVEMENTS
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
const std::map< SUMOVehicleClass, double > * getRestrictions(const std::string &id) const
Returns the restrictions for an edge type If no restrictions are present, 0 is returned.
void informVehicleStateListener(const SUMOVehicle *const vehicle, VehicleState to, const std::string &info="")
Informs all added listeners about a vehicle's state change.
bool hasPersons() const
Returns whether persons are simulated.
MSInsertionControl & getInsertionControl()
Returns the insertion control.
static const std::string STAGE_LANECHANGE
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
virtual MSTransportableControl & getPersonControl()
Returns the person control.
bool registerCollision(const SUMOTrafficObject *collider, const SUMOTrafficObject *victim, const std::string &collisionType, const MSLane *lane, double pos)
register collision and return whether it was the first one involving these vehicles
MSEdgeControl & getEdgeControl()
Returns the edge control.
virtual PersonDist nextBlocking(const MSLane *lane, double minPos, double minRight, double maxLeft, double stopTime=0, bool bidi=false)
returns the next pedestrian beyond minPos that is laterally between minRight and maxLeft or nullptr
virtual bool hasPedestrians(const MSLane *lane)
whether the given lane has pedestrians on it
static const double SAFETY_GAP
static bool isSignalized(SUMOVehicleClass svc)
static bool hasInstance()
static MSRailSignalControl & getInstance()
bool haveDeadlock(const SUMOVehicle *veh) const
whether there is a circle in the waiting-for relationships that contains the given vehicle
static bool hasInsertionConstraint(MSLink *link, const MSVehicle *veh, std::string &info, bool &isInsertionOrder)
int size() const
Returns the number of edges to pass.
const MSEdge * getLastEdge() const
returns the destination edge
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
const MSLane * lane
The lane to stop at (microsim only)
MSRouteIterator edge
The edge in the route to stop at.
double getEndPos(const SUMOVehicle &veh) const
return halting position for upcoming stop;
const SUMOVehicleParameter::Stop pars
The stop parameter.
MSPModel * getMovementModel()
Returns the default movement model for this kind of transportables.
virtual double getEdgePos() const
Return the position on the edge.
const MSVehicleType & getVehicleType() const override
Returns the object's "vehicle" type.
Reroutes traffic objects passing an edge.
bool isRemoteAffected(SUMOTime t) const
The class responsible for building and deletion of vehicles.
void registerTeleportYield()
register one non-collision-related teleport
double getMinDeceleration() const
return the minimum deceleration capability for all road vehicles that ever entered the network
void countCollision(bool teleport)
registers one collision-related teleport
void registerTeleportJam()
register one non-collision-related teleport
double getMaxSpeedFactor() const
return the maximum speed factor for all vehicles that ever entered the network
double getMinDecelerationRail() const
return the minimum deceleration capability for all ral vehicles that ever entered the network
void scheduleVehicleRemoval(SUMOVehicle *veh, bool checkDuplicate=false)
Removes a vehicle after it has ended.
void registerTeleportWrongLane()
register one non-collision-related teleport
Representation of a vehicle in the micro simulation.
double getRightSideOnEdge(const MSLane *lane=0) const
Get the vehicle's lateral position on the edge of the given lane (or its current edge if lane == 0)
void checkLinkLeader(const MSLink *link, const MSLane *lane, double seen, DriveProcessItem *const lastLink, double &v, double &vLinkPass, double &vLinkWait, bool &setRequest, bool isShadowLink=false) const
checks for link leaders on the given link
void updateBestLanes(bool forceRebuild=false, const MSLane *startLane=0)
computes the best lanes to use in order to continue the route
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
SUMOTime getLastActionTime() const
Returns the time of the vehicle's last action point.
PositionVector getBoundingPoly(double offset=0) const
get bounding polygon
void setTentativeLaneAndPosition(MSLane *lane, double pos, double posLat=0)
set tentative lane and position during insertion to ensure that all cfmodels work (some of them requi...
bool brokeDown() const
Returns how long the vehicle has been stopped already due to lack of energy.
void registerInsertionApproach(MSLink *link, double dist)
register approach on insertion
void enterLaneAtInsertion(MSLane *enteredLane, double pos, double speed, double posLat, MSMoveReminder::Notification notification)
Update when the vehicle enters a new lane in the emit step.
SUMOTime getWaitingTime(const bool accumulated=false) const
Returns the SUMOTime waited (speed was lesser than 0.1m/s)
bool isFrontOnLane(const MSLane *lane) const
Returns the information whether the front of the vehicle is on the given lane.
MSAbstractLaneChangeModel & getLaneChangeModel()
double getLeftSideOnLane() const
Get the lateral position of the vehicles left side on the lane:
double getActionStepLengthSecs() const
Returns the vehicle's action step length in secs, i.e. the interval between two action points.
const std::vector< MSLane * > getUpstreamOppositeLanes() const
Returns the sequence of opposite lanes corresponding to past lanes.
PositionVector getBoundingBox(double offset=0) const
get bounding rectangle
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the best sequence of lanes to continue the route starting at myLane.
bool ignoreCollision() const
whether this vehicle is except from collision checks
void onRemovalFromNet(const MSMoveReminder::Notification reason)
Called when the vehicle is removed from the network.
bool resumeFromStopping()
int getBestLaneOffset() const
void adaptToJunctionLeader(const std::pair< const MSVehicle *, double > leaderInfo, const double seen, DriveProcessItem *const lastLink, const MSLane *const lane, double &v, double &vLinkPass, double distToCrossing=-1) const
double getBackPositionOnLane(const MSLane *lane) const
Get the vehicle's position relative to the given lane.
void resetActionOffset(const SUMOTime timeUntilNextAction=0)
Resets the action offset for the vehicle.
void leaveLane(const MSMoveReminder::Notification reason, const MSLane *approachedLane=0)
Update of members if vehicle leaves a new lane in the lane change step or at arrival.
double getLatOffset(const MSLane *lane) const
Get the offset that that must be added to interpret myState.myPosLat for the given lane.
bool hasArrived() const
Returns whether this vehicle has already arrived (reached the arrivalPosition on its final edge)
SUMOTime collisionStopTime() const
Returns the remaining time a vehicle needs to stop due to a collision. A negative value indicates tha...
double getBestLaneDist() const
returns the distance that can be driven without lane change
bool executeMove()
Executes planned vehicle movements with regards to right-of-way.
const MSLane * getLane() const
Returns the lane the vehicle is on.
bool isLeader(const MSLink *link, const MSVehicle *veh, const double gap) const
whether the given vehicle must be followed at the given junction
MSLane * getMutableLane() const
Returns the lane the vehicle is on Non const version indicates that something volatile is going on.
Influencer & getInfluencer()
bool isBidiOn(const MSLane *lane) const
whether this vehicle is driving against lane
double getRightSideOnLane() const
Get the lateral position of the vehicles right side on the lane:
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
double getSpeed() const
Returns the vehicle's current speed.
const std::vector< MSLane * > & getFurtherLanes() const
const std::vector< LaneQ > & getBestLanes() const
Returns the description of best lanes to use in order to continue the route.
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
double getPositionOnLane() const
Get the vehicle's position along the lane.
double getLateralOverlap() const
return the amount by which the vehicle extends laterally outside it's primary lane
double getAngle() const
Returns the vehicle's direction in radians.
bool hasInfluencer() const
whether the vehicle is individually influenced (via TraCI or special parameters)
double getBrakeGap(bool delayed=false) const
get distance for coming to a stop (used for rerouting checks)
void executeFractionalMove(double dist)
move vehicle forward by the given distance during insertion
double getCenterOnEdge(const MSLane *lane=0) const
Get the vehicle's lateral position on the edge of the given lane (or its current edge if lane == 0)
static MSVehicleTransfer * getInstance()
Returns the instance of this object.
void add(const SUMOTime t, MSVehicle *veh)
Adds a vehicle to this transfer object.
double getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
double getMinGap() const
Get the free space in front of vehicles of this class.
double getLength() const
Get vehicle's length [m].
SUMOVehicleShape getGuiShape() const
Get this vehicle type's shape.
const SUMOVTypeParameter & getParameter() const
Base class for objects which have an id.
std::string myID
The name of the object.
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
const std::string & getID() const
Returns the id.
A RT-tree for efficient storing of SUMO's Named objects.
A storage for options typed value containers)
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
Static storage of an output device and its base (abstract) implementation.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const ATTR_TYPE &attr, const T &val, const bool isNull=false)
writes a named attribute
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
void unsetParameter(const std::string &key)
Removes a parameter.
virtual void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
bool overlapsWith(const AbstractPoly &poly, double offset=0) const
Returns the information whether the given polygon overlaps with this.
double distance2D(const Position &p, bool perpendicular=false) const
closest 2D-distance to point p (or -1 if perpendicular is true and the point is beyond this vector)
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
double angleAt2D(int pos) const
get angle in certain position of position vector (in radians between -M_PI and M_PI)
static void loadState(const std::string &state, SumoRNG *rng=nullptr)
load rng state from string
static void initRand(SumoRNG *which=nullptr, const bool random=false, const int seed=23423)
Initialises the random number generator with hardware randomness or seed.
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)
static std::string saveState(SumoRNG *rng=nullptr)
save rng state to string
virtual SUMOVehicleClass getVClass() const =0
Returns the object's access class.
SUMOTime getTimeToTeleport(SUMOTime defaultValue) const
return time-to-teleport (either custom or default)
SUMOTime getTimeToTeleportBidi(SUMOTime defaultValue) const
return time-to-teleport.bidi (either custom or default)
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 const MSEdge * succEdge(int nSuccs) const =0
Returns the nSuccs'th successor of edge the vehicle is currently at.
Definition of vehicle stop (position and duration)
std::string lane
The lane to stop at.
double speed
the speed at which this stop counts as reached (waypoint mode)
std::string split
the id of the vehicle (train portion) that splits of upon reaching this stop
double startPos
The stopping position start.
int parametersSet
Information for the output which parameter were set.
double endPos
The stopping position end.
bool collision
Whether this stop was triggered by a collision.
SUMOTime duration
The stopping duration.
Structure representing possible vehicle parameter.
double departPosLat
(optional) The lateral position the vehicle shall depart from
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle's end speed shall be chosen.
double departSpeed
(optional) The initial speed of the vehicle
DepartPosLatDefinition departPosLatProcedure
Information how the vehicle shall choose the lateral departure position.
double departPos
(optional) The position the vehicle shall depart from
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
double arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
A scoped lock which only triggers on condition.
bool isDefined() const
check if stopOffset was defined
SVCPermissions getPermissions() const
get permissions
double getOffset() const
get offset
TRACI_CONST int CMD_GET_VEHICLE_VARIABLE
TRACI_CONST int CMD_GET_EDGE_VARIABLE
TRACI_CONST int CMD_GET_PERSON_VARIABLE
TRACI_CONST int CMD_GET_LANE_VARIABLE
TRACI_CONST int ROUTING_MODE_IGNORE_TRANSIENT_PERMISSIONS
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
std::pair< MSVehicle *, double > vehAndGap