 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
86 #define DEBUG_COND (isSelected())
88 #define DEBUG_COND2(obj) ((obj != 0 && (obj)->isSelected()))
127 if (nextIsMyVehicles()) {
128 if (myI1 != myI1End) {
129 return myLane->myVehicles[myI1];
130 }
else if (myI3 != myI3End) {
131 return myLane->myTmpVehicles[myI3];
136 return myLane->myPartialVehicles[myI2];
147 if (myI1 == myI1End && myI3 == myI3End) {
148 if (myI2 != myI2End) {
154 if (myI2 == myI2End) {
157 MSVehicle* cand = myI1 == myI1End ? myLane->myTmpVehicles[myI3] : myLane->myVehicles[myI1];
165 if (cand->
getPositionOnLane() < myLane->myPartialVehicles[myI2]->getPositionOnLane(myLane)) {
168 return !myDownstream;
181 const std::string& type) :
204 , mySimulationTask(*this, 0)
210 assert(
myRNGs.size() > 0);
216 for (MSLinkCont::iterator i =
myLinks.begin(); i !=
myLinks.end(); ++i) {
260 (*veh)->addReminder(rem);
274 std::cout <<
SIMTIME <<
" setPartialOccupation. lane=" <<
getID() <<
" veh=" << v->
getID() <<
"\n";
290 std::cout <<
SIMTIME <<
" resetPartialOccupation. lane=" <<
getID() <<
" veh=" << v->
getID() <<
"\n";
309 std::cout <<
SIMTIME <<
" setManeuverReservation. lane=" <<
getID() <<
" veh=" << v->
getID() <<
"\n";
320 std::cout <<
SIMTIME <<
" resetManeuverReservation(): lane=" <<
getID() <<
" veh=" << v->
getID() <<
"\n";
361 if (leader ==
nullptr) {
366 leader = leaderInfo.first;
372 if (leader ==
nullptr) {
378 if (leaderBack >= frontGapNeeded) {
379 pos =
MIN2(pos, leaderBack - frontGapNeeded);
393 bool adaptableSpeed =
true;
402 if (missingRearGap > 0) {
403 if (minPos + missingRearGap <=
myLength) {
410 return isInsertionSuccess(&veh, mspeed, minPos + missingRearGap, posLat, adaptableSpeed, notification);
415 return isInsertionSuccess(&veh, mspeed, minPos, posLat, adaptableSpeed, notification);
422 const double speed = adaptableSpeed ? leader->
getSpeed() : mspeed;
424 if (leaderPos >= frontGapNeeded) {
434 MSLane::VehCont::iterator predIt =
myVehicles.begin();
445 double speed = mspeed;
446 if (adaptableSpeed && leader !=
nullptr) {
452 if (leader !=
nullptr) {
455 frontMax = leaderRearPos - frontGapNeeded;
463 if (frontMax > minPos && backMin +
POSITION_EPS < frontMax) {
540 bool patchSpeed =
true;
557 for (
int i = 0; i < 10; i++) {
589 for (
int i = 0; i < 10; i++) {
620 MSLane::checkFailure(
const MSVehicle* aVehicle,
double& speed,
double& dist,
const double nspeed,
const bool patchSpeed,
const std::string errorMsg)
const {
621 if (nspeed < speed) {
623 speed =
MIN2(nspeed, speed);
625 }
else if (speed > 0) {
629 if (emergencyBrakeGap <= dist) {
632 WRITE_WARNING(
"Vehicle '" + aVehicle->
getID() +
"' is inserted in emergency situation.");
637 if (errorMsg !=
"") {
638 WRITE_ERROR(
"Vehicle '" + aVehicle->
getID() +
"' will not be able to depart using the given velocity (" + errorMsg +
")!");
650 double speed,
double pos,
double posLat,
bool patchSpeed,
655 aVehicle->
getID() +
"'. Inserting at lane end instead.");
659 #ifdef DEBUG_INSERTION
661 std::cout <<
"\nIS_INSERTION_SUCCESS\n"
663 <<
" veh '" << aVehicle->
getID() <<
"'\n";
671 std::vector<MSLane*>::const_iterator ri = bestLaneConts.begin();
678 bool hadRailSignal =
false;
684 if (nextStop.
lane ==
this) {
685 std::stringstream msg;
686 msg <<
"scheduled stop on lane '" <<
myID <<
"' too close";
687 const double distToStop = nextStop.
pars.
endPos - pos;
689 patchSpeed, msg.str())) {
699 MSLane* currentLane =
this;
702 while (seen < dist && ri != bestLaneConts.end()) {
704 MSLinkCont::const_iterator link =
succLinkSec(*aVehicle, nRouteSuccs, *currentLane, bestLaneConts);
712 patchSpeed,
"arrival speed too low")) {
720 patchSpeed,
"junction too close")) {
727 hadRailSignal |= (*link)->getTLLogic() !=
nullptr;
730 || !(*link)->havePriority()) {
732 std::string errorMsg =
"";
733 const LinkState state = (*link)->getState();
739 errorMsg =
"unpriorised junction too close";
742 patchSpeed, errorMsg)) {
746 #ifdef DEBUG_INSERTION
748 std::cout <<
"trying insertion before minor link: "
749 <<
"insertion speed = " << speed <<
" dist=" << dist
760 nextLane = (*link)->getViaLaneOrLane();
762 if (nextLane !=
nullptr) {
773 if (nextStop.
lane == nextLane) {
774 std::stringstream msg;
775 msg <<
"scheduled stop on lane '" << nextStop.
lane->
getID() <<
"' too close";
776 const double distToStop = seen + nextStop.
pars.
endPos;
778 patchSpeed, msg.str())) {
789 #ifdef DEBUG_INSERTION
791 <<
" leader on lane '" << nextLane->
getID() <<
"': " << leaders.
toString() <<
" nspeed=" << nspeed <<
"\n";
795 #ifdef DEBUG_INSERTION
797 <<
" isInsertionSuccess lane=" <<
getID()
798 <<
" veh=" << aVehicle->
getID()
800 <<
" posLat=" << posLat
801 <<
" patchSpeed=" << patchSpeed
802 <<
" speed=" << speed
803 <<
" nspeed=" << nspeed
804 <<
" nextLane=" << nextLane->
getID()
807 <<
" failed (@641)!\n";
817 if (nspeed < speed) {
823 WRITE_ERROR(
"Vehicle '" + aVehicle->
getID() +
"' will not be able to depart using the given velocity (slow lane ahead)!");
832 if ((*link)->hasApproachingFoe(arrivalTime, leaveTime, speed, cfModel.
getMaxDecel())) {
840 currentLane = nextLane;
841 if ((*link)->getViaLane() ==
nullptr) {
855 #ifdef DEBUG_INSERTION
857 <<
" isInsertionSuccess lane=" <<
getID()
858 <<
" veh=" << aVehicle->
getID()
860 <<
" posLat=" << posLat
861 <<
" patchSpeed=" << patchSpeed
862 <<
" speed=" << speed
863 <<
" nspeed=" << nspeed
864 <<
" nextLane=" << nextLane->
getID()
865 <<
" leaders=" << leaders.
toString()
866 <<
" failed (@700)!\n";
870 #ifdef DEBUG_INSERTION
872 <<
" speed = " << speed
873 <<
" nspeed = " << nspeed
878 for (
int i = 0; i < followers.
numSublanes(); ++i) {
879 const MSVehicle* follower = followers[i].first;
880 if (follower !=
nullptr) {
882 if (followers[i].second < backGapNeeded) {
884 #ifdef DEBUG_INSERTION
886 <<
" isInsertionSuccess lane=" <<
getID()
887 <<
" veh=" << aVehicle->
getID()
889 <<
" posLat=" << posLat
890 <<
" patchSpeed=" << patchSpeed
891 <<
" speed=" << speed
892 <<
" nspeed=" << nspeed
893 <<
" follower=" << follower->
getID()
894 <<
" backGapNeeded=" << backGapNeeded
895 <<
" gap=" << followers[i].second
896 <<
" failure (@719)!\n";
908 #ifdef DEBUG_INSERTION
913 if (shadowLane !=
nullptr) {
915 for (
int i = 0; i < followers.
numSublanes(); ++i) {
916 const MSVehicle* follower = followers[i].first;
917 if (follower !=
nullptr) {
919 if (followers[i].second < backGapNeeded) {
921 #ifdef DEBUG_INSERTION
923 <<
" isInsertionSuccess shadowlane=" << shadowLane->
getID()
924 <<
" veh=" << aVehicle->
getID()
926 <<
" posLat=" << posLat
927 <<
" patchSpeed=" << patchSpeed
928 <<
" speed=" << speed
929 <<
" nspeed=" << nspeed
930 <<
" follower=" << follower->
getID()
931 <<
" backGapNeeded=" << backGapNeeded
932 <<
" gap=" << followers[i].second
933 <<
" failure (@812)!\n";
942 if (veh !=
nullptr) {
945 if (gap < gapNeeded) {
947 #ifdef DEBUG_INSERTION
949 <<
" isInsertionSuccess shadowlane=" << shadowLane->
getID()
950 <<
" veh=" << aVehicle->
getID()
952 <<
" posLat=" << posLat
953 <<
" patchSpeed=" << patchSpeed
954 <<
" speed=" << speed
955 <<
" nspeed=" << nspeed
956 <<
" leader=" << veh->
getID()
957 <<
" gapNeeded=" << gapNeeded
959 <<
" failure (@842)!\n";
970 if (missingRearGap > 0) {
972 #ifdef DEBUG_INSERTION
974 <<
" isInsertionSuccess lane=" <<
getID()
975 <<
" veh=" << aVehicle->
getID()
977 <<
" posLat=" << posLat
978 <<
" patchSpeed=" << patchSpeed
979 <<
" speed=" << speed
980 <<
" nspeed=" << nspeed
981 <<
" missingRearGap=" << missingRearGap
982 <<
" failure (@728)!\n";
989 #ifdef DEBUG_INSERTION
991 <<
" isInsertionSuccess lane=" <<
getID()
992 <<
" veh=" << aVehicle->
getID()
994 <<
" posLat=" << posLat
995 <<
" patchSpeed=" << patchSpeed
996 <<
" speed=" << speed
997 <<
" nspeed=" << nspeed
998 <<
" failed (@733)!\n";
1004 #ifdef DEBUG_INSERTION
1006 <<
" isInsertionSuccess lane=" <<
getID()
1007 <<
" veh=" << aVehicle->
getID()
1009 <<
" posLat=" << posLat
1010 <<
" patchSpeed=" << patchSpeed
1011 <<
" speed=" << speed
1012 <<
" nspeed=" << nspeed
1016 <<
"\n leaders=" << leaders.
toString()
1034 double nspeed = speed;
1035 #ifdef DEBUG_INSERTION
1037 std::cout <<
SIMTIME <<
" safeInsertionSpeed veh=" << veh->
getID() <<
" speed=" << speed <<
"\n";
1042 if (leader !=
nullptr) {
1047 nspeed =
MIN2(nspeed,
1049 #ifdef DEBUG_INSERTION
1051 std::cout <<
" leader=" << leader->
getID() <<
" nspeed=" << nspeed <<
"\n";
1069 int freeSublanes = 1;
1074 while (freeSublanes > 0 && veh !=
nullptr) {
1075 #ifdef DEBUG_PLAN_MOVE
1078 std::cout <<
" getLastVehicleInformation lane=" <<
getID() <<
" minPos=" << minPos <<
" veh=" << veh->
getID() <<
" pos=" << veh->
getPositionOnLane(
this) <<
"\n";
1083 freeSublanes = leaderTmp.
addLeader(veh,
true, latOffset);
1084 #ifdef DEBUG_PLAN_MOVE
1086 std::cout <<
" latOffset=" << latOffset <<
" newLeaders=" << leaderTmp.
toString() <<
"\n";
1092 if (ego ==
nullptr && minPos == 0) {
1097 #ifdef DEBUG_PLAN_MOVE
1126 int freeSublanes = 1;
1128 while (freeSublanes > 0 && veh !=
nullptr) {
1129 #ifdef DEBUG_PLAN_MOVE
1131 std::cout <<
" veh=" << veh->
getID() <<
" pos=" << veh->
getPositionOnLane(
this) <<
" maxPos=" << maxPos <<
"\n";
1138 #ifdef DEBUG_PLAN_MOVE
1140 std::cout <<
" veh=" << veh->
getID() <<
" latOffset=" << latOffset <<
"\n";
1143 freeSublanes = followerTmp.
addLeader(veh,
true, latOffset);
1147 if (ego ==
nullptr && maxPos == std::numeric_limits<double>::max()) {
1152 #ifdef DEBUG_PLAN_MOVE
1175 double cumulatedVehLength = 0.;
1179 VehCont::reverse_iterator veh =
myVehicles.rbegin();
1182 #ifdef DEBUG_PLAN_MOVE
1186 <<
" planMovements() lane=" <<
getID()
1194 #ifdef DEBUG_PLAN_MOVE
1196 std::cout <<
" plan move for: " << (*veh)->getID();
1200 #ifdef DEBUG_PLAN_MOVE
1202 std::cout <<
" leaders=" << leaders.
toString() <<
"\n";
1205 (*veh)->planMove(t, leaders, cumulatedVehLength);
1206 cumulatedVehLength += (*veh)->getVehicleType().getLengthWithGap();
1215 veh->setApproachingForAllLinks(t);
1224 bool nextToConsiderIsPartial;
1227 while (moreReservationsAhead || morePartialVehsAhead) {
1228 if ((!moreReservationsAhead || (*vehRes)->getPositionOnLane(
this) <= veh->
getPositionOnLane())
1229 && (!morePartialVehsAhead || (*vehPart)->getPositionOnLane(
this) <= veh->
getPositionOnLane())) {
1235 if (moreReservationsAhead && !morePartialVehsAhead) {
1236 nextToConsiderIsPartial =
false;
1237 }
else if (morePartialVehsAhead && !moreReservationsAhead) {
1238 nextToConsiderIsPartial =
true;
1240 assert(morePartialVehsAhead && moreReservationsAhead);
1242 nextToConsiderIsPartial = (*vehPart)->getPositionOnLane(
this) > (*vehRes)->getPositionOnLane(
this);
1245 if (nextToConsiderIsPartial) {
1246 const double latOffset = (*vehPart)->getLatOffset(
this);
1247 #ifdef DEBUG_PLAN_MOVE
1249 std::cout <<
" partial ahead: " << (*vehPart)->getID() <<
" latOffset=" << latOffset <<
"\n";
1252 ahead.
addLeader(*vehPart,
false, latOffset);
1256 const double latOffset = (*vehRes)->getLatOffset(
this);
1257 #ifdef DEBUG_PLAN_MOVE
1259 std::cout <<
" reservation ahead: " << (*vehRes)->getID() <<
" latOffset=" << latOffset <<
"\n";
1262 ahead.
addLeader(*vehRes,
false, latOffset);
1273 #ifdef DEBUG_COLLISIONS
1275 std::vector<const MSVehicle*> all;
1277 all.push_back(*last);
1279 std::cout <<
SIMTIME <<
" detectCollisions stage=" << stage <<
" lane=" <<
getID() <<
":\n"
1282 <<
" all=" <<
toString(all) <<
"\n"
1291 std::set<const MSVehicle*, ComparatorNumericalIdLess> toRemove;
1292 std::set<const MSVehicle*, ComparatorNumericalIdLess> toTeleport;
1295 #ifdef DEBUG_JUNCTION_COLLISIONS
1297 std::cout <<
SIMTIME <<
" detect junction Collisions stage=" << stage <<
" lane=" <<
getID() <<
":\n"
1304 const std::vector<const MSLane*>& foeLanes =
myLinks.front()->getFoeLanes();
1309 for (std::vector<const MSLane*>::const_iterator it = foeLanes.begin(); it != foeLanes.end(); ++it) {
1310 const MSLane* foeLane = *it;
1311 #ifdef DEBUG_JUNCTION_COLLISIONS
1313 std::cout <<
" foeLane " << foeLane->
getID()
1321 if (victim == collider) {
1325 #ifdef DEBUG_JUNCTION_COLLISIONS
1328 <<
" bound=" << colliderBoundary <<
" foeBound=" << victim->
getBoundingBox()
1345 if (
myLinks.front()->getWalkingAreaFoe() !=
nullptr) {
1348 if (
myLinks.front()->getWalkingAreaFoeExit() !=
nullptr) {
1359 VehCont::reverse_iterator lastVeh =
myVehicles.rend() - 1;
1360 for (VehCont::reverse_iterator pred =
myVehicles.rbegin(); pred != lastVeh; ++pred) {
1361 VehCont::reverse_iterator veh = pred + 1;
1372 double high = (*veh)->getPositionOnLane(
this);
1373 double low = (*veh)->getBackPositionOnLane(
this);
1380 double low2 =
myLength - (*veh2)->getPositionOnLane(bidiLane);
1381 double high2 =
myLength - (*veh2)->getBackPositionOnLane(bidiLane);
1382 if (!(high < low2 || high2 < low)) {
1387 std::swap(victim, collider);
1409 if (lead == follow) {
1428 if (lead !=
nullptr && lead != follow && shadowLane->
detectCollisionBetween(timestep, stage, follow, lead, toRemove, toTeleport)) {
1438 #ifdef DEBUG_PEDESTRIAN_COLLISIONS
1440 std::cout <<
SIMTIME <<
" detect pedestrian collisions stage=" << stage <<
" lane=" <<
getID() <<
"\n";
1450 #ifdef DEBUG_PEDESTRIAN_COLLISIONS
1452 std::cout <<
SIMTIME <<
" back=" << back <<
" right=" << right <<
" person=" <<
Named::getIDSecure(leader.first) <<
" dist=" << leader.second <<
"\n";
1455 if (leader.first != 0 && leader.second < length) {
1457 "Vehicle '" + v->
getID()
1458 +
"' collision with person '" + leader.first->getID()
1459 +
"', lane='" +
getID()
1460 +
"', gap=" +
toString(leader.second - length)
1462 +
" stage=" + stage +
".");
1469 for (std::set<const MSVehicle*, ComparatorNumericalIdLess>::iterator it = toRemove.begin(); it != toRemove.end(); ++it) {
1473 if (toTeleport.count(veh) > 0) {
1485 SUMOTime timestep,
const std::string& stage) {
1487 #ifdef DEBUG_PEDESTRIAN_COLLISIONS
1489 std::cout <<
SIMTIME <<
" detect pedestrian junction collisions stage=" << stage <<
" lane=" <<
getID() <<
" foeLane=" << foeLane->
getID() <<
"\n";
1493 for (std::vector<MSTransportable*>::const_iterator it_p = persons.begin(); it_p != persons.end(); ++it_p) {
1494 #ifdef DEBUG_PEDESTRIAN_COLLISIONS
1496 std::cout <<
" collider=" << collider->
getID()
1497 <<
" ped=" << (*it_p)->getID()
1498 <<
" colliderBoundary=" << colliderBoundary
1499 <<
" pedBoundary=" << (*it_p)->getBoundingBox()
1503 if (colliderBoundary.
overlapsWith((*it_p)->getBoundingBox())) {
1505 "Vehicle '" + collider->
getID()
1506 +
"' collision with person '" + (*it_p)->getID()
1507 +
"', lane='" +
getID()
1509 +
" stage=" + stage +
".");
1519 std::set<const MSVehicle*, ComparatorNumericalIdLess>& toRemove,
1520 std::set<const MSVehicle*, ComparatorNumericalIdLess>& toTeleport)
const {
1527 if (collider == victim) {
1534 std::swap(victim, collider);
1542 #ifdef DEBUG_COLLISIONS
1545 <<
" thisLane=" <<
getID()
1546 <<
" collider=" << collider->
getID()
1547 <<
" victim=" << victim->
getID()
1550 <<
" colliderPos=" << colliderPos
1555 <<
" minGapFactor=" << minGapFactor
1572 && victim->
getLane() !=
this) {
1576 #ifdef DEBUG_COLLISIONS
1578 std::cout <<
SIMTIME <<
" detectedCollision gap=" << gap <<
" latGap=" << latGap <<
"\n";
1590 double gap,
double latGap, std::set<const MSVehicle*, ComparatorNumericalIdLess>& toRemove,
1591 std::set<const MSVehicle*, ComparatorNumericalIdLess>& toTeleport)
const {
1594 ?
"frontal collision" :
"collision");
1597 std::swap(collider, victim);
1599 std::string prefix =
"Vehicle '" + collider->
getID() +
"'; " + collisionType +
" with vehicle '" + victim->
getID() ;
1604 std::string dummyError;
1618 double victimSpeed = victim->
getSpeed();
1619 double colliderSpeed = collider->
getSpeed();
1622 if (collisionAngle < 45) {
1624 colliderSpeed =
MIN2(colliderSpeed, victimSpeed);
1625 }
else if (collisionAngle < 135) {
1642 victim->
addStop(stop, dummyError, 0,
true);
1649 collider->
addStop(stop, dummyError, 0,
true);
1660 prefix =
"Teleporting vehicle '" + collider->
getID() +
"'; " + collisionType +
" with vehicle '" + victim->
getID() ;
1661 toRemove.insert(collider);
1662 toTeleport.insert(collider);
1665 prefix =
"Removing " + collisionType +
" participants: vehicle '" + collider->
getID() +
"', vehicle '" + victim->
getID();
1666 bool removeCollider =
true;
1667 bool removeVictim =
true;
1671 toRemove.insert(victim);
1673 if (removeCollider) {
1674 toRemove.insert(collider);
1676 if (!removeVictim) {
1677 if (!removeCollider) {
1678 prefix =
"Keeping remote-controlled " + collisionType +
" participants: vehicle '" + collider->
getID() +
"', vehicle '" + victim->
getID();
1680 prefix =
"Removing " + collisionType +
" participant: vehicle '" + collider->
getID() +
"', keeping remote-controlled vehicle '" + victim->
getID();
1682 }
else if (!removeCollider) {
1683 prefix =
"Keeping remote-controlled " + collisionType +
" participant: vehicle '" + collider->
getID() +
"', removing vehicle '" + victim->
getID();
1692 +
"', lane='" +
getID()
1696 +
" stage=" + stage +
".");
1697 #ifdef DEBUG_COLLISIONS
1699 toRemove.erase(collider);
1700 toTeleport.erase(collider);
1703 toRemove.erase(victim);
1704 toTeleport.erase(victim);
1726 #ifdef DEBUG_EXEC_MOVE
1728 std::cout <<
SIMTIME <<
" veh " << veh->
getID() <<
" has arrived." << std::endl;
1733 }
else if (target !=
nullptr && moved) {
1751 WRITE_WARNING(
"Teleporting vehicle '" + veh->
getID() +
"'; beyond end of lane, target lane='" +
getID() +
"', time=" +
1777 i = VehCont::reverse_iterator(
myVehicles.erase(i.base()));
1788 const bool minorLink = !wrongLane && (link !=
myLinks.end()) && !((*link)->havePriority());
1789 const std::string reason = (wrongLane ?
" (wrong lane)" : (minorLink ?
" (yield)" :
" (jam)"));
1796 + (r2 ?
" (highway)" :
"")
1800 }
else if (minorLink) {
1853 const MSLane* firstInternal =
this;
1855 while (pred !=
nullptr && pred->
isInternal()) {
1856 firstInternal = pred;
1860 return firstInternal;
1867 DictType::iterator it =
myDict.find(
id);
1868 if (it ==
myDict.end()) {
1870 myDict.insert(DictType::value_type(
id, ptr));
1879 DictType::iterator it =
myDict.find(
id);
1880 if (it ==
myDict.end()) {
1890 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
1899 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
1900 into.push_back((*i).first);
1905 template<
class RTREE>
void
1907 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
1911 const float cmin[2] = {(float) b.
xmin(), (float) b.
ymin()};
1912 const float cmax[2] = {(float) b.
xmax(), (float) b.
ymax()};
1913 into.Insert(cmin, cmax, l);
1917 template void MSLane::fill<NamedRTree>(
NamedRTree& into);
1935 return (link !=
myLinks.end());
1945 assert(veh->getLane() ==
this);
1959 #ifdef DEBUG_VEHICLE_CONTAINER
1977 #ifdef DEBUG_CONTEXT
1979 std::cout <<
"sortManeuverReservations on lane " <<
getID()
1984 #ifdef DEBUG_CONTEXT
2060 MSLinkCont::const_iterator
2062 const MSLane& succLinkSource,
const std::vector<MSLane*>& conts) {
2065 if (nRouteEdge ==
nullptr) {
2067 return succLinkSource.
myLinks.end();
2071 assert(succLinkSource.
myLinks.size() == 1);
2074 return succLinkSource.
myLinks.begin();
2085 MSLinkCont::const_iterator link;
2086 if (nRouteSuccs < (
int)conts.size()) {
2088 for (link = succLinkSource.
myLinks.begin(); link != succLinkSource.
myLinks.end(); ++link) {
2089 if ((*link)->getLane() !=
nullptr && (*link)->getLane()->myEdge == nRouteEdge && (*link)->getLane()->allowsVehicleClass(veh.
getVehicleType().
getVehicleClass())) {
2091 if ((*link)->getLane() == conts[nRouteSuccs]) {
2098 return succLinkSource.
myLinks.end();
2101 #ifdef DEBUG_NO_CONNECTION
2103 WRITE_WARNING(
"Could not find connection between lane " + succLinkSource.
getID() +
" and lane " + conts[nRouteSuccs]->getID() +
2106 return succLinkSource.
myLinks.end();
2118 MSLinkCont::const_iterator l =
myLinks.begin();
2121 if ((*l)->getViaLane()->getID() == target->
getID()) {
2128 if ((*l)->getLane()->getID() == target->
getID()) {
2142 const MSLane*
internal =
this;
2181 assert(remVehicle->
getLane() ==
this);
2183 if (remVehicle == *it) {
2218 }
else if (!approachingEdge->
isInternal() && warnMultiCon) {
2221 WRITE_WARNING(
"Lane '" +
getID() +
"' is approached multiple times from edge '" + approachingEdge->
getID() +
"'. This may cause collisions.");
2235 std::map<MSEdge*, std::vector<MSLane*> >::const_iterator i =
myApproachingLanes.find(edge);
2239 const std::vector<MSLane*>& lanes = (*i).second;
2240 return std::find(lanes.begin(), lanes.end(), lane) != lanes.end();
2246 inline int operator()(
const std::pair<const MSVehicle*, double>& p1,
const std::pair<const MSVehicle*, double>& p2)
const {
2247 return p1.second < p2.second;
2259 const MSVehicle* v = followerInfo.first;
2278 std::pair<MSVehicle* const, double>
2279 MSLane::getLeader(
const MSVehicle* veh,
const double vehPos,
const std::vector<MSLane*>& bestLaneConts,
double dist,
bool checkTmpVehicles)
const {
2282 #ifdef DEBUG_CONTEXT
2287 if (checkTmpVehicles) {
2294 #ifdef DEBUG_CONTEXT
2296 std::cout << std::setprecision(
gPrecision) <<
" getLeader lane=" <<
getID() <<
" ego=" << veh->
getID() <<
" egoPos=" << vehPos <<
" pred=" << pred->
getID() <<
" predPos=" << pred->
getPositionOnLane() <<
"\n";
2310 #ifdef DEBUG_CONTEXT
2312 std::cout <<
" getLeader lane=" <<
getID() <<
" ego=" << veh->
getID() <<
" egoPos=" << vehPos
2322 if (bestLaneConts.size() > 0) {
2328 #ifdef DEBUG_CONTEXT
2330 std::cout <<
" getLeader lane=" <<
getID() <<
" seen=" << seen <<
" dist=" << dist <<
"\n";
2334 return std::pair<MSVehicle* const, double>(
static_cast<MSVehicle*
>(
nullptr), -1);
2338 return std::make_pair(
static_cast<MSVehicle*
>(
nullptr), -1);
2343 std::pair<MSVehicle* const, double>
2345 const std::vector<MSLane*>& bestLaneConts)
const {
2346 #ifdef DEBUG_CONTEXT
2348 std::cout <<
" getLeaderOnConsecutive lane=" <<
getID() <<
" ego=" << veh.
getID() <<
" seen=" << seen <<
" dist=" << dist <<
" conts=" <<
toString(bestLaneConts) <<
"\n";
2352 return std::make_pair(
static_cast<MSVehicle*
>(
nullptr), -1);
2360 #ifdef DEBUG_CONTEXT
2367 return std::pair<MSVehicle* const, double>(pred, gap);
2370 const MSLane* nextLane =
this;
2375 MSLinkCont::const_iterator link =
succLinkSec(veh, view, *nextLane, bestLaneConts);
2378 #ifdef DEBUG_CONTEXT
2380 std::cout <<
" cannot continue after nextLane=" << nextLane->
getID() <<
"\n";
2387 #ifdef DEBUG_CONTEXT
2392 const bool laneChanging = veh.
getLane() !=
this;
2394 #ifdef DEBUG_CONTEXT
2398 if (linkLeaders.size() > 0) {
2399 std::pair<MSVehicle*, double> result;
2400 double shortestGap = std::numeric_limits<double>::max();
2401 for (
auto ll : linkLeaders) {
2402 double gap = ll.vehAndGap.second;
2404 if (lVeh !=
nullptr) {
2408 #ifdef DEBUG_CONTEXT
2411 <<
" isLeader=" << veh.
isLeader(*link, lVeh)
2412 <<
" gap=" << ll.vehAndGap.second
2413 <<
" gap+brakeing=" << gap
2418 if (lVeh !=
nullptr && !laneChanging && !veh.
isLeader(*link, lVeh)) {
2421 if (gap < shortestGap) {
2423 result = ll.vehAndGap;
2426 if (shortestGap != std::numeric_limits<double>::max()) {
2427 #ifdef DEBUG_CONTEXT
2429 std::cout <<
" found linkLeader after nextLane=" << nextLane->
getID() <<
"\n";
2435 bool nextInternal = (*link)->getViaLane() !=
nullptr;
2436 nextLane = (*link)->getViaLaneOrLane();
2437 if (nextLane ==
nullptr) {
2442 if (leader !=
nullptr) {
2443 #ifdef DEBUG_CONTEXT
2445 std::cout <<
" found leader " << leader->
getID() <<
" on nextLane=" << nextLane->
getID() <<
"\n";
2450 return std::make_pair(leader, dist);
2461 if (!nextInternal) {
2464 }
while (seen <= dist || nextLane->
isInternal());
2465 return std::make_pair(
static_cast<MSVehicle*
>(
nullptr), -1);
2469 std::pair<MSVehicle* const, double>
2471 #ifdef DEBUG_CONTEXT
2473 std::cout <<
SIMTIME <<
" getCriticalLeader. lane=" <<
getID() <<
" veh=" << veh.
getID() <<
"\n";
2477 std::pair<MSVehicle*, double> result = std::make_pair(
static_cast<MSVehicle*
>(
nullptr), -1);
2478 double safeSpeed = std::numeric_limits<double>::max();
2483 const MSLane* nextLane =
this;
2487 MSLinkCont::const_iterator link =
succLinkSec(veh, view, *nextLane, bestLaneConts);
2494 for (MSLink::LinkLeaders::const_iterator it = linkLeaders.begin(); it != linkLeaders.end(); ++it) {
2495 const MSVehicle* leader = (*it).vehAndGap.first;
2496 if (leader !=
nullptr && leader != result.first) {
2500 const double tmpSpeed = veh.
getSafeFollowSpeed((*it).vehAndGap, seen, nextLane, (*it).distToCrossing);
2501 #ifdef DEBUG_CONTEXT
2503 std::cout <<
" linkLeader=" << leader->
getID() <<
" gap=" << result.second <<
" tmpSpeed=" << tmpSpeed <<
" safeSpeed=" << safeSpeed <<
"\n";
2506 if (tmpSpeed < safeSpeed) {
2507 safeSpeed = tmpSpeed;
2508 result = (*it).vehAndGap;
2512 bool nextInternal = (*link)->getViaLane() !=
nullptr;
2513 nextLane = (*link)->getViaLaneOrLane();
2514 if (nextLane ==
nullptr) {
2518 if (leader !=
nullptr && leader != result.first) {
2521 if (tmpSpeed < safeSpeed) {
2522 safeSpeed = tmpSpeed;
2523 result = std::make_pair(leader, gap);
2534 if (!nextInternal) {
2537 }
while (seen <= dist || nextLane->
isInternal());
2547 for (MSEdgeVector::iterator i = pred.begin(); i != pred.end();) {
2556 if (pred.size() != 0) {
2558 MSEdge* best = *pred.begin();
2580 MSLane* cand = (*i).lane;
2581 if (&(cand->
getEdge()) == &fromEdge) {
2601 #ifdef DEBUG_LANE_SORTER
2602 std::cout <<
"\nBest predecessor lane for lane '" <<
myID <<
"': '" << best.
lane->
getID() <<
"'" << std::endl;
2617 std::vector<MSLink*> candidateLinks =
myLinks;
2620 MSLane* best = (*candidateLinks.begin())->getViaLaneOrLane();
2621 #ifdef DEBUG_LANE_SORTER
2622 std::cout <<
"\nBest successor lane for lane '" <<
myID <<
"': '" << best->
getID() <<
"'" << std::endl;
2632 if (pred ==
nullptr) {
2640 const std::vector<std::pair<const MSLane*, const MSEdge*> >
2642 std::vector<std::pair<const MSLane*, const MSEdge*> > result;
2644 assert(link->getLane() !=
nullptr);
2645 result.push_back(std::make_pair(link->getLane(), link->getViaLane() ==
nullptr ?
nullptr : &link->getViaLane()->getEdge()));
2667 for (MSLinkCont::const_iterator i =
myLinks.begin(); i !=
myLinks.end(); ++i) {
2668 if ((*i)->getLane()->getEdge().isCrossing()) {
2669 return (
int)(i -
myLinks.begin());
2713 wtime += (*i)->getWaitingSeconds();
2726 for (VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2727 v += (*i)->getSpeed();
2739 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2740 ret += (*i)->getCO2Emissions();
2751 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2752 ret += (*i)->getCOEmissions();
2763 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2764 ret += (*i)->getPMxEmissions();
2775 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2776 ret += (*i)->getNOxEmissions();
2787 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2788 ret += (*i)->getHCEmissions();
2799 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2800 ret += (*i)->getFuelConsumption();
2811 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2812 ret += (*i)->getElectricityConsumption();
2823 if (vehs.size() == 0) {
2827 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2828 double sv = (*i)->getHarmonoise_NoiseEmissions();
2829 ret += (double) pow(10., (sv / 10.));
2868 myLaneDir(e->getLanes()[0]->
getShape().angleAt2D(0)) {
2879 if (ae1 !=
nullptr && ae1->size() != 0) {
2889 if (ae2 !=
nullptr && ae2->size() != 0) {
2909 myLaneDir(targetLane->
getShape().angleAt2D(0)) {}
2927 #ifdef DEBUG_LANE_SORTER
2928 std::cout <<
"\nincoming_lane_priority sorter()\n"
2929 <<
"noninternal predecessor for lane '" << laneInfo1.
lane->
getID()
2930 <<
"': '" << noninternal1->
getID() <<
"'\n"
2931 <<
"noninternal predecessor for lane '" << laneInfo2.
lane->
getID()
2932 <<
"': '" << noninternal2->
getID() <<
"'\n";
2940 bool priorized1 =
true;
2941 bool priorized2 =
true;
2943 std::vector<MSLink*>::const_iterator j;
2944 #ifdef DEBUG_LANE_SORTER
2945 std::cout <<
"FoeLinks of '" << noninternal1->
getID() <<
"'" << std::endl;
2948 #ifdef DEBUG_LANE_SORTER
2949 std::cout << (*j)->getLaneBefore()->getID() << std::endl;
2957 #ifdef DEBUG_LANE_SORTER
2958 std::cout <<
"FoeLinks of '" << noninternal2->
getID() <<
"'" << std::endl;
2961 #ifdef DEBUG_LANE_SORTER
2962 std::cout << (*j)->getLaneBefore()->getID() << std::endl;
2971 assert(priorized1 || priorized2);
2972 if (priorized1 != priorized2) {
2987 myLaneDir(sourceLane->
getShape().angleAt2D(0)) {}
2993 if (target2 ==
nullptr) {
2996 if (target1 ==
nullptr) {
3000 #ifdef DEBUG_LANE_SORTER
3001 std::cout <<
"\noutgoing_lane_priority sorter()\n"
3002 <<
"noninternal successors for lane '" << myLane->
getID()
3003 <<
"': '" << target1->
getID() <<
"' and "
3004 <<
"'" << target2->
getID() <<
"'\n";
3011 if (priority1 != priority2) {
3012 return priority1 > priority2;
3050 for (
const std::string&
id : vehIds) {
3079 bool allSublanes,
double searchDist,
bool ignoreMinorLinks)
const {
3082 #ifdef DEBUG_CONTEXT
3084 std::cout <<
SIMTIME <<
" getFollowers lane=" <<
getID() <<
" ego=" << ego->
getID()
3085 <<
" backOffset=" << backOffset <<
" pos=" << egoPos
3086 <<
" allSub=" << allSublanes <<
" searchDist=" << searchDist <<
" ignoreMinor=" << ignoreMinorLinks
3096 #ifdef DEBUG_CONTEXT
3106 #ifdef DEBUG_CONTEXT
3108 std::cout <<
" (1) added veh=" << veh->
getID() <<
" latOffset=" << latOffset <<
" result=" << result.
toString() <<
"\n";
3113 #ifdef DEBUG_CONTEXT
3115 std::cout <<
" result.numFreeSublanes=" << result.
numFreeSublanes() <<
"\n";
3123 if (searchDist == -1) {
3125 #ifdef DEBUG_CONTEXT
3127 std::cout <<
" computed searchDist=" << searchDist <<
"\n";
3131 std::set<const MSEdge*> egoFurther;
3132 for (
MSLane* further : ego->getFurtherLanes()) {
3133 egoFurther.insert(&further->getEdge());
3135 if (ego->getPositionOnLane() < ego->getVehicleType().getLength() && egoFurther.size() == 0
3136 && ego->getLane()->getLogicalPredecessorLane() !=
nullptr) {
3138 egoFurther.insert(&ego->getLane()->getLogicalPredecessorLane()->getEdge());
3143 std::vector<MSLane::IncomingLaneInfo> newFound;
3145 while (toExamine.size() != 0) {
3146 for (std::vector<MSLane::IncomingLaneInfo>::iterator it = toExamine.begin(); it != toExamine.end(); ++it) {
3147 MSLane* next = (*it).lane;
3151 #ifdef DEBUG_CONTEXT
3153 std::cout <<
" next=" << next->
getID() <<
" seen=" << (*it).length <<
" first=" << first.
toString() <<
" firstFront=" << firstFront.
toString() <<
"\n";
3157 if (backOffset + (*it).length - next->
getLength() < 0
3158 && egoFurther.count(&next->
getEdge()) != 0
3162 for (
const auto& ll : linkLeaders) {
3163 if (ll.vehAndGap.first !=
nullptr) {
3164 const bool egoIsLeader = ll.vehAndGap.first->isLeader((*it).viaLink, ego);
3165 const double gap = egoIsLeader ?
NUMERICAL_EPS : ll.vehAndGap.second;
3167 #ifdef DEBUG_CONTEXT
3169 std::cout <<
SIMTIME <<
" ego=" << ego->getID() <<
" link=" << (*it).viaLink->getViaLaneOrLane()->getID()
3171 <<
" gap=" << ll.vehAndGap.second <<
" dtC=" << ll.distToCrossing
3172 <<
" egoIsLeader=" << egoIsLeader <<
" gap2=" << gap
3179 #ifdef DEBUG_CONTEXT
3192 if (v !=
nullptr && v != ego) {
3199 agap = (*it).length - next->
getLength() + backOffset
3202 #ifdef DEBUG_CONTEXT
3204 std::cout <<
" agap1=" << agap <<
"\n";
3207 if (agap > 0 && &v->
getLane()->
getEdge() != &ego->getLane()->getEdge()) {
3211 if (v !=
nullptr && v != ego) {
3219 if (!(*it).viaLink->havePriority() && !ego->onFurtherEdge(&(*it).lane->getEdge())
3223 agap =
MAX2(agap, 0.0);
3227 #ifdef DEBUG_CONTEXT
3234 if ((*it).length < searchDist) {
3235 const std::vector<MSLane::IncomingLaneInfo>& followers = next->
getIncomingLanes();
3236 for (std::vector<MSLane::IncomingLaneInfo>::const_iterator j = followers.begin(); j != followers.end(); ++j) {
3237 if (visited.find((*j).lane) == visited.end() && ((*j).viaLink->havePriority() || !ignoreMinorLinks)) {
3238 visited.insert((*j).lane);
3240 ili.
lane = (*j).lane;
3241 ili.
length = (*j).length + (*it).length;
3243 newFound.push_back(ili);
3249 swap(newFound, toExamine);
3274 const MSLane* nextLane =
this;
3280 MSLinkCont::const_iterator link =
succLinkSec(*ego, view, *nextLane, bestLaneConts);
3287 if (linkLeaders.size() > 0) {
3293 #ifdef DEBUG_CONTEXT
3295 std::cout <<
" linkleader=" << veh->
getID() <<
" gap=" << ll.
vehAndGap.second <<
"\n";
3303 bool nextInternal = (*link)->getViaLane() !=
nullptr;
3304 nextLane = (*link)->getViaLaneOrLane();
3305 if (nextLane ==
nullptr) {
3310 #ifdef DEBUG_CONTEXT
3312 std::cout <<
SIMTIME <<
" getLeadersOnConsecutive lane=" <<
getID() <<
" nextLane=" << nextLane->
getID() <<
" leaders=" << leaders.
toString() <<
"\n";
3317 for (
int i = 0; i < iMax; ++i) {
3319 if (veh !=
nullptr) {
3320 #ifdef DEBUG_CONTEXT
3340 if (!nextInternal) {
3355 #ifdef DEBUG_CONTEXT
3357 std::cout <<
SIMTIME <<
" getPartialBehind lane=" <<
getID() <<
" ego=" << ego->
getID() <<
" found=" << veh->
getID() <<
"\n";
3363 #ifdef DEBUG_CONTEXT
3386 std::set<MSVehicle*>
3388 assert(checkedLanes !=
nullptr);
3389 if (checkedLanes->find(
this) != checkedLanes->end()) {
3390 #ifdef DEBUG_SURROUNDING
3391 std::cout <<
"Skipping previously scanned lane: " <<
getID() << std::endl;
3393 return std::set<MSVehicle*>();
3396 (*checkedLanes)[
this] = std::make_pair(
MAX2(0.0, startPos - upstreamDist),
MIN2(startPos + downstreamDist,
getLength()));
3398 #ifdef DEBUG_SURROUNDING
3399 std::cout <<
"Scanning on lane " <<
myID <<
"(downstr. " << downstreamDist <<
", upstr. " << upstreamDist <<
", startPos " << startPos <<
"): " << std::endl;
3402 if (startPos < upstreamDist) {
3405 MSLane* incoming = incomingInfo.lane;
3406 #ifdef DEBUG_SURROUNDING
3407 std::cout <<
"Checking on incoming: " << incoming->
getID() << std::endl;
3408 if (checkedLanes->find(incoming) != checkedLanes->end()) {
3409 std::cout <<
"Skipping previous: " << incoming->
getID() << std::endl;
3413 foundVehicles.insert(newVehs.begin(), newVehs.end());
3417 if (
getLength() < startPos + downstreamDist) {
3421 #ifdef DEBUG_SURROUNDING
3422 std::cout <<
"Checking on outgoing: " << l->getViaLaneOrLane()->getID() << std::endl;
3424 std::set<MSVehicle*> newVehs = l->getViaLaneOrLane()->getSurroundingVehicles(0.0, downstreamDist - (
myLength - startPos), upstreamDist, checkedLanes);
3425 foundVehicles.insert(newVehs.begin(), newVehs.end());
3428 #ifdef DEBUG_SURROUNDING
3429 std::cout <<
"On lane (2) " <<
myID <<
": \nFound vehicles: " << std::endl;
3431 std::cout << v->getID() <<
" pos = " << v->getPositionOnLane() << std::endl;
3434 return foundVehicles;
3438 std::set<MSVehicle*>
3440 std::set<MSVehicle*> res;
3443 if (!vehs.empty()) {
3445 if (veh->getPositionOnLane() >= a) {
3446 if (veh->getBackPositionOnLane() > b) {
3458 std::vector<const MSJunction*>
3461 std::vector<const MSJunction*> junctions;
3463 junctions.insert(junctions.end(), l->getJunction());
3469 std::vector<const MSLink*>
3471 #ifdef DEBUG_SURROUNDING
3472 std::cout <<
"getUpcoming links on lane '" <<
getID() <<
"' with pos=" << pos
3473 <<
" range=" << range << std::endl;
3476 std::vector<const MSLink*> links;
3479 const MSLane* lane =
this;
3482 std::vector<MSLane*>::const_iterator contLanesIt = contLanes.begin();
3488 assert(*contLanesIt ==
nullptr);
3490 links.insert(links.end(), link);
3495 assert(*(contLanesIt + 1) == lane);
3497 while (++contLanesIt != contLanes.end()) {
3501 #ifdef DEBUG_SURROUNDING
3502 std::cout <<
"Distance until end of lane '" << lane->
getID() <<
"' is " << dist <<
"." << std::endl;
3508 if (link !=
nullptr) {
3509 links.insert(links.end(), link);
3511 lane = *contLanesIt;
3529 if (opposite ==
nullptr) {
3531 throw ProcessError(
"Lane '" +
getID() +
"' cannot compute oppositePos as there is no opposite lane.");
3538 std::pair<MSVehicle* const, double>
3543 #ifdef DEBUG_CONTEXT
3545 std::cout <<
" getFollower lane=" <<
getID() <<
" egoPos=" << egoPos <<
" pred=" << pred->
getID() <<
" predPos=" << pred->
getPositionOnLane(
this) <<
"\n";
3554 return std::make_pair(
const_cast<MSVehicle*
>(result.first), result.second);
3557 std::pair<MSVehicle* const, double>
3559 #ifdef DEBUG_OPPOSITE
3561 <<
" ego=" << ego->
getID()
3565 <<
" oppositeDir=" << oppositeDir
3573 std::pair<MSVehicle* const, double> result =
getFollower(ego, egoPos + egoLength, dist,
true);
3580 std::pair<MSVehicle* const, double>
3582 #ifdef DEBUG_OPPOSITE
3584 <<
" ego=" << ego->
getID()
3594 if (result.first !=
nullptr) {
3595 if (result.first->getLaneChangeModel().isOpposite()) {
3596 result.second -= result.first->getVehicleType().getLength();
3600 return std::make_pair(
static_cast<MSVehicle*
>(
nullptr), -1);
3611 const std::string action = oc.
getString(
"collision.action");
3612 if (action ==
"none") {
3614 }
else if (action ==
"warn") {
3616 }
else if (action ==
"teleport") {
3618 }
else if (action ==
"remove") {
3621 WRITE_ERROR(
"Invalid collision.action '" + action +
"'.");
3659 #ifdef DEBUG_INSERTION
3661 std::cout <<
SIMTIME <<
" check for pedestrians on lane=" <<
getID() <<
" pos=" << pos <<
"\n";
3666 if (leader.first != 0) {
3669 if (gap < 0 ||
checkFailure(aVehicle, speed, dist, stopSpeed, patchSpeed,
"")) {
3671 #ifdef DEBUG_INSERTION
3673 <<
" isInsertionSuccess lane=" <<
getID()
3674 <<
" veh=" << aVehicle->
getID()
3677 <<
" patchSpeed=" << patchSpeed
3678 <<
" speed=" << speed
3679 <<
" stopSpeed=" << stopSpeed
3680 <<
" pedestrianLeader=" << leader.first->getID()
3681 <<
" failed (@796)!\n";
3694 const int numRNGs = oc.
getInt(
"thread-rngs");
3695 const bool random = oc.
getBool(
"random");
3696 int seed = oc.
getInt(
"seed");
3698 for (
int i = 0; i < numRNGs; i++) {
3699 myRNGs.push_back(std::mt19937());
3708 if (bidiEdge ==
nullptr) {
3712 assert(bidiEdge->
getLanes().size() == 1);
std::vector< MSMoveReminder * > myMoveReminders
This lane's move reminder.
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
const std::string & getEdgeType() const
Returns the type of the edge.
double processNextStop(double currentVelocity)
Processes stops, returns the velocity needed to reach the stop.
void updateBestLanes(bool forceRebuild=false, const MSLane *startLane=0)
computes the best lanes to use in order to continue the route
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 getWaitingSeconds() const
Returns the overall waiting time on this lane.
int myI3End
end index for myTmpVehicles
static DictType myDict
Static dictionary to associate string-ids with objects.
SUMOTime collisionStopTime() const
Returns the remaining time a vehicle needs to stop due to a collision. A negative value indicates tha...
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
void gotActive(MSLane *l)
Informs the control that the given lane got active.
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
double brakeGap(const double speed) const
Returns the distance the vehicle needs to halt including driver's reaction time tau (i....
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
bool hasDeparted() const
Returns whether this vehicle has already departed.
@ LINKSTATE_EQUAL
This is an uncontrolled, right-before-left link.
double getCOEmissions() const
Returns the sum of last step CO emissions.
double getDepartPosLat(const MSVehicle &veh)
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
LinkState getIncomingLinkState() const
get the state of the link from the logical predecessor to this lane
bool hasArrived() const
Returns whether this vehicle has already arived (reached the arrivalPosition on its final edge)
std::vector< IncomingLaneInfo > myIncomingLanes
All direct predecessor lanes.
const std::set< MSTransportable * > & getPersons() const
Returns this edge's persons set.
LinkState getState() const
Returns the current state of the link.
int operator()(const MSLink *link1, const MSLink *link2) const
comparing operator
virtual double getArrivalPos() const
Returns this vehicle's desired arrivalPos for its current route (may change on reroute)
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
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.
#define WRITE_WARNING(msg)
MSLeaderInfo myFollowerInfo
followers on all sublanes as seen by vehicles on consecutive lanes (cached)
int operator()(const IncomingLaneInfo &lane1, const IncomingLaneInfo &lane2) const
comparing operator
const std::vector< LaneQ > & getBestLanes() const
Returns the description of best lanes to use in order to continue the route.
@ DEPART_POSLAT_RANDOM_FREE
If a fixed number of random choices fails, a free lateral position is chosen.
Representation of a lane in the micro simulation.
bool isStopped() const
Returns whether the vehicle is at a stop.
Base class for objects which have an id.
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle's end speed shall be chosen.
bool isLinkEnd(MSLinkCont::const_iterator &i) const
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
bool isVaporizing() const
Returns whether vehicles on this edge shall be vaporized.
bool executeMove()
Executes planned vehicle movements with regards to right-of-way.
std::string lane
The lane to stop at.
static double angleDiff(const double angle1, const double angle2)
Returns the difference of the second angle to the first angle in radiants.
void sortPartialVehicles()
sorts myPartialVehicles
std::vector< MSTransportable * > getSortedPersons(SUMOTime timestep, bool includeRiding=false) const
Returns this edge's persons sorted by pos.
saves leader/follower vehicles and their distances relative to an ego vehicle
MSVehicle * getLastAnyVehicle() const
returns the last vehicle that is fully or partially on this lane
double ymin() const
Returns minimum y-coordinate.
virtual void resetPartialOccupation(MSVehicle *v)
Removes the information about a vehicle lapping into this lane.
Static storage of an output device and its base (abstract) implementation.
void registerTeleportJam()
register one non-collision-related teleport
AnyVehicleIterator anyVehiclesUpstreamBegin() const
begin iterator for iterating over all vehicles touching this lane in upstream direction
std::vector< std::string > myNeighs
virtual void setJunctionApproaches(const SUMOTime t) const
Register junction approaches for all vehicles after velocities have been planned.
int myNumericalID
Unique numerical ID (set on reading by netload)
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 hasInfluencer() const
ConstMSEdgeVector::const_iterator MSRouteIterator
static std::vector< std::mt19937 > myRNGs
MSLane * getCanonicalSuccessorLane() const
const std::string myLaneType
the type of this lane
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.
bool overlapsWith(const AbstractPoly &poly, double offset=0) const
Returns the information whether the given polygon overlaps with this.
double departSpeed
(optional) The initial speed of the vehicle
void sortManeuverReservations()
sorts myManeuverReservations
double getLatOffset(const MSLane *lane) const
Get the offset that that must be added to interpret myState.myPosLat for the given lane.
PositionVector getBoundingBox() const
get bounding rectangle
double getMinDeceleration() const
return the minimum deceleration capability for all vehicles that ever entered the network
void informVehicleStateListener(const SUMOVehicle *const vehicle, VehicleState to, const std::string &info="")
Informs all added listeners about a vehicle's state change.
MSLeaderInfo getPartialBeyond() const
get all vehicles that are inlapping from consecutive edges
double myNettoVehicleLengthSumToRemove
The length of all vehicles that have left this lane in the current step (this lane,...
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
@ DEPART_POS_STOP
depart position is endPos of first stop
virtual double getSecureGap(const MSVehicle *const, const MSVehicle *const, const double speed, const double leaderSpeed, const double leaderMaxDecel) const
Returns the minimum gap to reserve if the leader is braking at maximum (>=0)
virtual const std::string & getID() const =0
Get the vehicle's ID.
int myDirection
index delta
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...
static double myCollisionMinGapFactor
const MSLeaderInfo getLastVehicleInformation(const MSVehicle *ego, double latOffset, double minPos=0, bool allowCached=true) const
Returns the last vehicles on the lane.
Container & getContainer()
std::string busstop
(Optional) bus stop if one is assigned to the stop
std::pair< MSVehicle *const, double > getOppositeFollower(const MSVehicle *ego) const
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...
VehCont myManeuverReservations
The vehicles which registered maneuvering into the lane within their current action step....
@ DEPART_POSLAT_LEFT
At the leftmost side of the lane.
bool isParking() const
Returns whether the vehicle is parking.
double getRightSideOnEdge() const
MSInsertionControl & getInsertionControl()
Returns the insertion control.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
@ DEPART_POS_DEFAULT
No information given; use default.
static MSLinkCont::const_iterator succLinkSec(const SUMOVehicle &veh, int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane * > &conts)
void needsVehicleIntegration(MSLane *const l)
static int gNumSimThreads
how many threads to use for simulation
const MSEdge * getLastEdge() const
returns the destination edge
@ DEPART_POS_LAST
Insert behind the last vehicle as close as possible to still allow the specified departSpeed....
@ SUMO_TAG_LANE
begin/end of the description of a single lane
const std::vector< MSLink * > & getFoeLinks() const
Representation of a vehicle.
std::vector< MSVehicle * > VehCont
Container for vehicles.
const MSRoute & getRoute() const
Returns the current route.
bool resumeFromStopping()
void initRestrictions()
initialized vClass-specific speed limits
double xmax() const
Returns maximum x-coordinate.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
double getDepartSpeed(const MSVehicle &veh, bool &patchSpeed)
int numFreeSublanes() const
void recalcCache()
Recalculates the cached values.
double getHarmonoise_NoiseEmissions() const
Returns the sum of last step noise emissions.
bool addStop(const SUMOVehicleParameter::Stop &stopPar, std::string &errorMsg, SUMOTime untilOffset=0, bool collision=false, MSRouteIterator *searchStart=0)
Adds a stop.
void onRemovalFromNet(const MSMoveReminder::Notification reason)
Called when the vehicle is removed from the network.
int getPriority() const
Returns the priority of the edge.
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.
static CollisionAction myCollisionAction
the action to take on collisions
std::string parkingarea
(Optional) parking area if one is assigned to the stop
double getHCEmissions() const
Returns the sum of last step HC emissions.
Structure representing possible vehicle parameter.
virtual void planMovements(const SUMOTime t)
Compute safe velocities for all vehicles based on positions and speeds from the last time step....
PositionVector myShape
The shape of the lane.
const MSVehicle * operator*()
MSVehicle * getLastFullVehicle() const
returns the last vehicle for which this lane is responsible or 0
@ SUMO_TAG_VIEWSETTINGS_VEHICLES
void scheduleVehicleRemoval(SUMOVehicle *veh, bool checkDuplicate=false)
Removes a vehicle after it has ended.
void forceVehicleInsertion(MSVehicle *veh, double pos, MSMoveReminder::Notification notification, double posLat=0)
Inserts the given vehicle at the given position.
static CollisionAction getCollisionAction()
MSLeaderInfo myLeaderInfo
leaders on all sublanes as seen by approaching vehicles (cached)
MSLane * getBidiLane() const
retrieve bidirectional lane or nullptr
virtual int addLeader(const MSVehicle *veh, bool beyond, double latOffset=0)
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
bool triggered
whether an arriving person lets the vehicle continue
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
void setMaxSpeed(double val)
Sets a new maximum speed for the lane (used by TraCI and MSCalibrator)
double getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
AnyVehicleIterator & operator++()
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...
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
void addLink(MSLink *link)
Delayed initialization.
Sorts vehicles by their position (descending)
MSAbstractLaneChangeModel & getLaneChangeModel()
@ DEPART_POSLAT_RIGHT
At the rightmost side of the lane.
double myRightSideOnEdge
the combined width of all lanes with lower index on myEdge
bool isChangingLanes() const
return true if the vehicle currently performs a lane change maneuver
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
double angleAt2D(int pos) const
get angle in certain position of position vector
const double myWidth
Lane width [m].
@ DEPART_SPEED_LIMIT
The maximum lane speed is used (speedLimit)
static double gLateralResolution
Influencer & getInfluencer()
Returns the velocity/lane influencer.
Something on a lane to be noticed about vehicle movement.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
@ NOTIFICATION_VAPORIZED
The vehicle got vaporized.
double getChosenSpeedFactor() const
Returns the precomputed factor by which the driver wants to be faster than the speed limit.
MSVehicle * getPartialBehind(const MSVehicle *ego) const
MSLane * myCanonicalSuccessorLane
Main successor lane,.
static MSVehicleTransfer * getInstance()
Returns the instance of this object.
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
double myBruttoVehicleLengthSumToRemove
The length of all vehicles that have left this lane in the current step (this lane,...
double myBruttoVehicleLengthSum
The current length of all vehicles on this lane, including their minGaps.
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 isInternal() const
return whether this edge is an internal edge
double myNettoVehicleLengthSum
The current length of all vehicles on this lane, excluding their minGaps.
@ DEPART_POSLAT_FREE
A free lateral position is chosen.
int myI2
index for myPartialVehicles
static void insertIDs(std::vector< std::string > &into)
Adds the ids of all stored lanes into the given vector.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
void addParking(MSVehicle *veh)
add parking vehicle. This should only used during state loading
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic,...
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
double getCO2Emissions() const
Returns the sum of last step CO2 emissions.
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.
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
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.
SUMOTime myFollowerInfoTime
time step for which myFollowerInfo was last updated
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
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
virtual void executeMovements(const SUMOTime t)
Executes planned vehicle movements with regards to right-of-way.
MSLane * getLane() const
Returns the connected lane.
by_connections_to_sorter(const MSEdge *const e)
constructor
virtual void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
double getElectricityConsumption() const
Returns the sum of last step electricity 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)
std::pair< const MSPerson *, double > PersonDist
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...
double getPositionOnLane() const
Get the vehicle's position along the lane.
std::map< SVCPermissions, double > myStopOffsets
const double myLengthGeometryFactor
precomputed myShape.length / myLength
double getImpatience() const
Returns this vehicles impatience.
static const long CHANGE_PERMISSIONS_PERMANENT
double xmin() const
Returns minimum x-coordinate.
SUMOTime myLeaderInfoTime
time step for which myLeaderInfo was last updated
@ DEPART_POS_FREE
A free position is chosen.
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
static void initRNGs(const OptionsCont &oc)
initialize rngs
@ DEPART_SPEED_DESIRED
The maximum lane speed is used (speedLimit * speedFactor)
virtual std::string toString() const
print a debugging representation
int getVehicleNumberWithPartials() const
Returns the number of vehicles on this lane (including partial occupators)
double getStopOffset(const MSVehicle *veh) const
Returns vehicle class specific stopOffset for the vehicle.
MSLane * getShadowLane() const
Returns the lane the vehicle's shadow is on during continuous/sublane lane change.
double getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
const bool myIsRampAccel
whether this lane is an acceleration lane
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.
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 changeLanes(const SUMOTime time)
virtual void addMoveReminder(MSMoveReminder *rem)
Add a move-reminder to move-reminder container.
@ DEPART_SPEED_GIVEN
The speed is given.
int myI1
index for myVehicles
SUMOTime until
The time at which the vehicle may continue its journey.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
void leftByLaneChange(MSVehicle *v)
MSLane * myLogicalPredecessorLane
@ COLLISION_ACTION_REMOVE
A scoped lock which only triggers on condition.
std::set< MSVehicle * > getVehiclesInRange(const double a, const double b) const
Returns all vehicles on the lane overlapping with the interval [a,b].
bool insertVehicle(MSVehicle &v)
Tries to insert the given vehicle.
A class that stores a 2D geometrical boundary.
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....
double getNOxEmissions() const
Returns the sum of last step NOx emissions.
virtual bool appropriate(const MSVehicle *veh)
std::vector< LinkLeader > LinkLeaders
double getLength() const
Returns the lane's length.
PositionVector getBoundingPoly() const
get bounding polygon
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...
double getOppositePos(double pos) const
return the corresponding position on the opposite lane
static void clear()
Clears the dictionary.
void descheduleDeparture(const SUMOVehicle *veh)
stops trying to emit the given vehicle (and delete it)
@ VEHICLE_STATE_COLLISION
The vehicle is involved in a collision.
std::pair< MSVehicle *const, double > getOppositeLeader(const MSVehicle *ego, double dist, bool oppositeDir) const
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...
std::pair< MSVehicle *, double > vehAndGap
double getAngle() const
Returns the vehicle's direction in radians.
SVCPermissions myOriginalPermissions
The original vClass permissions for this lane (before temporary modifications)
double getMeanSpeed() const
Returns the mean speed on this lane.
int operator()(const std::pair< const MSVehicle *, double > &p1, const std::pair< const MSVehicle *, double > &p2) const
double getEndPos(const SUMOVehicle &veh) const
return halting position for upcoming stop;
std::string time2string(SUMOTime t)
bool freeInsertion(MSVehicle &veh, double speed, double posLat, MSMoveReminder::Notification notification=MSMoveReminder::NOTIFICATION_DEPARTED)
Tries to insert the given vehicle on any place.
Sorts lanes (their origin link) by the priority of their noninternal target edges or,...
const MSLane * lane
The lane to stop at.
Sorts edges by their angle relative to the given edge (straight comes first)
void addApproachingLane(MSLane *lane, bool warnMultiCon)
const MSEdge * getBidiEdge() const
return opposite superposable/congruent edge, if it exist and 0 else
void registerTeleportYield()
register one non-collision-related teleport
@ LINKSTATE_DEADEND
This is a dead end link.
const MSEdge * getNextNormal() const
Returns the lane's follower if it is an internal lane, the edge of the lane otherwise.
double getMinGap() const
Get the free space in front of vehicles of this class.
bool checkForPedestrians(const MSVehicle *aVehicle, double &speed, double &dist, double pos, bool patchSpeed) const
check whether pedestrians on this lane interfere with vehicle insertion
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
A storage for options typed value containers)
A road/street connecting two junctions.
bool myNeedsCollisionCheck
whether a collision check is currently needed
double endPos
The stopping position end.
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...
@ DEPART_SPEED_RANDOM
The speed is chosen randomly.
int operator()(MSVehicle *v1, MSVehicle *v2) const
Comparing operator.
double getInternalLengthsAfter() const
Returns the cumulative length of all internal lanes after this link.
bool isLeader(const MSLink *link, const MSVehicle *veh) const
whether the given vehicle must be followed at the given junction
@ DEPART_POS_RANDOM
The position is chosen randomly.
bool nextIsMyVehicles() const
virtual void resetManeuverReservation(MSVehicle *v)
Unregisters a vehicle, which previously registered for maneuvering into this lane.
MSLane * getCanonicalPredecessorLane() const
@ LINKSTATE_MINOR
This is an uncontrolled, minor link, has to brake.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
int operator()(MSVehicle *v1, MSVehicle *v2) const
Comparing operator.
@ NOTIFICATION_DEPARTED
The vehicle has departed (was inserted into the network)
double getNettoOccupancy() const
Returns the netto (excluding minGaps) occupancy of this lane during the last step (including minGaps)
const std::vector< MSLane * > * allowedLanes(const MSEdge &destination, SUMOVehicleClass vclass=SVC_IGNORING) const
Get the allowed lanes to reach the destination-edge.
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
@ ARRIVAL_SPEED_GIVEN
The speed is given.
int myI1End
end index for myVehicles
virtual void setManeuverReservation(MSVehicle *v)
Registers the lane change intentions (towards this lane) for the given vehicle.
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...
AnyVehicleIterator anyVehiclesEnd() const
end iterator for iterating over all vehicles touching this lane in downstream direction
@ SVC_SHIP
is an arbitrary ship
int myI3
index for myTmpVehicles
SUMOTime string2time(const std::string &r)
double departPosLat
(optional) The lateral position the vehicle shall depart from
virtual void detectCollisions(SUMOTime timestep, const std::string &stage)
Check if vehicles are too close.
void loadState(const std::vector< std::string > &vehIDs, MSVehicleControl &vc)
Loads the state of this segment with the given parameters.
void updateLengthSum()
updated current vehicle length sum (delayed to avoid lane-order-dependency)
std::string toString() const
print a debugging representation
double getPMxEmissions() const
Returns the sum of last step PMx emissions.
static bool haveLateralDynamics()
whether any kind of lateral dynamics is active
bool isApproachedFrom(MSEdge *const edge)
double basePos(const MSEdge *edge) const
departure position where the vehicle fits fully onto the edge (if possible)
const SUMOVehicleParameter::Stop pars
The stop parameter.
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
MSLane * getOpposite() const
return the opposite direction lane for lane changing or 0
int addFollower(const MSVehicle *veh, const MSVehicle *ego, double gap, double latOffset=0, int sublane=-1)
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
Definition of vehicle stop (position and duration)
double startPos
The stopping position start.
MSLane * getLane() const
Returns the lane the vehicle is on.
static bool myCheckJunctionCollisions
virtual ~MSLane()
Destructor.
double getMaximumBrakeDist() const
compute maximum braking distance on this lane
MSEdge & getEdge() const
Returns the lane's edge.
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 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 registerCollision()
registers one collision-related teleport
const std::map< SUMOVehicleClass, double > * myRestrictions
The vClass speed restrictions for this lane.
void addIncomingLane(MSLane *lane, MSLink *viaLink)
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
virtual const MSEdge * succEdge(int nSuccs) const =0
Returns the nSuccs'th successor of edge the vehicle is currently at.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static bool gUnitTests
whether unit tests are being run
MSEdge *const myEdge
The lane's edge, for routing only.
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...
int myRightmostSublane
the index of the rightmost sublane of this lane on myEdge
const PositionVector & getShape() const
Returns this lane's shape.
virtual bool hasPedestrians(const MSLane *lane)
whether the given lane has pedestrians on it
bool containerTriggered
whether an arriving container lets the vehicle continue
void registerTeleportWrongLane()
register one non-collision-related teleport
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
int myIndex
The lane index.
std::map< std::string, MSLane * > DictType
definition of the static dictionary type
static SUMOTime gTimeToGridlock
std::map< MSEdge *, std::vector< MSLane * > > myApproachingLanes
All direct internal and direct (disregarding internal predecessors) non-internal predecessor lanes of...
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 *, ComparatorNumericalIdLess > &toTeleport) const
take action upon collision
void saveState(OutputDevice &out)
Saves the state of this lane into the given stream.
bool mustCheckJunctionCollisions() const
whether this lane must check for junction collisions
@ NOTIFICATION_ARRIVED
The vehicle arrived at its destination (is deleted)
bool checkFailure(const MSVehicle *aVehicle, double &speed, double &dist, const double nspeed, const bool patchSpeed, const std::string errorMsg) const
int index
at which position in the stops list
double getLength() const
Get vehicle's length [m].
@ DEPART_POSLAT_DEFAULT
No information given; use default.
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)
virtual int addLeader(const MSVehicle *veh, double gap, double latOffset=0, int sublane=-1)
incoming_lane_priority_sorter(const MSLane *targetLane)
constructor
virtual void integrateNewVehicles()
Insert buffered vehicle into the real lane.
@ DEPART_POSLAT_RANDOM
The lateral position is chosen randomly.
@ DEPART_POS_RANDOM_FREE
If a fixed number of random choices fails, a free position is chosen.
const SVCPermissions SVCAll
all VClasses are allowed
SVCPermissions myPermissions
The vClass permissions for this lane.
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 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)
double myLength
Lane length [m].
double getCollisionMinGapFactor() const
Get the factor of minGap that must be maintained to avoid a collision event.
AnyVehicleIterator anyVehiclesUpstreamEnd() const
end iterator for iterating over all vehicles touching this lane in upstream direction
bool isRemoteAffected(SUMOTime t) const
std::vector< MSEdge * > MSEdgeVector
const MSEdge * succEdge(int nSuccs) const
Returns the nSuccs'th successor of edge the vehicle is currently at.
double getRightSideOnLane() const
Get the vehicle's lateral position on the lane:
SUMOVehicleClass getVClass() const
Returns the vehicle's access class.
MSLink * getLinkTo(const MSLane *) const
returns the link to the given lane or 0, if it is not connected
void setLength(double val)
Sets a new length for the lane (used by TraCI only)
NumericalID getNumericalID() const
return the numerical ID which is only for internal usage
double getEmergencyDecel() const
Get the vehicle type's maximal phisically possible deceleration [m/s^2].
FXSynchQue< MSVehicle *, std::vector< MSVehicle * > > myVehBuffer
Buffer for vehicles that moved from their previous lane onto this one. Integrated after all vehicles ...
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the best sequence of lanes to continue the route starting at myLane.
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.
static void fill(RTREE &into)
Fills the given RTree with lane instances.
const std::string & getID() const
Returns the name of the vehicle.
MSLane * getParallelLane(int offset, bool includeOpposite=true) const
Returns the lane with the given offset parallel to this one or 0 if it does not exist.
VehCont myPartialVehicles
The lane's partial vehicles. This container holds all vehicles that are partially on this lane but wh...
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
virtual void removeParking(MSVehicle *veh)
remove parking vehicle. This must be syncrhonized when running with GUI
double getBackPositionOnLane(const MSLane *lane) const
Get the vehicle's position relative to the given lane.
int operator()(const MSEdge *const e1, const MSEdge *const e2) const
comparing operator
A RT-tree for efficient storing of SUMO's Named objects.
@ DEPART_SPEED_MAX
The maximum safe speed is used.
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
double getWidth() const
Returns the lane's width.
static MSPModel * getModel()
std::set< const MSVehicle * > myParkingVehicles
virtual void changeLanes(SUMOTime t)
Performs lane changing on this edge.
The car-following model abstraction.
void add(const SUMOTime t, MSVehicle *veh)
Adds a vehicle to this transfer object.
SUMOTime getWaitingTime() const
Returns the SUMOTime waited (speed was lesser than 0.1m/s)
@ LINKSTATE_ALLWAY_STOP
This is an uncontrolled, all-way stop link.
static bool hasOncomingRailTraffic(MSLink *link)
MSVehicle * getFirstAnyVehicle() const
returns the first vehicle that is fully or partially on this lane
The class responsible for building and deletion of vehicles.
@ DEPART_POS_BASE
Back-at-zero position.
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
@ DEPART_SPEED_DEFAULT
No information given; use default.
bool gDebugFlag1
global utility flags for debugging
@ COLLISION_ACTION_TELEPORT
double getSpeed() const
Returns the vehicle's current speed.
int gPrecision
the precision for floating point outputs
Boundary & grow(double by)
extends the boundary by the given amount
bool operator()(const MSVehicle *cmp, double pos) const
compares vehicle position to the detector position
MSLane * myCanonicalPredecessorLane
Similar to LogicalPredecessorLane,.
static SUMOTime gLaneChangeDuration
@ DEPART_POS_GIVEN
The position is given.
bool isFrontOnLane(const MSLane *lane) const
Returns the information whether the front of the vehicle is on the given lane.
const std::vector< std::pair< const MSLane *, const MSEdge * > > getOutgoingViaLanes() const
get the list of outgoing lanes
const MSLane * getNormalPredecessorLane() const
get normal lane leading to this internal lane, for normal lanes, the lane itself is returned
DepartPosLatDefinition departPosLatProcedure
Information how the vehicle shall choose the lateral departure position.
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.
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.
@ DEPART_POSLAT_CENTER
At the center of the lane.
std::map< long long, SVCPermissions > myPermissionChanges
std::pair< const MSVehicle *, double > CLeaderDist
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
MSEdgeControl & getEdgeControl()
Returns the edge control.
std::string myID
The name of the object.
double getFuelConsumption() const
Returns the sum of last step fuel consumption.
virtual double setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
double getMaxSpeedFactor() const
return the maximum speed factor for all vehicles that ever entered the network
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
int getCrossingIndex() const
return the index of the link to the next crossing if this is walkingArea, else -1
bool parking
whether the vehicle is removed from the net while stopping
std::string chargingStation
(Optional) charging station if one is assigned to the stop
MSVehicle * getFirstFullVehicle() const
returns the first vehicle for which this lane is responsible or 0
const std::string & getID() const
Returns the id.
Notification
Definition of a vehicle state.
std::string containerstop
(Optional) container stop if one is assigned to the stop
@ NOTIFICATION_JUNCTION
The vehicle arrived at a junction.
outgoing_lane_priority_sorter(const MSLane *sourceLane)
constructor
Sorts lanes (IncomingLaneInfos) by their priority or, if this doesn't apply, wrt. the angle differenc...
@ DEPART_POSLAT_GIVEN
The position is given.
AnyVehicleIterator is a structure, which manages the iteration through all vehicles on the lane,...
void addNeigh(const std::string &id)
Adds a neighbor to this lane.
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...
VehCont myVehicles
The lane's vehicles. This container holds all vehicles that have their front (longitudinally) and the...
static SUMOTime gTimeToGridlockHighways
double myMaxSpeed
Lane-wide speedlimit [m/s].
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
@ NOTIFICATION_TELEPORT
The vehicle is being teleported.
double departPos
(optional) The position the vehicle shall depart from
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
void resetPermissions(long long transientID)
void enteredByLaneChange(MSVehicle *v)
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.
static SUMOTime myCollisionStopTime
Definition of vehicle stop (position and duration)
VehCont myTmpVehicles
Container for lane-changing vehicles. After completion of lane-change- process, the containers will b...
static double sum(double val)
Computes the resulting noise.
double ymax() const
Returns maximum y-coordinate.
MSLink * getEntryLink() const
Returns the entry link if this is an internal lane, else 0.
double arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
AnyVehicleIterator anyVehiclesBegin() const
begin iterator for iterating over all vehicles touching this lane in downstream direction
bool hasStops() const
Returns whether the vehicle has to stop somewhere.
@ LINKSTATE_STOP
This is an uncontrolled, minor link, has to stop.
static void initCollisionOptions(const OptionsCont &oc)
const MSEdgeVector & getPredecessors() const
Representation of a vehicle in the micro simulation.
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)