84 #define DEBUG_COND (true) 86 #define DEBUG_COND2(obj) ((obj != 0 && (obj)->isSelected())) 192 for (MSLinkCont::iterator i =
myLinks.begin(); i !=
myLinks.end(); ++i) {
221 (*veh)->addReminder(rem);
231 std::cout <<
SIMTIME <<
" setPartialOccupation. lane=" <<
getID() <<
" veh=" << v->
getID() <<
"\n";
244 std::cout <<
SIMTIME <<
" resetPartialOccupation. lane=" <<
getID() <<
" veh=" << v->
getID() <<
"\n";
291 leader = leaderInfo.first;
303 if (leaderBack >= frontGapNeeded) {
304 pos =
MIN2(pos, leaderBack - frontGapNeeded);
318 bool adaptableSpeed =
true;
327 if (missingRearGap > 0) {
328 if (minPos + missingRearGap <=
myLength) {
335 return isInsertionSuccess(&veh, mspeed, minPos + missingRearGap, posLat, adaptableSpeed, notification);
340 return isInsertionSuccess(&veh, mspeed, minPos, posLat, adaptableSpeed, notification);
347 const double speed = adaptableSpeed ? leader->
getSpeed() : mspeed;
349 if (leaderPos >= frontGapNeeded) {
359 MSLane::VehCont::iterator predIt =
myVehicles.begin();
370 double speed = mspeed;
371 if (adaptableSpeed && leader != 0) {
380 frontMax = leaderRearPos - frontGapNeeded;
388 if (frontMax > minPos && backMin +
POSITION_EPS < frontMax) {
457 bool patchSpeed =
true;
474 for (
int i = 0; i < 10; i++) {
500 for (
int i = 0; i < 10; i++) {
536 if (nspeed < speed) {
538 speed =
MIN2(nspeed, speed);
540 }
else if (speed > 0) {
541 if (errorMsg !=
"") {
542 WRITE_ERROR(
"Vehicle '" + aVehicle->
getID() +
"' will not be able to depart using the given velocity (" + errorMsg +
")!");
554 double speed,
double pos,
double posLat,
bool patchSpeed,
559 aVehicle->
getID() +
"'. Inserting at lane end instead.");
563 #ifdef DEBUG_INSERTION 564 if (
DEBUG_COND2(aVehicle)) std::cout <<
"\nIS_INSERTION_SUCCESS\n" 566 <<
" veh '" << aVehicle->
getID() <<
"'\n";
573 std::vector<MSLane*>::const_iterator ri = bestLaneConts.begin();
581 if (nextStop.
lane ==
this) {
582 std::stringstream msg;
583 msg <<
"scheduled stop on lane '" <<
myID <<
"' too close";
584 const double distToStop = nextStop.
endPos - pos;
586 patchSpeed, msg.str())) {
596 MSLane* currentLane =
this;
599 while (seen < dist && ri != bestLaneConts.end()) {
601 MSLinkCont::const_iterator link =
succLinkSec(*aVehicle, nRouteSuccs, *currentLane, bestLaneConts);
607 patchSpeed,
"arrival speed too low")) {
615 patchSpeed,
"junction too close")) {
624 || !(*link)->havePriority()) {
626 std::string errorMsg =
"";
627 const LinkState state = (*link)->getState();
633 errorMsg =
"unpriorised junction too close";
636 patchSpeed, errorMsg)) {
640 #ifdef DEBUG_INSERTION 642 std::cout <<
"trying insertion before minor link: " 643 <<
"insertion speed = " << speed <<
" dist=" << dist
650 nextLane = (*link)->getViaLaneOrLane();
658 if (nextStop.
lane == nextLane) {
659 std::stringstream msg;
660 msg <<
"scheduled stop on lane '" << nextStop.
lane->
getID() <<
"' too close";
661 const double distToStop = seen + nextStop.
endPos;
663 patchSpeed, msg.str())) {
675 #ifdef DEBUG_INSERTION 677 <<
"leader on lane '" << nextLane->
getID() <<
"': " << leader->
getID() <<
"\n";
686 if (
checkFailure(aVehicle, speed, dist, nspeed, patchSpeed,
"")) {
688 #ifdef DEBUG_INSERTION 690 <<
" isInsertionSuccess lane=" <<
getID()
691 <<
" veh=" << aVehicle->
getID()
693 <<
" posLat=" << posLat
694 <<
" patchSpeed=" << patchSpeed
695 <<
" speed=" << speed
696 <<
" nspeed=" << nspeed
697 <<
" nextLane=" << nextLane->
getID()
698 <<
" lead=" << leader->
getID()
700 <<
" failed (@641)!\n";
707 if (nspeed < speed) {
713 WRITE_ERROR(
"Vehicle '" + aVehicle->
getID() +
"' will not be able to depart using the given velocity (slow lane ahead)!");
722 if ((*link)->hasApproachingFoe(arrivalTime, leaveTime, speed, cfModel.
getMaxDecel())) {
730 currentLane = nextLane;
731 if ((*link)->getViaLane() == 0) {
743 if (nspeed < 0 ||
checkFailure(aVehicle, speed, dist, nspeed, patchSpeed,
"")) {
748 #ifdef DEBUG_INSERTION 750 <<
" isInsertionSuccess lane=" <<
getID()
751 <<
" veh=" << aVehicle->
getID()
753 <<
" posLat=" << posLat
754 <<
" patchSpeed=" << patchSpeed
755 <<
" speed=" << speed
756 <<
" nspeed=" << nspeed
757 <<
" nextLane=" << nextLane->
getID()
758 <<
" leaders=" << leaders.
toString()
759 <<
" failed (@700)!\n";
763 #ifdef DEBUG_INSERTION 765 <<
" speed = " << speed
766 <<
" nspeed = " << nspeed
771 for (
int i = 0; i < followers.
numSublanes(); ++i) {
772 const MSVehicle* follower = followers[i].first;
775 if (followers[i].second < backGapNeeded) {
777 #ifdef DEBUG_INSERTION 779 <<
" isInsertionSuccess lane=" <<
getID()
780 <<
" veh=" << aVehicle->
getID()
782 <<
" posLat=" << posLat
783 <<
" patchSpeed=" << patchSpeed
784 <<
" speed=" << speed
785 <<
" nspeed=" << nspeed
786 <<
" follower=" << follower->
getID()
787 <<
" backGapNeeded=" << backGapNeeded
788 <<
" gap=" << followers[i].second
789 <<
" failure (@719)!\n";
796 #ifdef DEBUG_INSERTION 801 if (shadowLane != 0) {
803 for (
int i = 0; i < followers.
numSublanes(); ++i) {
804 const MSVehicle* follower = followers[i].first;
807 if (followers[i].second < backGapNeeded) {
809 #ifdef DEBUG_INSERTION 811 <<
" isInsertionSuccess shadowlane=" << shadowLane->
getID()
812 <<
" veh=" << aVehicle->
getID()
814 <<
" posLat=" << posLat
815 <<
" patchSpeed=" << patchSpeed
816 <<
" speed=" << speed
817 <<
" nspeed=" << nspeed
818 <<
" follower=" << follower->
getID()
819 <<
" backGapNeeded=" << backGapNeeded
820 <<
" gap=" << followers[i].second
821 <<
" failure (@812)!\n";
833 if (gap < gapNeeded) {
835 #ifdef DEBUG_INSERTION 837 <<
" isInsertionSuccess shadowlane=" << shadowLane->
getID()
838 <<
" veh=" << aVehicle->
getID()
840 <<
" posLat=" << posLat
841 <<
" patchSpeed=" << patchSpeed
842 <<
" speed=" << speed
843 <<
" nspeed=" << nspeed
844 <<
" leader=" << veh->
getID()
845 <<
" gapNeeded=" << gapNeeded
847 <<
" failure (@842)!\n";
858 if (missingRearGap > 0) {
860 #ifdef DEBUG_INSERTION 862 <<
" isInsertionSuccess lane=" <<
getID()
863 <<
" veh=" << aVehicle->
getID()
865 <<
" posLat=" << posLat
866 <<
" patchSpeed=" << patchSpeed
867 <<
" speed=" << speed
868 <<
" nspeed=" << nspeed
869 <<
" missingRearGap=" << missingRearGap
870 <<
" failure (@728)!\n";
877 #ifdef DEBUG_INSERTION 879 <<
" isInsertionSuccess lane=" <<
getID()
880 <<
" veh=" << aVehicle->
getID()
882 <<
" posLat=" << posLat
883 <<
" patchSpeed=" << patchSpeed
884 <<
" speed=" << speed
885 <<
" nspeed=" << nspeed
886 <<
" failed (@733)!\n";
892 #ifdef DEBUG_INSERTION 894 <<
" isInsertionSuccess lane=" <<
getID()
895 <<
" veh=" << aVehicle->
getID()
897 <<
" posLat=" << posLat
898 <<
" patchSpeed=" << patchSpeed
899 <<
" speed=" << speed
900 <<
" nspeed=" << nspeed
921 double nspeed = speed;
929 nspeed =
MIN2(nspeed,
943 int freeSublanes = 1;
948 while (freeSublanes > 0 && veh != 0) {
949 #ifdef DEBUG_PLAN_MOVE 952 std::cout <<
" getLastVehicleInformation lane=" <<
getID() <<
" minPos=" << minPos <<
" veh=" << veh->
getID() <<
" pos=" << veh->
getPositionOnLane(
this) <<
"\n";
958 #ifdef DEBUG_PLAN_MOVE 966 if (ego == 0 && minPos == 0) {
971 #ifdef DEBUG_PLAN_MOVE 997 int freeSublanes = 1;
999 while (freeSublanes > 0 && veh != 0) {
1000 #ifdef DEBUG_PLAN_MOVE 1002 std::cout <<
" veh=" << veh->
getID() <<
" pos=" << veh->
getPositionOnLane(
this) <<
" maxPos=" << maxPos <<
"\n";
1009 #ifdef DEBUG_PLAN_MOVE 1011 std::cout <<
" veh=" << veh->
getID() <<
" latOffset=" << latOffset <<
"\n";
1023 #ifdef DEBUG_PLAN_MOVE 1046 double cumulatedVehLength = 0.;
1049 VehCont::reverse_iterator veh =
myVehicles.rbegin();
1051 #ifdef DEBUG_PLAN_MOVE 1055 <<
" planMovements lane=" <<
getID()
1063 && ((*vehPart)->getPositionOnLane(
this) > (*veh)->getPositionOnLane())) {
1064 const double latOffset = (*vehPart)->getLatOffset(
this);
1065 #ifdef DEBUG_PLAN_MOVE 1067 std::cout <<
" partial ahead: " << (*vehPart)->getID() <<
" latOffset=" << latOffset <<
"\n";
1070 ahead.
addLeader(*vehPart,
false, latOffset);
1073 #ifdef DEBUG_PLAN_MOVE 1075 std::cout <<
" plan move for: " << (*veh)->getID() <<
" ahead=" << ahead.
toString() <<
"\n";
1078 (*veh)->planMove(t, ahead, cumulatedVehLength);
1079 cumulatedVehLength += (*veh)->getVehicleType().getLengthWithGap();
1087 #ifdef DEBUG_COLLISIONS 1089 std::vector<const MSVehicle*> all;
1091 all.push_back(*last);
1093 std::cout <<
SIMTIME <<
" detectCollisions stage=" << stage <<
" lane=" <<
getID() <<
":\n" 1096 <<
" all=" <<
toString(all) <<
"\n" 1104 std::set<const MSVehicle*, SUMOVehicle::ComparatorIdLess> toRemove;
1105 std::set<const MSVehicle*> toTeleport;
1108 VehCont::iterator lastVeh =
myVehicles.end() - 1;
1109 for (VehCont::iterator veh =
myVehicles.begin(); veh != lastVeh; ++veh) {
1110 VehCont::iterator pred = veh + 1;
1130 if (lead == follow) {
1149 if (lead != 0 && lead != follow && shadowLane->
detectCollisionBetween(timestep, stage, follow, lead, toRemove, toTeleport)) {
1158 #ifdef DEBUG_JUNCTION_COLLISIONS 1160 std::cout <<
SIMTIME <<
" detect junction Collisions stage=" << stage <<
" lane=" <<
getID() <<
":\n" 1168 const std::vector<const MSLane*>& foeLanes =
myLinks.front()->getFoeLanes();
1173 for (std::vector<const MSLane*>::const_iterator it = foeLanes.begin(); it != foeLanes.end(); ++it) {
1174 const MSLane* foeLane = *it;
1180 #ifdef DEBUG_JUNCTION_COLLISIONS 1182 std::cout <<
SIMTIME <<
" foe=" << victim->
getID() <<
" bound=" << colliderBoundary <<
" foeBound=" << victim->
getBoundingBox() <<
"\n";
1194 if (
myLinks.front()->getWalkingAreaFoe() != 0) {
1201 #ifdef DEBUG_PEDESTRIAN_COLLISIONS 1203 std::cout <<
SIMTIME <<
" detect pedestrian collisions stage=" << stage <<
" lane=" <<
getID() <<
"\n";
1213 #ifdef DEBUG_PEDESTRIAN_COLLISIONS 1215 std::cout <<
SIMTIME <<
" back=" << back <<
" right=" << right <<
" person=" <<
Named::getIDSecure(leader.first) <<
" dist=" << leader.second <<
"\n";
1218 if (leader.first != 0 && leader.second < length) {
1220 "Vehicle '" + v->
getID()
1221 +
"' collision with pedestrian '" + leader.first->getID()
1222 +
"', lane='" +
getID()
1223 +
"', gap=" +
toString(leader.second - length)
1225 +
" stage=" + stage +
".");
1232 for (std::set<const MSVehicle*, SUMOVehicle::ComparatorIdLess>::iterator it = toRemove.begin(); it != toRemove.end(); ++it) {
1236 if (toTeleport.count(veh) > 0) {
1248 SUMOTime timestep,
const std::string& stage) {
1250 #ifdef DEBUG_PEDESTRIAN_COLLISIONS 1252 std::cout <<
SIMTIME <<
" detect pedestrian junction collisions stage=" << stage <<
" lane=" <<
getID() <<
" foeLane=" << foeLane->
getID() <<
"\n";
1256 for (std::vector<MSTransportable*>::const_iterator it_p = persons.begin(); it_p != persons.end(); ++it_p) {
1257 #ifdef DEBUG_PEDESTRIAN_COLLISIONS 1259 std::cout <<
" collider=" << collider->
getID()
1260 <<
" ped=" << (*it_p)->getID()
1261 <<
" colliderBoundary=" << colliderBoundary
1262 <<
" pedBoundary=" << (*it_p)->getBoundingBox()
1266 if (colliderBoundary.
overlapsWith((*it_p)->getBoundingBox())) {
1268 "Vehicle '" + collider->
getID()
1269 +
"' collision with pedestrian '" + (*it_p)->getID()
1270 +
"', lane='" +
getID()
1272 +
" stage=" + stage +
".");
1281 std::set<const MSVehicle*, SUMOVehicle::ComparatorIdLess>& toRemove,
1282 std::set<const MSVehicle*>& toTeleport)
const {
1292 std::swap(victim, collider);
1299 #ifdef DEBUG_COLLISIONS 1301 <<
" thisLane=" <<
getID()
1302 <<
" collider=" << collider->
getID()
1303 <<
" victim=" << victim->
getID()
1306 <<
" colliderPos=" << colliderPos
1325 && victim->
getLane() !=
this) {
1338 double gap,
double latGap, std::set<const MSVehicle*, SUMOVehicle::ComparatorIdLess>& toRemove,
1339 std::set<const MSVehicle*>& toTeleport)
const {
1340 std::string prefix =
"Vehicle '" + collider->
getID() +
"'; collision with vehicle '" + victim->
getID() ;
1345 std::string dummyError;
1365 victim->
addStop(stop, dummyError, 0,
true);
1372 collider->
addStop(stop, dummyError, 0,
true);
1379 prefix =
"Teleporting vehicle '" + collider->
getID() +
"'; collision with vehicle '" + victim->
getID() ;
1380 toRemove.insert(collider);
1381 toTeleport.insert(collider);
1384 prefix =
"Removing collision participants: vehicle '" + collider->
getID() +
"', vehicle '" + victim->
getID();
1385 bool removeCollider =
true;
1386 bool removeVictim =
true;
1391 toRemove.insert(victim);
1393 if (removeCollider) {
1394 toRemove.insert(collider);
1396 if (!removeVictim) {
1397 if (!removeCollider) {
1398 prefix =
"Keeping remote-controlled collision participants: vehicle '" + collider->
getID() +
"', vehicle '" + victim->
getID();
1400 prefix =
"Removing collision participant: vehicle '" + collider->
getID() +
"', keeping remote-controlled vehicle '" + victim->
getID();
1402 }
else if (!removeCollider) {
1403 prefix =
"Keeping remote-controlled collision participant: vehicle '" + collider->
getID() +
"', removing vehicle '" + victim->
getID();
1406 toRemove.insert(victim);
1407 toRemove.insert(collider);
1416 +
"', lane='" +
getID()
1418 + (latGap == 0 ?
"" :
"', latGap=" +
toString(latGap))
1420 +
" stage=" + stage +
".");
1439 }
else if (target != 0 && moved) {
1447 lanesWithVehiclesToIntegrate.push_back(target);
1457 WRITE_WARNING(
"Teleporting vehicle '" + veh->
getID() +
"'; beyond end of lane, target lane='" +
getID() +
"', time=" +
1483 i = VehCont::reverse_iterator(
myVehicles.erase(i.base()));
1494 const bool minorLink = !wrongLane && (link !=
myLinks.end()) && !((*link)->havePriority());
1495 const std::string reason = (wrongLane ?
" (wrong lane)" : (minorLink ?
" (yield)" :
" (jam)"));
1502 + (r2 ?
" (highway)" :
"")
1506 }
else if (minorLink) {
1518 lanesWithVehiclesToIntegrate.push_back(
this);
1540 const MSLane* firstInternal =
this;
1543 firstInternal = pred;
1547 return firstInternal;
1554 DictType::iterator it =
myDict.find(
id);
1555 if (it ==
myDict.end()) {
1557 myDict.insert(DictType::value_type(
id, ptr));
1566 DictType::iterator it =
myDict.find(
id);
1567 if (it ==
myDict.end()) {
1577 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
1586 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
1587 into.push_back((*i).first);
1592 template<
class RTREE>
void 1594 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
1598 const float cmin[2] = {(float) b.
xmin(), (float) b.
ymin()};
1599 const float cmax[2] = {(float) b.
xmax(), (float) b.
ymax()};
1600 into.Insert(cmin, cmax, l);
1604 template void MSLane::fill<NamedRTree>(
NamedRTree& into);
1624 return (link !=
myLinks.end());
1634 assert(veh->
getLane() ==
this);
1647 #ifdef DEBUG_VEHICLE_CONTAINER 1651 return wasInactive &&
myVehicles.size() != 0;
1729 MSLinkCont::const_iterator
1731 const MSLane& succLinkSource,
const std::vector<MSLane*>& conts) {
1734 if (nRouteEdge == 0) {
1736 return succLinkSource.
myLinks.end();
1740 assert(succLinkSource.
myLinks.size() == 1);
1743 return succLinkSource.
myLinks.begin();
1754 MSLinkCont::const_iterator link;
1755 if (nRouteSuccs < (
int)conts.size()) {
1757 for (link = succLinkSource.
myLinks.begin(); link != succLinkSource.
myLinks.end(); ++link) {
1758 if ((*link)->getLane() != 0 && (*link)->getLane()->myEdge == nRouteEdge && (*link)->getLane()->allowsVehicleClass(veh.
getVehicleType().
getVehicleClass())) {
1760 if ((*link)->getLane() == conts[nRouteSuccs]) {
1767 return succLinkSource.
myLinks.end();
1772 WRITE_WARNING(
"Could not find connection between lane " + succLinkSource.
getID() +
" and lane " + conts[nRouteSuccs]->getID() +
1775 return succLinkSource.
myLinks.end();
1787 MSLinkCont::const_iterator l =
myLinks.begin();
1790 if ((*l)->getViaLane()->getID() == target->
getID()) {
1797 if ((*l)->getLane()->getID() == target->
getID()) {
1811 const MSLane*
internal =
this;
1850 assert(remVehicle->
getLane() ==
this);
1852 if (remVehicle == *it) {
1887 }
else if (!approachingEdge->
isInternal() && warnMultiCon) {
1890 WRITE_WARNING(
"Lane '" +
getID() +
"' is approached multiple times from edge '" + approachingEdge->
getID() +
"'. This may cause collisions.");
1904 std::map<MSEdge*, std::vector<MSLane*> >::const_iterator i =
myApproachingLanes.find(edge);
1908 const std::vector<MSLane*>& lanes = (*i).second;
1909 return find(lanes.begin(), lanes.end(), lane) != lanes.end();
1915 inline int operator()(
const std::pair<const MSVehicle*, double>& p1,
const std::pair<const MSVehicle*, double>& p2)
const {
1916 return p1.second < p2.second;
1928 const MSVehicle* v = followerInfo.first;
1946 std::pair<MSVehicle* const, double>
1947 MSLane::getLeader(
const MSVehicle* veh,
const double vehPos,
const std::vector<MSLane*>& bestLaneConts,
double dist,
bool checkTmpVehicles)
const {
1950 #ifdef DEBUG_CONTEXT 1955 if (checkTmpVehicles) {
1962 #ifdef DEBUG_CONTEXT 1964 std::cout <<
" getLeader lane=" <<
getID() <<
" ego=" << veh->
getID() <<
" egoPos=" << vehPos <<
" pred=" << pred->
getID() <<
" predPos=" << pred->
getPositionOnLane() <<
"\n";
1978 #ifdef DEBUG_CONTEXT 1980 std::cout <<
" getLeader lane=" <<
getID() <<
" ego=" << veh->
getID() <<
" egoPos=" << vehPos
1990 if (bestLaneConts.size() > 0) {
1996 #ifdef DEBUG_CONTEXT 1998 std::cout <<
" getLeader lane=" <<
getID() <<
" seen=" << seen <<
" dist=" << dist <<
"\n";
2002 return std::pair<MSVehicle* const, double>(
static_cast<MSVehicle*
>(0), -1);
2006 return std::make_pair(static_cast<MSVehicle*>(0), -1);
2011 std::pair<MSVehicle* const, double>
2013 const std::vector<MSLane*>& bestLaneConts)
const {
2014 #ifdef DEBUG_CONTEXT 2016 std::cout <<
" getLeaderOnConsecutive lane=" <<
getID() <<
" ego=" << veh.
getID() <<
" seen=" << seen <<
" dist=" << dist <<
" conts=" <<
toString(bestLaneConts) <<
"\n";
2020 return std::make_pair(static_cast<MSVehicle*>(0), -1);
2027 #ifdef DEBUG_CONTEXT 2034 const MSLane* nextLane =
this;
2037 nextLane->getVehiclesSecure();
2039 MSLinkCont::const_iterator link =
succLinkSec(veh, view, *nextLane, bestLaneConts);
2040 if (nextLane->isLinkEnd(link) || !(*link)->opened(arrivalTime, speed, speed, veh.
getVehicleType().
getLength(),
2042 #ifdef DEBUG_CONTEXT 2044 std::cout <<
" cannot continue after nextLane=" << nextLane->getID() <<
"\n";
2047 nextLane->releaseVehicles();
2052 nextLane->releaseVehicles();
2053 if (linkLeaders.size() > 0) {
2056 #ifdef DEBUG_CONTEXT 2058 std::cout <<
" found linkLeader after nextLane=" << nextLane->getID() <<
"\n";
2061 return linkLeaders[0].vehAndGap;
2063 bool nextInternal = (*link)->getViaLane() != 0;
2064 nextLane = (*link)->getViaLaneOrLane();
2065 if (nextLane == 0) {
2068 nextLane->getVehiclesSecure();
2069 MSVehicle* leader = nextLane->getLastAnyVehicle();
2071 #ifdef DEBUG_CONTEXT 2073 std::cout <<
" found leader " << leader->
getID() <<
" on nextLane=" << nextLane->getID() <<
"\n";
2077 nextLane->releaseVehicles();
2078 return std::make_pair(leader, dist);
2080 nextLane->releaseVehicles();
2081 if (nextLane->getVehicleMaxSpeed(&veh) < speed) {
2084 seen += nextLane->getLength();
2089 if (!nextInternal) {
2092 }
while (seen <= dist);
2093 return std::make_pair(static_cast<MSVehicle*>(0), -1);
2097 std::pair<MSVehicle* const, double>
2100 std::pair<MSVehicle*, double> result = std::make_pair(static_cast<MSVehicle*>(0), -1);
2106 const MSLane* nextLane =
this;
2110 MSLinkCont::const_iterator link =
succLinkSec(veh, view, *nextLane, bestLaneConts);
2117 for (MSLink::LinkLeaders::const_iterator it = linkLeaders.begin(); it != linkLeaders.end(); ++it) {
2118 const MSVehicle* leader = (*it).vehAndGap.first;
2119 if (leader != 0 && leader != result.first) {
2123 const double tmpSpeed = veh.
getSafeFollowSpeed((*it).vehAndGap, seen, nextLane, (*it).distToCrossing);
2124 if (tmpSpeed < safeSpeed) {
2125 safeSpeed = tmpSpeed;
2126 result = (*it).vehAndGap;
2130 bool nextInternal = (*link)->getViaLane() != 0;
2131 nextLane = (*link)->getViaLaneOrLane();
2132 if (nextLane == 0) {
2136 if (leader != 0 && leader != result.first) {
2139 if (tmpSpeed < safeSpeed) {
2140 safeSpeed = tmpSpeed;
2141 result = std::make_pair(leader, gap);
2152 if (!nextInternal) {
2155 }
while (seen <= dist);
2168 for (MSEdgeVector::iterator i = pred.begin(); i != pred.end();) {
2177 if (pred.size() != 0) {
2179 MSEdge* best = *pred.begin();
2191 MSLane* cand = (*i).lane;
2192 if (&(cand->
getEdge()) == &fromEdge) {
2212 #ifdef DEBUG_LANE_SORTER 2213 std::cout <<
"\nBest predecessor lane for lane '" <<
myID <<
"': '" << best.lane->getID() <<
"'" << std::endl;
2228 std::vector<MSLink*> candidateLinks =
myLinks;
2231 MSLane* best = (*candidateLinks.begin())->getViaLaneOrLane();
2232 #ifdef DEBUG_LANE_SORTER 2233 std::cout <<
"\nBest successor lane for lane '" <<
myID <<
"': '" << best->getID() <<
"'" << std::endl;
2251 std::vector<const MSLane*>
2253 std::vector<const MSLane*> result;
2254 for (MSLinkCont::const_iterator i =
myLinks.begin(); i !=
myLinks.end(); ++i) {
2255 assert((*i)->getLane() != 0);
2256 result.push_back((*i)->getLane());
2278 for (MSLinkCont::const_iterator i =
myLinks.begin(); i !=
myLinks.end(); ++i) {
2279 if ((*i)->getLane()->getEdge().isCrossing()) {
2280 return (
int)(i -
myLinks.begin());
2324 wtime += (*i)->getWaitingSeconds();
2337 for (VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2338 v += (*i)->getSpeed();
2350 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2351 ret += (*i)->getCO2Emissions();
2362 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2363 ret += (*i)->getCOEmissions();
2374 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2375 ret += (*i)->getPMxEmissions();
2386 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2387 ret += (*i)->getNOxEmissions();
2398 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2399 ret += (*i)->getHCEmissions();
2410 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2411 ret += (*i)->getFuelConsumption();
2422 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2423 ret += (*i)->getElectricityConsumption();
2434 if (vehs.size() == 0) {
2438 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2439 double sv = (*i)->getHarmonoise_NoiseEmissions();
2440 ret += (double) pow(10., (sv / 10.));
2471 myLaneDir(e->getLanes()[0]->
getShape().angleAt2D(0)) {
2482 if (ae1 != 0 && ae1->size() != 0) {
2492 if (ae2 != 0 && ae2->size() != 0) {
2530 #ifdef DEBUG_LANE_SORTER 2531 std::cout <<
"\nincoming_lane_priority sorter()\n" 2532 <<
"noninternal predecessor for lane '" << laneInfo1.
lane->
getID()
2533 <<
"': '" << noninternal1->
getID() <<
"'\n" 2534 <<
"noninternal predecessor for lane '" << laneInfo2.
lane->
getID()
2535 <<
"': '" << noninternal2->
getID() <<
"'\n";
2543 bool priorized1 =
true;
2544 bool priorized2 =
true;
2546 std::vector<MSLink*>::const_iterator j;
2547 #ifdef DEBUG_LANE_SORTER 2548 std::cout <<
"FoeLinks of '" << noninternal1->
getID() <<
"'" << std::endl;
2551 #ifdef DEBUG_LANE_SORTER 2552 std::cout << (*j)->getLaneBefore()->getID() << std::endl;
2560 #ifdef DEBUG_LANE_SORTER 2561 std::cout <<
"FoeLinks of '" << noninternal2->
getID() <<
"'" << std::endl;
2564 #ifdef DEBUG_LANE_SORTER 2565 std::cout << (*j)->getLaneBefore()->getID() << std::endl;
2574 assert(priorized1 || priorized2);
2575 if (priorized1 != priorized2) {
2603 #ifdef DEBUG_LANE_SORTER 2604 std::cout <<
"\noutgoing_lane_priority sorter()\n" 2605 <<
"noninternal successors for lane '" <<
myLane->
getID()
2606 <<
"': '" << target1->
getID() <<
"' and " 2607 <<
"'" << target2->
getID() <<
"'\n";
2614 if (priority1 != priority2) {
2615 return priority1 > priority2;
2651 for (std::vector<std::string>::const_iterator it = vehIds.begin(); it != vehIds.end(); ++it) {
2665 bool allSublanes,
double searchDist,
bool ignoreMinorLinks)
const {
2668 #ifdef DEBUG_CONTEXT 2670 std::cout <<
SIMTIME <<
" getFollowers lane=" <<
getID() <<
" ego=" << ego->
getID() <<
" pos=" << egoPos <<
"\n";
2679 #ifdef DEBUG_CONTEXT 2689 #ifdef DEBUG_CONTEXT 2691 std::cout <<
" (1) added veh=" << veh->
getID() <<
" latOffset=" << latOffset <<
" result=" << result.
toString() <<
"\n";
2696 #ifdef DEBUG_CONTEXT 2698 std::cout <<
" result.numFreeSublanes=" << result.
numFreeSublanes() <<
"\n";
2706 if (searchDist == -1) {
2710 std::set<MSLane*> visited;
2711 std::vector<MSLane::IncomingLaneInfo> newFound;
2713 while (toExamine.size() != 0) {
2714 for (std::vector<MSLane::IncomingLaneInfo>::iterator it = toExamine.begin(); it != toExamine.end(); ++it) {
2715 MSLane* next = (*it).lane;
2719 #ifdef DEBUG_CONTEXT 2721 std::cout <<
" next=" << next->
getID() <<
" first=" << first.toString() <<
" firstFront=" << firstFront.
toString() <<
"\n";
2724 for (
int i = 0; i < first.numSublanes(); ++i) {
2727 if (v != 0 && v != ego) {
2734 agap = (*it).length - next->
getLength() + backOffset
2741 if (v != 0 && v != ego) {
2749 if (!(*it).viaLink->havePriority() && !ego->onFurtherEdge(&(*it).lane->getEdge())
2753 agap =
MAX2(agap, 0.0);
2757 #ifdef DEBUG_CONTEXT 2764 if ((*it).length < searchDist) {
2765 const std::vector<MSLane::IncomingLaneInfo>& followers = next->
getIncomingLanes();
2766 for (std::vector<MSLane::IncomingLaneInfo>::const_iterator j = followers.begin(); j != followers.end(); ++j) {
2767 if (visited.find((*j).lane) == visited.end() && ((*j).viaLink->havePriority() || !ignoreMinorLinks)) {
2768 visited.insert((*j).lane);
2770 ili.
lane = (*j).lane;
2771 ili.
length = (*j).length + (*it).length;
2773 newFound.push_back(ili);
2779 swap(newFound, toExamine);
2804 const MSLane* nextLane =
this;
2810 MSLinkCont::const_iterator link =
succLinkSec(*ego, view, *nextLane, bestLaneConts);
2817 if (linkLeaders.size() > 0) {
2823 #ifdef DEBUG_CONTEXT 2825 std::cout <<
" linkleader=" << veh->
getID() <<
" gap=" << ll.
vehAndGap.second <<
"\n";
2833 bool nextInternal = (*link)->getViaLane() != 0;
2834 nextLane = (*link)->getViaLaneOrLane();
2835 if (nextLane == 0) {
2840 #ifdef DEBUG_CONTEXT 2842 std::cout <<
SIMTIME <<
" getLeadersOnConsecutive lane=" <<
getID() <<
" nextLane=" << nextLane->
getID() <<
" leaders=" << leaders.
toString() <<
"\n";
2847 for (
int i = 0; i < iMax; ++i) {
2850 #ifdef DEBUG_CONTEXT 2870 if (!nextInternal) {
2885 #ifdef DEBUG_CONTEXT 2887 std::cout <<
SIMTIME <<
" getPartialBehind lane=" <<
getID() <<
" ego=" << ego->
getID() <<
" found=" << veh->
getID() <<
"\n";
2893 #ifdef DEBUG_CONTEXT 2928 if (opposite == 0) {
2930 throw ProcessError(
"Lane '" +
getID() +
"' cannot compute oppositePos as there is no opposite lane.");
2937 std::pair<MSVehicle* const, double>
2942 #ifdef DEBUG_CONTEXT 2944 std::cout <<
" getFollower lane=" <<
getID() <<
" egoPos=" << egoPos <<
" pred=" << pred->
getID() <<
" predPos=" << pred->
getPositionOnLane(
this) <<
"\n";
2953 return std::make_pair(const_cast<MSVehicle*>(result.first), result.second);
2956 std::pair<MSVehicle* const, double>
2958 #ifdef DEBUG_OPPOSITE 2960 <<
" ego=" << ego->
getID()
2964 <<
" oppositeDir=" << oppositeDir
2972 std::pair<MSVehicle* const, double> result =
getFollower(ego, egoPos + egoLength, dist,
true);
2979 std::pair<MSVehicle* const, double>
2981 #ifdef DEBUG_OPPOSITE 2983 <<
" ego=" << ego->
getID()
2993 if (result.second > 0) {
2995 return std::make_pair(static_cast<MSVehicle*>(0), -1);
3005 const std::string action = oc.
getString(
"collision.action");
3006 if (action ==
"none") {
3008 }
else if (action ==
"warn") {
3010 }
else if (action ==
"teleport") {
3012 }
else if (action ==
"remove") {
3015 WRITE_ERROR(
"Invalid collision.action '" + action +
"'.");
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 operator()(const MSLink *link1, const MSLink *link2) const
comparing operator
bool gDebugFlag1
global utility flags for debugging
double xmax() const
Returns maximum x-coordinate.
void loadState(std::vector< std::string > &vehIDs, MSVehicleControl &vc)
Loads the state of this segment with the given parameters.
double getMinGap() const
Get the free space in front of vehicles of this class.
static double gLateralResolution
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
SVCPermissions myPermissions
The vClass permissions for this lane.
VehCont myVehicles
The lane's vehicles. This container holds all vehicles that have their front (longitudinally) and the...
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
saves leader/follower vehicles and their distances relative to an ego vehicle
MSEdge & getEdge() const
Returns the lane's edge.
double getHarmonoise_NoiseEmissions() const
Returns the sum of last step noise emissions.
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.
A free lateral position is chosen.
double getWidth() const
Returns the lane's width.
Representation of a vehicle in the micro simulation.
bool isLinkEnd(MSLinkCont::const_iterator &i) const
MSVehicle * getLastAnyVehicle() const
returns the last vehicle that is fully or partially on this lane
static MSLinkCont::const_iterator succLinkSec(const SUMOVehicle &veh, int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane * > &conts)
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
void resetPermissions(long transientID)
void descheduleDeparture(SUMOVehicle *veh)
stops trying to emit the given vehicle (and delete it)
At the leftmost side of the lane.
virtual int addLeader(const MSVehicle *veh, bool beyond, double latOffset=0)
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)
Constructor.
virtual std::string toString() const
print a debugging representation
std::string containerstop
(Optional) container stop if one is assigned to the stop
static void insertIDs(std::vector< std::string > &into)
Adds the ids of all stored lanes into the given vector.
const MSEdge * getNextNormal() const
Returns the lane's follower if it is an internal lane, the edge of the lane otherwise.
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 enterLaneAtInsertion(MSLane *enteredLane, double pos, double speed, double posLat, MSMoveReminder::Notification notification)
Update when the vehicle enters a new lane in the emit step.
Sorts lanes (IncomingLaneInfos) by their priority or, if this doesn't apply, wrt. the angle differenc...
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
MSVehicle * getFirstAnyVehicle() const
returns the first vehicle that is fully or partially on this lane
bool parking
whether the vehicle is removed from the net while stopping
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
MSLink * getLinkTo(const MSLane *) const
returns the link to the given lane or 0, if it is not connected
begin/end of the description of a single lane
int operator()(MSVehicle *v1, MSVehicle *v2) const
Comparing operator.
bool isChangingLanes() const
return true if the vehicle currently performs a lane change maneuver
int myI2
index for myPartialVehicles
std::pair< MSVehicle *const, double > getOppositeLeader(const MSVehicle *ego, double dist, bool oppositeDir) const
double getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
bool resumeFromStopping()
double getCOEmissions() const
Returns the sum of last step CO emissions.
bool hasInfluencer() const
SUMOTime duration
The stopping duration.
double getMinDeceleration() const
return the minimum deceleration capability for all vehicles that ever entered the network ...
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...
virtual const MSEdge * succEdge(int nSuccs) const =0
Returns the nSuccs'th successor of edge the vehicle is currently at.
double getLatOffset(const MSLane *lane) const
Get the offset that that must be added to interpret myState.myPosLat for the given lane...
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)
const std::vector< MSLink * > & getFoeLinks() const
const MSLeaderInfo & getLastVehicleInformation(const MSVehicle *ego, double latOffset, double minPos=0, bool allowCached=true) const
Returns the last vehicles on the lane.
MSLane * getOpposite() const
return the opposite direction lane for lane changing or 0
void registerTeleportYield()
register one non-collision-related teleport
static void fill(RTREE &into)
Fills the given RTree with lane instances.
The vehicle arrived at a junction.
void setMaxSpeed(double val)
Sets a new maximum speed for the lane (used by TraCI and MSCalibrator)
SUMOTime getWaitingTime() const
Returns the SUMOTime waited (speed was lesser than 0.1m/s)
double ymax() const
Returns maximum y-coordinate.
double getPMxEmissions() const
Returns the sum of last step PMx emissions.
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)
void recalcCache()
Recalculates the cached values.
This is an uncontrolled, minor link, has to stop.
const MSEdge * getLastEdge() const
returns the destination edge
double getNettoOccupancy() const
Returns the netto (excluding minGaps) occupancy of this lane during the last step (including minGaps)...
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.
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
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
void addLink(MSLink *link)
Delayed initialization.
MSLane * myCanonicalPredecessorLane
Similar to LogicalPredecessorLane,.
int myIndex
The lane index.
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
virtual bool integrateNewVehicle(SUMOTime t)
Insert buffered vehicle into the real lane.
The lateral position is chosen randomly.
SUMOTime myLeaderInfoTime
time step for which myLeaderInfo was last updated
MSVehicle * getFirstFullVehicle() const
returns the first vehicle for which this lane is responsible or 0
If a fixed number of random choices fails, a free lateral position is chosen.
static SUMOTime myCollisionStopTime
Notification
Definition of a vehicle state.
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.
const MSEdge *const myEdge
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.
void addIncomingLane(MSLane *lane, MSLink *viaLink)
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) ...
double getLength() const
Returns the lane's length.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
const MSRoute & getRoute() const
Returns the current route.
by_connections_to_sorter(const MSEdge *const e)
constructor
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.
static void initCollisionOptions(const OptionsCont &oc)
virtual void addMoveReminder(MSMoveReminder *rem)
Add a move-reminder to move-reminder container.
bool hasDeparted() const
Returns whether this vehicle has already departed.
std::vector< MSTransportable * > getSortedPersons(SUMOTime timestep, bool includeRiding=false) const
Returns this edge's persons sorted by pos.
The vehicle got vaporized.
double getPositionOnLane() const
Get the vehicle's position along the lane.
void leftByLaneChange(MSVehicle *v)
SUMOTime until
The time at which the vehicle may continue its journey.
bool addStop(const SUMOVehicleParameter::Stop &stopPar, std::string &errorMsg, SUMOTime untilOffset=0, bool collision=false, MSRouteIterator *searchStart=0)
Adds a stop.
Definition of vehicle stop (position and duration)
This is an uncontrolled, right-before-left link.
std::map< long, SVCPermissions > myPermissionChanges
bool executeMove()
Executes planned vehicle movements with regards to right-of-way.
void addNeigh(const std::string &id)
Adds a neighbor to this lane.
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle's end speed shall be chosen.
int operator()(const MSEdge *const e1, const MSEdge *const e2) const
comparing operator
const SVCPermissions SVCAll
all VClasses are allowed
void gotActive(MSLane *l)
Informs the control that the given lane got active.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
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...
The position is chosen randomly.
double getMaxSpeedFactor() const
return the maximum speed factor for all vehicles that ever entered the network
static bool myCheckJunctionCollisions
bool hasStops() const
Returns whether the vehicle has to stop somewhere.
This is an uncontrolled, all-way stop link.
int myI1End
end index for myVehicles
double getNOxEmissions() const
Returns the sum of last step NOx emissions.
A class that stores a 2D geometrical boundary.
int myDirection
index delta
std::string parkingarea
(Optional) parking area if one is assigned to the stop
PositionVector myShape
The shape of the lane.
#define WRITE_WARNING(msg)
bool overlapsWith(const AbstractPoly &poly, double offset=0) const
Returns the information whether the given polygon overlaps with this.
std::set< const MSVehicle * > myParkingVehicles
bool myDownstream
iteration direction
MSAbstractLaneChangeModel & getLaneChangeModel()
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
std::vector< std::string > myNeighs
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.
double getOppositePos(double pos) const
return the corresponding position on the opposite lane
static CollisionAction myCollisionAction
the action to take on collisions
std::map< std::string, MSLane * > DictType
definition of the static dictionary type
static CollisionAction getCollisionAction()
double basePos(const MSVehicle &veh) const
departure position where the vehicle fits fully onto the lane (if possible)
virtual void detectCollisions(SUMOTime timestep, const std::string &stage)
Check if vehicles are too close.
double getImpatience() const
Returns this vehicles impatience.
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...
double getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
std::string busstop
(Optional) bus stop if one is assigned to the stop
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
void addApproachingLane(MSLane *lane, bool warnMultiCon)
double departSpeed
(optional) The initial speed of the vehicle
const std::string & getID() const
Returns the id.
A road/street connecting two junctions.
int operator()(MSVehicle *v1, MSVehicle *v2) const
Comparing operator.
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)
bool insertVehicle(MSVehicle &v)
Tries to insert the given vehicle.
MSLane * getCanonicalSuccessorLane() const
int numFreeSublanes() const
double myLength
Lane length [m].
double getFuelConsumption() const
Returns the sum of last step fuel consumption.
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
VehCont myTmpVehicles
Container for lane-changing vehicles. After completion of lane-change- process, the containers will b...
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)
virtual void resetPartialOccupation(MSVehicle *v)
Removes the information about a vehicle lapping into this lane.
LinkState getIncomingLinkState() const
get the state of the link from the logical predecessor to this lane
const bool myIsRampAccel
whether this lane is an acceleration lane
Representation of a vehicle.
PositionVector getBoundingBox() const
get bounding rectangle
double startPos
The stopping position start.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
const MSEdgeVector & getPredecessors() 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.
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
Sorts vehicles by their position (descending)
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the best sequence of lanes to continue the route starting at myLane.
double myRightSideOnEdge
the combined width of all lanes with lower index on myEdge
std::string chargingStation
(Optional) charging station if one is assigned to the stop
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...
MSLane * getLane() const
Returns the connected lane.
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)
double getElectricityConsumption() const
Returns the sum of last step electricity consumption.
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
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
MSLane * getParallelLane(int offset) const
Returns the lane with the given offset parallel to this one or 0 if it does not exist.
const MSLane * getFirstInternalInConnection(double &offset) const
Returns 0 if the lane is not internal. Otherwise the first part of the connection (sequence of intern...
const MSLane * lane
The lane to stop at.
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...
const std::map< SUMOVehicleClass, double > * myRestrictions
The vClass speed restrictions for this lane.
bool triggered
whether an arriving person lets the vehicle continue
ConstMSEdgeVector::const_iterator MSRouteIterator
PositionVector getBoundingPoly() const
get bounding polygon
The vehicle arrived at its destination (is deleted)
bool isStopped() const
Returns whether the vehicle is at a stop.
SUMOTime collisionStopTime() const
Returns the remaining time a vehicle needs to stop due to a collision. A negative value indicates tha...
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic, in MSLink and GNEInternalLane.
Sorts edges by their angle relative to the given edge (straight comes first)
The maximum speed is used.
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 forceVehicleInsertion(MSVehicle *veh, double pos, MSMoveReminder::Notification notification, double posLat=0)
Inserts the given vehicle at the given position.
SUMOTime string2time(const std::string &r)
bool isVaporizing() const
Returns whether vehicles on this edge shall be vaporized.
void add(const SUMOTime t, MSVehicle *veh)
Adds a vehicle to this transfer object.
std::vector< LinkLeader > LinkLeaders
No information given; use default.
int operator()(const IncomingLaneInfo &lane1, const IncomingLaneInfo &lane2) const
comparing operator
void onRemovalFromNet(const MSMoveReminder::Notification reason)
Called when the vehicle is removed from the network.
std::pair< MSVehicle *, double > vehAndGap
double getBackPositionOnLane(const MSLane *lane) const
Get the vehicle's position relative to the given lane.
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
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 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) ...
int myRightmostSublane
the index of the rightmost sublane of this lane on myEdge
MSLane * myLogicalPredecessorLane
double endPos
The stopping position end.
Something on a lane to be noticed about vehicle movement.
MSLane * getShadowLane() const
Returns the lane the vehicles shadow is on during continuous/sublane lane change. ...
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
virtual void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
void registerTeleportJam()
register one non-collision-related teleport
bool isInternal() const
return whether this edge is an internal edge
If a fixed number of random choices fails, a free position is chosen.
bool isParking() const
Returns whether the vehicle is parking.
const std::vector< LaneQ > & getBestLanes() const
Returns the description of best lanes to use in order to continue the route.
std::map< MSEdge *, std::vector< MSLane * > > myApproachingLanes
All direct internal and direct (disregarding internal predecessors) non-internal predecessor lanes of...
virtual double insertionFollowSpeed(const MSVehicle *const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel) const
Computes the vehicle's safe speed (no dawdling) This method is used during the insertion stage...
const std::string & getEdgeType() const
Returns the type of the edge.
std::vector< MSVehicle * > VehCont
Container for vehicles.
bool containerTriggered
whether an arriving container lets the vehicle continue
int operator()(const std::pair< const MSVehicle *, double > &p1, const std::pair< const MSVehicle *, double > &p2) const
Base class for objects which have an id.
int myNumericalID
Unique numerical ID (set on reading by netload)
std::vector< MSMoveReminder * > myMoveReminders
This lane's move reminder.
void handleCollisionBetween(SUMOTime timestep, const std::string &stage, MSVehicle *collider, MSVehicle *victim, double gap, double latGap, std::set< const MSVehicle *, SUMOVehicle::ComparatorIdLess > &toRemove, std::set< const MSVehicle * > &toTeleport) const
take action upon collision
const MSLane *const myLane
incoming_lane_priority_sorter(const MSLane *targetLane)
constructor
std::string lane
The lane to stop at.
void initRestrictions()
initialized vClass-specific speed limits
MSLane * getCanonicalPredecessorLane() const
bool operator()(const MSVehicle *cmp, double pos) const
compares vehicle position to the detector position
double getMeanSpeed() const
Returns the mean speed on this lane.
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
void sortPartialVehicles()
sorts myPartialVehicles
void setPermissions(SVCPermissions permissions, long transientID)
Sets the permissions to the given value. If a transientID is given, the permissions are recored as te...
bool freeInsertion(MSVehicle &veh, double speed, double posLat, MSMoveReminder::Notification notification=MSMoveReminder::NOTIFICATION_DEPARTED)
Tries to insert the given vehicle on any place.
std::vector< const MSLane * > getOutgoingLanes() const
get the list of outgoing lanes
double getLength() const
Get vehicle's length [m].
double safeInsertionSpeed(const MSVehicle *veh, const MSLeaderInfo &leaders, double speed)
return the maximum safe speed for insertion behind leaders (a negative value indicates that safe inse...
double departPos
(optional) The position the vehicle shall depart from
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
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.
The vehicle has departed (was inserted into the network)
Influencer & getInfluencer()
Returns the velocity/lane influencer.
void scheduleVehicleRemoval(SUMOVehicle *veh)
Removes a vehicle after it has ended.
Structure representing possible vehicle parameter.
const MSEdge * succEdge(int nSuccs) const
Returns the nSuccs'th successor of edge the vehicle is currently at.
int myI1
index for myVehicles
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...
int getPriority() const
Returns the priority of the edge.
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...
MSLane * parallelLane(const MSLane *const lane, int offset) const
Returns the lane with the given offset parallel to the given lane one or 0 if it does not exist...
MSInsertionControl & getInsertionControl()
Returns the insertion control.
static void clear()
Clears the dictionary.
double xmin() const
Returns minimum x-coordinate.
MSEdge *const myEdge
The lane's edge, for routing only.
Definition of vehicle stop (position and duration)
const std::vector< MSLane * > * allowedLanes(const MSEdge &destination, SUMOVehicleClass vclass=SVC_IGNORING) const
Get the allowed lanes to reach the destination-edge.
At the rightmost side of the lane.
At the center of the lane.
const MSLane * myLane
the lane that is being iterated
MSVehicle * getPartialBehind(const MSVehicle *ego) const
bool checkFailure(MSVehicle *aVehicle, double &speed, double &dist, const double nspeed, const bool patchSpeed, const std::string errorMsg) const
A storage for options typed value containers)
MSLeaderInfo getPartialBeyond() const
get all vehicles that are inlaping from consecutve edges
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
double getMaximumBrakeDist() const
compute maximum braking distance on this lane
int index
at which position in the stops list
bool isApproachedFrom(MSEdge *const edge)
virtual const std::string & getID() const =0
Get the vehicle's ID.
std::pair< MSVehicle *const, double > getOppositeFollower(const MSVehicle *ego) const
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
static SUMOTime gTimeToGridlock
double getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
double ymin() const
Returns minimum y-coordinate.
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) ...
bool isFrontOnLane(const MSLane *lane) const
Returns the information whether the front of the vehicle is on the given lane.
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
AnyVehicleIterator anyVehiclesEnd() const
end iterator for iterating over all vehicles touching this lane in downstream direction ...
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
void saveState(OutputDevice &out)
Saves the state of this lane into the given stream.
const PositionVector & getShape() const
Returns this lane's shape.
MSLeaderInfo myLeaderInfo
leaders on all sublanes as seen by approaching vehicles (cached)
const MSLane *const myLane
double getRightSideOnEdge() const
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...
LinkState getState() const
Returns the current state of the link.
MSLane * myCanonicalSuccessorLane
Main successor lane,.
Static storage of an output device and its base (abstract) implementation.
bool nextIsMyVehicles() const
const std::set< MSTransportable * > & getPersons() const
Returns this edge's persons set.
bool closeTag()
Closes the most recently opened tag.
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 MSEdgeVector & getSuccessors() const
Returns the following edges.
void registerCollision()
registers one collision-related teleport
MSEdgeControl & getEdgeControl()
Returns the edge control.
double myNettoVehicleLengthSum
The current length of all vehicles on this lane, excluding their minGaps.
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.
std::string toString() const
print a debugging representation
double getHCEmissions() const
Returns the sum of last step HC emissions.
void addParking(MSVehicle *veh)
add parking vehicle. This should only used during state loading
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
No information given; use default.
A free position is chosen.
double getCO2Emissions() const
Returns the sum of last step CO2 emissions.
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
MSLeaderInfo myLeaderInfoTmp
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.
VehCont myVehBuffer
Buffer for vehicles that moved from their previous lane onto this one. Integrated after all vehicles ...
static double angleDiff(const double angle1, const double angle2)
Returns the difference of the second angle to the first angle in radiants.
double getDepartPosLat(const MSVehicle &veh)
double endPos
The stopping position end.
static const long CHANGE_PERMISSIONS_PERMANENT
MSLane * getLane() const
Returns the lane the vehicle is on.
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
virtual bool executeMovements(SUMOTime t, std::vector< MSLane * > &lanesWithVehiclesToIntegrate)
Executes planned vehicle movements with regards to right-of-way.
SUMOTime myFollowerInfoTime
time step for which myFollowerInfo was last updated
MSVehicle * getLastFullVehicle() const
returns the last vehicle for which this lane is responsible or 0
static SUMOTime gLaneChangeDuration
double myMaxSpeed
Lane-wide speedlimit [m/s].
AnyVehicleIterator anyVehiclesBegin() const
begin iterator for iterating over all vehicles touching this lane in downstream direction ...
static double sum(double val)
Computes the resulting noise.
double getWaitingSeconds() const
Returns the overall waiting time on this lane.
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
void registerTeleportWrongLane()
register one non-collision-related teleport
Representation of a lane in the micro simulation.
AnyVehicleIterator anyVehiclesUpstreamEnd() const
end iterator for iterating over all vehicles touching this lane in upstream direction ...
bool isVTDAffected(SUMOTime t) const
int getCrossingIndex() const
return the index of the link to the next crossing if this is walkingArea, else -1 ...
double brakeGap(const double speed) const
Returns the distance the vehicle needs to halt including driver's reaction time tau (i...
double angleAt2D(int pos) const
get angle in certain position of position vector
const double myWidth
Lane width [m].
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
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.
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...
bool detectCollisionBetween(SUMOTime timestep, const std::string &stage, MSVehicle *collider, MSVehicle *victim, std::set< const MSVehicle *, SUMOVehicle::ComparatorIdLess > &toRemove, std::set< const MSVehicle * > &toTeleport) const
detect whether there is a collision between the two vehicles
const std::string & getID() const
Returns the name of the vehicle.
double getSpeed() const
Returns the vehicle's current speed.
AnyVehicleIterator anyVehiclesUpstreamBegin() const
begin iterator for iterating over all vehicles touching this lane in upstream direction ...
double getDepartSpeed(const MSVehicle &veh, bool &patchSpeed)
DepartPosLatDefinition departPosLatProcedure
Information how the vehicle shall choose the lateral departure position.