87 #define DEBUG_COND (isSelected()) 89 #define DEBUG_COND2(obj) ((obj != 0 && (obj)->isSelected())) 182 const std::string& type) :
205 , mySimulationTask(*this, 0)
211 assert(
myRNGs.size() > 0);
217 for (MSLinkCont::iterator i =
myLinks.begin(); i !=
myLinks.end(); ++i) {
261 (*veh)->addReminder(rem);
272 std::cout <<
SIMTIME <<
" setPartialOccupation. lane=" <<
getID() <<
" veh=" << v->
getID() <<
"\n";
285 std::cout <<
SIMTIME <<
" resetPartialOccupation. lane=" <<
getID() <<
" veh=" << v->
getID() <<
"\n";
304 std::cout <<
SIMTIME <<
" setManeuverReservation. lane=" <<
getID() <<
" veh=" << v->
getID() <<
"\n";
315 std::cout <<
SIMTIME <<
" resetManeuverReservation(): lane=" <<
getID() <<
" veh=" << v->
getID() <<
"\n";
356 if (leader ==
nullptr) {
361 leader = leaderInfo.first;
367 if (leader ==
nullptr) {
373 if (leaderBack >= frontGapNeeded) {
374 pos =
MIN2(pos, leaderBack - frontGapNeeded);
388 bool adaptableSpeed =
true;
397 if (missingRearGap > 0) {
398 if (minPos + missingRearGap <=
myLength) {
405 return isInsertionSuccess(&veh, mspeed, minPos + missingRearGap, posLat, adaptableSpeed, notification);
410 return isInsertionSuccess(&veh, mspeed, minPos, posLat, adaptableSpeed, notification);
417 const double speed = adaptableSpeed ? leader->
getSpeed() : mspeed;
419 if (leaderPos >= frontGapNeeded) {
429 MSLane::VehCont::iterator predIt =
myVehicles.begin();
440 double speed = mspeed;
441 if (adaptableSpeed && leader !=
nullptr) {
447 if (leader !=
nullptr) {
450 frontMax = leaderRearPos - frontGapNeeded;
458 if (frontMax > minPos && backMin +
POSITION_EPS < frontMax) {
535 bool patchSpeed =
true;
552 for (
int i = 0; i < 10; i++) {
578 for (
int i = 0; i < 10; i++) {
609 MSLane::checkFailure(
const MSVehicle* aVehicle,
double& speed,
double& dist,
const double nspeed,
const bool patchSpeed,
const std::string errorMsg)
const {
610 if (nspeed < speed) {
612 speed =
MIN2(nspeed, speed);
614 }
else if (speed > 0) {
618 if (emergencyBrakeGap <= dist) {
621 WRITE_WARNING(
"Vehicle '" + aVehicle->
getID() +
"' is inserted in emergency situation.");
626 if (errorMsg !=
"") {
627 WRITE_ERROR(
"Vehicle '" + aVehicle->
getID() +
"' will not be able to depart using the given velocity (" + errorMsg +
")!");
639 double speed,
double pos,
double posLat,
bool patchSpeed,
644 aVehicle->
getID() +
"'. Inserting at lane end instead.");
648 #ifdef DEBUG_INSERTION 650 std::cout <<
"\nIS_INSERTION_SUCCESS\n" 652 <<
" veh '" << aVehicle->
getID() <<
"'\n";
660 std::vector<MSLane*>::const_iterator ri = bestLaneConts.begin();
667 bool hadRailSignal =
false;
673 if (nextStop.
lane ==
this) {
674 std::stringstream msg;
675 msg <<
"scheduled stop on lane '" <<
myID <<
"' too close";
676 const double distToStop = nextStop.
pars.
endPos - pos;
678 patchSpeed, msg.str())) {
688 MSLane* currentLane =
this;
691 while (seen < dist && ri != bestLaneConts.end()) {
693 MSLinkCont::const_iterator link =
succLinkSec(*aVehicle, nRouteSuccs, *currentLane, bestLaneConts);
701 patchSpeed,
"arrival speed too low")) {
709 patchSpeed,
"junction too close")) {
716 hadRailSignal |= (*link)->getTLLogic() !=
nullptr;
719 || !(*link)->havePriority()) {
721 std::string errorMsg =
"";
722 const LinkState state = (*link)->getState();
728 errorMsg =
"unpriorised junction too close";
731 patchSpeed, errorMsg)) {
735 #ifdef DEBUG_INSERTION 737 std::cout <<
"trying insertion before minor link: " 738 <<
"insertion speed = " << speed <<
" dist=" << dist
749 nextLane = (*link)->getViaLaneOrLane();
751 if (nextLane !=
nullptr) {
762 if (nextStop.
lane == nextLane) {
763 std::stringstream msg;
764 msg <<
"scheduled stop on lane '" << nextStop.
lane->
getID() <<
"' too close";
765 const double distToStop = seen + nextStop.
pars.
endPos;
767 patchSpeed, msg.str())) {
778 #ifdef DEBUG_INSERTION 780 <<
" leader on lane '" << nextLane->
getID() <<
"': " << leaders.
toString() <<
" nspeed=" << nspeed <<
"\n";
784 #ifdef DEBUG_INSERTION 786 <<
" isInsertionSuccess lane=" <<
getID()
787 <<
" veh=" << aVehicle->
getID()
789 <<
" posLat=" << posLat
790 <<
" patchSpeed=" << patchSpeed
791 <<
" speed=" << speed
792 <<
" nspeed=" << nspeed
793 <<
" nextLane=" << nextLane->
getID()
796 <<
" failed (@641)!\n";
806 if (nspeed < speed) {
812 WRITE_ERROR(
"Vehicle '" + aVehicle->
getID() +
"' will not be able to depart using the given velocity (slow lane ahead)!");
821 if ((*link)->hasApproachingFoe(arrivalTime, leaveTime, speed, cfModel.
getMaxDecel())) {
829 currentLane = nextLane;
830 if ((*link)->getViaLane() ==
nullptr) {
844 #ifdef DEBUG_INSERTION 846 <<
" isInsertionSuccess lane=" <<
getID()
847 <<
" veh=" << aVehicle->
getID()
849 <<
" posLat=" << posLat
850 <<
" patchSpeed=" << patchSpeed
851 <<
" speed=" << speed
852 <<
" nspeed=" << nspeed
853 <<
" nextLane=" << nextLane->
getID()
854 <<
" leaders=" << leaders.
toString()
855 <<
" failed (@700)!\n";
859 #ifdef DEBUG_INSERTION 861 <<
" speed = " << speed
862 <<
" nspeed = " << nspeed
867 for (
int i = 0; i < followers.
numSublanes(); ++i) {
868 const MSVehicle* follower = followers[i].first;
869 if (follower !=
nullptr) {
871 if (followers[i].second < backGapNeeded) {
873 #ifdef DEBUG_INSERTION 875 <<
" isInsertionSuccess lane=" <<
getID()
876 <<
" veh=" << aVehicle->
getID()
878 <<
" posLat=" << posLat
879 <<
" patchSpeed=" << patchSpeed
880 <<
" speed=" << speed
881 <<
" nspeed=" << nspeed
882 <<
" follower=" << follower->
getID()
883 <<
" backGapNeeded=" << backGapNeeded
884 <<
" gap=" << followers[i].second
885 <<
" failure (@719)!\n";
897 #ifdef DEBUG_INSERTION 902 if (shadowLane !=
nullptr) {
904 for (
int i = 0; i < followers.
numSublanes(); ++i) {
905 const MSVehicle* follower = followers[i].first;
906 if (follower !=
nullptr) {
908 if (followers[i].second < backGapNeeded) {
910 #ifdef DEBUG_INSERTION 912 <<
" isInsertionSuccess shadowlane=" << shadowLane->
getID()
913 <<
" veh=" << aVehicle->
getID()
915 <<
" posLat=" << posLat
916 <<
" patchSpeed=" << patchSpeed
917 <<
" speed=" << speed
918 <<
" nspeed=" << nspeed
919 <<
" follower=" << follower->
getID()
920 <<
" backGapNeeded=" << backGapNeeded
921 <<
" gap=" << followers[i].second
922 <<
" failure (@812)!\n";
931 if (veh !=
nullptr) {
934 if (gap < gapNeeded) {
936 #ifdef DEBUG_INSERTION 938 <<
" isInsertionSuccess shadowlane=" << shadowLane->
getID()
939 <<
" veh=" << aVehicle->
getID()
941 <<
" posLat=" << posLat
942 <<
" patchSpeed=" << patchSpeed
943 <<
" speed=" << speed
944 <<
" nspeed=" << nspeed
945 <<
" leader=" << veh->
getID()
946 <<
" gapNeeded=" << gapNeeded
948 <<
" failure (@842)!\n";
959 if (missingRearGap > 0) {
961 #ifdef DEBUG_INSERTION 963 <<
" isInsertionSuccess lane=" <<
getID()
964 <<
" veh=" << aVehicle->
getID()
966 <<
" posLat=" << posLat
967 <<
" patchSpeed=" << patchSpeed
968 <<
" speed=" << speed
969 <<
" nspeed=" << nspeed
970 <<
" missingRearGap=" << missingRearGap
971 <<
" failure (@728)!\n";
978 #ifdef DEBUG_INSERTION 980 <<
" isInsertionSuccess lane=" <<
getID()
981 <<
" veh=" << aVehicle->
getID()
983 <<
" posLat=" << posLat
984 <<
" patchSpeed=" << patchSpeed
985 <<
" speed=" << speed
986 <<
" nspeed=" << nspeed
987 <<
" failed (@733)!\n";
993 #ifdef DEBUG_INSERTION 995 <<
" isInsertionSuccess lane=" <<
getID()
996 <<
" veh=" << aVehicle->
getID()
998 <<
" posLat=" << posLat
999 <<
" patchSpeed=" << patchSpeed
1000 <<
" speed=" << speed
1001 <<
" nspeed=" << nspeed
1005 <<
"\n leaders=" << leaders.
toString()
1023 double nspeed = speed;
1024 #ifdef DEBUG_INSERTION 1026 std::cout <<
SIMTIME <<
" safeInsertionSpeed veh=" << veh->
getID() <<
" speed=" << speed <<
"\n";
1031 if (leader !=
nullptr) {
1036 nspeed =
MIN2(nspeed,
1038 #ifdef DEBUG_INSERTION 1040 std::cout <<
" leader=" << leader->
getID() <<
" nspeed=" << nspeed <<
"\n";
1058 int freeSublanes = 1;
1063 while (freeSublanes > 0 && veh !=
nullptr) {
1064 #ifdef DEBUG_PLAN_MOVE 1067 std::cout <<
" getLastVehicleInformation lane=" <<
getID() <<
" minPos=" << minPos <<
" veh=" << veh->
getID() <<
" pos=" << veh->
getPositionOnLane(
this) <<
"\n";
1072 freeSublanes = leaderTmp.
addLeader(veh,
true, latOffset);
1073 #ifdef DEBUG_PLAN_MOVE 1075 std::cout <<
" latOffset=" << latOffset <<
" newLeaders=" << leaderTmp.
toString() <<
"\n";
1081 if (ego ==
nullptr && minPos == 0) {
1086 #ifdef DEBUG_PLAN_MOVE 1115 int freeSublanes = 1;
1117 while (freeSublanes > 0 && veh !=
nullptr) {
1118 #ifdef DEBUG_PLAN_MOVE 1120 std::cout <<
" veh=" << veh->
getID() <<
" pos=" << veh->
getPositionOnLane(
this) <<
" maxPos=" << maxPos <<
"\n";
1127 #ifdef DEBUG_PLAN_MOVE 1129 std::cout <<
" veh=" << veh->
getID() <<
" latOffset=" << latOffset <<
"\n";
1132 freeSublanes = followerTmp.
addLeader(veh,
true, latOffset);
1136 if (ego ==
nullptr && maxPos == std::numeric_limits<double>::max()) {
1141 #ifdef DEBUG_PLAN_MOVE 1164 double cumulatedVehLength = 0.;
1168 VehCont::reverse_iterator veh =
myVehicles.rbegin();
1171 #ifdef DEBUG_PLAN_MOVE 1175 <<
" planMovements() lane=" <<
getID()
1183 #ifdef DEBUG_PLAN_MOVE 1185 std::cout <<
" plan move for: " << (*veh)->getID();
1189 #ifdef DEBUG_PLAN_MOVE 1191 std::cout <<
" leaders=" << leaders.
toString() <<
"\n";
1194 (*veh)->planMove(t, leaders, cumulatedVehLength);
1195 cumulatedVehLength += (*veh)->getVehicleType().getLengthWithGap();
1204 veh->setApproachingForAllLinks(t);
1213 bool nextToConsiderIsPartial;
1216 while (moreReservationsAhead || morePartialVehsAhead) {
1217 if ((!moreReservationsAhead || (*vehRes)->getPositionOnLane(
this) <= veh->
getPositionOnLane())
1218 && (!morePartialVehsAhead || (*vehPart)->getPositionOnLane(
this) <= veh->
getPositionOnLane())) {
1224 if (moreReservationsAhead && !morePartialVehsAhead) {
1225 nextToConsiderIsPartial =
false;
1226 }
else if (morePartialVehsAhead && !moreReservationsAhead) {
1227 nextToConsiderIsPartial =
true;
1229 assert(morePartialVehsAhead && moreReservationsAhead);
1231 nextToConsiderIsPartial = (*vehPart)->getPositionOnLane(
this) > (*vehRes)->getPositionOnLane(
this);
1234 if (nextToConsiderIsPartial) {
1235 const double latOffset = (*vehPart)->getLatOffset(
this);
1236 #ifdef DEBUG_PLAN_MOVE 1238 std::cout <<
" partial ahead: " << (*vehPart)->getID() <<
" latOffset=" << latOffset <<
"\n";
1241 ahead.
addLeader(*vehPart,
false, latOffset);
1245 const double latOffset = (*vehRes)->getLatOffset(
this);
1246 #ifdef DEBUG_PLAN_MOVE 1248 std::cout <<
" reservation ahead: " << (*vehRes)->getID() <<
" latOffset=" << latOffset <<
"\n";
1251 ahead.
addLeader(*vehRes,
false, latOffset);
1262 #ifdef DEBUG_COLLISIONS 1264 std::vector<const MSVehicle*> all;
1266 all.push_back(*last);
1268 std::cout <<
SIMTIME <<
" detectCollisions stage=" << stage <<
" lane=" <<
getID() <<
":\n" 1271 <<
" all=" <<
toString(all) <<
"\n" 1280 std::set<const MSVehicle*, ComparatorNumericalIdLess> toRemove;
1281 std::set<const MSVehicle*> toTeleport;
1284 #ifdef DEBUG_JUNCTION_COLLISIONS 1286 std::cout <<
SIMTIME <<
" detect junction Collisions stage=" << stage <<
" lane=" <<
getID() <<
":\n" 1293 const std::vector<const MSLane*>& foeLanes =
myLinks.front()->getFoeLanes();
1298 for (std::vector<const MSLane*>::const_iterator it = foeLanes.begin(); it != foeLanes.end(); ++it) {
1299 const MSLane* foeLane = *it;
1300 #ifdef DEBUG_JUNCTION_COLLISIONS 1302 std::cout <<
" foeLane " << foeLane->
getID()
1310 if (victim == collider) {
1314 #ifdef DEBUG_JUNCTION_COLLISIONS 1317 <<
" bound=" << colliderBoundary <<
" foeBound=" << victim->
getBoundingBox()
1334 if (
myLinks.front()->getWalkingAreaFoe() !=
nullptr) {
1337 if (
myLinks.front()->getWalkingAreaFoeExit() !=
nullptr) {
1348 VehCont::reverse_iterator lastVeh =
myVehicles.rend() - 1;
1349 for (VehCont::reverse_iterator pred =
myVehicles.rbegin(); pred != lastVeh; ++pred) {
1350 VehCont::reverse_iterator veh = pred + 1;
1361 double high = (*veh)->getPositionOnLane(
this);
1362 double low = (*veh)->getBackPositionOnLane(
this);
1369 double low2 =
myLength - (*veh2)->getPositionOnLane(bidiLane);
1370 double high2 =
myLength - (*veh2)->getBackPositionOnLane(bidiLane);
1371 if (!(high < low2 || high2 < low)) {
1376 std::swap(victim, collider);
1398 if (lead == follow) {
1417 if (lead !=
nullptr && lead != follow && shadowLane->
detectCollisionBetween(timestep, stage, follow, lead, toRemove, toTeleport)) {
1427 #ifdef DEBUG_PEDESTRIAN_COLLISIONS 1429 std::cout <<
SIMTIME <<
" detect pedestrian collisions stage=" << stage <<
" lane=" <<
getID() <<
"\n";
1439 #ifdef DEBUG_PEDESTRIAN_COLLISIONS 1441 std::cout <<
SIMTIME <<
" back=" << back <<
" right=" << right <<
" person=" <<
Named::getIDSecure(leader.first) <<
" dist=" << leader.second <<
"\n";
1444 if (leader.first != 0 && leader.second < length) {
1446 "Vehicle '" + v->
getID()
1447 +
"' collision with person '" + leader.first->getID()
1448 +
"', lane='" +
getID()
1449 +
"', gap=" +
toString(leader.second - length)
1451 +
" stage=" + stage +
".");
1458 for (std::set<const MSVehicle*, ComparatorNumericalIdLess>::iterator it = toRemove.begin(); it != toRemove.end(); ++it) {
1462 if (toTeleport.count(veh) > 0) {
1474 SUMOTime timestep,
const std::string& stage) {
1476 #ifdef DEBUG_PEDESTRIAN_COLLISIONS 1478 std::cout <<
SIMTIME <<
" detect pedestrian junction collisions stage=" << stage <<
" lane=" <<
getID() <<
" foeLane=" << foeLane->
getID() <<
"\n";
1482 for (std::vector<MSTransportable*>::const_iterator it_p = persons.begin(); it_p != persons.end(); ++it_p) {
1483 #ifdef DEBUG_PEDESTRIAN_COLLISIONS 1485 std::cout <<
" collider=" << collider->
getID()
1486 <<
" ped=" << (*it_p)->getID()
1487 <<
" colliderBoundary=" << colliderBoundary
1488 <<
" pedBoundary=" << (*it_p)->getBoundingBox()
1492 if (colliderBoundary.
overlapsWith((*it_p)->getBoundingBox())) {
1494 "Vehicle '" + collider->
getID()
1495 +
"' collision with person '" + (*it_p)->getID()
1496 +
"', lane='" +
getID()
1498 +
" stage=" + stage +
".");
1508 std::set<const MSVehicle*, ComparatorNumericalIdLess>& toRemove,
1509 std::set<const MSVehicle*>& toTeleport)
const {
1516 if (collider == victim) {
1523 std::swap(victim, collider);
1531 #ifdef DEBUG_COLLISIONS 1534 <<
" thisLane=" <<
getID()
1535 <<
" collider=" << collider->
getID()
1536 <<
" victim=" << victim->
getID()
1539 <<
" colliderPos=" << colliderPos
1544 <<
" minGapFactor=" << minGapFactor
1561 && victim->
getLane() !=
this) {
1565 #ifdef DEBUG_COLLISIONS 1567 std::cout <<
SIMTIME <<
" detectedCollision gap=" << gap <<
" latGap=" << latGap <<
"\n";
1579 double gap,
double latGap, std::set<const MSVehicle*, ComparatorNumericalIdLess>& toRemove,
1580 std::set<const MSVehicle*>& toTeleport)
const {
1583 ?
"frontal collision" :
"collision");
1586 std::swap(collider, victim);
1588 std::string prefix =
"Vehicle '" + collider->
getID() +
"'; " + collisionType +
" with vehicle '" + victim->
getID() ;
1593 std::string dummyError;
1607 double victimSpeed = victim->
getSpeed();
1608 double colliderSpeed = collider->
getSpeed();
1611 if (collisionAngle < 45) {
1613 colliderSpeed =
MIN2(colliderSpeed, victimSpeed);
1614 }
else if (collisionAngle < 135) {
1631 victim->
addStop(stop, dummyError, 0,
true);
1638 collider->
addStop(stop, dummyError, 0,
true);
1649 prefix =
"Teleporting vehicle '" + collider->
getID() +
"'; " + collisionType +
" with vehicle '" + victim->
getID() ;
1650 toRemove.insert(collider);
1651 toTeleport.insert(collider);
1654 prefix =
"Removing " + collisionType +
" participants: vehicle '" + collider->
getID() +
"', vehicle '" + victim->
getID();
1655 bool removeCollider =
true;
1656 bool removeVictim =
true;
1660 toRemove.insert(victim);
1662 if (removeCollider) {
1663 toRemove.insert(collider);
1665 if (!removeVictim) {
1666 if (!removeCollider) {
1667 prefix =
"Keeping remote-controlled " + collisionType +
" participants: vehicle '" + collider->
getID() +
"', vehicle '" + victim->
getID();
1669 prefix =
"Removing " + collisionType +
" participant: vehicle '" + collider->
getID() +
"', keeping remote-controlled vehicle '" + victim->
getID();
1671 }
else if (!removeCollider) {
1672 prefix =
"Keeping remote-controlled " + collisionType +
" participant: vehicle '" + collider->
getID() +
"', removing vehicle '" + victim->
getID();
1681 +
"', lane='" +
getID()
1685 +
" stage=" + stage +
".");
1686 #ifdef DEBUG_COLLISIONS 1688 toRemove.erase(collider);
1689 toTeleport.erase(collider);
1692 toRemove.erase(victim);
1693 toTeleport.erase(victim);
1715 #ifdef DEBUG_EXEC_MOVE 1717 std::cout <<
SIMTIME <<
" veh " << veh->
getID() <<
" has arrived." << std::endl;
1722 }
else if (target !=
nullptr && moved) {
1740 WRITE_WARNING(
"Teleporting vehicle '" + veh->
getID() +
"'; beyond end of lane, target lane='" +
getID() +
"', time=" +
1766 i = VehCont::reverse_iterator(
myVehicles.erase(i.base()));
1777 const bool minorLink = !wrongLane && (link !=
myLinks.end()) && !((*link)->havePriority());
1778 const std::string reason = (wrongLane ?
" (wrong lane)" : (minorLink ?
" (yield)" :
" (jam)"));
1785 + (r2 ?
" (highway)" :
"")
1789 }
else if (minorLink) {
1842 const MSLane* firstInternal =
this;
1844 while (pred !=
nullptr && pred->
isInternal()) {
1845 firstInternal = pred;
1849 return firstInternal;
1856 DictType::iterator it =
myDict.find(
id);
1857 if (it ==
myDict.end()) {
1859 myDict.insert(DictType::value_type(
id, ptr));
1868 DictType::iterator it =
myDict.find(
id);
1869 if (it ==
myDict.end()) {
1879 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
1888 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
1889 into.push_back((*i).first);
1894 template<
class RTREE>
void 1896 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
1900 const float cmin[2] = {(float) b.
xmin(), (float) b.
ymin()};
1901 const float cmax[2] = {(float) b.
xmax(), (float) b.
ymax()};
1902 into.Insert(cmin, cmax, l);
1906 template void MSLane::fill<NamedRTree>(
NamedRTree& into);
1924 return (link !=
myLinks.end());
1934 assert(veh->getLane() ==
this);
1948 #ifdef DEBUG_VEHICLE_CONTAINER 1966 #ifdef DEBUG_CONTEXT 1968 std::cout <<
"sortManeuverReservations on lane " <<
getID()
1973 #ifdef DEBUG_CONTEXT 2049 MSLinkCont::const_iterator
2051 const MSLane& succLinkSource,
const std::vector<MSLane*>& conts) {
2054 if (nRouteEdge ==
nullptr) {
2056 return succLinkSource.
myLinks.end();
2060 assert(succLinkSource.
myLinks.size() == 1);
2063 return succLinkSource.
myLinks.begin();
2074 MSLinkCont::const_iterator link;
2075 if (nRouteSuccs < (
int)conts.size()) {
2077 for (link = succLinkSource.
myLinks.begin(); link != succLinkSource.
myLinks.end(); ++link) {
2078 if ((*link)->getLane() !=
nullptr && (*link)->getLane()->myEdge == nRouteEdge && (*link)->getLane()->allowsVehicleClass(veh.
getVehicleType().
getVehicleClass())) {
2080 if ((*link)->getLane() == conts[nRouteSuccs]) {
2087 return succLinkSource.
myLinks.end();
2090 #ifdef DEBUG_NO_CONNECTION 2092 WRITE_WARNING(
"Could not find connection between lane " + succLinkSource.
getID() +
" and lane " + conts[nRouteSuccs]->getID() +
2095 return succLinkSource.
myLinks.end();
2107 MSLinkCont::const_iterator l =
myLinks.begin();
2110 if ((*l)->getViaLane()->getID() == target->
getID()) {
2117 if ((*l)->getLane()->getID() == target->
getID()) {
2131 const MSLane*
internal =
this;
2170 assert(remVehicle->
getLane() ==
this);
2172 if (remVehicle == *it) {
2207 }
else if (!approachingEdge->
isInternal() && warnMultiCon) {
2210 WRITE_WARNING(
"Lane '" +
getID() +
"' is approached multiple times from edge '" + approachingEdge->
getID() +
"'. This may cause collisions.");
2224 std::map<MSEdge*, std::vector<MSLane*> >::const_iterator i =
myApproachingLanes.find(edge);
2228 const std::vector<MSLane*>& lanes = (*i).second;
2229 return std::find(lanes.begin(), lanes.end(), lane) != lanes.end();
2235 inline int operator()(
const std::pair<const MSVehicle*, double>& p1,
const std::pair<const MSVehicle*, double>& p2)
const {
2236 return p1.second < p2.second;
2248 const MSVehicle* v = followerInfo.first;
2267 std::pair<MSVehicle* const, double>
2268 MSLane::getLeader(
const MSVehicle* veh,
const double vehPos,
const std::vector<MSLane*>& bestLaneConts,
double dist,
bool checkTmpVehicles)
const {
2271 #ifdef DEBUG_CONTEXT 2276 if (checkTmpVehicles) {
2283 #ifdef DEBUG_CONTEXT 2285 std::cout << std::setprecision(
gPrecision) <<
" getLeader lane=" <<
getID() <<
" ego=" << veh->
getID() <<
" egoPos=" << vehPos <<
" pred=" << pred->
getID() <<
" predPos=" << pred->
getPositionOnLane() <<
"\n";
2299 #ifdef DEBUG_CONTEXT 2301 std::cout <<
" getLeader lane=" <<
getID() <<
" ego=" << veh->
getID() <<
" egoPos=" << vehPos
2311 if (bestLaneConts.size() > 0) {
2317 #ifdef DEBUG_CONTEXT 2319 std::cout <<
" getLeader lane=" <<
getID() <<
" seen=" << seen <<
" dist=" << dist <<
"\n";
2323 return std::pair<MSVehicle* const, double>(
static_cast<MSVehicle*
>(
nullptr), -1);
2327 return std::make_pair(static_cast<MSVehicle*>(
nullptr), -1);
2332 std::pair<MSVehicle* const, double>
2334 const std::vector<MSLane*>& bestLaneConts)
const {
2335 #ifdef DEBUG_CONTEXT 2337 std::cout <<
" getLeaderOnConsecutive lane=" <<
getID() <<
" ego=" << veh.
getID() <<
" seen=" << seen <<
" dist=" << dist <<
" conts=" <<
toString(bestLaneConts) <<
"\n";
2341 return std::make_pair(static_cast<MSVehicle*>(
nullptr), -1);
2349 #ifdef DEBUG_CONTEXT 2356 return std::pair<MSVehicle* const, double>(pred, gap);
2359 const MSLane* nextLane =
this;
2362 nextLane->getVehiclesSecure();
2364 MSLinkCont::const_iterator link =
succLinkSec(veh, view, *nextLane, bestLaneConts);
2365 if (nextLane->isLinkEnd(link) || !(*link)->opened(arrivalTime, speed, speed, veh.
getVehicleType().
getLength(),
2367 #ifdef DEBUG_CONTEXT 2369 std::cout <<
" cannot continue after nextLane=" << nextLane->getID() <<
"\n";
2372 nextLane->releaseVehicles();
2376 #ifdef DEBUG_CONTEXT 2381 const bool laneChanging = veh.
getLane() !=
this;
2383 #ifdef DEBUG_CONTEXT 2386 nextLane->releaseVehicles();
2387 if (linkLeaders.size() > 0) {
2388 std::pair<MSVehicle*, double> result;
2389 double shortestGap = std::numeric_limits<double>::max();
2390 for (
auto ll : linkLeaders) {
2391 double gap = ll.vehAndGap.second;
2393 if (lVeh !=
nullptr) {
2397 #ifdef DEBUG_CONTEXT 2400 <<
" isLeader=" << veh.
isLeader(*link, lVeh)
2401 <<
" gap=" << ll.vehAndGap.second
2402 <<
" gap+brakeing=" << gap
2407 if (lVeh !=
nullptr && !laneChanging && !veh.
isLeader(*link, lVeh)) {
2410 if (gap < shortestGap) {
2412 result = ll.vehAndGap;
2415 if (shortestGap != std::numeric_limits<double>::max()) {
2416 #ifdef DEBUG_CONTEXT 2418 std::cout <<
" found linkLeader after nextLane=" << nextLane->getID() <<
"\n";
2424 bool nextInternal = (*link)->getViaLane() !=
nullptr;
2425 nextLane = (*link)->getViaLaneOrLane();
2426 if (nextLane ==
nullptr) {
2429 nextLane->getVehiclesSecure();
2430 MSVehicle* leader = nextLane->getLastAnyVehicle();
2431 if (leader !=
nullptr) {
2432 #ifdef DEBUG_CONTEXT 2434 std::cout <<
" found leader " << leader->
getID() <<
" on nextLane=" << nextLane->getID() <<
"\n";
2438 nextLane->releaseVehicles();
2439 return std::make_pair(leader, dist);
2441 nextLane->releaseVehicles();
2442 if (nextLane->getVehicleMaxSpeed(&veh) < speed) {
2445 seen += nextLane->getLength();
2450 if (!nextInternal) {
2453 }
while (seen <= dist || nextLane->
isInternal());
2454 return std::make_pair(static_cast<MSVehicle*>(
nullptr), -1);
2458 std::pair<MSVehicle* const, double>
2460 #ifdef DEBUG_CONTEXT 2462 std::cout <<
SIMTIME <<
" getCriticalLeader. lane=" <<
getID() <<
" veh=" << veh.
getID() <<
"\n";
2466 std::pair<MSVehicle*, double> result = std::make_pair(static_cast<MSVehicle*>(
nullptr), -1);
2467 double safeSpeed = std::numeric_limits<double>::max();
2472 const MSLane* nextLane =
this;
2476 MSLinkCont::const_iterator link =
succLinkSec(veh, view, *nextLane, bestLaneConts);
2483 for (MSLink::LinkLeaders::const_iterator it = linkLeaders.begin(); it != linkLeaders.end(); ++it) {
2484 const MSVehicle* leader = (*it).vehAndGap.first;
2485 if (leader !=
nullptr && leader != result.first) {
2489 const double tmpSpeed = veh.
getSafeFollowSpeed((*it).vehAndGap, seen, nextLane, (*it).distToCrossing);
2490 #ifdef DEBUG_CONTEXT 2492 std::cout <<
" linkLeader=" << leader->
getID() <<
" gap=" << result.second <<
" tmpSpeed=" << tmpSpeed <<
" safeSpeed=" << safeSpeed <<
"\n";
2495 if (tmpSpeed < safeSpeed) {
2496 safeSpeed = tmpSpeed;
2497 result = (*it).vehAndGap;
2501 bool nextInternal = (*link)->getViaLane() !=
nullptr;
2502 nextLane = (*link)->getViaLaneOrLane();
2503 if (nextLane ==
nullptr) {
2507 if (leader !=
nullptr && leader != result.first) {
2510 if (tmpSpeed < safeSpeed) {
2511 safeSpeed = tmpSpeed;
2512 result = std::make_pair(leader, gap);
2523 if (!nextInternal) {
2526 }
while (seen <= dist || nextLane->
isInternal());
2536 for (MSEdgeVector::iterator i = pred.begin(); i != pred.end();) {
2545 if (pred.size() != 0) {
2547 MSEdge* best = *pred.begin();
2569 MSLane* cand = (*i).lane;
2570 if (&(cand->
getEdge()) == &fromEdge) {
2590 #ifdef DEBUG_LANE_SORTER 2591 std::cout <<
"\nBest predecessor lane for lane '" <<
myID <<
"': '" << best.lane->getID() <<
"'" << std::endl;
2606 std::vector<MSLink*> candidateLinks =
myLinks;
2609 MSLane* best = (*candidateLinks.begin())->getViaLaneOrLane();
2610 #ifdef DEBUG_LANE_SORTER 2611 std::cout <<
"\nBest successor lane for lane '" <<
myID <<
"': '" << best->getID() <<
"'" << std::endl;
2621 if (pred ==
nullptr) {
2629 const std::vector<std::pair<const MSLane*, const MSEdge*> >
2631 std::vector<std::pair<const MSLane*, const MSEdge*> > result;
2633 assert(link->getLane() !=
nullptr);
2634 result.push_back(std::make_pair(link->getLane(), link->getViaLane() ==
nullptr ? nullptr : &link->getViaLane()->getEdge()));
2656 for (MSLinkCont::const_iterator i =
myLinks.begin(); i !=
myLinks.end(); ++i) {
2657 if ((*i)->getLane()->getEdge().isCrossing()) {
2658 return (
int)(i -
myLinks.begin());
2702 wtime += (*i)->getWaitingSeconds();
2715 for (VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2716 v += (*i)->getSpeed();
2728 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2729 ret += (*i)->getCO2Emissions();
2740 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2741 ret += (*i)->getCOEmissions();
2752 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2753 ret += (*i)->getPMxEmissions();
2764 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2765 ret += (*i)->getNOxEmissions();
2776 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2777 ret += (*i)->getHCEmissions();
2788 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2789 ret += (*i)->getFuelConsumption();
2800 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2801 ret += (*i)->getElectricityConsumption();
2812 if (vehs.size() == 0) {
2816 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2817 double sv = (*i)->getHarmonoise_NoiseEmissions();
2818 ret += (double) pow(10., (sv / 10.));
2849 myLaneDir(e->getLanes()[0]->
getShape().angleAt2D(0)) {
2860 if (ae1 !=
nullptr && ae1->size() != 0) {
2870 if (ae2 !=
nullptr && ae2->size() != 0) {
2908 #ifdef DEBUG_LANE_SORTER 2909 std::cout <<
"\nincoming_lane_priority sorter()\n" 2910 <<
"noninternal predecessor for lane '" << laneInfo1.
lane->
getID()
2911 <<
"': '" << noninternal1->
getID() <<
"'\n" 2912 <<
"noninternal predecessor for lane '" << laneInfo2.
lane->
getID()
2913 <<
"': '" << noninternal2->
getID() <<
"'\n";
2921 bool priorized1 =
true;
2922 bool priorized2 =
true;
2924 std::vector<MSLink*>::const_iterator j;
2925 #ifdef DEBUG_LANE_SORTER 2926 std::cout <<
"FoeLinks of '" << noninternal1->
getID() <<
"'" << std::endl;
2929 #ifdef DEBUG_LANE_SORTER 2930 std::cout << (*j)->getLaneBefore()->getID() << std::endl;
2938 #ifdef DEBUG_LANE_SORTER 2939 std::cout <<
"FoeLinks of '" << noninternal2->
getID() <<
"'" << std::endl;
2942 #ifdef DEBUG_LANE_SORTER 2943 std::cout << (*j)->getLaneBefore()->getID() << std::endl;
2952 assert(priorized1 || priorized2);
2953 if (priorized1 != priorized2) {
2974 if (target2 ==
nullptr) {
2977 if (target1 ==
nullptr) {
2981 #ifdef DEBUG_LANE_SORTER 2982 std::cout <<
"\noutgoing_lane_priority sorter()\n" 2983 <<
"noninternal successors for lane '" <<
myLane->
getID()
2984 <<
"': '" << target1->
getID() <<
"' and " 2985 <<
"'" << target2->
getID() <<
"'\n";
2992 if (priority1 != priority2) {
2993 return priority1 > priority2;
3031 for (
const std::string&
id : vehIds) {
3060 bool allSublanes,
double searchDist,
bool ignoreMinorLinks)
const {
3063 #ifdef DEBUG_CONTEXT 3065 std::cout <<
SIMTIME <<
" getFollowers lane=" <<
getID() <<
" ego=" << ego->
getID()
3066 <<
" backOffset=" << backOffset <<
" pos=" << egoPos
3067 <<
" allSub=" << allSublanes <<
" searchDist=" << searchDist <<
" ignoreMinor=" << ignoreMinorLinks
3077 #ifdef DEBUG_CONTEXT 3087 #ifdef DEBUG_CONTEXT 3089 std::cout <<
" (1) added veh=" << veh->
getID() <<
" latOffset=" << latOffset <<
" result=" << result.
toString() <<
"\n";
3094 #ifdef DEBUG_CONTEXT 3096 std::cout <<
" result.numFreeSublanes=" << result.
numFreeSublanes() <<
"\n";
3104 if (searchDist == -1) {
3106 #ifdef DEBUG_CONTEXT 3108 std::cout <<
" computed searchDist=" << searchDist <<
"\n";
3112 std::set<const MSEdge*> egoFurther;
3113 for (
MSLane* further : ego->getFurtherLanes()) {
3114 egoFurther.insert(&further->getEdge());
3116 if (ego->getPositionOnLane() < ego->getVehicleType().getLength() && egoFurther.size() == 0
3117 && ego->getLane()->getLogicalPredecessorLane() !=
nullptr) {
3119 egoFurther.insert(&ego->getLane()->getLogicalPredecessorLane()->getEdge());
3124 std::vector<MSLane::IncomingLaneInfo> newFound;
3126 while (toExamine.size() != 0) {
3127 for (std::vector<MSLane::IncomingLaneInfo>::iterator it = toExamine.begin(); it != toExamine.end(); ++it) {
3128 MSLane* next = (*it).lane;
3132 #ifdef DEBUG_CONTEXT 3134 std::cout <<
" next=" << next->
getID() <<
" seen=" << (*it).length <<
" first=" << first.toString() <<
" firstFront=" << firstFront.
toString() <<
"\n";
3138 if (backOffset + (*it).length - next->
getLength() < 0
3139 && egoFurther.count(&next->
getEdge()) != 0
3143 for (
const auto& ll : linkLeaders) {
3144 if (ll.vehAndGap.first !=
nullptr) {
3145 const bool egoIsLeader = ll.vehAndGap.first->isLeader((*it).viaLink, ego);
3146 const double gap = egoIsLeader ?
NUMERICAL_EPS : ll.vehAndGap.second;
3148 #ifdef DEBUG_CONTEXT 3150 std::cout <<
SIMTIME <<
" ego=" << ego->getID() <<
" link=" << (*it).viaLink->getViaLaneOrLane()->getID()
3152 <<
" gap=" << ll.vehAndGap.second <<
" dtC=" << ll.distToCrossing
3153 <<
" egoIsLeader=" << egoIsLeader <<
" gap2=" << gap
3160 #ifdef DEBUG_CONTEXT 3166 for (
int i = 0; i < first.numSublanes(); ++i) {
3173 if (v !=
nullptr && v != ego) {
3180 agap = (*it).length - next->
getLength() + backOffset
3183 #ifdef DEBUG_CONTEXT 3185 std::cout <<
" agap1=" << agap <<
"\n";
3188 if (agap > 0 && &v->
getLane()->
getEdge() != &ego->getLane()->getEdge()) {
3192 if (v !=
nullptr && v != ego) {
3200 if (!(*it).viaLink->havePriority() && !ego->onFurtherEdge(&(*it).lane->getEdge())
3204 agap =
MAX2(agap, 0.0);
3208 #ifdef DEBUG_CONTEXT 3215 if ((*it).length < searchDist) {
3216 const std::vector<MSLane::IncomingLaneInfo>& followers = next->
getIncomingLanes();
3217 for (std::vector<MSLane::IncomingLaneInfo>::const_iterator j = followers.begin(); j != followers.end(); ++j) {
3218 if (visited.find((*j).lane) == visited.end() && ((*j).viaLink->havePriority() || !ignoreMinorLinks)) {
3219 visited.insert((*j).lane);
3221 ili.
lane = (*j).lane;
3222 ili.
length = (*j).length + (*it).length;
3224 newFound.push_back(ili);
3230 swap(newFound, toExamine);
3255 const MSLane* nextLane =
this;
3261 MSLinkCont::const_iterator link =
succLinkSec(*ego, view, *nextLane, bestLaneConts);
3268 if (linkLeaders.size() > 0) {
3274 #ifdef DEBUG_CONTEXT 3276 std::cout <<
" linkleader=" << veh->
getID() <<
" gap=" << ll.
vehAndGap.second <<
"\n";
3284 bool nextInternal = (*link)->getViaLane() !=
nullptr;
3285 nextLane = (*link)->getViaLaneOrLane();
3286 if (nextLane ==
nullptr) {
3291 #ifdef DEBUG_CONTEXT 3293 std::cout <<
SIMTIME <<
" getLeadersOnConsecutive lane=" <<
getID() <<
" nextLane=" << nextLane->
getID() <<
" leaders=" << leaders.
toString() <<
"\n";
3298 for (
int i = 0; i < iMax; ++i) {
3300 if (veh !=
nullptr) {
3301 #ifdef DEBUG_CONTEXT 3321 if (!nextInternal) {
3336 #ifdef DEBUG_CONTEXT 3338 std::cout <<
SIMTIME <<
" getPartialBehind lane=" <<
getID() <<
" ego=" << ego->
getID() <<
" found=" << veh->
getID() <<
"\n";
3344 #ifdef DEBUG_CONTEXT 3367 std::set<MSVehicle*>
3369 assert(checkedLanes !=
nullptr);
3370 if (checkedLanes->find(
this) != checkedLanes->end()) {
3371 #ifdef DEBUG_SURROUNDING 3372 std::cout <<
"Skipping previously scanned lane: " <<
getID() << std::endl;
3374 return std::set<MSVehicle*>();
3377 (*checkedLanes)[
this] = std::make_pair(
MAX2(0.0, startPos - upstreamDist),
MIN2(startPos + downstreamDist,
getLength()));
3379 #ifdef DEBUG_SURROUNDING 3380 std::cout <<
"Scanning on lane " <<
myID <<
"(downstr. " << downstreamDist <<
", upstr. " << upstreamDist <<
", startPos " << startPos <<
"): " << std::endl;
3383 if (startPos < upstreamDist) {
3386 MSLane* incoming = incomingInfo.lane;
3387 #ifdef DEBUG_SURROUNDING 3388 std::cout <<
"Checking on incoming: " << incoming->
getID() << std::endl;
3389 if (checkedLanes->find(incoming) != checkedLanes->end()) {
3390 std::cout <<
"Skipping previous: " << incoming->
getID() << std::endl;
3394 foundVehicles.insert(newVehs.begin(), newVehs.end());
3398 if (
getLength() < startPos + downstreamDist) {
3402 #ifdef DEBUG_SURROUNDING 3403 std::cout <<
"Checking on outgoing: " << l->getViaLaneOrLane()->getID() << std::endl;
3405 std::set<MSVehicle*> newVehs = l->getViaLaneOrLane()->getSurroundingVehicles(0.0, downstreamDist - (
myLength - startPos), upstreamDist, checkedLanes);
3406 foundVehicles.insert(newVehs.begin(), newVehs.end());
3409 #ifdef DEBUG_SURROUNDING 3410 std::cout <<
"On lane (2) " <<
myID <<
": \nFound vehicles: " << std::endl;
3412 std::cout << v->getID() <<
" pos = " << v->getPositionOnLane() << std::endl;
3415 return foundVehicles;
3419 std::set<MSVehicle*>
3421 std::set<MSVehicle*> res;
3424 if (!vehs.empty()) {
3426 if (veh->getPositionOnLane() >= a) {
3427 if (veh->getBackPositionOnLane() > b) {
3439 std::vector<const MSJunction*>
3442 std::vector<const MSJunction*> junctions;
3444 junctions.insert(junctions.end(), l->getJunction());
3450 std::vector<const MSLink*>
3452 #ifdef DEBUG_SURROUNDING 3453 std::cout <<
"getUpcoming links on lane '" <<
getID() <<
"' with pos=" << pos
3454 <<
" range=" << range << std::endl;
3457 std::vector<const MSLink*> links;
3460 const MSLane* lane =
this;
3463 std::vector<MSLane*>::const_iterator contLanesIt = contLanes.begin();
3469 assert(*contLanesIt ==
nullptr);
3471 links.insert(links.end(), link);
3476 assert(*(contLanesIt + 1) == lane);
3478 while (++contLanesIt != contLanes.end()) {
3482 #ifdef DEBUG_SURROUNDING 3483 std::cout <<
"Distance until end of lane '" << lane->
getID() <<
"' is " << dist <<
"." << std::endl;
3489 if (link !=
nullptr) {
3490 links.insert(links.end(), link);
3492 lane = *contLanesIt;
3510 if (opposite ==
nullptr) {
3512 throw ProcessError(
"Lane '" +
getID() +
"' cannot compute oppositePos as there is no opposite lane.");
3519 std::pair<MSVehicle* const, double>
3524 #ifdef DEBUG_CONTEXT 3526 std::cout <<
" getFollower lane=" <<
getID() <<
" egoPos=" << egoPos <<
" pred=" << pred->
getID() <<
" predPos=" << pred->
getPositionOnLane(
this) <<
"\n";
3535 return std::make_pair(const_cast<MSVehicle*>(result.first), result.second);
3538 std::pair<MSVehicle* const, double>
3540 #ifdef DEBUG_OPPOSITE 3542 <<
" ego=" << ego->
getID()
3546 <<
" oppositeDir=" << oppositeDir
3554 std::pair<MSVehicle* const, double> result =
getFollower(ego, egoPos + egoLength, dist,
true);
3561 std::pair<MSVehicle* const, double>
3563 #ifdef DEBUG_OPPOSITE 3565 <<
" ego=" << ego->
getID()
3575 if (result.first !=
nullptr) {
3576 if (result.first->getLaneChangeModel().isOpposite()) {
3577 result.second -= result.first->getVehicleType().getLength();
3581 return std::make_pair(static_cast<MSVehicle*>(
nullptr), -1);
3592 const std::string action = oc.
getString(
"collision.action");
3593 if (action ==
"none") {
3595 }
else if (action ==
"warn") {
3597 }
else if (action ==
"teleport") {
3599 }
else if (action ==
"remove") {
3602 WRITE_ERROR(
"Invalid collision.action '" + action +
"'.");
3640 #ifdef DEBUG_INSERTION 3642 std::cout <<
SIMTIME <<
" check for pedestrians on lane=" <<
getID() <<
" pos=" << pos <<
"\n";
3647 if (leader.first != 0) {
3650 if (gap < 0 ||
checkFailure(aVehicle, speed, dist, stopSpeed, patchSpeed,
"")) {
3652 #ifdef DEBUG_INSERTION 3654 <<
" isInsertionSuccess lane=" <<
getID()
3655 <<
" veh=" << aVehicle->
getID()
3658 <<
" patchSpeed=" << patchSpeed
3659 <<
" speed=" << speed
3660 <<
" stopSpeed=" << stopSpeed
3661 <<
" pedestrianLeader=" << leader.first->getID()
3662 <<
" failed (@796)!\n";
3674 const int numRNGs = oc.
getInt(
"thread-rngs");
3675 const bool random = oc.
getBool(
"random");
3676 int seed = oc.
getInt(
"seed");
3677 for (
int i = 0; i < numRNGs; i++) {
3678 myRNGs.push_back(std::mt19937());
3686 if (bidiEdge ==
nullptr) {
3690 assert(bidiEdge->
getLanes().size() == 1);
void detectPedestrianJunctionCollision(const MSVehicle *collider, const PositionVector &colliderBoundary, const MSLane *foeLane, SUMOTime timestep, const std::string &stage)
detect whether a vehicle collids with pedestrians on the junction
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
bool gDebugFlag1
global utility flags for debugging
std::pair< MSVehicle *const, double > getFollower(const MSVehicle *ego, double egoPos, double dist, bool ignoreMinorLinks) const
Find follower vehicle for the given ego vehicle (which may be on the opposite direction lane) ...
void changeLanes(const SUMOTime time)
bool isChangingLanes() const
return true if the vehicle currently performs a lane change maneuver
double getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
double getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
static double gLateralResolution
void needsVehicleIntegration(MSLane *const l)
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
SVCPermissions myPermissions
The vClass permissions for this lane.
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
double ymin() const
Returns minimum y-coordinate.
VehCont myVehicles
The lane's vehicles. This container holds all vehicles that have their front (longitudinally) and the...
double brakeGap(const double speed) const
Returns the distance the vehicle needs to halt including driver's reaction time tau (i...
const MSLeaderInfo getLastVehicleInformation(const MSVehicle *ego, double latOffset, double minPos=0, bool allowCached=true) const
Returns the last vehicles on the lane.
saves leader/follower vehicles and their distances relative to an ego vehicle
virtual double freeSpeed(const MSVehicle *const veh, double speed, double seen, double maxSpeed, const bool onInsertion=false) const
Computes the vehicle's safe speed without a leader.
double xmax() const
Returns maximum x-coordinate.
double getNOxEmissions() const
Returns the sum of last step NOx emissions.
MSEdge & getEdge() const
Returns the lane's edge.
A free lateral position is chosen.
Representation of a vehicle in the micro simulation.
std::string lane
The lane to stop at.
MSVehicle * getFirstFullVehicle() const
returns the first vehicle for which this lane is responsible or 0
At the leftmost side of the lane.
virtual int addLeader(const MSVehicle *veh, bool beyond, double latOffset=0)
bool detectCollisionBetween(SUMOTime timestep, const std::string &stage, MSVehicle *collider, MSVehicle *victim, std::set< const MSVehicle *, ComparatorNumericalIdLess > &toRemove, std::set< const MSVehicle *> &toTeleport) const
detect whether there is a collision between the two vehicles
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
int getPriority() const
Returns the priority of the edge.
double getAngle() const
Returns the vehicle's direction in radians.
void informVehicleStateListener(const SUMOVehicle *const vehicle, VehicleState to, const std::string &info="")
Informs all added listeners about a vehicle's state change.
PositionVector getBoundingPoly() const
get bounding polygon
int operator()(MSVehicle *v1, MSVehicle *v2) const
Comparing operator.
void sortManeuverReservations()
sorts myManeuverReservations
SUMOTime getWaitingTime() const
Returns the SUMOTime waited (speed was lesser than 0.1m/s)
const MSEdge * getNextNormal() const
Returns the lane's follower if it is an internal lane, the edge of the lane otherwise.
static void insertIDs(std::vector< std::string > &into)
Adds the ids of all stored lanes into the given vector.
const std::string myLaneType
the type of this lane
std::set< MSVehicle * > getSurroundingVehicles(double startPos, double downstreamDist, double upstreamDist, std::shared_ptr< LaneCoverageInfo > checkedLanes) const
Returns all vehicles closer than downstreamDist along the along the road network starting on the give...
static bool hasOncomingRailTraffic(MSLink *link)
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.
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...
Sorts lanes (IncomingLaneInfos) by their priority or, if this doesn't apply, wrt. the angle differenc...
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.
virtual bool hasPedestrians(const MSLane *lane)
whether the given lane has pedestrians on it
virtual void removeParking(MSVehicle *veh)
remove parking vehicle. This must be syncrhonized when running with GUI
std::pair< MSVehicle *const, double > getOppositeLeader(const MSVehicle *ego, double dist, bool oppositeDir) const
MSLane * getLane() const
Returns the connected lane.
double getMaxSpeedFactor() const
return the maximum speed factor for all vehicles that ever entered the network
begin/end of the description of a single lane
bool hasDeparted() const
Returns whether this vehicle has already departed.
bool checkFailure(const MSVehicle *aVehicle, double &speed, double &dist, const double nspeed, const bool patchSpeed, const std::string errorMsg) const
virtual const std::string & getID() const =0
Get the vehicle's ID.
static void initRNGs(const OptionsCont &oc)
initialize rngs
int myI2
index for myPartialVehicles
bool resumeFromStopping()
MSLane * getLane() const
Returns the lane the vehicle is on.
double getFuelConsumption() const
Returns the sum of last step fuel consumption.
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 registerTeleportYield()
register one non-collision-related teleport
static void fill(RTREE &into)
Fills the given RTree with lane instances.
double getMaximumBrakeDist() const
compute maximum braking distance on this lane
int gPrecision
the precision for floating point outputs
The vehicle arrived at a junction.
void setMaxSpeed(double val)
Sets a new maximum speed for the lane (used by TraCI and MSCalibrator)
virtual void executeMovements(const SUMOTime t)
Executes planned vehicle movements with regards to right-of-way.
const SUMOVehicleParameter::Stop pars
The stop parameter.
void recalcCache()
Recalculates the cached values.
This is an uncontrolled, minor link, has to stop.
const MSEdgeVector & getPredecessors() const
static bool haveLateralDynamics()
whether any kind of lateral dynamics is active
std::vector< IncomingLaneInfo > myIncomingLanes
All direct predecessor lanes.
The car-following model abstraction.
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
int myI2End
end index for myPartialVehicles
double getPositionOnLane() const
Get the vehicle's position along the lane.
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 addLink(MSLink *link)
Delayed initialization.
static std::vector< std::mt19937 > myRNGs
MSLane * myCanonicalPredecessorLane
Similar to LogicalPredecessorLane,.
int myIndex
The lane index.
double myNettoVehicleLengthSumToRemove
The length of all vehicles that have left this lane in the current step (this lane, excluding their minGaps)
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
The lateral position is chosen randomly.
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
static double myCollisionMinGapFactor
SUMOTime myLeaderInfoTime
time step for which myLeaderInfo was last updated
If a fixed number of random choices fails, a free lateral position is chosen.
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
bool operator()(const MSVehicle *cmp, double pos) const
compares vehicle position to the detector position
AnyVehicleIterator is a structure, which manages the iteration through all vehicles on the lane...
static SUMOTime myCollisionStopTime
Notification
Definition of a vehicle state.
virtual void resetManeuverReservation(MSVehicle *v)
Unregisters a vehicle, which previously registered for maneuvering into this lane.
std::string time2string(SUMOTime t)
A RT-tree for efficient storing of SUMO's Named objects.
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
double myBruttoVehicleLengthSum
The current length of all vehicles on this lane, including their minGaps.
MSVehicle * getFirstAnyVehicle() const
returns the first vehicle that is fully or partially on this lane
const std::vector< MSLane * > * allowedLanes(const MSEdge &destination, SUMOVehicleClass vclass=SVC_IGNORING) const
Get the allowed lanes to reach the destination-edge.
const MSEdge *const myEdge
std::map< long long, SVCPermissions > myPermissionChanges
std::string busstop
(Optional) bus stop if one is assigned to the stop
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
void addIncomingLane(MSLane *lane, MSLink *viaLink)
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
double getPMxEmissions() const
Returns the sum of last step PMx emissions.
by_connections_to_sorter(const MSEdge *const e)
constructor
double getLength() const
Returns the lane's length.
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
const PositionVector & getShape() const
Returns this lane's shape.
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
The speed is chosen randomly.
PositionVector getBoundingBox() const
get bounding rectangle
bool isLinkEnd(MSLinkCont::const_iterator &i) const
static void initCollisionOptions(const OptionsCont &oc)
virtual void addMoveReminder(MSMoveReminder *rem)
Add a move-reminder to move-reminder container.
const MSRoute & getRoute() const
Returns the current route.
MSLink * getLinkTo(const MSLane *) const
returns the link to the given lane or 0, if it is not connected
double getCollisionMinGapFactor() const
Get the factor of minGap that must be maintained to avoid a collision event.
The vehicle got vaporized.
void leftByLaneChange(MSVehicle *v)
bool addStop(const SUMOVehicleParameter::Stop &stopPar, std::string &errorMsg, SUMOTime untilOffset=0, bool collision=false, MSRouteIterator *searchStart=0)
Adds a stop.
double getRightSideOnLane() const
Get the vehicle's lateral position on the lane:
const MSEdge * getLastEdge() const
returns the destination edge
MSLane * getCanonicalPredecessorLane() const
FXSynchQue< MSVehicle *, std::vector< MSVehicle * > > myVehBuffer
Buffer for vehicles that moved from their previous lane onto this one. Integrated after all vehicles ...
This is an uncontrolled, right-before-left link.
bool executeMove()
Executes planned vehicle movements with regards to right-of-way.
double getSafeFollowSpeed(const std::pair< const MSVehicle *, double > leaderInfo, const double seen, const MSLane *const lane, double distToCrossing) const
compute safe speed for following the given leader
void addNeigh(const std::string &id)
Adds a neighbor to this lane.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle's end speed shall be chosen.
const std::string & getID() const
Returns the id.
const SVCPermissions SVCAll
all VClasses are allowed
void gotActive(MSLane *l)
Informs the control that the given lane got active.
bool mustCheckJunctionCollisions() const
whether this lane must check for junction collisions
double getInternalLengthsAfter() const
Returns the cumulative length of all internal lanes after this link.
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 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 parkingarea
(Optional) parking area if one is assigned to the stop
virtual double setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
VehCont myPartialVehicles
The lane's partial vehicles. This container holds all vehicles that are partially on this lane but wh...
std::vector< MSTransportable * > getSortedPersons(SUMOTime timestep, bool includeRiding=false) const
Returns this edge's persons sorted by pos.
The position is chosen randomly.
static bool myCheckJunctionCollisions
This is an uncontrolled, all-way stop link.
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.
virtual void setManeuverReservation(MSVehicle *v)
Registers the lane change intentions (towards this lane) for the given vehicle.
double getWidth() const
Returns the lane's width.
int myI1End
end index for myVehicles
bool hasArrived() const
Returns whether this vehicle has already arived (reached the arrivalPosition on its final edge) ...
Container & getContainer()
A class that stores a 2D geometrical boundary.
int myDirection
index delta
const MSEdge * getBidiEdge() const
return opposite superposable/congruent edge, if it exist and 0 else
PositionVector myShape
The shape of the lane.
#define WRITE_WARNING(msg)
int myI3
index for myTmpVehicles
MSLane * getCanonicalSuccessorLane() const
std::set< const MSVehicle * > myParkingVehicles
void getLeadersOnConsecutive(double dist, double seen, double speed, const MSVehicle *ego, const std::vector< MSLane *> &bestLaneConts, MSLeaderDistanceInfo &result) const
Returns the immediate leaders and the distance to them (as getLeaderOnConsecutive but for the sublane...
bool triggered
whether an arriving person lets the vehicle continue
bool myDownstream
iteration direction
MSAbstractLaneChangeModel & getLaneChangeModel()
bool isVaporizing() const
Returns whether vehicles on this edge shall be vaporized.
int getVehicleNumberWithPartials() const
Returns the number of vehicles on this lane (including partial occupators)
bool isFrontOnLane(const MSLane *lane) const
Returns the information whether the front of the vehicle is on the given lane.
std::vector< std::string > myNeighs
LinkState getState() const
Returns the current state of the link.
bool isLeader(const MSLink *link, const MSVehicle *veh) const
whether the given vehicle must be followed at the given junction
static CollisionAction myCollisionAction
the action to take on collisions
const std::string & getEdgeType() const
Returns the type of the edge.
std::map< std::string, MSLane *> DictType
definition of the static dictionary type
static CollisionAction getCollisionAction()
double getChosenSpeedFactor() const
Returns the precomputed factor by which the driver wants to be faster than the speed limit...
virtual void detectCollisions(SUMOTime timestep, const std::string &stage)
Check if vehicles are too close.
static DictType myDict
Static dictionary to associate string-ids with objects.
Sorts lanes (their origin link) by the priority of their noninternal target edges or...
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...
void addApproachingLane(MSLane *lane, bool warnMultiCon)
double departSpeed
(optional) The initial speed of the vehicle
virtual const MSEdge * succEdge(int nSuccs) const =0
Returns the nSuccs'th successor of edge the vehicle is currently at.
A road/street connecting two junctions.
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.
virtual int addLeader(const MSVehicle *veh, double gap, double latOffset=0, int sublane=-1)
double getLatOffset(const MSLane *lane) const
Get the offset that that must be added to interpret myState.myPosLat for the given lane...
bool insertVehicle(MSVehicle &v)
Tries to insert the given vehicle.
No information given; use default.
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
A scoped lock which only triggers on condition.
double myLength
Lane length [m].
void resetPermissions(long long transientID)
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
const MSLane * getNormalPredecessorLane() const
get normal lane leading to this internal lane, for normal lanes, the lane itself is returned ...
VehCont myTmpVehicles
Container for lane-changing vehicles. After completion of lane-change- process, the containers will b...
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...
int operator()(const IncomingLaneInfo &lane1, const IncomingLaneInfo &lane2) const
comparing operator
MSLink * getEntryLink() const
Returns the entry link if this is an internal lane, else 0.
const MSVehicle * operator*()
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
int getCrossingIndex() const
return the index of the link to the next crossing if this is walkingArea, else -1 ...
The vehicle is involved in a collision.
virtual void resetPartialOccupation(MSVehicle *v)
Removes the information about a vehicle lapping into this lane.
double getCO2Emissions() const
Returns the sum of last step CO2 emissions.
const bool myIsRampAccel
whether this lane is an acceleration lane
virtual double getSecureGap(const double speed, const double leaderSpeed, const double leaderMaxDecel) const
Returns the minimum gap to reserve if the leader is braking at maximum (>=0)
Representation of a vehicle.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
int operator()(const std::pair< const MSVehicle *, double > &p1, const std::pair< const MSVehicle *, double > &p2) const
void setLength(double val)
Sets a new length for the lane (used by TraCI only)
static MSPModel * getModel()
This is an uncontrolled, minor link, has to brake.
Sorts vehicles by their position (descending)
double myRightSideOnEdge
the combined width of all lanes with lower index on myEdge
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...
SVCPermissions myOriginalPermissions
The original vClass permissions for this lane (before temporary modifications)
outgoing_lane_priority_sorter(const MSLane *sourceLane)
constructor
void updateBestLanes(bool forceRebuild=false, const MSLane *startLane=0)
computes the best lanes to use in order to continue the route
void enteredByLaneChange(MSVehicle *v)
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the best sequence of lanes to continue the route starting at myLane.
double getEmergencyDecel() const
Get the vehicle type's maximal phisically possible deceleration [m/s^2].
static int gNumSimThreads
how many threads to use for simulation
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
const std::set< MSTransportable * > & getPersons() const
Returns this edge's persons set.
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) ...
double getMinDeceleration() const
return the minimum deceleration capability for all vehicles that ever entered the network ...
const std::map< SUMOVehicleClass, double > * myRestrictions
The vClass speed restrictions for this lane.
SUMOTime until
The time at which the vehicle may continue its journey.
std::pair< MSVehicle *const, double > getOppositeFollower(const MSVehicle *ego) const
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::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
ConstMSEdgeVector::const_iterator MSRouteIterator
The vehicle arrived at its destination (is deleted)
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...
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
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.
bool hasStops() const
Returns whether the vehicle has to stop somewhere.
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic, in MSLink and GNEInternalLane.
int operator()(const MSLink *link1, const MSLink *link2) const
comparing operator
Sorts edges by their angle relative to the given edge (straight comes first)
The maximum safe speed is used.
std::string toString() const
print a debugging representation
void forceVehicleInsertion(MSVehicle *veh, double pos, MSMoveReminder::Notification notification, double posLat=0)
Inserts the given vehicle at the given position.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
SUMOTime string2time(const std::string &r)
The maximum lane speed is used (speedLimit * speedFactor)
MSVehicle * getPartialBehind(const MSVehicle *ego) const
double xmin() const
Returns minimum x-coordinate.
AnyVehicleIterator anyVehiclesEnd() const
end iterator for iterating over all vehicles touching this lane in downstream direction ...
void add(const SUMOTime t, MSVehicle *veh)
Adds a vehicle to this transfer object.
AnyVehicleIterator anyVehiclesBegin() const
begin iterator for iterating over all vehicles touching this lane in downstream direction ...
std::vector< LinkLeader > LinkLeaders
LinkState getIncomingLinkState() const
get the state of the link from the logical predecessor to this lane
double getImpatience() const
Returns this vehicles impatience.
No information given; use default.
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 onRemovalFromNet(const MSMoveReminder::Notification reason)
Called when the vehicle is removed from the network.
std::pair< MSVehicle *, double > vehAndGap
virtual PersonDist nextBlocking(const MSLane *lane, double minPos, double minRight, double maxLeft, double stopTime=0)
returns the next pedestrian beyond minPos that is laterally between minRight and maxLeft or 0 ...
Boundary & grow(double by)
extends the boundary by the given amount
bool hasInfluencer() const
int myRightmostSublane
the index of the rightmost sublane of this lane on myEdge
MSLane * myLogicalPredecessorLane
double getMinGap() const
Get the free space in front of vehicles of this class.
SUMOTime collisionStopTime() const
Returns the remaining time a vehicle needs to stop due to a collision. A negative value indicates tha...
Something on a lane to be noticed about vehicle movement.
const std::vector< std::pair< const MSLane *, const MSEdge * > > getOutgoingViaLanes() const
get the list of outgoing lanes
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
double basePos(const MSEdge *edge) const
departure position where the vehicle fits fully onto the edge (if possible)
MSLane * getOpposite() const
return the opposite direction lane for lane changing or 0
bool overlapsWith(const AbstractPoly &poly, double offset=0) const
Returns the information whether the given polygon overlaps with this.
AnyVehicleIterator anyVehiclesUpstreamBegin() const
begin iterator for iterating over all vehicles touching this lane in upstream direction ...
double endPos
The stopping position end.
virtual void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
bool isInternal() const
return whether this edge is an internal edge
void registerTeleportJam()
register one non-collision-related teleport
double getHCEmissions() const
Returns the sum of last step HC emissions.
If a fixed number of random choices fails, a free position is chosen.
std::map< MSEdge *, std::vector< MSLane * > > myApproachingLanes
All direct internal and direct (disregarding internal predecessors) non-internal predecessor lanes of...
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
std::vector< MSVehicle * > VehCont
Container for vehicles.
const MSLane * lane
The lane to stop at.
static MSLinkCont::const_iterator succLinkSec(const SUMOVehicle &veh, int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane *> &conts)
int operator()(const MSEdge *const e1, const MSEdge *const e2) const
comparing operator
Base class for objects which have an id.
std::map< SVCPermissions, double > myStopOffsets
int myNumericalID
Unique numerical ID (set on reading by netload)
std::vector< MSMoveReminder *> myMoveReminders
This lane's move reminder.
The maximum lane speed is used (speedLimit)
VehCont myManeuverReservations
The vehicles which registered maneuvering into the lane within their current action step...
const MSLane *const myLane
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
double getRightSideOnEdge() const
Definition of vehicle stop (position and duration)
incoming_lane_priority_sorter(const MSLane *targetLane)
constructor
MSLeaderInfo getPartialBeyond() const
get all vehicles that are inlapping from consecutive edges
void initRestrictions()
initialized vClass-specific speed limits
int index
at which position in the stops list
AnyVehicleIterator & operator++()
static MSVehicleTransfer * getInstance()
Returns the instance of this object.
double departPosLat
(optional) The lateral position the vehicle shall depart from
std::pair< const MSPerson *, double > PersonDist
static void initRand(std::mt19937 *which=0, const bool random=false, const int seed=23423)
Initialises the random number generator with hardware randomness or seed.
MSVehicle * getLastFullVehicle() const
returns the last vehicle for which this lane is responsible or 0
void sortPartialVehicles()
sorts myPartialVehicles
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
virtual void setJunctionApproaches(const SUMOTime t) const
Register junction approaches for all vehicles after velocities have been planned. ...
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
bool freeInsertion(MSVehicle &veh, double speed, double posLat, MSMoveReminder::Notification notification=MSMoveReminder::NOTIFICATION_DEPARTED)
Tries to insert the given vehicle on any place.
virtual void integrateNewVehicles()
Insert buffered vehicle into the real lane.
virtual std::string toString() const
print a debugging representation
double getElectricityConsumption() const
Returns the sum of last step electricity consumption.
double departPos
(optional) The position the vehicle shall depart from
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
double startPos
The stopping position start.
static SUMOTime gTimeToGridlockHighways
std::pair< const MSVehicle *, double > CLeaderDist
int addFollower(const MSVehicle *veh, const MSVehicle *ego, double gap, double latOffset=0, int sublane=-1)
std::string myID
The name of the object.
const std::vector< MSLink * > & getFoeLinks() const
SUMOVehicleClass getVClass() const
Returns the vehicle's access class.
The vehicle has departed (was inserted into the network)
Influencer & getInfluencer()
Returns the velocity/lane influencer.
double getCOEmissions() const
Returns the sum of last step CO emissions.
Structure representing possible vehicle parameter.
std::pair< MSVehicle *const, double > getLeaderOnConsecutive(double dist, double seen, double speed, const MSVehicle &veh, const std::vector< MSLane *> &bestLaneConts) const
Returns the immediate leader and the distance to him.
int myI1
index for myVehicles
double getOppositePos(double pos) const
return the corresponding position on the opposite lane
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
static bool gUnitTests
whether unit tests are being run
double processNextStop(double currentVelocity)
Processes stops, returns the velocity needed to reach the stop.
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 containerTriggered
whether an arriving container lets the vehicle continue
static MSLink * getConnectingLink(const MSLane &from, const MSLane &to)
Returns the link connecting both lanes Both lanes have to be non-internal; 0 may be returned if no co...
MSInsertionControl & getInsertionControl()
Returns the insertion control.
static void clear()
Clears the dictionary.
const MSLane * getFirstInternalInConnection(double &offset) const
Returns 0 if the lane is not internal. Otherwise the first part of the connection (sequence of intern...
virtual void changeLanes(SUMOTime t)
Performs lane changing on this edge.
bool nextIsMyVehicles() const
int myI3End
end index for myTmpVehicles
MSEdge *const myEdge
The lane's edge, for routing only.
At the rightmost side of the lane.
At the center of the lane.
const MSLane * myLane
the lane that is being iterated
A storage for options typed value containers)
void handleCollisionBetween(SUMOTime timestep, const std::string &stage, MSVehicle *collider, MSVehicle *victim, double gap, double latGap, std::set< const MSVehicle *, ComparatorNumericalIdLess > &toRemove, std::set< const MSVehicle *> &toTeleport) const
take action upon collision
double angleAt2D(int pos) const
get angle in certain position of position vector
MSLane(const std::string &id, double maxSpeed, double length, MSEdge *const edge, int numericalID, const PositionVector &shape, double width, SVCPermissions permissions, int index, bool isRampAccel, const std::string &type)
Constructor.
MSVehicle * getLastAnyVehicle() const
returns the last vehicle that is fully or partially on this lane
bool isApproachedFrom(MSEdge *const edge)
double getHarmonoise_NoiseEmissions() const
Returns the sum of last step noise emissions.
double getStopOffset(const MSVehicle *veh) const
Returns vehicle class specific stopOffset for the vehicle.
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...
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.
MSLane * getBidiLane() const
retrieve bidirectional lane or nullptr
static SUMOTime gTimeToGridlock
double getLength() const
Get vehicle's length [m].
AnyVehicleIterator anyVehiclesUpstreamEnd() const
end iterator for iterating over all vehicles touching this lane in upstream direction ...
const MSEdge * succEdge(int nSuccs) const
Returns the nSuccs'th successor of edge the vehicle is currently at.
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
int operator()(MSVehicle *v1, MSVehicle *v2) const
Comparing operator.
bool isRemoteAffected(SUMOTime t) const
void saveState(OutputDevice &out)
Saves the state of this lane into the given stream.
MSLeaderInfo myLeaderInfo
leaders on all sublanes as seen by approaching vehicles (cached)
const MSLane *const myLane
void loadState(const std::vector< std::string > &vehIDs, MSVehicleControl &vc)
Loads the state of this segment with the given parameters.
double getBackPositionOnLane(const MSLane *lane) const
Get the vehicle's position relative to the given lane.
MSLane * myCanonicalSuccessorLane
Main successor lane,.
Static storage of an output device and its base (abstract) implementation.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
void registerCollision()
registers one collision-related teleport
MSEdgeControl & getEdgeControl()
Returns the edge control.
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
double myNettoVehicleLengthSum
The current length of all vehicles on this lane, excluding their minGaps.
double getMeanSpeed() const
Returns the mean speed on this lane.
MSLeaderInfo myFollowerInfo
followers on all sublanes as seen by vehicles on consecutive lanes (cached)
double arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
virtual ~MSLane()
Destructor.
MSLane * getShadowLane() const
Returns the lane the vehicle's shadow is on during continuous/sublane lane change.
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
std::string chargingStation
(Optional) charging station if one is assigned to the stop
void addParking(MSVehicle *veh)
add parking vehicle. This should only used during state loading
int numFreeSublanes() const
bool isStopped() const
Returns whether the vehicle is at a stop.
std::string containerstop
(Optional) container stop if one is assigned to the stop
No information given; use default.
A free position is chosen.
The class responsible for building and deletion of vehicles.
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 ...
const double myLengthGeometryFactor
precomputed myShape.length / myLength
std::vector< MSEdge * > MSEdgeVector
Insert behind the last vehicle as close as possible to still allow the specified departSpeed. Fallback to DEPART_POS_BASE if there is no vehicle on the departLane yet.
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
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) ...
const std::vector< LaneQ > & getBestLanes() const
Returns the description of best lanes to use in order to continue the route.
static double angleDiff(const double angle1, const double angle2)
Returns the difference of the second angle to the first angle in radiants.
virtual double getArrivalPos() const
Returns this vehicle's desired arrivalPos for its current route (may change on reroute) ...
bool isParking() const
Returns whether the vehicle is parking.
double getDepartPosLat(const MSVehicle &veh)
double getSpeed() const
Returns the vehicle's current speed.
static const long CHANGE_PERMISSIONS_PERMANENT
double myBruttoVehicleLengthSumToRemove
The length of all vehicles that have left this lane in the current step (this lane, including their minGaps)
MSLeaderDistanceInfo getFollowersOnConsecutive(const MSVehicle *ego, double backOffset, bool allSublanes, double searchDist=-1, bool ignoreMinorLinks=false) const
return the sublane followers with the largest missing rear gap among all predecessor lanes (within di...
double ymax() const
Returns maximum y-coordinate.
SUMOTime myFollowerInfoTime
time step for which myFollowerInfo was last updated
void updateLengthSum()
updated current vehicle length sum (delayed to avoid lane-order-dependency)
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
static SUMOTime gLaneChangeDuration
double myMaxSpeed
Lane-wide speedlimit [m/s].
double getNettoOccupancy() const
Returns the netto (excluding minGaps) occupancy of this lane during the last step (including minGaps)...
std::set< MSVehicle * > getVehiclesInRange(const double a, const double b) const
Returns all vehicles on the lane overlapping with the interval [a,b].
static double sum(double val)
Computes the resulting noise.
const std::string & getID() const
Returns the name of the vehicle.
void registerTeleportWrongLane()
register one non-collision-related teleport
Representation of a lane in the micro simulation.
std::vector< const MSLink * > getUpcomingLinks(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...
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
SUMOTime duration
The stopping duration.
void scheduleVehicleRemoval(SUMOVehicle *veh, bool checkDuplicate=false)
Removes a vehicle after it has ended.
double getWaitingSeconds() const
Returns the overall waiting time on this lane.
void descheduleDeparture(const SUMOVehicle *veh)
stops trying to emit the given vehicle (and delete it)
bool myNeedsCollisionCheck
whether a collision check is currently needed
const double myWidth
Lane width [m].
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
virtual double stopSpeed(const MSVehicle *const veh, const double speed, double gap) const =0
Computes the vehicle's safe speed for approaching a non-moving obstacle (no dawdling) ...
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
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.
bool parking
whether the vehicle is removed from the net while stopping
virtual bool appropriate(const MSVehicle *veh)
The vehicle is being teleported.
virtual void planMovements(const SUMOTime t)
Compute safe velocities for all vehicles based on positions and speeds from the last time step...
Definition of vehicle stop (position and duration)
double getDepartSpeed(const MSVehicle &veh, bool &patchSpeed)
DepartPosLatDefinition departPosLatProcedure
Information how the vehicle shall choose the lateral departure position.