73 #ifdef CHECK_MEMORY_LEAKS 75 #endif // CHECK_MEMORY_LEAKS 83 #define DEBUG_COND (getID() == "disabled") 84 #define DEBUG_COND2(obj) ((obj != 0 && (obj)->getID() == "disabled")) 185 for (MSLinkCont::iterator i =
myLinks.begin(); i !=
myLinks.end(); ++i) {
208 (*veh)->addReminder(rem);
217 std::cout <<
SIMTIME <<
" setPartialOccupation. lane=" <<
getID() <<
" veh=" << v->
getID() <<
"\n";
230 std::cout <<
SIMTIME <<
" resetPartialOccupation. lane=" <<
getID() <<
" veh=" << v->
getID() <<
"\n";
279 leader = leaderInfo.first;
291 if (leaderBack >= frontGapNeeded) {
292 pos =
MIN2(pos, leaderBack - frontGapNeeded);
306 bool adaptableSpeed =
true;
315 if (missingRearGap > 0) {
316 if (minPos + missingRearGap <=
myLength) {
323 return isInsertionSuccess(&veh, mspeed, minPos + missingRearGap, 0, adaptableSpeed, notification);
337 if (leaderPos >= frontGapNeeded) {
347 MSLane::VehCont::iterator predIt =
myVehicles.begin();
359 if (adaptableSpeed && leader != 0) {
368 frontMax = leaderRearPos - frontGapNeeded;
376 if (frontMax > minPos && backMin +
POSITION_EPS < frontMax) {
422 bool patchSpeed =
true;
438 for (
int i = 0; i < 10; i++) {
472 for (
int i = 0; i < 10; i++) {
509 if (nspeed < speed) {
511 speed =
MIN2(nspeed, speed);
513 }
else if (speed > 0) {
514 if (errorMsg !=
"") {
515 WRITE_ERROR(
"Vehicle '" + aVehicle->
getID() +
"' will not be able to depart using the given velocity (" + errorMsg +
")!");
532 aVehicle->
getID() +
"'. Inserting at lane end instead.");
536 #ifdef DEBUG_INSERTION 537 if (
DEBUG_COND2(aVehicle)) std::cout <<
"\nIS_INSERTION_SUCCESS\n" 539 <<
" veh '" << aVehicle->
getID() <<
"'\n";
546 std::vector<MSLane*>::const_iterator ri = bestLaneConts.begin();
554 if (nextStop.
lane ==
this) {
555 std::stringstream msg;
556 msg <<
"scheduled stop on lane '" <<
myID <<
"' too close";
559 patchSpeed, msg.str())) {
569 MSLane* currentLane =
this;
572 while (seen < dist && ri != bestLaneConts.end()) {
574 MSLinkCont::const_iterator link =
succLinkSec(*aVehicle, nRouteSuccs, *currentLane, bestLaneConts);
580 patchSpeed,
"arrival speed too low")) {
588 patchSpeed,
"junction too close")) {
597 || !(*link)->havePriority()) {
599 std::string errorMsg =
"";
600 const LinkState state = (*link)->getState();
606 errorMsg =
"unpriorised junction too close";
609 patchSpeed, errorMsg)) {
613 #ifdef DEBUG_INSERTION 615 std::cout <<
"trying insertion before minor link: " 616 <<
"insertion speed = " << speed <<
" dist=" << dist
623 nextLane = (*link)->getViaLaneOrLane();
631 if (nextStop.
lane == nextLane) {
632 std::stringstream msg;
633 msg <<
"scheduled stop on lane '" << nextStop.
lane->
getID() <<
"' too close";
636 patchSpeed, msg.str())) {
648 #ifdef DEBUG_INSERTION 650 <<
"leader on lane '" << nextLane->
getID() <<
"': " << leader->
getID() <<
"\n";
659 if (
checkFailure(aVehicle, speed, dist, nspeed, patchSpeed,
"")) {
661 #ifdef DEBUG_INSERTION 663 <<
" isInsertionSuccess lane=" <<
getID()
664 <<
" veh=" << aVehicle->
getID()
666 <<
" posLat=" << posLat
667 <<
" patchSpeed=" << patchSpeed
668 <<
" speed=" << speed
669 <<
" nspeed=" << nspeed
670 <<
" nextLane=" << nextLane->
getID()
671 <<
" lead=" << leader->
getID()
673 <<
" failed (@641)!\n";
680 if (nspeed < speed) {
686 WRITE_ERROR(
"Vehicle '" + aVehicle->
getID() +
"' will not be able to depart using the given velocity (slow lane ahead)!");
695 if ((*link)->hasApproachingFoe(arrivalTime, leaveTime, speed, cfModel.
getMaxDecel())) {
703 currentLane = nextLane;
704 #ifdef HAVE_INTERNAL_LANES 705 if ((*link)->getViaLane() == 0) {
720 if (nspeed < 0 ||
checkFailure(aVehicle, speed, dist, nspeed, patchSpeed,
"")) {
725 #ifdef DEBUG_INSERTION 727 <<
" isInsertionSuccess lane=" <<
getID()
728 <<
" veh=" << aVehicle->
getID()
730 <<
" posLat=" << posLat
731 <<
" patchSpeed=" << patchSpeed
732 <<
" speed=" << speed
733 <<
" nspeed=" << nspeed
734 <<
" nextLane=" << nextLane->
getID()
735 <<
" leaders=" << leaders.
toString()
736 <<
" failed (@700)!\n";
740 #ifdef DEBUG_INSERTION 742 <<
" speed = " << speed
743 <<
" nspeed = " << nspeed
748 for (
int i = 0; i < followers.
numSublanes(); ++i) {
749 const MSVehicle* follower = followers[i].first;
752 if (followers[i].second < backGapNeeded) {
754 #ifdef DEBUG_INSERTION 756 <<
" isInsertionSuccess lane=" <<
getID()
757 <<
" veh=" << aVehicle->
getID()
759 <<
" posLat=" << posLat
760 <<
" patchSpeed=" << patchSpeed
761 <<
" speed=" << speed
762 <<
" nspeed=" << nspeed
763 <<
" follower=" << follower->
getID()
764 <<
" backGapNeeded=" << backGapNeeded
765 <<
" gap=" << followers[i].second
766 <<
" failure (@719)!\n";
776 if (missingRearGap > 0) {
778 #ifdef DEBUG_INSERTION 780 <<
" isInsertionSuccess lane=" <<
getID()
781 <<
" veh=" << aVehicle->
getID()
783 <<
" posLat=" << posLat
784 <<
" patchSpeed=" << patchSpeed
785 <<
" speed=" << speed
786 <<
" nspeed=" << nspeed
787 <<
" missingRearGap=" << missingRearGap
788 <<
" failure (@728)!\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 <<
" failed (@733)!\n";
810 #ifdef DEBUG_INSERTION 812 <<
" isInsertionSuccess lane=" <<
getID()
813 <<
" veh=" << aVehicle->
getID()
815 <<
" posLat=" << posLat
816 <<
" patchSpeed=" << patchSpeed
817 <<
" speed=" << speed
818 <<
" nspeed=" << nspeed
844 nspeed =
MIN2(nspeed,
858 int freeSublanes = 1;
863 while (freeSublanes > 0 && veh != 0) {
864 #ifdef DEBUG_PLAN_MOVE 866 std::cout <<
" getLastVehicleInformation lane=" <<
getID() <<
" minPos=" << minPos <<
" veh=" << veh->
getID() <<
" pos=" << veh->
getPositionOnLane(
this) <<
"\n";
872 #ifdef DEBUG_PLAN_MOVE 880 if (ego == 0 && minPos == 0) {
885 #ifdef DEBUG_PLAN_MOVE 910 int freeSublanes = 1;
912 while (freeSublanes > 0 && veh != 0) {
913 #ifdef DEBUG_PLAN_MOVE 915 std::cout <<
" veh=" << veh->
getID() <<
" pos=" << veh->
getPositionOnLane(
this) <<
" maxPos=" << maxPos <<
"\n";
922 #ifdef DEBUG_PLAN_MOVE 924 std::cout <<
" veh=" << veh->
getID() <<
" latOffset=" << latOffset <<
"\n";
936 #ifdef DEBUG_PLAN_MOVE 962 VehCont::reverse_iterator veh =
myVehicles.rbegin();
964 #ifdef DEBUG_PLAN_MOVE 968 <<
" planMovements lane=" <<
getID()
976 && ((*vehPart)->getPositionOnLane(
this) > (*veh)->getPositionOnLane())) {
977 const SUMOReal latOffset = (*vehPart)->getLatOffset(
this);
978 #ifdef DEBUG_PLAN_MOVE 980 std::cout <<
" partial ahead: " << (*vehPart)->getID() <<
" latOffset=" << latOffset <<
"\n";
983 ahead.
addLeader(*vehPart,
false, latOffset);
986 #ifdef DEBUG_PLAN_MOVE 988 std::cout <<
" plan move for: " << (*veh)->getID() <<
" ahead=" << ahead.
toString() <<
"\n";
991 (*veh)->planMove(t, ahead, cumulatedVehLength);
992 cumulatedVehLength += (*veh)->getVehicleType().getLengthWithGap();
1000 #ifdef DEBUG_COLLISIONS 1002 std::vector<const MSVehicle*> all;
1004 all.push_back(*last);
1006 std::cout <<
SIMTIME <<
" detectCollisions stage=" << stage <<
" lane=" <<
getID() <<
":\n" 1009 <<
" all=" <<
toString(all) <<
"\n" 1017 std::set<const MSVehicle*, SUMOVehicle::ComparatorIdLess> toRemove;
1018 std::set<const MSVehicle*> toTeleport;
1021 VehCont::iterator lastVeh =
myVehicles.end() - 1;
1022 for (VehCont::iterator veh =
myVehicles.begin(); veh != lastVeh; ++veh) {
1023 VehCont::iterator pred = veh + 1;
1043 if (lead == follow) {
1061 if (lead != 0 && lead != follow && shadowLane->
detectCollisionBetween(timestep, stage, follow, lead, toRemove, toTeleport)) {
1072 const std::vector<const MSLane*>& foeLanes =
myLinks.front()->getFoeLanes();
1077 for (std::vector<const MSLane*>::const_iterator it = foeLanes.begin(); it != foeLanes.end(); ++it) {
1078 const MSLane* foeLane = *it;
1095 for (std::set<const MSVehicle*, SUMOVehicle::ComparatorIdLess>::iterator it = toRemove.begin(); it != toRemove.end(); ++it) {
1099 if (toTeleport.count(veh) > 0) {
1111 std::set<const MSVehicle*, SUMOVehicle::ComparatorIdLess>& toRemove,
1112 std::set<const MSVehicle*>& toTeleport)
const {
1123 std::swap(victim, collider);
1130 #ifdef DEBUG_COLLISIONS 1132 <<
" thisLane=" <<
getID()
1133 <<
" collider=" << collider->
getID()
1134 <<
" victim=" << victim->
getID()
1137 <<
" colliderPos=" << colliderPos
1156 && victim->
getLane() !=
this) {
1169 SUMOReal gap,
SUMOReal latGap, std::set<const MSVehicle*, SUMOVehicle::ComparatorIdLess>& toRemove,
1170 std::set<const MSVehicle*>& toTeleport)
const {
1174 prefix =
"Vehicle '" + collider->
getID() +
"'; collision with vehicle '" + victim->
getID() ;
1177 prefix =
"Teleporting vehicle '" + collider->
getID() +
"'; collision with vehicle '" + victim->
getID() ;
1178 toRemove.insert(collider);
1179 toTeleport.insert(collider);
1182 prefix =
"Removing collision participants: vehicle '" + collider->
getID() +
"', vehicle '" + victim->
getID();
1183 bool removeCollider =
true;
1184 bool removeVictim =
true;
1189 toRemove.insert(victim);
1191 if (removeCollider) {
1192 toRemove.insert(collider);
1194 if (!removeVictim) {
1195 if (!removeCollider) {
1196 prefix =
"Keeping remote-controlled collision participants: vehicle '" + collider->
getID() +
"', vehicle '" + victim->
getID();
1198 prefix =
"Removing collision participant: vehicle '" + collider->
getID() +
"', keeping remote-controlled vehicle '" + victim->
getID();
1200 }
else if (!removeCollider) {
1201 prefix =
"Keeping remote-controlled collision participant: vehicle '" + collider->
getID() +
"', removing vehicle '" + victim->
getID();
1204 toRemove.insert(victim);
1205 toRemove.insert(collider);
1213 +
"', lane='" +
getID()
1215 + (latGap == 0 ?
"" :
"', latGap=" +
toString(latGap))
1217 +
" stage=" + stage +
".");
1236 }
else if (target != 0 && moved) {
1244 lanesWithVehiclesToIntegrate.push_back(target);
1253 WRITE_WARNING(
"Teleporting vehicle '" + veh->
getID() +
"'; beyond end of lane, target lane='" +
getID() +
"', time=" +
1264 i = VehCont::reverse_iterator(
myVehicles.erase(i.base()));
1275 const bool minorLink = !wrongLane && (link !=
myLinks.end()) && !((*link)->havePriority());
1276 const std::string reason = (wrongLane ?
" (wrong lane)" : (minorLink ?
" (yield)" :
" (jam)"));
1283 + (r2 ?
" (highway)" :
"")
1287 }
else if (minorLink) {
1299 lanesWithVehiclesToIntegrate.push_back(
this);
1318 DictType::iterator it =
myDict.find(
id);
1319 if (it ==
myDict.end()) {
1321 myDict.insert(DictType::value_type(
id, ptr));
1330 DictType::iterator it =
myDict.find(
id);
1331 if (it ==
myDict.end()) {
1341 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
1350 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
1351 into.push_back((*i).first);
1356 template<
class RTREE>
void 1358 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
1362 const float cmin[2] = {(float) b.
xmin(), (float) b.
ymin()};
1363 const float cmax[2] = {(float) b.
xmax(), (float) b.
ymax()};
1364 into.Insert(cmin, cmax, l);
1368 template void MSLane::fill<NamedRTree>(
NamedRTree& into);
1388 return (link !=
myLinks.end());
1398 assert(veh->
getLane() ==
this);
1411 #ifdef DEBUG_VEHICLE_CONTAINER 1415 return wasInactive &&
myVehicles.size() != 0;
1493 MSLinkCont::const_iterator
1495 const MSLane& succLinkSource,
const std::vector<MSLane*>& conts) {
1498 if (nRouteEdge == 0) {
1500 return succLinkSource.
myLinks.end();
1504 assert(succLinkSource.
myLinks.size() == 1);
1507 return succLinkSource.
myLinks.begin();
1518 MSLinkCont::const_iterator link;
1519 if (nRouteSuccs < (
int)conts.size()) {
1521 for (link = succLinkSource.
myLinks.begin(); link != succLinkSource.
myLinks.end(); ++link) {
1522 if ((*link)->getLane() != 0 && (*link)->getLane()->myEdge == nRouteEdge && (*link)->getLane()->allowsVehicleClass(veh.
getVehicleType().
getVehicleClass())) {
1524 if ((*link)->getLane() == conts[nRouteSuccs]) {
1531 return succLinkSource.
myLinks.end();
1536 WRITE_WARNING(
"Could not find connection between lane " + succLinkSource.
getID() +
" and lane " + conts[nRouteSuccs]->getID() +
1539 return succLinkSource.
myLinks.end();
1577 assert(remVehicle->
getLane() ==
this);
1579 if (remVehicle == *it) {
1617 WRITE_WARNING(
"Lane '" +
getID() +
"' is approached multiple times from edge '" + approachingEdge->
getID() +
"'. This may cause collisions.");
1631 std::map<MSEdge*, std::vector<MSLane*> >::const_iterator i =
myApproachingLanes.find(edge);
1635 const std::vector<MSLane*>& lanes = (*i).second;
1636 return find(lanes.begin(), lanes.end(), lane) != lanes.end();
1642 inline int operator()(
const std::pair<const MSVehicle*, SUMOReal>& p1,
const std::pair<const MSVehicle*, SUMOReal>& p2)
const {
1643 return p1.second < p2.second;
1654 std::pair<MSVehicle* const, SUMOReal> followerInfo =
getFollowerOnConsecutive(backOffset, leaderSpeed, leaderMaxDecel);
1672 std::pair<MSVehicle* const, SUMOReal>
1682 #ifdef DEBUG_CONTEXT 1684 <<
" backOffset=" << backOffset
1685 <<
" leaderSpeed=" << leaderSpeed
1689 std::pair<MSVehicle*, SUMOReal> result(static_cast<MSVehicle*>(0), -1);
1691 std::set<MSLane*> visited;
1692 std::vector<MSLane::IncomingLaneInfo> newFound;
1694 while (toExamine.size() != 0) {
1695 for (std::vector<MSLane::IncomingLaneInfo>::iterator i = toExamine.begin(); i != toExamine.end(); ++i) {
1696 MSLane* next = (*i).lane;
1697 #ifdef DEBUG_CONTEXT 1699 std::cout <<
SIMTIME <<
" nextLane=" << next->
getID() <<
"\n";
1715 if (!v->isFrontOnLane(next)) {
1716 agap = (*i).length - next->
getLength() + backOffset
1718 - v->getVehicleType().getMinGap();
1724 agap = (*i).length - v->
getPositionOnLane() + backOffset - v->getVehicleType().getMinGap();
1728 agap = (*i).length - v->getPositionOnLane() + backOffset - v->getVehicleType().getMinGap();
1730 #ifdef DEBUG_CONTEXT 1739 const SUMOReal missingRearGap = v->getCarFollowModel().getSecureGap(v->getSpeed(), leaderSpeed, leaderMaxDecel) - agap;
1740 if (missingRearGap > missingRearGapMax) {
1741 missingRearGapMax = missingRearGap;
1743 result.second = agap;
1746 if ((*i).length < dist) {
1747 const std::vector<MSLane::IncomingLaneInfo>& followers = next->
getIncomingLanes();
1748 for (std::vector<MSLane::IncomingLaneInfo>::const_iterator j = followers.begin(); j != followers.end(); ++j) {
1749 if (visited.find((*j).lane) == visited.end() && ((*j).viaLink->havePriority() || !ignoreMinorLinks)) {
1750 visited.insert((*j).lane);
1752 ili.
lane = (*j).lane;
1753 ili.
length = (*j).length + (*i).length;
1755 newFound.push_back(ili);
1762 swap(newFound, toExamine);
1767 std::pair<MSVehicle* const, SUMOReal>
1771 #ifdef DEBUG_CONTEXT 1776 if (checkTmpVehicles) {
1783 #ifdef DEBUG_CONTEXT 1785 std::cout <<
" getLeader lane=" <<
getID() <<
" ego=" << veh->
getID() <<
" egoPos=" << vehPos <<
" pred=" << pred->
getID() <<
" predPos=" << pred->
getPositionOnLane() <<
"\n";
1799 #ifdef DEBUG_CONTEXT 1801 std::cout <<
" getLeader lane=" <<
getID() <<
" ego=" << veh->
getID() <<
" egoPos=" << vehPos
1811 if (bestLaneConts.size() > 0) {
1817 #ifdef DEBUG_CONTEXT 1819 std::cout <<
" getLeader lane=" <<
getID() <<
" seen=" << seen <<
" dist=" << dist <<
"\n";
1823 return std::pair<MSVehicle* const, SUMOReal>(
static_cast<MSVehicle*
>(0), -1);
1827 return std::make_pair(static_cast<MSVehicle*>(0), -1);
1832 std::pair<MSVehicle* const, SUMOReal>
1834 const std::vector<MSLane*>& bestLaneConts)
const {
1835 #ifdef DEBUG_CONTEXT 1837 std::cout <<
" getLeaderOnConsecutive lane=" <<
getID() <<
" ego=" << veh.
getID() <<
" seen=" << seen <<
" dist=" << dist <<
" conts=" <<
toString(bestLaneConts) <<
"\n";
1841 return std::make_pair(static_cast<MSVehicle*>(0), -1);
1848 #ifdef DEBUG_CONTEXT 1855 const MSLane* nextLane =
this;
1858 nextLane->getVehiclesSecure();
1860 MSLinkCont::const_iterator link =
succLinkSec(veh, view, *nextLane, bestLaneConts);
1861 if (nextLane->isLinkEnd(link) || !(*link)->opened(arrivalTime, speed, speed, veh.
getVehicleType().
getLength(),
1863 #ifdef DEBUG_CONTEXT 1865 std::cout <<
" cannot continue after nextLane=" << nextLane->getID() <<
"\n";
1868 nextLane->releaseVehicles();
1871 #ifdef HAVE_INTERNAL_LANES 1874 nextLane->releaseVehicles();
1875 if (linkLeaders.size() > 0) {
1878 #ifdef DEBUG_CONTEXT 1880 std::cout <<
" found linkLeader after nextLane=" << nextLane->getID() <<
"\n";
1883 return linkLeaders[0].vehAndGap;
1885 bool nextInternal = (*link)->getViaLane() != 0;
1887 nextLane = (*link)->getViaLaneOrLane();
1888 if (nextLane == 0) {
1891 nextLane->getVehiclesSecure();
1892 MSVehicle* leader = nextLane->getLastAnyVehicle();
1894 #ifdef DEBUG_CONTEXT 1896 std::cout <<
" found leader " << leader->
getID() <<
" on nextLane=" << nextLane->getID() <<
"\n";
1900 nextLane->releaseVehicles();
1901 return std::make_pair(leader, dist);
1903 nextLane->releaseVehicles();
1904 if (nextLane->getVehicleMaxSpeed(&veh) < speed) {
1907 seen += nextLane->getLength();
1912 #ifdef HAVE_INTERNAL_LANES 1913 if (!nextInternal) {
1919 }
while (seen <= dist);
1920 return std::make_pair(static_cast<MSVehicle*>(0), -1);
1924 std::pair<MSVehicle* const, SUMOReal>
1927 std::pair<MSVehicle*, SUMOReal> result = std::make_pair(static_cast<MSVehicle*>(0), -1);
1933 const MSLane* nextLane =
this;
1937 MSLinkCont::const_iterator link =
succLinkSec(veh, view, *nextLane, bestLaneConts);
1942 #ifdef HAVE_INTERNAL_LANES 1945 for (MSLink::LinkLeaders::const_iterator it = linkLeaders.begin(); it != linkLeaders.end(); ++it) {
1946 const MSVehicle* leader = (*it).vehAndGap.first;
1947 if (leader != 0 && leader != result.first) {
1952 if (tmpSpeed < safeSpeed) {
1953 safeSpeed = tmpSpeed;
1954 result = (*it).vehAndGap;
1958 bool nextInternal = (*link)->getViaLane() != 0;
1960 nextLane = (*link)->getViaLaneOrLane();
1961 if (nextLane == 0) {
1965 if (leader != 0 && leader != result.first) {
1968 if (tmpSpeed < safeSpeed) {
1969 safeSpeed = tmpSpeed;
1970 result = std::make_pair(leader, gap);
1981 #ifdef HAVE_INTERNAL_LANES 1982 if (!nextInternal) {
1988 }
while (seen <= dist);
2001 for (MSEdgeVector::iterator i = pred.begin(); i != pred.end();) {
2010 if (pred.size() != 0) {
2012 MSEdge* best = *pred.begin();
2024 MSLane* cand = (*i).lane;
2025 if (&(cand->
getEdge()) == &fromEdge) {
2044 std::vector<const MSLane*>
2046 std::vector<const MSLane*> result;
2047 for (MSLinkCont::const_iterator i =
myLinks.begin(); i !=
myLinks.end(); ++i) {
2048 assert((*i)->getLane() != 0);
2049 result.push_back((*i)->getLane());
2071 for (MSLinkCont::const_iterator i =
myLinks.begin(); i !=
myLinks.end(); ++i) {
2072 if ((*i)->getLane()->getEdge().isCrossing()) {
2073 return (
int)(i -
myLinks.begin());
2117 wtime += (*i)->getWaitingSeconds();
2130 for (VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2131 v += (*i)->getSpeed();
2143 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2144 ret += (*i)->getCO2Emissions();
2155 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2156 ret += (*i)->getCOEmissions();
2167 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2168 ret += (*i)->getPMxEmissions();
2179 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2180 ret += (*i)->getNOxEmissions();
2191 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2192 ret += (*i)->getHCEmissions();
2203 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2204 ret += (*i)->getFuelConsumption();
2215 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2216 ret += (*i)->getElectricityConsumption();
2227 if (vehs.size() == 0) {
2231 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
2232 SUMOReal sv = (*i)->getHarmonoise_NoiseEmissions();
2233 ret += (
SUMOReal) pow(10., (sv / 10.));
2264 myLaneDir(e->getLanes()[0]->
getShape().angleAt2D(0)) {
2273 if (ae1 != 0 && ae1->size() != 0) {
2277 if (ae2 != 0 && ae2->size() != 0) {
2297 for (std::vector<std::string>::const_iterator it = vehIds.begin(); it != vehIds.end(); ++it) {
2312 #ifdef DEBUG_CONTEXT 2324 #ifdef DEBUG_CONTEXT 2334 #ifdef DEBUG_CONTEXT 2336 std::cout <<
" (1) added veh=" << veh->
getID() <<
" latOffset=" << latOffset <<
" result=" << result.
toString() <<
"\n";
2341 #ifdef DEBUG_CONTEXT 2343 std::cout <<
" result.numFreeSublanes=" << result.
numFreeSublanes() <<
"\n";
2347 const SUMOReal backOffset = ego->getBackPositionOnLane(ego->getLane());
2354 std::set<MSLane*> visited;
2355 std::vector<MSLane::IncomingLaneInfo> newFound;
2357 while (toExamine.size() != 0) {
2358 for (std::vector<MSLane::IncomingLaneInfo>::iterator it = toExamine.begin(); it != toExamine.end(); ++it) {
2359 MSLane* next = (*it).lane;
2363 #ifdef DEBUG_CONTEXT 2365 std::cout <<
" next=" << next->
getID() <<
" first=" << first.toString() <<
" firstFront=" << firstFront.
toString() <<
"\n";
2368 for (
int i = 0; i < first.numSublanes(); ++i) {
2371 if (v != 0 && v != ego) {
2378 agap = (*it).length - next->
getLength() + backOffset
2385 if (v != 0 && v != ego) {
2395 #ifdef DEBUG_CONTEXT 2402 if ((*it).length < dist) {
2403 const std::vector<MSLane::IncomingLaneInfo>& followers = next->
getIncomingLanes();
2404 for (std::vector<MSLane::IncomingLaneInfo>::const_iterator j = followers.begin(); j != followers.end(); ++j) {
2405 if (visited.find((*j).lane) == visited.end()) {
2406 visited.insert((*j).lane);
2408 ili.
lane = (*j).lane;
2409 ili.
length = (*j).length + (*it).length;
2411 newFound.push_back(ili);
2417 swap(newFound, toExamine);
2442 const MSLane* nextLane =
this;
2448 MSLinkCont::const_iterator link =
succLinkSec(*ego, view, *nextLane, bestLaneConts);
2453 #ifdef HAVE_INTERNAL_LANES 2456 if (linkLeaders.size() > 0) {
2467 bool nextInternal = (*link)->getViaLane() != 0;
2469 nextLane = (*link)->getViaLaneOrLane();
2470 if (nextLane == 0) {
2475 #ifdef DEBUG_CONTEXT 2477 std::cout <<
SIMTIME <<
" getLeadersOnConsecutive lane=" <<
getID() <<
" nextLane=" << nextLane->
getID() <<
" leaders=" << leaders.
toString() <<
"\n";
2482 for (
int i = 0; i < iMax; ++i) {
2485 #ifdef DEBUG_CONTEXT 2505 #ifdef HAVE_INTERNAL_LANES 2506 if (!nextInternal) {
2524 #ifdef DEBUG_CONTEXT 2526 std::cout <<
SIMTIME <<
" getPartialBehind lane=" <<
getID() <<
" ego=" << ego->
getID() <<
" found=" << veh->
getID() <<
"\n";
2532 #ifdef DEBUG_CONTEXT 2553 if (opposite == 0) {
2555 throw ProcessError(
"Lane '" +
getID() +
"' cannot compute oppositePos as there is no opposite lane.");
2562 std::pair<MSVehicle* const, SUMOReal>
2567 #ifdef DEBUG_CONTEXT 2569 std::cout <<
" getFollower lane=" <<
getID() <<
" egoPos=" << egoPos <<
" pred=" << pred->
getID() <<
" predPos=" << pred->
getPositionOnLane(
this) <<
"\n";
2581 std::pair<MSVehicle* const, SUMOReal>
2583 #ifdef DEBUG_OPPOSITE 2585 <<
" ego=" << ego->
getID()
2589 <<
" oppositeDir=" << oppositeDir
2597 std::pair<MSVehicle* const, SUMOReal> result =
getFollower(ego, egoPos + egoLength, dist,
true);
2604 std::pair<MSVehicle* const, SUMOReal>
2606 #ifdef DEBUG_OPPOSITE 2608 <<
" ego=" << ego->
getID()
2618 if (result.second > 0) {
2620 return std::make_pair(static_cast<MSVehicle*>(0), -1);
2630 const std::string action = oc.
getString(
"collision.action");
2631 if (action ==
"none") {
2633 }
else if (action ==
"warn") {
2635 }
else if (action ==
"teleport") {
2637 }
else if (action ==
"remove") {
2640 throw ProcessError(
"Invalid collision.action '" + action +
"'.");
const std::map< SUMOVehicleClass, SUMOReal > * myRestrictions
The vClass speed restrictions for this lane.
void loadState(std::vector< std::string > &vehIDs, MSVehicleControl &vc)
Loads the state of this segment with the given parameters.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
std::pair< MSVehicle *const, SUMOReal > getFollowerOnConsecutive(SUMOReal backOffset, SUMOReal leaderSpeed, SUMOReal leaderMaxDecel, SUMOReal dist=-1, bool ignoreMinorLinks=false) const
return the follower with the largest missing rear gap among all predecessor lanes (within dist) ...
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...
saves leader/follower vehicles and their distances relative to an ego vehicle
MSEdge & getEdge() const
Returns the lane's edge.
A free lateral position is chosen.
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 std::string toString() const
print a debugging representation
std::pair< MSVehicle *, SUMOReal > vehAndGap
SUMOReal getWaitingSeconds() const
Returns the overall waiting time on this lane.
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, SUMOReal > getFollower(const MSVehicle *ego, SUMOReal egoPos, SUMOReal dist, bool ignoreMinorLinks) const
Find follower vehicle for the given ego vehicle (which may be on the opposite direction lane) ...
MSVehicle * getFirstAnyVehicle() const
returns the first vehicle that is fully or partially on this lane
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
begin/end of the description of a single lane
int operator()(MSVehicle *v1, MSVehicle *v2) const
Comparing operator.
void setTentativeLaneAndPosition(MSLane *lane, SUMOReal pos, SUMOReal posLat=0)
set tentative lane and position during insertion to ensure that all cfmodels work (some of them requi...
bool isChangingLanes() const
return true if the vehicle currently performs a lane change maneuver
int myI2
index for myPartialVehicles
std::pair< MSVehicle *const, SUMOReal > getOppositeFollower(const MSVehicle *ego) const
void enterLaneAtInsertion(MSLane *enteredLane, SUMOReal pos, SUMOReal speed, SUMOReal posLat, MSMoveReminder::Notification notification)
Update when the vehicle enters a new lane in the emit step.
bool hasInfluencer() const
SUMOReal getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
SUMOReal getImpatience() const
Returns this vehicles impatience.
virtual const MSEdge * succEdge(int nSuccs) const =0
Returns the nSuccs'th successor of edge the vehicle is currently at.
virtual SUMOReal insertionFollowSpeed(const MSVehicle *const veh, SUMOReal speed, SUMOReal gap2pred, SUMOReal predSpeed, SUMOReal predMaxDecel) const
Computes the vehicle's safe speed (no dawdling) This method is used during the insertion stage...
MSLane * getOpposite() const
return the opposite direction lane for lane changing or 0
void registerTeleportYield()
register one non-collision-related teleport
const std::map< SUMOVehicleClass, SUMOReal > * getRestrictions(const std::string &id) const
Returns the restrictions for an edge type If no restrictions are present, 0 is returned.
static void fill(RTREE &into)
Fills the given RTree with lane instances.
The vehicle arrived at a junction.
SUMOTime getWaitingTime() const
Returns the SUMOTime waited (speed was lesser than 0.1m/s)
SUMOReal ymin() const
Returns minimum y-coordinate.
void recalcCache()
Recalculates the cached values.
This is an uncontrolled, minor link, has to stop.
const MSEdge * getLastEdge() const
returns the destination edge
SUMOReal getLength() const
Returns the lane's length.
SUMOReal departSpeed
(optional) The initial speed of the vehicle
bool hasArrived() const
Returns whether this vehicle has already arived (reached the arrivalPosition on its final edge) ...
std::vector< IncomingLaneInfo > myIncomingLanes
The car-following model abstraction.
int myI2End
end index for myPartialVehicles
void setLength(SUMOReal val)
Sets a new length for the lane (used by TraCI only)
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.
int myIndex
The lane index.
virtual bool integrateNewVehicle(SUMOTime t)
Insert buffered vehicle into the real lane.
The lateral position is chosen randomly.
SUMOReal arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
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.
SUMOReal xmin() const
Returns minimum x-coordinate.
Notification
Definition of a vehicle state.
static SUMOReal rand()
Returns a random real number in [0, 1)
std::string time2string(SUMOTime t)
SUMOReal getFuelConsumption() const
Returns the sum of last step fuel consumption.
A RT-tree for efficient storing of SUMO's Named objects.
SUMOReal getLength() const
Get vehicle's length [m].
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
const MSEdge *const myEdge
SUMOReal getWidth() const
Returns the lane's width.
SUMOReal getMaximumBrakeDist() const
compute maximum braking distance on this lane
void addIncomingLane(MSLane *lane, MSLink *viaLink)
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
SUMOReal getNettoOccupancy() const
Returns the netto (excluding minGaps) occupancy of this lane during the last step (including minGaps)...
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.
The vehicle got vaporized.
void leftByLaneChange(MSVehicle *v)
void getLeadersOnConsecutive(SUMOReal dist, SUMOReal seen, SUMOReal 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...
SUMOReal getSecureGap(const SUMOReal speed, const SUMOReal leaderSpeed, const SUMOReal leaderMaxDecel) const
Returns the minimum gap to reserve if the leader is braking at maximum (>=0)
Definition of vehicle stop (position and duration)
This is an uncontrolled, right-before-left link.
SUMOReal getElectricityConsumption() const
Returns the sum of last step electricity consumption.
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.
virtual SUMOReal stopSpeed(const MSVehicle *const veh, const SUMOReal speed, SUMOReal gap) const =0
Computes the vehicle's safe speed for approaching a non-moving obstacle (no dawdling) ...
SUMOReal getPositionOnLane() const
Get the vehicle's position along the lane.
int operator()(const MSEdge *const e1, const MSEdge *const e2) const
comparing operator
const SVCPermissions SVCAll
void gotActive(MSLane *l)
Informs the control that the given lane got active.
std::pair< MSVehicle *const, SUMOReal > getCriticalLeader(SUMOReal dist, SUMOReal seen, SUMOReal speed, const MSVehicle &veh) const
Returns the most dangerous leader and the distance to him.
const SUMOReal myWidth
Lane width [m].
SUMOReal processNextStop(SUMOReal currentVelocity)
Processes stops, returns the velocity needed to reach the stop.
static SUMOReal angleDiff(const SUMOReal angle1, const SUMOReal angle2)
Returns the difference of the second angle to the first angle in radiants.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
bool freeInsertion(MSVehicle &veh, SUMOReal speed, MSMoveReminder::Notification notification=MSMoveReminder::NOTIFICATION_DEPARTED)
Tries to insert the given vehicle on any place.
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.
static bool myCheckJunctionCollisions
bool hasStops() const
Returns whether the vehicle has to stop somewhere.
This is an uncontrolled, all-way stop link.
SUMOReal myMaxSpeed
Lane-wide speedlimit [m/s].
SUMOReal xmax() const
Returns maximum x-coordinate.
int myI1End
end index for myVehicles
A class that stores a 2D geometrical boundary.
int myDirection
index delta
PositionVector myShape
The shape of the lane.
#define WRITE_WARNING(msg)
MSLeaderDistanceInfo getFollowersOnConsecutive(const MSVehicle *ego, bool allSublanes) const
return the sublane followers with the largest missing rear gap among all predecessor lanes (within di...
bool myDownstream
iteration direction
MSAbstractLaneChangeModel & getLaneChangeModel()
SUMOReal getHCEmissions() const
Returns the sum of last step HC emissions.
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
std::vector< std::string > myNeighs
void setMaxSpeed(SUMOReal val)
Sets a new maximum speed for the lane (used by TraCI and MSCalibrator)
static CollisionAction myCollisionAction
the action to take on collisions
std::map< std::string, MSLane * > DictType
definition of the static dictionary type
SUMOReal getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
virtual void incorporateVehicle(MSVehicle *veh, SUMOReal pos, SUMOReal speed, SUMOReal 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 void detectCollisions(SUMOTime timestep, const std::string &stage)
Check if vehicles are too close.
static DictType myDict
Static dictionary to associate string-ids with objects.
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)
const std::string & getID() const
Returns the id.
A road/street connecting two junctions.
int operator()(MSVehicle *v1, MSVehicle *v2) const
Comparing operator.
bool insertVehicle(MSVehicle &v)
Tries to insert the given vehicle.
int numFreeSublanes() const
SUMOReal myRightSideOnEdge
the combined width of all lanes with lower index on myEdge
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
SUMOReal brakeGap(const SUMOReal speed) const
Returns the distance the vehicle needs to halt including driver's reaction time, assuming that during...
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...
std::pair< MSVehicle *const, SUMOReal > getLeaderOnConsecutive(SUMOReal dist, SUMOReal seen, SUMOReal speed, const MSVehicle &veh, const std::vector< MSLane * > &bestLaneConts) const
Returns the immediate leader and the distance to him.
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
SUMOReal getMissingRearGap(SUMOReal backOffset, SUMOReal leaderSpeed, SUMOReal leaderMaxDecel) const
return by how much further the leader must be inserted to avoid rear end collisions ...
SUMOReal basePos(const MSVehicle &veh) const
departure position where the vehicle fits fully onto the lane (if possible)
Representation of a vehicle.
PositionVector getBoundingBox() const
get bounding rectangle
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
const MSEdgeVector & getPredecessors() const
Returns the edge at the given position from the list of reachable edges.
virtual int addLeader(const MSVehicle *veh, bool beyond, SUMOReal latOffset=0)
SUMOReal getMinGap() const
Get the free space in front of vehicles of this class.
This is an uncontrolled, minor link, has to brake.
SUMOReal getDepartSpeed(const MSVehicle &veh, bool &patchSpeed)
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.
SVCPermissions myOriginalPermissions
The original vClass permissions for this lane (before temporary modifications)
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)
SUMOReal getMaxSpeedFactor() const
return the maximum speed factor for all vehicles that ever entered the network
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 * lane
The lane to stop at.
SUMOReal getMeanSpeed() const
Returns the mean speed on this lane.
ConstMSEdgeVector::const_iterator MSRouteIterator
PositionVector getBoundingPoly() const
get bounding polygon
bool lastInsertion(MSVehicle &veh, SUMOReal mspeed, bool patchSpeed)
inserts vehicle as close as possible to the last vehicle on this lane (or at the end of the lane if t...
The vehicle arrived at its destination (is deleted)
bool isStopped() const
Returns whether the vehicle is at a stop.
const MSLeaderInfo & getLastVehicleInformation(const MSVehicle *ego, SUMOReal latOffset, SUMOReal minPos=0, bool allowCached=true) const
Returns the last vehicles on the lane.
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic, in MSLink and GNEInternalLane.
The maximum speed is used.
SUMOReal getSafeFollowSpeed(const std::pair< const MSVehicle *, SUMOReal > leaderInfo, const SUMOReal seen, const MSLane *const lane, SUMOReal distToCrossing) const
compute safe speed for following the given leader
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
SUMOReal getSpeedLimit() const
Returns the lane's maximum allowed speed.
No information given; use default.
void onRemovalFromNet(const MSMoveReminder::Notification reason)
Called when the vehicle is removed from the network.
MSLane(const std::string &id, SUMOReal maxSpeed, SUMOReal length, MSEdge *const edge, int numericalID, const PositionVector &shape, SUMOReal width, SVCPermissions permissions, int index)
Constructor.
int myRightmostSublane
the index of the rightmost sublane of this lane on myEdge
MSLane * myLogicalPredecessorLane
virtual int addLeader(const MSVehicle *veh, SUMOReal gap, SUMOReal latOffset=0, int sublane=-1)
Something on a lane to be noticed about vehicle movement.
SUMOReal myLength
Lane length [m].
SUMOReal getMaxDecel() const
Get the vehicle type's maximum deceleration [m/s^2].
MSLane * getShadowLane() const
Returns the lane the vehicles shadow is on during continuous/sublane lane change. ...
virtual SUMOReal setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.
virtual void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
virtual SUMOReal freeSpeed(const MSVehicle *const veh, SUMOReal speed, SUMOReal seen, SUMOReal maxSpeed, const bool onInsertion=false) const
Computes the vehicle's safe speed without a leader.
void registerTeleportJam()
register one non-collision-related teleport
void handleCollisionBetween(SUMOTime timestep, const std::string &stage, const MSVehicle *collider, const MSVehicle *victim, SUMOReal gap, SUMOReal latGap, std::set< const MSVehicle *, SUMOVehicle::ComparatorIdLess > &toRemove, std::set< const MSVehicle * > &toTeleport) const
take action upon collision
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
const std::string & getEdgeType() const
Returns the type of the edge.
int addFollower(const MSVehicle *veh, const MSVehicle *ego, SUMOReal gap, SUMOReal latOffset=0, int sublane=-1)
std::vector< MSVehicle * > VehCont
Container for vehicles.
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.
SUMOReal safeInsertionSpeed(const MSVehicle *veh, const MSLeaderInfo &leaders, SUMOReal speed)
return the maximum safe speed for insertion behind leaders (a negative value indicates that safe inse...
const SUMOReal myLengthGeometryFactor
precomputed myShape.length / myLength
AnyVehicleIterator & operator++()
static MSVehicleTransfer * getInstance()
Returns the instance of this object.
void leaveLane(const MSMoveReminder::Notification reason)
Update of members if vehicle leaves a new lane in the lane change step or at arrival.
void forceVehicleInsertion(MSVehicle *veh, SUMOReal pos, MSMoveReminder::Notification notification, SUMOReal posLat=0)
Inserts the given vehicle at the given position.
void sortPartialVehicles()
sorts myPartialVehicles
SUMOReal getWidth() const
Get the width which vehicles of this class shall have when being drawn.
void setPermissions(SVCPermissions permissions, long transientID)
Sets the permissions to the given value. If a transientID is given, the permissions are recored as te...
std::vector< const MSLane * > getOutgoingLanes() const
get the list of outgoing lanes
SUMOReal getLatOffset(const MSLane *lane) const
Get the offset that that must be added to interpret myState.myPosLat for the given lane...
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
SUMOReal getNOxEmissions() const
Returns the sum of last step NOx emissions.
static SUMOTime gTimeToGridlockHighways
Boundary & grow(SUMOReal by)
extends the boundary by the given amount
std::string myID
The name of the object.
SUMOReal getPMxEmissions() const
Returns the sum of last step PMx emissions.
EdgeBasicFunction getPurpose() const
Returns the edge type (EdgeBasicFunction)
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
bool detectCollisionBetween(SUMOTime timestep, const std::string &stage, const MSVehicle *collider, const 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
bool operator()(const MSVehicle *cmp, SUMOReal pos) const
compares vehicle position to the detector position
SUMOReal myBruttoVehicleLengthSum
The current length of all vehicles on this lane, including their minGaps.
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.
SUMOReal 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) ...
SUMOReal getCO2Emissions() const
Returns the sum of last step CO2 emissions.
MSEdge *const myEdge
The lane's edge, for routing only.
const std::vector< MSLane * > * allowedLanes(const MSEdge &destination, SUMOVehicleClass vclass=SVC_IGNORING) const
Get the allowed lanes to reach the destination-edge.
SUMOReal getCOEmissions() const
Returns the sum of last step CO emissions.
At the rightmost side of the lane.
At the center of the lane.
const MSLane * myLane
the lane that is being iterated
bool checkFailure(MSVehicle *aVehicle, SUMOReal &speed, SUMOReal &dist, const SUMOReal nspeed, const bool patchSpeed, const std::string errorMsg) const
MSVehicle * getPartialBehind(const MSVehicle *ego) const
A storage for options typed value containers)
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
static SUMOReal gLateralResolution
bool overlapsWith(const AbstractPoly &poly, SUMOReal offset=0) const
Returns the information whether the given polygon overlaps with this.
bool isApproachedFrom(MSEdge *const edge)
std::pair< MSVehicle *const, SUMOReal > getOppositeLeader(const MSVehicle *ego, SUMOReal dist, bool oppositeDir) const
const SUMOReal SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
virtual const std::string & getID() const =0
Get the vehicle's ID.
static SUMOReal sum(SUMOReal val)
Computes the resulting noise.
SUMOReal getSpeed() const
Returns the vehicle's current speed.
static SUMOTime gTimeToGridlock
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
bool isFrontOnLane(const MSLane *lane) const
Returns the information whether the front of the vehicle is on the given lane.
SUMOReal departPos
(optional) The position the vehicle shall depart from
SUMOReal getMinDeceleration() const
return the minimum deceleration capability for all vehicles that ever entered the network ...
const MSLeaderInfo & getFirstVehicleInformation(const MSVehicle *ego, SUMOReal latOffset, bool onlyFrontOnLane, SUMOReal maxPos=std::numeric_limits< SUMOReal >::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.
AnyVehicleIterator anyVehiclesEnd() const
end iterator for iterating over all vehicles touching this lane in downstream direction ...
SUMOReal getBackPositionOnLane(const MSLane *lane) const
Get the vehicle's position relative to the given lane.
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)
SUMOReal endPos
The stopping position end.
SUMOReal getOppositePos(SUMOReal pos) const
return the corresponding position on the opposite lane
LinkState getState() const
Returns the current state of the link.
Static storage of an output device and its base (abstract) implementation.
bool nextIsMyVehicles() const
bool closeTag()
Closes the most recently opened tag.
const MSEdgeVector & getSuccessors() const
Returns the following edges.
void registerCollision()
registers one collision-related teleport
SUMOReal ymax() const
Returns maximum y-coordinate.
MSEdgeControl & getEdgeControl()
Returns the edge control.
MSLeaderInfo myFollowerInfo
followers on all sublanes as seen by vehicles on consecutive lanes (cached)
virtual ~MSLane()
Destructor.
int operator()(const std::pair< const MSVehicle *, SUMOReal > &p1, const std::pair< const MSVehicle *, SUMOReal > &p2) const
SUMOReal myNettoVehicleLengthSum
The current length of all vehicles on this lane, excluding their minGaps.
std::string toString() const
print a debugging representation
bool isInsertionSuccess(MSVehicle *vehicle, SUMOReal speed, SUMOReal pos, SUMOReal posLat, bool recheckNextLanes, MSMoveReminder::Notification notification)
Tries to insert the given vehicle with the given state (speed and pos)
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
No information given; use default.
A free position is chosen.
The class responsible for building and deletion of vehicles.
std::vector< MSEdge * > MSEdgeVector
MSLeaderInfo myLeaderInfoTmp
virtual SUMOReal insertionStopSpeed(const MSVehicle *const veh, SUMOReal speed, SUMOReal gap) const
Computes the vehicle's safe speed for approaching an obstacle at insertion without constraints due to...
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 ...
SUMOReal getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
SUMOReal getHarmonoise_NoiseEmissions() const
Returns the sum of last step noise emissions.
static const long CHANGE_PERMISSIONS_PERMANENT
MSLane * getLane() const
Returns the lane the vehicle is on.
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
The edge is an internal edge.
SUMOReal getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
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
AnyVehicleIterator anyVehiclesBegin() const
begin iterator for iterating over all vehicles touching this lane in downstream direction ...
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
void registerTeleportWrongLane()
register one non-collision-related teleport
SUMOReal departPosLat
(optional) The lateral position the vehicle shall depart from
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 ...
std::pair< MSVehicle *const, SUMOReal > getLeader(const MSVehicle *veh, const SUMOReal vehPos, const std::vector< MSLane * > &bestLaneConts, SUMOReal dist=-1, bool checkTmpVehicles=false) const
Returns the immediate leader of veh and the distance to veh starting on this lane.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
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...
SUMOReal getRightSideOnEdge() const
const std::string & getID() const
Returns the name of the vehicle.
AnyVehicleIterator anyVehiclesUpstreamBegin() const
begin iterator for iterating over all vehicles touching this lane in upstream direction ...
DepartPosLatDefinition departPosLatProcedure
Information how the vehicle shall choose the lateral departure position.