98 #define DEBUG_COND (isSelected()) 101 #define STOPPING_PLACE_OFFSET 0.5 103 #define CRLL_LOOK_AHEAD 5 105 #define JUNCTION_BLOCKAGE_TIME 5 // s 108 #define DIST_TO_STOPLINE_EXPECT_PRIORITY 1.0 185 if (memorySpan == -1) {
190 if (i->second >= memorySpan) {
191 if (i->first >= memorySpan) {
194 totalWaitingTime += memorySpan - i->first;
197 totalWaitingTime += i->second - i->first;
200 return totalWaitingTime;
207 bool startNewInterval = i == end || (i->first != 0);
218 waitingIntervalList::iterator::difference_type d = std::distance(i, end);
226 }
else if (!startNewInterval) {
243 mySpeedAdaptationStarted(true),
244 myConsiderSafeVelocity(true),
245 myConsiderMaxAcceleration(true),
246 myConsiderMaxDeceleration(true),
247 myRespectJunctionPriority(true),
248 myEmergencyBrakeRedLight(true),
308 duration -= i->first;
335 speed =
MIN2(speed, vSafe);
338 speed =
MIN2(speed, vMax);
341 speed =
MAX2(speed, vMin);
363 if (destinationLaneIndex < (
int)currentEdge.
getLanes().size()) {
364 if (currentLaneIndex > destinationLaneIndex) {
366 }
else if (currentLaneIndex < destinationLaneIndex) {
371 }
else if (currentEdge.
getLanes().back()->getOpposite() != 0) {
393 }
else if ((state & LCA_TRACI) != 0) {
400 state &= ~LCA_WANTS_LANECHANGE_OR_STAY;
408 state &= ~LCA_WANTS_LANECHANGE_OR_STAY;
429 switch (changeRequest) {
498 const bool wasOnRoad = v->
isOnRoad();
547 if (distAlongRoute != std::numeric_limits<double>::max()) {
548 dist = distAlongRoute;
597 return busstop->getLastFreePos(veh);
598 }
else if (containerstop != 0) {
599 return containerstop->getLastFreePos(veh);
600 }
else if (parkingarea != 0) {
601 return parkingarea->getLastFreePos(veh);
602 }
else if (chargingStation != 0) {
603 return chargingStation->getLastFreePos(veh);
611 if (parkingarea != 0) {
612 return "parkingArea:" + parkingarea->getID();
613 }
else if (containerstop != 0) {
614 return "containerStop:" + containerstop->getID();
615 }
else if (busstop != 0) {
616 return "busStop:" + busstop->getID();
617 }
else if (chargingStation != 0) {
618 return "chargingStation:" + chargingStation->getID();
620 return "lane:" + lane->getID() +
" pos:" +
toString(pars.endPos);
632 if (containerstop != 0) {
635 if (busstop == 0 && containerstop == 0) {
643 if (pars.until >= 0) {
646 if (pars.triggered) {
649 if (pars.containerTriggered) {
655 if (pars.awaitedPersons.size() > 0) {
658 if (pars.awaitedContainers.size() > 0) {
689 myStopDist(std::numeric_limits<double>::max()),
694 if (!(*myCurrEdge)->isTazConnector()) {
696 if ((*myCurrEdge)->getDepartLane(*
this) == 0) {
697 throw ProcessError(
"Invalid departlane definition for vehicle '" + pars->
id +
"'.");
701 throw ProcessError(
"Vehicle '" + pars->
id +
"' is not allowed to depart on any lane of its first edge.");
706 "' is too high for the vehicle type '" + type->
getID() +
"'.");
721 (*i)->resetPartialOccupation(
this);
741 #ifdef DEBUG_ACTIONSTEPS 743 std::cout <<
SIMTIME <<
" Removing vehicle '" <<
getID() <<
"' (reason: " <<
toString(reason) <<
")" << std::endl;
776 (newCurrEdge + 1) == edges.end() || (*(newCurrEdge + 1)) != &(
myLane->
getOutgoingViaLanes().front().first->getEdge()))) {
793 if (stopsFromScratch) {
798 for (std::list<Stop>::iterator iter =
myStops.begin(); iter !=
myStops.end();) {
799 if (removeStops && find(
myCurrEdge, edges.end(), &iter->lane->getEdge()) == edges.end()) {
803 iter->edge = find(
myCurrEdge, edges.end(), &iter->lane->getEdge());
809 for (std::vector<SUMOVehicleParameter::Stop>::const_iterator i = newRoute->
getStops().begin(); i != newRoute->
getStops().end(); ++i) {
878 if (!rem->first->notifyMove(*
this, oldPos + rem->second, newPos + rem->second,
MAX2(0., newSpeed))) {
880 if (myTraceMoveReminders) {
881 traceMoveReminder(
"notifyMove", rem->first, rem->second,
false);
887 if (myTraceMoveReminders) {
888 traceMoveReminder(
"notifyMove", rem->first, rem->second,
true);
904 rem->second += oldLaneLength;
908 if (myTraceMoveReminders) {
909 traceMoveReminder(
"adaptedPos", rem->first, rem->second,
true);
942 if (
myStops.begin()->parkingarea != 0) {
943 return myStops.begin()->parkingarea->getVehiclePosition(*
this);
953 if (offset == 0. && !changingLanes) {
968 auto nextBestLane = bestLanes.begin();
991 while (nextBestLane != bestLanes.end() && *nextBestLane == 0) {
996 assert(lane == *nextBestLane);
1000 assert(nextBestLane == bestLanes.end() || *nextBestLane != 0);
1001 if (nextBestLane == bestLanes.end()) {
1028 int furtherIndex = 0;
1037 offset += lastLength;
1062 #ifdef DEBUG_FURTHER 1064 std::cout <<
SIMTIME <<
" veh '" <<
getID() <<
" setAngle(" << angle <<
") straightenFurther=" << straightenFurther << std::endl;
1079 if (
myStops.begin()->parkingarea != 0) {
1080 return myStops.begin()->parkingarea->getVehicleAngle(*
this);
1105 double result = (p1 != p2 ? p2.
angleTo2D(p1) :
1110 #ifdef DEBUG_FURTHER 1130 #ifdef DEBUG_FURTHER 1149 errorMsg =
"Vehicle '" +
myParameter->
id +
"' is not allowed to stop on lane '" + stopPar.
lane +
"'.";
1161 if (stopPar.
until != -1) {
1169 std::string stopType =
"stop";
1170 std::string stopID =
"";
1172 stopType =
"busStop";
1175 stopType =
"containerStop";
1178 stopType =
"chargingStation";
1181 stopType =
"parkingArea";
1184 const std::string errorMsgStart = stopID ==
"" ? stopType : stopType +
" '" + stopID +
"'";
1187 errorMsg = errorMsgStart +
" for vehicle '" +
myParameter->
id +
"' on lane '" + stopPar.
lane +
"' has an invalid position.";
1192 errorMsg = errorMsgStart +
" on lane '" + stopPar.
lane +
"' is too short for vehicle '" +
myParameter->
id +
"'.";
1196 if (searchStart == 0) {
1203 std::list<Stop>::iterator iter =
myStops.begin();
1206 prevStopEdge =
myStops.back().edge;
1207 prevStopPos =
myStops.back().pars.endPos;
1210 if (prevStopEdge == stop.
edge && prevStopPos > stop.
pars.
endPos) {
1216 while (iter !=
myStops.end() && (iter->edge < stop.
edge ||
1217 (iter->pars.endPos < stop.
pars.
endPos && iter->edge == stop.
edge))) {
1218 prevStopEdge = iter->edge;
1219 prevStopPos = iter->pars.endPos;
1223 int index = stopPar.
index;
1225 prevStopEdge = iter->edge;
1226 prevStopPos = iter->pars.endPos;
1234 (prevStopEdge == stop.
edge && prevStopPos > stop.
pars.
endPos && !collision)
1239 return addStop(stopPar, errorMsg, untilOffset, collision, &next);
1241 errorMsg = errorMsgStart +
" for vehicle '" +
myParameter->
id +
"' on lane '" + stopPar.
lane +
"' is not downstream the current route.";
1263 errorMsg = errorMsgStart +
" for vehicle '" +
myParameter->
id +
"' on lane '" + stopPar.
lane +
"' is too close to break.";
1272 pos += (*myCurrEdge)->getLength();
1282 return addStop(stopPar, errorMsg, untilOffset, collision, &next);
1284 errorMsg = errorMsgStart +
" for vehicle '" +
myParameter->
id +
"' on lane '" + stopPar.
lane +
"' is before departPos.";
1288 if (iter !=
myStops.begin()) {
1289 std::list<Stop>::iterator iter2 = iter;
1292 errorMsg = errorMsgStart +
" for vehicle '" +
myParameter->
id +
"' on lane '" + stopPar.
lane +
"' ends earlier than previous stop.";
1303 assert(parkingArea != 0);
1305 errorMsg =
"Vehicle '" +
myParameter->
id +
"' has no stops.";
1311 errorMsg =
"current stop already reached";
1315 errorMsg =
"current stop is not a parkingArea";
1319 errorMsg =
"current stop is the same as the new parking area";
1325 int removeStops = 0;
1328 for (std::list<Stop>::const_iterator iter =
myStops.begin(); iter !=
myStops.end(); ++iter) {
1329 if (duration == 0) {
1330 duration = iter->duration;
1333 if (iter->parkingarea != 0 && iter->parkingarea == parkingArea) {
1334 duration += iter->duration;
1359 while (removeStops > 0) {
1363 const bool result =
addStop(stopPar, errorMsg);
1381 return nextParkingArea;
1415 return myStops.front().duration;
1449 return currentVelocity;
1454 std::cout <<
"\nPROCESS_NEXT_STOP\n" <<
SIMTIME <<
" vehicle '" <<
getID() <<
"'" << std::endl;
1464 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' reached stop.\n" 1479 for (std::vector<MSTransportable*>::const_iterator i = persons.begin(); i != persons.end(); ++i) {
1490 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' unregisters as waiting for person." << std::endl;
1498 for (std::vector<MSTransportable*>::const_iterator i = containers.begin(); i != containers.end(); ++i) {
1509 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' unregisters as waiting for container." << std::endl;
1517 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' resumes from stopping." << std::endl;
1524 WRITE_WARNING(
"Vehicle '" +
getID() +
"' ignores triggered stop on lane '" + stop.
lane->
getID() +
"' due to capacity constraints.");
1532 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' registers as waiting for person." << std::endl;
1538 WRITE_WARNING(
"Vehicle '" +
getID() +
"' ignores container triggered stop on lane '" + stop.
lane->
getID() +
"' due to capacity constraints.");
1546 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' registers as waiting for container." << std::endl;
1565 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' hasn't reached next stop." << std::endl;
1573 bool useStoppingPlace =
false;
1574 bool fitsOnStoppingPlace =
true;
1576 useStoppingPlace =
true;
1580 fitsOnStoppingPlace &= stop.
busstop->
fits(endPos, *
this);
1584 useStoppingPlace =
true;
1593 fitsOnStoppingPlace =
false;
1602 if (
myStops.empty() ||
myStops.front().parkingarea != oldParkingArea) {
1604 return currentVelocity;
1616 std::cout <<
" pos=" <<
myState.
pos() <<
" speed=" << currentVelocity <<
" endPos=" << endPos <<
" fits=" << fitsOnStoppingPlace <<
" reachedThresh=" << reachedThreshold <<
"\n";
1624 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' reached next stop." << std::endl;
1663 return currentVelocity;
1670 for (std::list<Stop>::const_iterator iter =
myStops.begin(); iter !=
myStops.end(); ++iter) {
1671 result.push_back(*iter->edge);
1682 && (&
myStops.front().lane->getEdge()) == *
myStops.front().edge) {
1707 if (timeSinceLastAction == 0) {
1709 timeSinceLastAction = oldActionStepLength;
1711 if (timeSinceLastAction >= newActionStepLength) {
1713 myLastActionTime = now;
1715 SUMOTime timeUntilNextAction = newActionStepLength - timeSinceLastAction;
1724 #ifdef DEBUG_PLAN_MOVE 1729 <<
" veh=" <<
getID()
1738 #ifdef DEBUG_ACTIONSTEPS 1740 std::cout <<
STEPS2TIME(t) <<
" vehicle '" <<
getID() <<
"' skips action." << std::endl;
1748 #ifdef DEBUG_ACTIONSTEPS 1750 std::cout <<
STEPS2TIME(t) <<
" vehicle = '" <<
getID() <<
"' takes action." << std::endl;
1756 #ifdef DEBUG_PLAN_MOVE 1758 DriveItemVector::iterator i;
1761 <<
" vPass=" << (*i).myVLinkPass
1762 <<
" vWait=" << (*i).myVLinkWait
1763 <<
" linkLane=" << ((*i).myLink == 0 ?
"NULL" : (*i).myLink->getViaLaneOrLane()->getID())
1764 <<
" request=" << (*i).mySetRequest
1772 #ifdef DEBUG_PLAN_MOVE 1774 std::cout <<
" after checkRewindLinkLanes\n";
1775 DriveItemVector::iterator i;
1778 <<
" vPass=" << (*i).myVLinkPass
1779 <<
" vWait=" << (*i).myVLinkWait
1780 <<
" linkLane=" << ((*i).myLink == 0 ?
"NULL" : (*i).myLink->getViaLaneOrLane()->getID())
1781 <<
" request=" << (*i).mySetRequest
1782 <<
" atime=" << (*i).myArrivalTime
1783 <<
" atimeB=" << (*i).myArrivalTimeBraking
1801 myStopDist = std::numeric_limits<double>::max();
1809 double lateralShift = 0;
1813 laneMaxV =
MIN2(laneMaxV, l->getVehicleMaxSpeed(
this));
1817 laneMaxV =
MAX2(laneMaxV, vMinComfortable);
1819 laneMaxV = std::numeric_limits<double>::max();
1822 double v =
MIN2(maxV, laneMaxV);
1831 #ifdef DEBUG_PLAN_MOVE 1833 std::cout <<
" dist=" << dist <<
" bestLaneConts=" <<
toString(bestLaneConts) <<
"\n";
1836 assert(bestLaneConts.size() > 0);
1837 bool hadNonInternal =
false;
1840 myNextTurn.first = seen;
1842 bool encounteredTurn =
false;
1843 double seenNonInternal = 0;
1848 bool slowedDownForMinor =
false;
1854 #pragma warning(push) 1855 #pragma warning(disable: 4127) // do not warn about constant conditional expression 1859 #pragma warning(pop) 1870 if (leader.first != 0 && leader.first->getLane() == leaderLane && leader.first->getLaneChangeModel().isOpposite()) {
1874 adaptToLeaders(ahead, lateralShift, seen, lastLink, leaderLane, v, vLinkPass);
1875 #ifdef DEBUG_PLAN_MOVE 1877 std::cout <<
"\nv = " << v <<
"\n";
1885 if (shadowLane != 0) {
1889 seen, lastLink, shadowLane, v, vLinkPass);
1894 const double relativePos = lane->
getLength() - seen;
1895 #ifdef DEBUG_PLAN_MOVE 1897 std::cout <<
SIMTIME <<
" adapt to pedestrians on lane=" << lane->
getID() <<
" relPos=" << relativePos <<
"\n";
1902 if (leader.first != 0) {
1904 v =
MIN2(v, stopSpeed);
1905 #ifdef DEBUG_PLAN_MOVE 1907 std::cout <<
SIMTIME <<
" pedLeader=" << leader.first->getID() <<
" dist=" << leader.second <<
" v=" << v <<
"\n";
1920 myStopDist = seen + endPos - lane->
getLength();
1923 if (lastLink != 0) {
1926 v =
MIN2(v, stopSpeed);
1928 MSLinkCont::const_iterator exitLink =
MSLane::succLinkSec(*
this, view + 1, *lane, bestLaneConts);
1930 bool dummySetRequest;
1931 double dummyVLinkWait;
1936 #ifdef DEBUG_PLAN_MOVE 1938 std::cout <<
"\n" <<
SIMTIME <<
" next stop: distance = " << myStopDist <<
" requires stopSpeed = " << stopSpeed <<
"\n";
1948 MSLinkCont::const_iterator link =
MSLane::succLinkSec(*
this, view + 1, *lane, bestLaneConts);
1951 if (!encounteredTurn) {
1959 myNextTurn.first = seen;
1960 myNextTurn.second = linkDir;
1961 encounteredTurn =
true;
1962 #ifdef DEBUG_NEXT_TURN 1965 <<
" at " << myNextTurn.first <<
"m." << std::endl;
1981 if (lastLink != 0) {
1989 ((*link)->getViaLane() == 0
2003 if (lastLink != 0) {
2011 #ifdef DEBUG_PLAN_MOVE 2022 lateralShift += (*link)->getLateralShift();
2023 const bool yellowOrRed = (*link)->haveRed() || (*link)->haveYellow();
2034 double laneStopOffset;
2039 laneStopOffset = majorStopOffset;
2040 }
else if ((*link)->havePriority()) {
2042 laneStopOffset =
MIN2((*link)->getFoeVisibilityDistance() -
POSITION_EPS, majorStopOffset);
2045 laneStopOffset =
MIN2((*link)->getFoeVisibilityDistance() -
POSITION_EPS, minorStopOffset);
2048 const double stopDist =
MAX2(0., seen - laneStopOffset);
2050 #ifdef DEBUG_PLAN_MOVE 2052 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" effective stopOffset on lane '" << lane->
getID()
2053 <<
"' is " << laneStopOffset <<
" (-> stopDist=" << stopDist <<
")" << std::endl;
2066 assert(timeRemaining != 0);
2069 #ifdef DEBUG_PLAN_MOVE 2071 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" slowing down to finish continuous change before" 2072 <<
" link=" << (*link)->getViaLaneOrLane()->getID()
2073 <<
" timeRemaining=" << timeRemaining
2086 const bool abortRequestAfterMinor = slowedDownForMinor && (*link)->getInternalLaneBefore() == 0;
2088 bool setRequest = (v > 0 && !abortRequestAfterMinor) || (leavingCurrentIntersection);
2092 const bool canBrake = seen >= brakeDist;
2093 #ifdef DEBUG_PLAN_MOVE 2096 <<
" stopDist=" << stopDist
2097 <<
" vLinkWait=" << vLinkWait
2098 <<
" brakeDist=" << brakeDist
2106 if (yellowOrRed && canBrake && !
ignoreRed(*link, canBrake)) {
2121 #ifdef DEBUG_EXEC_MOVE 2123 <<
" ignoreRed spent=" <<
STEPS2TIME(t - (*link)->getLastStateChange())
2124 <<
" redSpeed=" << redSpeed
2134 if (lastLink != 0) {
2137 double arrivalSpeed = vLinkPass;
2143 double visibilityDistance = (*link)->getFoeVisibilityDistance();
2144 double determinedFoePresence = seen <= visibilityDistance;
2149 #ifdef DEBUG_PLAN_MOVE 2151 std::cout <<
" approaching link=" << (*link)->getViaLaneOrLane()->getID() <<
" prio=" << (*link)->havePriority() <<
" seen=" << seen <<
" visibilityDistance=" << visibilityDistance <<
" brakeDist=" << brakeDist <<
"\n";
2155 if (!(*link)->havePriority() && !determinedFoePresence && brakeDist < seen && !(*link)->lastWasContMajor()) {
2160 arrivalSpeed =
MIN2(vLinkPass, maxArrivalSpeed);
2161 slowedDownForMinor =
true;
2162 #ifdef DEBUG_PLAN_MOVE 2164 std::cout <<
" slowedDownForMinor maxArrivalSpeed=" << maxArrivalSpeed <<
" arrivalSpeed=" << arrivalSpeed <<
"\n";
2181 double arrivalSpeedBraking = 0;
2188 arrivalSpeedBraking =
MIN2(arrivalSpeedBraking, arrivalSpeed);
2192 if (v + arrivalSpeedBraking <= 0.) {
2193 arrivalTimeBraking = std::numeric_limits<long long int>::max();
2195 arrivalTimeBraking =
MAX2(arrivalTime, t +
TIME2STEPS(seen / ((v + arrivalSpeedBraking) * 0.5)));
2199 arrivalTime, arrivalSpeed,
2200 arrivalTimeBraking, arrivalSpeedBraking,
2203 if ((*link)->getViaLane() == 0) {
2204 hadNonInternal =
true;
2207 #ifdef DEBUG_PLAN_MOVE 2209 std::cout <<
" checkAbort setRequest=" << setRequest <<
" v=" << v <<
" seen=" << seen <<
" dist=" << dist
2210 <<
" seenNonInternal=" << seenNonInternal
2211 <<
" seenInternal=" << seenInternal <<
" length=" << vehicleLength <<
"\n";
2215 if ((!setRequest || v <= 0 || seen > dist) && hadNonInternal && seenNonInternal >
MAX2(vehicleLength *
CRLL_LOOK_AHEAD, vehicleLength + seenInternal)) {
2219 lane = (*link)->getViaLaneOrLane();
2222 laneMaxV = std::numeric_limits<double>::max();
2236 leaderLane = opposite ? lane->
getOpposite() : lane;
2237 if (leaderLane == 0) {
2243 lastLink = &lfLinks.back();
2258 const MSLane*
const lane,
double& v,
double& vLinkPass)
const {
2261 ahead.
getSubLanes(
this, latOffset, rightmost, leftmost);
2262 #ifdef DEBUG_PLAN_MOVE 2264 <<
"\nADAPT_TO_LEADERS\nveh=" <<
getID()
2265 <<
" lane=" << lane->
getID()
2266 <<
" latOffset=" << latOffset
2267 <<
" rm=" << rightmost
2268 <<
" lm=" << leftmost
2282 for (
int sublane = rightmost; sublane <= leftmost; ++sublane) {
2284 if (pred != 0 && pred !=
this) {
2287 double gap = (lastLink == 0
2293 #ifdef DEBUG_PLAN_MOVE 2295 std::cout <<
" pred=" << pred->
getID() <<
" predLane=" << pred->
getLane()->
getID() <<
" predPos=" << pred->
getPositionOnLane() <<
" gap=" << gap <<
" predBack=" << predBack <<
" seen=" << seen <<
" lane=" << lane->
getID() <<
" myLane=" <<
myLane->
getID() <<
"\n";
2298 adaptToLeader(std::make_pair(pred, gap), seen, lastLink, lane, v, vLinkPass);
2307 const MSLane*
const lane,
double& v,
double& vLinkPass,
2308 double distToCrossing)
const {
2309 if (leaderInfo.first != 0) {
2310 const double vsafeLeader =
getSafeFollowSpeed(leaderInfo, seen, lane, distToCrossing);
2311 if (lastLink != 0) {
2314 v =
MIN2(v, vsafeLeader);
2315 vLinkPass =
MIN2(vLinkPass, vsafeLeader);
2317 #ifdef DEBUG_PLAN_MOVE 2321 <<
" veh=" <<
getID()
2322 <<
" lead=" << leaderInfo.first->getID()
2323 <<
" leadSpeed=" << leaderInfo.first->getSpeed()
2324 <<
" gap=" << leaderInfo.second
2325 <<
" leadLane=" << leaderInfo.first->getLane()->getID()
2326 <<
" predPos=" << leaderInfo.first->getPositionOnLane()
2328 <<
" lane=" << lane->
getID()
2330 <<
" dTC=" << distToCrossing
2332 <<
" vSafeLeader=" << vsafeLeader
2333 <<
" vLinkPass=" << vLinkPass
2342 DriveProcessItem*
const lastLink,
double& v,
double& vLinkPass,
double& vLinkWait,
bool& setRequest)
const {
2345 checkLinkLeader(link, lane, seen, lastLink, v, vLinkPass, vLinkWait, setRequest);
2348 if (parallelLink != 0) {
2349 checkLinkLeader(parallelLink, lane, seen, lastLink, v, vLinkPass, vLinkWait, setRequest,
true);
2358 DriveProcessItem*
const lastLink,
double& v,
double& vLinkPass,
double& vLinkWait,
bool& setRequest,
2359 bool isShadowLink)
const {
2360 #ifdef DEBUG_PLAN_MOVE_LEADERINFO 2366 #ifdef DEBUG_PLAN_MOVE_LEADERINFO 2371 for (MSLink::LinkLeaders::const_iterator it = linkLeaders.begin(); it != linkLeaders.end(); ++it) {
2373 const MSVehicle* leader = (*it).vehAndGap.first;
2377 adaptToLeader(std::make_pair(
this, -1), seen, lastLink, lane, v, vLinkPass, it->distToCrossing);
2378 }
else if (link->
isLeader(
this, leader)) {
2385 linkLeadersAhead.
addLeader(leader,
false, 0);
2389 #ifdef DEBUG_PLAN_MOVE 2393 <<
" isShadowLink=" << isShadowLink
2394 <<
" lane=" << lane->
getID()
2395 <<
" foe=" << leader->
getID()
2397 <<
" latOffset=" << latOffset
2399 <<
" linkLeadersAhead=" << linkLeadersAhead.
toString()
2404 adaptToLeader(it->vehAndGap, seen, lastLink, lane, v, vLinkPass, it->distToCrossing);
2406 if (lastLink != 0) {
2429 #ifdef DEBUG_PLAN_MOVE_LEADERINFO 2432 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" ignoring leader " << leader->
getID() <<
"\n";
2438 vLinkWait =
MIN2(vLinkWait, v);
2444 const double seen,
const MSLane*
const lane,
double distToCrossing)
const {
2445 assert(leaderInfo.first != 0);
2447 double vsafeLeader = 0;
2449 vsafeLeader = -std::numeric_limits<double>::max();
2451 if (leaderInfo.second >= 0) {
2452 vsafeLeader = cfModel.
followSpeed(
this,
getSpeed(), leaderInfo.second, leaderInfo.first->getSpeed(), leaderInfo.first->getCarFollowModel().getApparentDecel(), leaderInfo.first);
2458 if (distToCrossing >= 0) {
2491 double vSafeZipper = std::numeric_limits<double>::max();
2494 bool canBrakeVSafeMin =
false;
2499 MSLink* link = (*i).myLink;
2501 #ifdef DEBUG_EXEC_MOVE 2505 <<
" veh=" <<
getID()
2507 <<
" req=" << (*i).mySetRequest
2508 <<
" vP=" << (*i).myVLinkPass
2509 <<
" vW=" << (*i).myVLinkWait
2510 <<
" d=" << (*i).myDistance
2517 if (link != 0 && (*i).mySetRequest) {
2524 const bool ignoreRedLink =
ignoreRed(link, canBrake);
2525 if (yellow && canBrake && !ignoreRedLink) {
2526 vSafe = (*i).myVLinkWait;
2528 #ifdef DEBUG_CHECKREWINDLINKLANES 2530 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (yellow)\n";
2537 std::vector<const SUMOVehicle*> collectFoes;
2538 bool opened = (yellow || influencerPrio
2539 || link->
opened((*i).myArrivalTime, (*i).myArrivalSpeed, (*i).getLeaveSpeed(),
2544 ignoreRedLink,
this));
2547 if (parallelLink != 0) {
2550 opened = yellow || influencerPrio || (opened & parallelLink->
opened((*i).myArrivalTime, (*i).myArrivalSpeed, (*i).getLeaveSpeed(),
2554 ignoreRedLink,
this));
2555 #ifdef DEBUG_EXEC_MOVE 2558 <<
" veh=" <<
getID()
2562 <<
" opened=" << opened
2571 double determinedFoePresence = i->myDistance <= visibilityDistance;
2572 if (!determinedFoePresence && (canBrake || !yellow)) {
2573 vSafe = (*i).myVLinkWait;
2575 #ifdef DEBUG_CHECKREWINDLINKLANES 2577 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (minor)\n";
2602 canBrakeVSafeMin = canBrake;
2607 vSafe = (*i).myVLinkPass;
2611 #ifdef DEBUG_CHECKREWINDLINKLANES 2613 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (very slow)\n";
2618 vSafeZipper =
MIN2(vSafeZipper,
2619 link->
getZipperSpeed(
this, (*i).myDistance, (*i).myVLinkPass, (*i).myArrivalTime, &collectFoes));
2621 vSafe = (*i).myVLinkWait;
2623 #ifdef DEBUG_CHECKREWINDLINKLANES 2625 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (closed)\n";
2631 #ifdef DEBUG_EXEC_MOVE 2640 vSafe = (*i).myVLinkWait;
2643 #ifdef DEBUG_CHECKREWINDLINKLANES 2645 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (no request, braking)\n";
2671 #ifdef DEBUG_EXEC_MOVE 2673 std::cout <<
"vSafeMin Problem? vSafe=" << vSafe <<
" vSafeMin=" << vSafeMin <<
" vSafeMinDist=" << vSafeMinDist << std::endl;
2676 if (canBrakeVSafeMin) {
2681 #ifdef DEBUG_CHECKREWINDLINKLANES 2683 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (vSafe=" << vSafe <<
" < vSafeMin=" << vSafeMin <<
")\n";
2701 vSafe =
MIN2(vSafe, vSafeZipper);
2710 std::cout <<
SIMTIME <<
" MSVehicle::processTraCISpeedControl() for vehicle '" <<
getID() <<
"'" 2711 <<
" vSafe=" << vSafe <<
" (init)vNext=" << vNext;
2720 vMin =
MAX2(0., vMin);
2725 std::cout <<
" (processed)vNext=" << vNext << std::endl;
2735 #ifdef DEBUG_ACTIONSTEPS 2737 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" removePassedDriveItems()\n" 2738 <<
" Current items: ";
2740 if (j.myLink == 0) {
2741 std::cout <<
"\n Stop at distance " << j.myDistance;
2743 const MSLane* to = j.myLink->getViaLaneOrLane();
2744 const MSLane* from = j.myLink->getLaneBefore();
2745 std::cout <<
"\n Link at distance " << j.myDistance <<
": '" 2746 << (from == 0 ?
"NONE" : from->
getID()) <<
"' -> '" << (to == 0 ?
"NONE" : to->
getID()) <<
"'";
2749 std::cout <<
"\n myNextDriveItem: ";
2750 if (myLFLinkLanes.size() != 0) {
2756 std::cout <<
"\n Link at distance " <<
myNextDriveItem->myDistance <<
": '" 2757 << (from == 0 ?
"NONE" : from->
getID()) <<
"' -> '" << (to == 0 ?
"NONE" : to->
getID()) <<
"'";
2760 std::cout << std::endl;
2764 #ifdef DEBUG_ACTIONSTEPS 2766 std::cout <<
" Removing item: ";
2767 if (j->myLink == 0) {
2768 std::cout <<
"Stop at distance " << j->myDistance;
2770 const MSLane* to = j->myLink->getViaLaneOrLane();
2771 const MSLane* from = j->myLink->getLaneBefore();
2772 std::cout <<
"Link at distance " << j->myDistance <<
": '" 2773 << (from == 0 ?
"NONE" : from->
getID()) <<
"' -> '" << (to == 0 ?
"NONE" : to->
getID()) <<
"'";
2775 std::cout << std::endl;
2778 if (j->myLink != 0) {
2779 j->myLink->removeApproaching(
this);
2789 #ifdef DEBUG_ACTIONSTEPS 2791 std::cout <<
SIMTIME <<
" updateDriveItems(), veh='" <<
getID() <<
"' (lane: '" <<
getLane()->
getID() <<
"')\nCurrent drive items:" << std::endl;
2792 DriveItemVector::iterator i;
2795 <<
" vPass=" << (*i).myVLinkPass
2796 <<
" vWait=" << (*i).myVLinkWait
2797 <<
" linkLane=" << ((*i).myLink == 0 ?
"NULL" : (*i).myLink->getViaLaneOrLane()->getID())
2798 <<
" request=" << (*i).mySetRequest
2801 std::cout <<
" myNextDriveItem's linked lane: " << (
myNextDriveItem->myLink == 0 ?
"NULL" :
myNextDriveItem->myLink->getViaLaneOrLane()->getID()) << std::endl;
2808 const MSLink* nextPlannedLink = 0;
2812 nextPlannedLink = i->myLink;
2816 if (nextPlannedLink == 0) {
2818 #ifdef DEBUG_ACTIONSTEPS 2820 std::cout <<
"Found no link-related drive item." << std::endl;
2828 #ifdef DEBUG_ACTIONSTEPS 2830 std::cout <<
"Continuing on planned lane sequence, no update required." << std::endl;
2852 #ifdef DEBUG_ACTIONSTEPS 2854 std::cout <<
"Changed lane. Drive items will be updated along the current lane continuation." << std::endl;
2868 if (driveItemIt->myLink == 0) {
2878 #ifdef DEBUG_ACTIONSTEPS 2880 std::cout <<
"Reached end of the new continuation sequence. Erasing leftover link-items." << std::endl;
2884 if (driveItemIt->myLink == 0) {
2897 if (newLink == driveItemIt->myLink) {
2899 #ifdef DEBUG_ACTIONSTEPS 2901 std::cout <<
"Old and new continuation sequences merge at link\n" 2903 <<
"\nNo update beyond merge required." << std::endl;
2909 #ifdef DEBUG_ACTIONSTEPS 2911 std::cout <<
"lane=" << lane->
getID() <<
"\nUpdating link\n '" << driveItemIt->myLink->getLaneBefore()->getID() <<
"'->'" << driveItemIt->myLink->getViaLaneOrLane()->getID() <<
"'" 2915 newLink->
setApproaching(
this, driveItemIt->myLink->getApproaching(
this));
2916 driveItemIt->myLink->removeApproaching(
this);
2917 driveItemIt->myLink = newLink;
2924 #ifdef DEBUG_ACTIONSTEPS 2926 std::cout <<
"Updated drive items:" << std::endl;
2927 DriveItemVector::iterator i;
2930 <<
" vPass=" << (*i).myVLinkPass
2931 <<
" vWait=" << (*i).myVLinkWait
2932 <<
" linkLane=" << ((*i).myLink == 0 ?
"NULL" : (*i).myLink->getViaLaneOrLane()->getID())
2933 <<
" request=" << (*i).mySetRequest
2950 brakelightsOn =
true;
2952 if (brakelightsOn) {
3007 if (!further->getEdge().isInternal()) {
3008 if (further->getEdge().getBidiEdge() != *(
myCurrEdge + view)
3024 passedLanes.push_back(*i);
3026 if (passedLanes.size() == 0 || passedLanes.back() !=
myLane) {
3027 passedLanes.push_back(
myLane);
3049 if (link !=
nullptr) {
3053 emergencyReason =
" because of a red traffic light";
3061 }
else if (reverseTrain) {
3062 approachedLane = (*(
myCurrEdge + 1))->getLanes()[0];
3072 emergencyReason =
" because there is no connection to the next edge";
3073 approachedLane =
nullptr;
3076 if (approachedLane !=
myLane && approachedLane !=
nullptr) {
3093 WRITE_WARNING(
"Vehicle '" +
getID() +
"' could not finish continuous lane change (turn lane) time=" +
3103 passedLanes.push_back(approachedLane);
3108 #ifdef DEBUG_ACTIONSTEPS 3110 std::cout <<
"Updated drive items:" << std::endl;
3113 <<
" vPass=" << (*i).myVLinkPass
3114 <<
" vWait=" << (*i).myVLinkWait
3115 <<
" linkLane=" << ((*i).myLink == 0 ?
"NULL" : (*i).myLink->getViaLaneOrLane()->getID())
3116 <<
" request=" << (*i).mySetRequest
3133 #ifdef DEBUG_EXEC_MOVE 3135 std::cout <<
"\nEXECUTE_MOVE\n" 3137 <<
" veh=" <<
getID()
3145 double vSafe = std::numeric_limits<double>::max();
3147 double vSafeMin = -std::numeric_limits<double>::max();
3150 double vSafeMinDist = 0;
3155 #ifdef DEBUG_ACTIONSTEPS 3157 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"'\n" 3158 " vsafe from processLinkApproaches(): vsafe " << vSafe << std::endl;
3164 #ifdef DEBUG_ACTIONSTEPS 3166 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' skips processLinkApproaches()\n" 3168 <<
"speed: " <<
getSpeed() <<
" -> " << vSafe << std::endl;
3182 double vNext = vSafe;
3186 vNext =
MAX2(vNext, vSafeMin);
3194 #ifdef DEBUG_EXEC_MOVE 3196 std::cout <<
SIMTIME <<
" finalizeSpeed vSafe=" << vSafe <<
" vSafeMin=" << (vSafeMin == -std::numeric_limits<double>::max() ?
"-Inf" :
toString(vSafeMin))
3197 <<
" vNext=" << vNext <<
" (i.e. accel=" <<
SPEED2ACCEL(vNext -
getSpeed()) <<
")" << std::endl;
3214 vNext =
MAX2(vNext, 0.);
3229 std::vector<MSLane*> passedLanes;
3233 std::string emergencyReason =
" for unknown reasons";
3242 +
"'" + emergencyReason
3258 passedLanes.clear();
3260 #ifdef DEBUG_ACTIONSTEPS 3262 std::cout <<
SIMTIME <<
" veh '" <<
getID() <<
"' updates further lanes." << std::endl;
3289 #ifdef DEBUG_ACTIONSTEPS 3291 std::cout <<
SIMTIME <<
" veh '" <<
getID() <<
"' skips LCM->prepareStep()." << std::endl;
3298 #ifdef DEBUG_EXEC_MOVE 3337 #ifdef DEBUG_EXEC_MOVE 3339 std::cout <<
SIMTIME <<
" updateState() for veh '" <<
getID() <<
"': deltaPos=" << deltaPos
3376 const std::vector<MSLane*>& passedLanes) {
3377 #ifdef DEBUG_FURTHER 3379 <<
" updateFurtherLanes oldFurther=" <<
toString(furtherLanes)
3380 <<
" oldFurtherPosLat=" <<
toString(furtherLanesPosLat)
3381 <<
" passed=" <<
toString(passedLanes)
3384 for (std::vector<MSLane*>::iterator i = furtherLanes.begin(); i != furtherLanes.end(); ++i) {
3385 (*i)->resetPartialOccupation(
this);
3388 std::vector<MSLane*> newFurther;
3389 std::vector<double> newFurtherPosLat;
3392 if (passedLanes.size() > 1) {
3394 std::vector<MSLane*>::const_iterator fi = furtherLanes.begin();
3395 std::vector<double>::const_iterator fpi = furtherLanesPosLat.begin();
3396 for (
auto pi = passedLanes.rbegin() + 1; pi != passedLanes.rend() && backPosOnPreviousLane < 0; ++pi) {
3398 newFurther.push_back(*pi);
3399 backPosOnPreviousLane += (*pi)->setPartialOccupation(
this);
3400 if (fi != furtherLanes.end() && *pi == *fi) {
3402 newFurtherPosLat.push_back(*fpi);
3410 if (newFurtherPosLat.size() == 0) {
3417 newFurtherPosLat.push_back(newFurtherPosLat.back());
3420 #ifdef DEBUG_FURTHER 3422 std::cout <<
SIMTIME <<
" updateFurtherLanes \n" 3423 <<
" further lane '" << (*pi)->getID() <<
"' backPosOnPreviousLane=" << backPosOnPreviousLane
3428 furtherLanes = newFurther;
3429 furtherLanesPosLat = newFurtherPosLat;
3431 furtherLanes.clear();
3432 furtherLanesPosLat.clear();
3434 #ifdef DEBUG_FURTHER 3436 <<
" newFurther=" <<
toString(furtherLanes)
3437 <<
" newFurtherPosLat=" <<
toString(furtherLanesPosLat)
3438 <<
" newBackPos=" << backPosOnPreviousLane
3441 return backPosOnPreviousLane;
3447 #ifdef DEBUG_FURTHER 3450 <<
" getBackPositionOnLane veh=" <<
getID()
3481 leftLength -= (*i)->getLength();
3492 leftLength -= (*i)->getLength();
3503 auto j = furtherTargetLanes.begin();
3504 while (leftLength > 0 && j != furtherTargetLanes.end()) {
3505 leftLength -= (*i)->getLength();
3537 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
3541 && (*i)->isFrontOnLane(l)) {
3542 foundStopped =
true;
3543 const double ret = (*i)->getPositionOnLane() - (*i)->getVehicleType().getLengthWithGap() - lengths;
3547 lengths += (*i)->getVehicleType().getLengthWithGap();
3557 bool hadVehicle =
false;
3558 double seenSpace = -lengthsInFront;
3559 #ifdef DEBUG_CHECKREWINDLINKLANES 3561 std::cout <<
"\nCHECK_REWIND_LINKLANES\n" <<
" veh=" <<
getID() <<
" lengthsInFront=" << lengthsInFront <<
"\n";
3564 bool foundStopped =
false;
3567 for (
int i = 0; i < (int)lfLinks.size(); ++i) {
3570 #ifdef DEBUG_CHECKREWINDLINKLANES 3573 <<
" foundStopped=" << foundStopped;
3575 if (item.
myLink == 0 || foundStopped) {
3576 if (!foundStopped) {
3582 #ifdef DEBUG_CHECKREWINDLINKLANES 3591 if (approachedLane != 0) {
3595 if (approachedLane ==
myLane) {
3604 #ifdef DEBUG_CHECKREWINDLINKLANES 3606 <<
" approached=" << approachedLane->
getID()
3609 <<
" seenSpace=" << seenSpace
3611 <<
" lengthsInFront=" << lengthsInFront
3618 if (last == 0 || last ==
this) {
3619 seenSpace += approachedLane->
getLength();
3621 #ifdef DEBUG_CHECKREWINDLINKLANES 3635 foundStopped =
true;
3637 #ifdef DEBUG_CHECKREWINDLINKLANES 3639 <<
" approached=" << approachedLane->
getID()
3640 <<
" lastPoc=" << last->
getID()
3642 <<
" seenSpace=" << seenSpace
3660 foundStopped =
true;
3663 #ifdef DEBUG_CHECKREWINDLINKLANES 3665 <<
" approached=" << approachedLane->
getID()
3666 <<
" last=" << last->
getID()
3674 <<
" seenSpace=" << seenSpace
3675 <<
" foundStopped=" << foundStopped
3683 for (
int i = ((
int)lfLinks.size() - 1); i > 0; --i) {
3685 const bool canLeaveJunction = item.
myLink->
getViaLane() == 0 || lfLinks[i].mySetRequest;
3691 bool allowsContinuation = item.
myLink == 0 || item.
myLink->
isCont() || !lfLinks[i].hadVehicle || opened;
3692 if (!opened && item.
myLink != 0) {
3696 allowsContinuation =
true;
3700 if (allowsContinuation) {
3706 int removalBegin = -1;
3707 for (
int i = 0; hadVehicle && i < (int)lfLinks.size() && removalBegin < 0; ++i) {
3721 #ifdef DEBUG_CHECKREWINDLINKLANES 3724 <<
" veh=" <<
getID()
3727 <<
" leftSpace=" << leftSpace
3730 if (leftSpace < 0/* && item.myLink->willHaveBlockedFoe()*/) {
3731 double impatienceCorrection = 0;
3738 if (leftSpace < -impatienceCorrection / 10. &&
keepClear(item.
myLink)) {
3746 while (removalBegin < (
int)(lfLinks.size())) {
3748 lfLinks[removalBegin].myVLinkPass = lfLinks[removalBegin].myVLinkWait;
3750 lfLinks[removalBegin].mySetRequest =
false;
3761 for (DriveItemVector::iterator i = lfLinks.begin(); i != lfLinks.end(); ++i) {
3762 if ((*i).myLink != 0) {
3766 (*i).myLink->setApproaching(
this, (*i).myArrivalTime, (*i).myArrivalSpeed, (*i).getLeaveSpeed(),
3767 (*i).mySetRequest, (*i).myArrivalTimeBraking, (*i).myArrivalSpeedBraking,
getWaitingTime(), (*i).myDistance);
3772 for (DriveItemVector::iterator i = lfLinks.begin(); i != lfLinks.end(); ++i) {
3773 if ((*i).myLink != 0) {
3775 if (parallelLink != 0) {
3776 parallelLink->
setApproaching(
this, (*i).myArrivalTime, (*i).myArrivalSpeed, (*i).getLeaveSpeed(),
3777 (*i).mySetRequest, (*i).myArrivalTimeBraking, (*i).myArrivalSpeedBraking,
getWaitingTime(), (*i).myDistance);
3789 if (rem->first->getLane() != 0 && rem->second > 0.) {
3791 if (myTraceMoveReminders) {
3792 traceMoveReminder(
"notifyEnter_skipped", rem->first, rem->second,
true);
3797 if (rem->first->notifyEnter(*
this, reason, enteredLane)) {
3799 if (myTraceMoveReminders) {
3800 traceMoveReminder(
"notifyEnter", rem->first, rem->second,
true);
3806 if (myTraceMoveReminders) {
3807 traceMoveReminder(
"notifyEnter", rem->first, rem->second,
false);
3840 if (!onTeleporting) {
3844 assert(oldLane != 0);
3887 #ifdef DEBUG_FURTHER 3889 std::cout <<
SIMTIME <<
" enterLaneAtLaneChange \n";
3895 #ifdef DEBUG_FURTHER 3897 std::cout <<
SIMTIME <<
" enterLaneAtLaneChange \n";
3900 leftLength -= (lane)->setPartialOccupation(
this);
3908 #ifdef DEBUG_FURTHER 3940 MSLane* clane = enteredLane;
3941 while (leftLength > 0) {
3943 if (clane == 0 || clane ==
myLane) {
3948 leftLength -= (clane)->setPartialOccupation(
this);
3954 #ifdef DEBUG_FURTHER 3956 std::cout <<
SIMTIME <<
" enterLaneAtInsertion \n";
3959 (*i)->resetPartialOccupation(
this);
3980 if (rem->first->notifyLeave(*
this,
myState.
myPos + rem->second, reason, approachedLane)) {
3982 if (myTraceMoveReminders) {
3983 traceMoveReminder(
"notifyLeave", rem->first, rem->second,
true);
3989 if (myTraceMoveReminders) {
3990 traceMoveReminder(
"notifyLeave", rem->first, rem->second,
false);
4000 #ifdef DEBUG_FURTHER 4002 std::cout <<
SIMTIME <<
" leaveLane \n";
4005 (*i)->resetPartialOccupation(
this);
4039 const std::vector<MSVehicle::LaneQ>&
4047 #ifdef DEBUG_BESTLANES 4052 if (startLane == 0) {
4055 assert(startLane != 0);
4060 bool startLaneIsOpposite = (startLane->
isInternal()
4063 if (startLaneIsOpposite) {
4065 assert(startLane != 0);
4085 std::vector<LaneQ>& lanes = *it;
4086 assert(lanes.size() > 0);
4087 if (&(lanes[0].lane->getEdge()) == nextEdge) {
4089 std::vector<LaneQ> oldLanes = lanes;
4091 const std::vector<MSLane*>& sourceLanes = startLane->
getEdge().
getLanes();
4092 for (std::vector<MSLane*>::const_iterator it_source = sourceLanes.begin(); it_source != sourceLanes.end(); ++it_source) {
4093 for (std::vector<LaneQ>::iterator it_lane = oldLanes.begin(); it_lane != oldLanes.end(); ++it_lane) {
4094 if ((*it_source)->getLinkCont()[0]->getLane() == (*it_lane).lane) {
4095 lanes.push_back(*it_lane);
4102 for (
int i = 0; i < (int)lanes.size(); ++i) {
4103 if (i + lanes[i].bestLaneOffset < 0) {
4104 lanes[i].bestLaneOffset = -i;
4106 if (i + lanes[i].bestLaneOffset >= (
int)lanes.size()) {
4107 lanes[i].bestLaneOffset = (int)lanes.size() - i - 1;
4109 assert(i + lanes[i].bestLaneOffset >= 0);
4110 assert(i + lanes[i].bestLaneOffset < (
int)lanes.size());
4111 if (lanes[i].bestContinuations[0] != 0) {
4113 lanes[i].bestContinuations.insert(lanes[i].bestContinuations.begin(), (
MSLane*)0);
4115 if (startLane->
getLinkCont()[0]->getLane() == lanes[i].lane) {
4118 assert(&(lanes[i].lane->getEdge()) == nextEdge);
4131 myLastBestLanesEdge = &startLane->
getEdge();
4136 const MSLane* nextStopLane = 0;
4137 double nextStopPos = 0;
4140 nextStopLane = nextStop.
lane;
4141 nextStopEdge = nextStop.
edge;
4154 nextStopPos += (*nextStopEdge)->getLength();
4160 double seenLength = 0;
4161 bool progress =
true;
4163 std::vector<LaneQ> currentLanes;
4164 const std::vector<MSLane*>* allowed = 0;
4165 const MSEdge* nextEdge = 0;
4167 nextEdge = *(ce + 1);
4170 const std::vector<MSLane*>& lanes = (*ce)->getLanes();
4171 for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
4179 q.
allowsContinuation = allowed == 0 || find(allowed->begin(), allowed->end(), cl) != allowed->end();
4182 currentLanes.push_back(q);
4185 if (nextStopEdge == ce && !nextStopLane->
isInternal()) {
4187 for (std::vector<LaneQ>::iterator q = currentLanes.begin(); q != currentLanes.end(); ++q) {
4188 if (nextStopLane != 0 && nextStopLane != (*q).lane) {
4189 (*q).allowsContinuation =
false;
4190 (*q).length = nextStopPos;
4191 (*q).currentLength = (*q).length;
4198 seenLength += currentLanes[0].lane->getLength();
4200 progress &= (seen <= 4 || seenLength < 3000);
4201 progress &= (seen <= 8 || seenLength < 200);
4212 double bestLength = -1;
4213 int bestThisIndex = 0;
4216 for (std::vector<LaneQ>::iterator j = last.begin(); j != last.end(); ++j, ++index) {
4217 if ((*j).length > bestLength) {
4218 bestLength = (*j).length;
4219 bestThisIndex = index;
4223 for (std::vector<LaneQ>::iterator j = last.begin(); j != last.end(); ++j, ++index) {
4224 if ((*j).length < bestLength) {
4225 (*j).bestLaneOffset = bestThisIndex - index;
4229 #ifdef DEBUG_BESTLANES 4231 std::cout <<
" last edge:\n";
4233 for (std::vector<LaneQ>::iterator j = laneQs.begin(); j != laneQs.end(); ++j) {
4234 std::cout <<
" lane=" << (*j).lane->getID() <<
" length=" << (*j).length <<
" bestOffset=" << (*j).bestLaneOffset <<
"\n";
4240 for (std::vector<std::vector<LaneQ> >::reverse_iterator i =
myBestLanes.rbegin() + 1; i !=
myBestLanes.rend(); ++i) {
4241 std::vector<LaneQ>& nextLanes = (*(i - 1));
4242 std::vector<LaneQ>& clanes = (*i);
4243 MSEdge& cE = clanes[0].lane->getEdge();
4245 double bestConnectedLength = -1;
4246 double bestLength = -1;
4247 for (std::vector<LaneQ>::iterator j = nextLanes.begin(); j != nextLanes.end(); ++j, ++index) {
4248 if ((*j).lane->isApproachedFrom(&cE) && bestConnectedLength < (*j).length) {
4249 bestConnectedLength = (*j).length;
4251 if (bestLength < (*j).length) {
4252 bestLength = (*j).length;
4256 int bestThisIndex = 0;
4257 if (bestConnectedLength > 0) {
4259 for (std::vector<LaneQ>::iterator j = clanes.begin(); j != clanes.end(); ++j, ++index) {
4260 LaneQ bestConnectedNext;
4261 bestConnectedNext.
length = -1;
4262 if ((*j).allowsContinuation) {
4263 for (std::vector<LaneQ>::const_iterator m = nextLanes.begin(); m != nextLanes.end(); ++m) {
4264 if ((*m).lane->isApproachedFrom(&cE, (*j).lane)) {
4265 if (bestConnectedNext.
length < (*m).length || (bestConnectedNext.
length == (*m).length && abs(bestConnectedNext.
bestLaneOffset) > abs((*m).bestLaneOffset))) {
4266 bestConnectedNext = *m;
4270 if (bestConnectedNext.
length == bestConnectedLength && abs(bestConnectedNext.
bestLaneOffset) < 2) {
4271 (*j).
length += bestLength;
4273 (*j).length += bestConnectedNext.
length;
4278 if (clanes[bestThisIndex].length < (*j).length
4279 || (clanes[bestThisIndex].length == (*j).length && abs(clanes[bestThisIndex].bestLaneOffset) > abs((*j).bestLaneOffset))
4280 || (clanes[bestThisIndex].length == (*j).length && abs(clanes[bestThisIndex].bestLaneOffset) == abs((*j).bestLaneOffset) &&
4283 bestThisIndex = index;
4286 #ifdef DEBUG_BESTLANES 4288 std::cout <<
" edge=" << cE.
getID() <<
"\n";
4289 std::vector<LaneQ>& laneQs = clanes;
4290 for (std::vector<LaneQ>::iterator j = laneQs.begin(); j != laneQs.end(); ++j) {
4291 std::cout <<
" lane=" << (*j).lane->getID() <<
" length=" << (*j).length <<
" bestOffset=" << (*j).bestLaneOffset <<
"\n";
4298 int bestNextIndex = 0;
4299 int bestDistToNeeded = (int) clanes.size();
4301 for (std::vector<LaneQ>::iterator j = clanes.begin(); j != clanes.end(); ++j, ++index) {
4302 if ((*j).allowsContinuation) {
4304 for (std::vector<LaneQ>::const_iterator m = nextLanes.begin(); m != nextLanes.end(); ++m, ++nextIndex) {
4305 if ((*m).lane->isApproachedFrom(&cE, (*j).lane)) {
4306 if (bestDistToNeeded > abs((*m).bestLaneOffset)) {
4307 bestDistToNeeded = abs((*m).bestLaneOffset);
4308 bestThisIndex = index;
4309 bestNextIndex = nextIndex;
4315 clanes[bestThisIndex].length += nextLanes[bestNextIndex].length;
4316 copy(nextLanes[bestNextIndex].bestContinuations.begin(), nextLanes[bestNextIndex].bestContinuations.end(), back_inserter(clanes[bestThisIndex].bestContinuations));
4321 for (std::vector<LaneQ>::iterator j = clanes.begin(); j != clanes.end(); ++j, ++index) {
4322 if ((*j).length < clanes[bestThisIndex].length
4323 || ((*j).length == clanes[bestThisIndex].length && abs((*j).bestLaneOffset) > abs(clanes[bestThisIndex].bestLaneOffset))
4326 (*j).bestLaneOffset = bestThisIndex - index;
4329 (*j).length = (*j).currentLength;
4332 (*j).bestLaneOffset = 0;
4337 #ifdef DEBUG_BESTLANES 4348 if (conts.size() < 2) {
4364 std::vector<LaneQ>& currLanes = *
myBestLanes.begin();
4365 std::vector<LaneQ>::iterator i;
4366 for (i = currLanes.begin(); i != currLanes.end(); ++i) {
4367 double nextOccupation = 0;
4368 for (std::vector<MSLane*>::const_iterator j = (*i).bestContinuations.begin() + 1; j != (*i).bestContinuations.end(); ++j) {
4369 nextOccupation += (*j)->getBruttoVehLenSum();
4371 (*i).nextOccupation = nextOccupation;
4372 if ((*i).lane == startLane) {
4379 const std::vector<MSLane*>&
4384 return (*myCurrentLaneInBestLanes).bestContinuations;
4388 const std::vector<MSLane*>&
4400 if ((*i).lane == lane) {
4401 return (*i).bestContinuations;
4413 return (*myCurrentLaneInBestLanes).bestLaneOffset;
4420 std::vector<MSVehicle::LaneQ>& preb =
myBestLanes.front();
4421 assert(laneIndex < (
int)preb.size());
4422 preb[laneIndex].occupation = density + preb[laneIndex].nextOccupation;
4436 double distance = std::numeric_limits<double>::max();
4437 if (
isOnRoad() && destEdge != NULL) {
4451 std::pair<const MSVehicle* const, double>
4454 return std::make_pair(static_cast<const MSVehicle*>(0), -1);
4463 MSLane::VehCont::const_iterator it = std::find(vehs.begin(), vehs.end(),
this);
4464 if (it != vehs.end() && it + 1 != vehs.end()) {
4468 std::pair<const MSVehicle* const, double> result(
4484 std::pair<const MSVehicle* const, double> leaderInfo =
getLeader(-1);
4485 if (leaderInfo.first == 0 ||
getSpeed() == 0) {
4544 myStops.front().numExpectedPerson -= (int)
myStops.front().pars.awaitedPersons.count(person->
getID());
4545 if (
myStops.front().numExpectedPerson == 0) {
4554 if (
myStops.size() > 0 &&
myStops.front().reached &&
myStops.front().pars.containerTriggered &&
myStops.front().numExpectedContainer > 0) {
4555 myStops.front().numExpectedContainer -= (int)
myStops.front().pars.awaitedContainers.count(container->
getID());
4556 if (
myStops.front().numExpectedContainer == 0) {
4568 const bool blinkerManoeuvre = (((state &
LCA_SUBLANE) == 0) && (
4574 std::swap(left, right);
4576 if ((state &
LCA_LEFT) != 0 && blinkerManoeuvre) {
4578 }
else if ((state &
LCA_RIGHT) != 0 && blinkerManoeuvre) {
4590 switch ((*link)->getDirection()) {
4615 if (currentTime % 1000 == 0) {
4662 #ifdef DEBUG_FURTHER 4672 for (
int i = 0; i < (int)shadowFurther.size(); ++i) {
4674 if (shadowFurther[i] == lane) {
4695 #ifdef DEBUG_FURTHER 4703 #ifdef DEBUG_FURTHER 4710 for (
int i = 0; i < (int)shadowFurther.size(); ++i) {
4711 if (shadowFurther[i] == lane) {
4712 #ifdef DEBUG_FURTHER 4715 <<
" lane=" << lane->
getID()
4730 MSLane* targetLane = furtherTargets[i];
4731 if (targetLane == lane) {
4734 #ifdef DEBUG_TARGET_LANE 4736 std::cout <<
" getLatOffset veh=" <<
getID()
4742 <<
" targetDir=" << targetDir
4743 <<
" latOffset=" << latOffset
4760 assert(offset == 0 || offset == 1 || offset == -1);
4761 assert(
myLane !=
nullptr);
4766 double leftLimit = halfCurrentLaneWidth - halfVehWidth - latPos;
4767 double rightLimit = -halfCurrentLaneWidth + halfVehWidth - latPos;
4768 double latLaneDist = 0;
4770 if (latPos + halfVehWidth > halfCurrentLaneWidth) {
4772 latLaneDist = halfCurrentLaneWidth - latPos - halfVehWidth;
4773 }
else if (latPos - halfVehWidth < - halfCurrentLaneWidth) {
4775 latLaneDist = halfCurrentLaneWidth - latPos + halfVehWidth;
4777 }
else if (offset == -1) {
4779 }
else if (offset == 1) {
4782 #ifdef DEBUG_ACTIONSTEPS 4785 <<
" veh=" <<
getID()
4786 <<
" halfCurrentLaneWidth=" << halfCurrentLaneWidth
4787 <<
" halfVehWidth=" << halfVehWidth
4788 <<
" latPos=" << latPos
4789 <<
" latLaneDist=" << latLaneDist
4790 <<
" leftLimit=" << leftLimit
4791 <<
" rightLimit=" << rightLimit
4813 for (DriveItemVector::iterator i = lfLinks.begin(); i != lfLinks.end(); ++i) {
4814 if ((*i).myLink != 0) {
4815 (*i).myLink->removeApproaching(
this);
4835 while (!lane->
isLinkEnd(link) && seen <= dist) {
4838 || !(*link)->havePriority())) {
4842 if ((*di).myLink != 0) {
4843 const MSLane* diPredLane = (*di).myLink->getLaneBefore();
4844 if (diPredLane != 0) {
4855 const SUMOTime leaveTime = (*link)->getLeaveTime((*di).myArrivalTime, (*di).myArrivalSpeed,
4857 if ((*link)->hasApproachingFoe((*di).myArrivalTime, leaveTime, (*di).myArrivalSpeed,
getCarFollowModel().getMaxDecel())) {
4864 lane = (*link)->getViaLaneOrLane();
4907 result.push_back(line1[0]);
4908 result.push_back(line2[0]);
4909 result.push_back(line2[1]);
4910 result.push_back(line1[1]);
4913 result.push_back(line1[1]);
4914 result.push_back(line2[1]);
4915 result.push_back(line2[0]);
4916 result.push_back(line1[0]);
4928 if (&(*i)->getEdge() == edge) {
4945 if (destParkArea ==
nullptr) {
4947 errorMsg =
"Vehicle " +
getID() +
" is not driving to a parking area so it cannot be rerouted.";
4960 if (newParkingArea == 0) {
4961 errorMsg =
"Parking area ID " +
toString(parkingAreaID) +
" not found in the network.";
4974 if (!newDestination) {
4985 if (edgesFromPark.size() > 0) {
4986 edges.insert(edges.end(), edgesFromPark.begin() + 1, edgesFromPark.end());
4989 if (newDestination) {
5009 const bool parking,
const bool triggered,
const bool containerTriggered, std::string& errorMsg) {
5011 for (std::list<Stop>::iterator iter =
myStops.begin(); iter !=
myStops.end(); iter++) {
5012 if (iter->lane == lane && fabs(iter->pars.endPos - endPos) <
POSITION_EPS) {
5013 if (duration == 0 && !iter->reached) {
5018 iter->duration = duration;
5028 newStop.
until = until;
5037 if (containerTriggered) {
5043 const bool result =
addStop(newStop, errorMsg);
5057 const bool triggered,
const bool containerTriggered,
const SumoXMLTag stoppingPlaceType, std::string& errorMsg) {
5059 for (std::list<Stop>::iterator iter =
myStops.begin(); iter !=
myStops.end(); iter++) {
5061 switch (stoppingPlaceType) {
5063 stop = iter->busstop;
5066 stop = iter->containerstop;
5069 stop = iter->chargingStation;
5072 stop = iter->parkingarea;
5077 if (stop != 0 && stop->
getID() == stopId) {
5078 if (duration == 0 && !iter->reached) {
5081 iter->duration = duration;
5088 switch (stoppingPlaceType) {
5106 errorMsg =
"The " +
toString(stoppingPlaceType) +
" '" + stopId +
"' is not known for vehicle '" +
getID() +
"'";
5110 newStop.
until = until;
5121 if (containerTriggered) {
5127 const bool result =
addStop(newStop, errorMsg);
5147 if (
myStops.front().busstop != 0) {
5149 myStops.front().busstop->leaveFrom(
this);
5152 if (
myStops.front().containerstop != 0) {
5154 myStops.front().containerstop->leaveFrom(
this);
5156 if (
myStops.front().parkingarea != 0) {
5158 myStops.front().parkingarea->leaveFrom(
this);
5163 if (vehroutes != 0) {
5191 std::list<MSVehicle::Stop>
5269 #ifdef DEBUG_IGNORE_RED 5274 if (ignoreRedTime < 0) {
5282 #ifdef DEBUG_IGNORE_RED 5286 <<
" ignoreRedTime=" << ignoreRedTime
5287 <<
" spentRed=" << redDuration
5288 <<
" canBrake=" << canBrake <<
"\n";
5292 return !canBrake || ignoreRedTime > redDuration;
5320 std::vector<std::string> internals;
5331 for (std::list<Stop>::const_iterator it =
myStops.begin(); it !=
myStops.end(); ++it) {
5335 for (std::vector<MSDevice*>::const_iterator dev =
myDevices.begin(); dev !=
myDevices.end(); ++dev) {
5336 (*dev)->saveState(out);
5344 throw ProcessError(
"Error: Invalid vehicles in state (may be a meso state)!");
5355 myDeparture -= offset;
5366 myDriverState = std::make_shared<MSSimpleDriverState>(
this);
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
double myPos
the stored position
int getRoutePosition() const
bool gDebugFlag1
global utility flags for debugging
bool getRespectJunctionPriority() const
Returns whether junction priority rules shall be respected.
void adaptToLeader(const std::pair< const MSVehicle *, double > leaderInfo, const double seen, DriveProcessItem *const lastLink, const MSLane *const lane, double &v, double &vLinkPass, double distToCrossing=-1) const
double myLatDist
The requested lateral change.
A lane area vehicles can halt at.
void adaptToLeaders(const MSLeaderInfo &ahead, double latOffset, const double seen, DriveProcessItem *const lastLink, const MSLane *const lane, double &v, double &vLinkPass) const
const int STOP_CONTAINER_TRIGGER_SET
const std::vector< MSTransportable * > & getTransportables() const
Returns the list of transportables using this vehicle.
const MSLane * myLastBestLanesInternalLane
The link is a partial left direction.
bool isChangingLanes() const
return true if the vehicle currently performs a lane change maneuver
Drive process items represent bounds on the safe velocity corresponding to the upcoming links...
double getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
double computeAngle() const
compute the current vehicle angle
static double gLateralResolution
double getFuelConsumption() const
Returns fuel consumption of the current state.
const std::vector< double > & getShadowFurtherLanesPosLat() const
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
int getContainerNumber() const
Returns the number of containers.
double getAccumulatedWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s) within the last millisecs...
double getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
SumoXMLTag
Numbers representing SUMO-XML - element names.
SUMOVehicleShape getGuiShape() const
Get this vehicle type's shape.
double brakeGap(const double speed) const
Returns the distance the vehicle needs to halt including driver's reaction time tau (i...
void addWaiting(const MSEdge *const edge, SUMOVehicle *vehicle)
Adds a vehicle to the list of waiting vehiclse to a given edge.
double getNOxEmissions() const
Returns NOx emission of the current state.
bool enterLaneAtMove(MSLane *enteredLane, bool onTeleporting=false)
Update when the vehicle enters a new lane in the move step.
bool ignoreRed(const MSLink *link, bool canBrake) const
decide whether a red (or yellow light) may be ignore
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT() const
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 getLength() const
Returns the vehicle's length.
MSEdge & getEdge() const
Returns the lane's edge.
double myAngle
the angle in radians (
Representation of a vehicle in the micro simulation.
SUMOTime getDeparture() const
Returns this vehicle's real departure time.
double getJMParam(const SumoXMLAttr attr, const double defaultValue) const
Returns the named value from the map, or the default if it is not contained there.
double getBeginLanePosition() const
Returns the begin position of this stop.
bool isRemoteControlled() const
Returns the information whether the vehicle is fully controlled via TraCI.
bool hasPersons() const
Returns whether persons are simulated.
double getElectricityConsumption() const
Returns electricity consumption of the current state.
double getPreviousSpeed() const
Returns the vehicle's speed before the previous time step.
virtual int addLeader(const MSVehicle *veh, bool beyond, double latOffset=0)
double backPos() const
back Position of this state
bool keepClear() const
whether the junction after this link must be kept clear
void remove(MSVehicle *veh)
Remove a vehicle from this transfer object.
void informVehicleStateListener(const SUMOVehicle *const vehicle, VehicleState to, const std::string &info="")
Informs all added listeners about a vehicle's state change.
MSEdgeWeightsStorage * myEdgeWeights
MoveReminderCont myMoveReminders
Currently relevant move reminders.
The action is due to the default of keeping right "Rechtsfahrgebot".
PositionVector getBoundingPoly() const
get bounding polygon
const ConstMSEdgeVector & getEdges() const
The action is done to help someone else.
void replaceParameter(const SUMOVehicleParameter *newParameter)
replace the vehicle parameter (deleting the old one)
static int nextLinkPriority(const std::vector< MSLane *> &conts)
get a numerical value for the priority of the upcoming link
SUMOTime getWaitingTime() const
Returns the SUMOTime waited (speed was lesser than 0.1m/s)
const MSEdge * getNextNormal() const
Returns the lane's follower if it is an internal lane, the edge of the lane otherwise.
const MSEdge * myLastBestLanesEdge
std::string containerstop
(Optional) container stop if one is assigned to the stop
LaneChangeMode
modes for resolving conflicts between external control (traci) and vehicle control over lane changing...
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.
MSAbstractLaneChangeModel * myLaneChangeModel
void append(const PositionVector &v, double sameThreshold=2.0)
bool myAmOnNet
Whether the vehicle is on the network (not parking, teleported, vaporized, or arrived) ...
LaneChangeMode myRightDriveLC
changing to the rightmost lane
LinkDirection getDirection() const
Returns the direction the vehicle passing this link take.
virtual bool hasPedestrians(const MSLane *lane)
whether the given lane has pedestrians on it
std::pair< MSVehicle *const, double > getOppositeLeader(const MSVehicle *ego, double dist, bool oppositeDir) const
std::vector< std::vector< LaneQ > > myBestLanes
bool parking
whether the vehicle is removed from the net while stopping
MSLane * getLane() const
Returns the connected lane.
std::vector< MSLane * > myFurtherLanes
The information into which lanes the vehicle laps into.
State myState
This Vehicles driving state (pos and speed)
bool hasDeparted() const
Returns whether this vehicle has already departed.
double myOriginalSpeed
The velocity before influence.
void release() const
deletes the route if there are no further references to it
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
A lane area vehicles can halt at.
bool replaceParkingArea(MSParkingArea *parkingArea, std::string &errorMsg)
replace the current parking area stop with a new stop with merge duration
void enter(SUMOVehicle *what, double beg, double end)
Called if a vehicle enters this stop.
DriveItemVector myLFLinkLanes
bool resumeFromStopping()
bool myAmRegisteredAsWaitingForPerson
Whether this vehicle is registered as waiting for a person (for deadlock-recognition) ...
MSLane * getLane() const
Returns the lane the vehicle is on.
SUMOTime duration
The stopping duration.
ArrivalLaneDefinition arrivalLaneProcedure
Information how the vehicle shall choose the lane to arrive on.
bool warnOnce(const std::string &typeAndID)
return whether a warning regarding the given object shall be issued
int bestLaneOffset
The (signed) number of lanes to be crossed to get to the lane which allows to continue the drive...
virtual double minNextSpeed(double speed, const MSVehicle *const veh=0) const
Returns the minimum speed given the current speed (depends on the numerical update scheme and its ste...
double myTimeLoss
the time loss in seconds due to driving with less than maximum speed
void setBlinkerInformation()
sets the blue flashing light for emergency vehicles
SUMOTime myLastActionTime
Action offset (actions are taken at time myActionOffset + N*getActionStepLength()) Initialized to 0...
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
void addContainer(MSTransportable *container)
Adds a container.
SUMOTime getMemorySize() const
The vehicle arrived at a junction.
SUMOTime remainingStopDuration() const
Returns the remaining stop duration for a stopped vehicle or 0.
int getShadowDirection() const
return the direction in which the current shadow lane lies
double getManeuverDist() const
Returns the remaining unblocked distance for the current maneuver. (only used by sublane model) ...
std::pair< const MSVehicle *const, double > getLeader(double dist=0) const
Returns the leader of the vehicle looking for a fixed distance.
const SUMOVehicleParameter::Stop pars
The stop parameter.
int myRoutingMode
routing mode (see TraCIConstants.h)
SUMOTime duration
The stopping duration.
Signalling
Some boolean values which describe the state of some vehicle parts.
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
void updateTimeLoss(double vNext)
Updates the vehicle's time loss.
SUMOTime getLastStateChange() const
std::string getDescription() const
get a short description for showing in the gui
bool onFurtherEdge(const MSEdge *edge) const
whether this vehicle has its back (and no its front) on the given edge
std::list< Stop > getMyStops()
void enter(SUMOVehicle *what, double beg, double end)
Called if a vehicle enters this stop.
const double SUMO_const_laneWidth
void planMove(const SUMOTime t, const MSLeaderInfo &ahead, const double lengthsInFront)
Compute safe velocities for the upcoming lanes based on positions and speeds from the last time step...
const MSLane * getLaneBefore() const
return the internalLaneBefore if it exists and the laneBefore otherwise
The car-following model abstraction.
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
MSParkingArea * parkingarea
(Optional) parkingArea if one is assigned to the stop
MSStoppingPlace * busstop
(Optional) bus stop if one is assigned to the stop
double getPositionOnLane() const
Get the vehicle's position along the lane.
bool triggered
whether an arriving person lets the vehicle continue
bool myConsiderMaxAcceleration
Whether the maximum acceleration shall be regarded.
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
double myPosLat
the stored lateral position
int getBestLaneOffset() const
double myArrivalPos
The position on the destination lane where the vehicle stops.
The link is a 180 degree turn.
bool canReverse() const
whether the vehicle is a train that can reverse its direction at the current point in its route ...
virtual void clear()
discard all information
bool reached
Information whether the stop has been reached.
Notification
Definition of a vehicle state.
double getLastFreePos(const SUMOVehicle &forVehicle) const
Returns the last free position on this stop.
double getDistanceBetween(double fromPos, double toPos, const MSEdge *fromEdge, const MSEdge *toEdge, bool includeInternal=true) const
Compute the distance between 2 given edges on this route, including the length of internal lanes...
std::string time2string(SUMOTime t)
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
#define STOPPING_PLACE_OFFSET
Changes the wished vehicle speed / lanes.
virtual bool compute(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E *> &into)=0
Builds the route between the given edges using the minimum effort at the given time The definition of...
double lateralDistanceToLane(const int offset) const
Get the minimal lateral distance required to move fully onto the lane at given offset.
const std::vector< MSLane * > * allowedLanes(const MSEdge &destination, SUMOVehicleClass vclass=SVC_IGNORING) const
Get the allowed lanes to reach the destination-edge.
bool addTraciStopAtStoppingPlace(const std::string &stopId, const SUMOTime duration, const SUMOTime until, const bool parking, const bool triggered, const bool containerTriggered, const SumoXMLTag stoppingPlaceType, std::string &errorMsg)
bool myRespectJunctionPriority
Whether the junction priority rules are respected.
double getZipperSpeed(const MSVehicle *ego, const double dist, double vSafe, SUMOTime arrivalTime, std::vector< const SUMOVehicle *> *collectFoes) const
return the speed at which ego vehicle must approach the zipper link
double getLeaveSpeed() const
virtual VehicleVariables * createVehicleVariables() const
Returns model specific values which are stored inside a vehicle and must be used with casting...
void registerEmergencyStop()
register emergency stop
static const double ZIPPER_ADAPT_DIST
virtual double maxNextSpeed(double speed, const MSVehicle *const veh) const
Returns the maximum speed given the current speed.
bool isRoundabout() const
State & operator=(const State &state)
Assignment operator.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position ...
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
vehicle doesn't want to change
void createDriverState()
Create a DriverState for the vehicle.
TraciLaneChangePriority
modes for prioritizing traci lane change requests
void planMoveInternal(const SUMOTime t, MSLeaderInfo ahead, DriveItemVector &lfLinks, double &myStopDist, std::pair< double, LinkDirection > &myNextTurn) const
double getLength() const
Returns the lane's length.
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
const PositionVector & getShape() const
Returns this lane's shape.
const MSRoute * myRoute
This vehicle's route.
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
PositionVector getBoundingBox() const
get bounding rectangle
bool isLinkEnd(MSLinkCont::const_iterator &i) const
const MSRoute & getRoute() const
Returns the current route.
bool isStoppedOnLane() const
MSLink * getLinkTo(const MSLane *) const
returns the link to the given lane or 0, if it is not connected
The vehicle got vaporized.
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
PositionVector reverse() const
reverse position vector
double rotationAtOffset(double pos) const
Returns the rotation at the given length.
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.
bool checkActionStep(const SUMOTime t)
Returns whether the vehicle is supposed to take action in the current simulation step Updates myActio...
double getRightSideOnLane() const
Get the vehicle's lateral position on the lane:
void adaptBestLanesOccupation(int laneIndex, double density)
update occupation from MSLaneChanger
WaitingTimeCollector myWaitingTimeCollector
const MSEdge * getLastEdge() const
returns the destination edge
This is an uncontrolled, right-before-left link.
bool hasFoes() const
Returns whether this link belongs to a junction where more than one edge is incoming.
render as a sedan passenger vehicle ("Stufenheck")
bool executeMove()
Executes planned vehicle movements with regards to right-of-way.
double getSafeFollowSpeed(const std::pair< const MSVehicle *, double > leaderInfo, const double seen, const MSLane *const lane, double distToCrossing) const
compute safe speed for following the given leader
std::vector< const MSEdge * > ConstMSEdgeVector
std::set< std::string > awaitedPersons
IDs of persons the vehicle has to wait for until departing.
static double computeNoise(SUMOEmissionClass c, double v, double a)
Returns the noise produced by the a vehicle of the given type at the given speed. ...
SUMOTime myMemorySize
the maximal memory to store
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle's end speed shall be chosen.
int getLaneChangeMode() const
return the current lane change mode
int myArrivalLane
The destination lane where the vehicle stops.
const SUMOVehicleParameter * myParameter
This vehicle's parameter.
const std::string & getID() const
Returns the id.
The arrival position is given.
bool isRailway(SVCPermissions permissions)
Returns whether an edge with the given permission is a railway edge.
const std::vector< MSMoveReminder *> & getMoveReminders() const
Return the list of this lane's move reminders.
The base class for microscopic and mesoscopic vehicles.
bool myHaveToWaitOnNextLink
A storage for edge travel times and efforts.
int getSpeedMode() const
return the current speed mode
SUMOTime timeToBoardNextPerson
The time at which the vehicle is able to board another person.
double getLength() const
return the length of the edge
double nextOccupation
As occupation, but without the first lane.
double length
The overall length which may be driven when using this lane without a lane change.
bool rerouteParkingArea(const std::string &parkingAreaID, std::string &errorMsg)
This is an uncontrolled, all-way stop link.
The action is due to the wish to be faster (tactical lc)
bool wasRemoteControlled(SUMOTime lookBack=DELTA_T) const
Returns the information whether the vehicle is fully controlled via TraCI within the lookBack time...
double getLateralShift()
return lateral shift that must be applied when passing this link
double getWidth() const
Returns the lane's width.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
bool hasArrived() const
Returns whether this vehicle has already arived (reached the arrivalPosition on its final edge) ...
used by the sublane model
const MSEdge * getBidiEdge() const
return opposite superposable/congruent edge, if it exist and 0 else
void setApproaching(const SUMOVehicle *approaching, const SUMOTime arrivalTime, const double arrivalSpeed, const double leaveSpeed, const bool setRequest, const SUMOTime arrivalTimeBraking, const double arrivalSpeedBraking, const SUMOTime waitingTime, double dist)
Sets the information about an approaching vehicle.
virtual double finalizeSpeed(MSVehicle *const veh, double vPos) const
Applies interaction with stops and lane changing model influences. Called at most once per simulation...
void enterLaneAtLaneChange(MSLane *enteredLane)
Update when the vehicle enters a new lane in the laneChange step.
Position getPositionAlongBestLanes(double offset) const
Return the (x,y)-position, which the vehicle would reach if it continued along its best continuation ...
This is an uncontrolled, zipper-merge link.
The link is a (hard) left direction.
std::string parkingarea
(Optional) parking area if one is assigned to the stop
#define WRITE_WARNING(msg)
The simulated network and simulation perfomer.
The car-following model and parameter.
void checkLinkLeader(const MSLink *link, const MSLane *lane, double seen, DriveProcessItem *const lastLink, double &v, double &vLinkPass, double &vLinkWait, bool &setRequest, bool isShadowLink=false) const
checks for link leaders on the given link
virtual void saveState(OutputDevice &out)
Saves the (common) state of a vehicle.
bool containerTriggered
whether an arriving container lets the vehicle continue
WaitingTimeCollector(SUMOTime memory=MSGlobals::gWaitingTimeMemory)
Constructor.
MSAbstractLaneChangeModel & getLaneChangeModel()
bool isVaporizing() const
Returns whether vehicles on this edge shall be vaporized.
SUMOTime getLaneTimeLineDuration()
bool isStoppedInRange(double pos) const
return whether the given position is within range of the current stop
MSCFModel::VehicleVariables * myCFVariables
The per vehicle variables of the car following model.
MSLink * getParallelLink(int direction) const
return the link that is parallel to this lane or 0
double implicitDeltaPosRemote(const MSVehicle *veh)
return the change in longitudinal position that is implicit in the new remote position ...
bool isVehicleSpecific() const
Returns whether this type belongs to a single vehicle only (was modified)
bool isFrontOnLane(const MSLane *lane) const
Returns the information whether the front of the vehicle is on the given lane.
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
double getBackPositionOnLane() const
Get the vehicle's position relative to its current lane.
LinkState getState() const
Returns the current state of the link.
Right blinker lights are switched on.
std::vector< Stop > stops
List of the stops the vehicle will make, TraCI may add entries here.
virtual MSTransportableControl & getContainerControl()
Returns the container control.
const ConstMSEdgeVector getStopEdges() const
Returns the list of still pending stop edges.
LinkDirection
The different directions a link between two lanes may take (or a stream between two edges)...
static CollisionAction getCollisionAction()
bool replaceRoute(const MSRoute *route, const std::string &info, bool onInit=false, int offset=0, bool addStops=true, bool removeStops=true)
Replaces the current route by the given one.
bool replaceRouteEdges(ConstMSEdgeVector &edges, const std::string &info, bool onInit=false, bool check=false, bool removeStops=true)
Replaces the current route by the given edges.
The vehicles starts to stop.
The link is a straight direction.
void stopEnded(const SUMOVehicle *veh, const SUMOVehicleParameter::Stop &stop, const std::string &laneOrEdgeID)
double getMaxAccel() const
Get the vehicle type's maximum acceleration [m/s^2].
Needs to stay on the current lane.
bool willStop() const
Returns whether the vehicle will stop on the current edge.
double getMaxSpeed() const
Returns the maximum speed.
void calculateArrivalParams()
(Re-)Calculates the arrival position and lane from the vehicle parameters
std::vector< std::pair< SUMOTime, int > > myLaneTimeLine
The lane usage time line to apply.
double influenceSpeed(SUMOTime currentTime, double speed, double vSafe, double vMin, double vMax)
Applies stored velocity information on the speed to use.
double changeRequestRemainingSeconds(const SUMOTime currentTime) const
Return the remaining number of seconds of the current laneTimeLine assuming one exists.
std::vector< double > myFurtherLanesPosLat
lateral positions on further lanes
bool signalSet(int which) const
Returns whether the given signal is on.
bool getEmergencyBrakeRedLight() const
Returns whether red lights shall be a reason to brake.
WaitingTimeCollector & operator=(const WaitingTimeCollector &wt)
Assignment operator.
std::string busstop
(Optional) bus stop if one is assigned to the stop
bool operator!=(const State &state)
Operator !=.
double getDistanceToPosition(double destPos, const MSEdge *destEdge) const
double departSpeed
(optional) The initial speed of the vehicle
void stopEnded(const SUMOVehicleParameter::Stop &stop)
bool lastWasContMajor() const
whether this is a link past an internal junction which currently has priority
A road/street connecting two junctions.
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
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.
void setSpeedTimeLine(const std::vector< std::pair< SUMOTime, double > > &speedTimeLine)
Sets a new velocity timeline.
virtual void addPerson(MSTransportable *person)
Adds a person to this vehicle.
double getLatOffset(const MSLane *lane) const
Get the offset that that must be added to interpret myState.myPosLat for the given lane...
double getEndLanePosition() const
Returns the end position of this stop.
The vehicle changes lanes (micro only)
LaneChangeModel getLaneChangeModel() const
bool hasDriverState() const
Whether this vehicle is equipped with a MSDriverState.
MSLane * lane
The described lane.
double getBruttoVehLenSum() const
Returns the sum of lengths of vehicles, including their minGaps, which were on the lane during the la...
void setSpeedMode(int speedMode)
Sets speed-constraining behaviors.
static double naviDegree(const double angle)
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
double getCO2Emissions() const
Returns CO2 emission of the current state.
Left blinker lights are switched on.
double myDepartPos
The real depart position.
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
void setSublaneChange(double latDist)
Sets a new sublane-change request.
void setAngle(double angle, bool straightenFurther=false)
Set a custom vehicle angle in rad, optionally updates furtherLanePosLat.
blocked in all directions
const MSCFModel & getCarFollowModel() const
Returns the vehicle type's car following model definition (const version)
MSLane * getViaLane() const
Returns the following inner lane.
The vehicle got a new route.
Position validatePosition(Position result, double offset=0) const
ensure that a vehicle-relative position is not invalid
vehicle want's to change to right lane
void updateState(double vNext)
updates the vehicles state, given a next value for its speed. This value can be negative in case of t...
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
bool fits(double pos, const SUMOVehicle &veh) const
return whether the given vehicle fits at the given position
void stopStarted(const SUMOVehicle *veh, int numPersons, int numContainers, SUMOTime time)
#define DIST_TO_STOPLINE_EXPECT_PRIORITY
double getFoeVisibilityDistance() const
Returns the distance on the approaching lane from which an approaching vehicle is able to see all rel...
virtual double minNextSpeedEmergency(double speed, const MSVehicle *const veh=0) const
Returns the minimum speed after emergency braking, given the current speed (depends on the numerical ...
double getLateralOverlap() const
return the amount by which the vehicle extends laterally outside it's primary lane ...
The action is urgent (to be defined by lc-model)
double updateFurtherLanes(std::vector< MSLane *> &furtherLanes, std::vector< double > &furtherLanesPosLat, const std::vector< MSLane *> &passedLanes)
update a vector of further lanes and return the new backPos
Representation of a vehicle.
SUMOTime myLastRemoteAccess
render as a hatchback passenger vehicle ("Fliessheck")
Stores the waiting intervals over the previous seconds (memory is to be specified in ms...
bool opened(SUMOTime arrivalTime, double arrivalSpeed, double leaveSpeed, double vehicleLength, double impatience, double decel, SUMOTime waitingTime, double posLat=0, std::vector< const SUMOVehicle *> *collectFoes=0, bool ignoreRed=false, const SUMOVehicle *ego=0) const
Returns the information whether the link may be passed.
double startPos
The stopping position start.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
const MSTrafficLightLogic * getTLLogic() const
Returns the TLS index.
Encapsulated SAX-Attributes.
std::set< std::string > awaitedContainers
IDs of containers the vehicle has to wait for until departing.
The vehicle had to brake harder than permitted.
static MSPModel * getModel()
SUMOTime myCollisionImmunity
amount of time for which the vehicle is immune from collisions
virtual MSTransportableControl & getPersonControl()
Returns the person control.
void adaptLeaveSpeed(const double v)
double implicitSpeedRemote(const MSVehicle *veh, double oldSpeed)
return the speed that is implicit in the new remote position
double getCommittedSpeed() const
ChangeRequest
Requests set via TraCI.
std::string chargingStation
(Optional) charging station if one is assigned to the stop
A point in 2D or 3D with translation and scaling methods.
SUMOTime getActionStepLength() const
Returns the vehicle's action step length in millisecs, i.e. the interval between two action points...
double getCenterOnEdge() const
MSRouteIterator edge
The edge in the route to stop at.
classes which drive on tracks
TraciLaneChangePriority myTraciLaneChangePriority
flags for determining the priority of traci lane change requests
double posLat() const
Lateral Position of this state (m relative to the centerline of the lane).
void updateBestLanes(bool forceRebuild=false, const MSLane *startLane=0)
computes the best lanes to use in order to continue the route
static void clear()
Clears the dictionary.
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the best sequence of lanes to continue the route starting at myLane.
void registerOneWaiting(const bool isPerson)
increases the count of vehicles waiting for a transport to allow recognition of person / container re...
bool isLeader(const MSVehicle *ego, const MSVehicle *foe, bool updateLeader=true) const
Position myCachedPosition
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
double getSpaceTillLastStanding(const MSLane *l, bool &foundStopped) const
const MSLeaderInfo & getLastVehicleInformation(const MSVehicle *ego, double latOffset, double minPos=0, bool allowCached=true) const
Returns the last vehicles on the lane.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
const std::set< MSTransportable * > & getPersons() const
Returns this edge's persons set.
double getCenterOnEdge(const MSLane *lane=0) const
Get the vehicle's lateral position on the edge of the given lane (or its current edge if lane == 0) ...
double currentLength
The length which may be driven on this lane.
int getVehicleNumber() const
Returns the number of vehicles on this lane (for which this lane is responsible)
bool triggered
whether an arriving person lets the vehicle continue
const std::vector< MSLane * > & getFurtherLanes() const
std::list< Stop > myStops
The vehicle's list of stops.
ConstMSEdgeVector::const_iterator MSRouteIterator
void removeVType(const MSVehicleType *vehType)
bool hasContainers() const
Returns whether containers are simulated.
int parametersSet
Information for the output which parameter were set.
int getCapacity() const
Returns the area capacity.
bool collision
Whether this stop was triggered by a collision.
bool havePriority() const
Returns whether this link is a major link.
bool myConsiderMaxDeceleration
Whether the maximum deceleration shall be regarded.
MSLane * myLane
The lane the vehicle is on.
bool myAmRegisteredAsWaitingForContainer
Whether this vehicle is registered as waiting for a container (for deadlock-recognition) ...
void getSubLanes(const MSVehicle *veh, double latOffset, int &rightmost, int &leftmost) const
bool hasStops() const
Returns whether the vehicle has to stop somewhere.
static double fromNaviDegree(const double angle)
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic, in MSLink and GNEInternalLane.
Influencer * myInfluencer
An instance of a velocity/lane influencing instance; built in "getInfluencer".
void resetRoutePosition(int index)
std::vector< LaneQ >::iterator myCurrentLaneInBestLanes
void postProcessRemoteControl(MSVehicle *v)
MSDevice_Transportable * myPersonDevice
The passengers this vehicle may have.
double getDeltaPos(double accel)
calculates the distance covered in the next integration step given an acceleration and assuming the c...
void forceVehicleInsertion(MSVehicle *veh, double pos, MSMoveReminder::Notification notification, double posLat=0)
Inserts the given vehicle at the given position.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
const MSEdge * getNormalBefore() const
if this edge is an internal edge, return its first normal predecessor, otherwise the edge itself ...
bool keepClear(const MSLink *link) const
decide whether the given link must be kept clear
double getMaxSpeed() const
Get vehicle's maximum speed [m/s].
double getHarmonoise_NoiseEmissions() const
Returns noise emissions of the current state.
MSVehicle()
invalidated default constructor
bool considerSafeVelocity() const
Returns whether safe velocities shall be considered.
#define JUNCTION_BLOCKAGE_TIME
void resetActionOffset(const SUMOTime timeUntilNextAction=0)
Resets the action offset for the vehicle.
The link is a (hard) right direction.
const MSLane * getInternalLaneBefore() const
return myInternalLaneBefore (always 0 when compiled without internal lanes)
The action is needed to follow the route (navigational lc)
const std::string & getID() const
returns the id of the transportable
std::vector< LinkLeader > LinkLeaders
double getImpatience() const
Returns this vehicles impatience.
void write(OutputDevice &dev) const
Write the current stop configuration (used for state saving)
A blue emergency light is on.
A structure representing the best lanes for continuing the current route starting at 'lane'...
void loadState(const SUMOSAXAttributes &attrs, const SUMOTime offset)
Loads the state of this vehicle from the given description.
void onRemovalFromNet(const MSMoveReminder::Notification reason)
Called when the vehicle is removed from the network.
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 ...
double myStopDist
distance to the next stop or -1 if there is none
bool isStoppedTriggered() const
Returns whether the vehicle is on a triggered stop.
bool hasInfluencer() const
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
double endPos
The stopping position end.
double getMinGap() const
Get the free space in front of vehicles of this class.
SUMOTime collisionStopTime() const
Returns the remaining time a vehicle needs to stop due to a collision. A negative value indicates tha...
const std::vector< std::pair< const MSLane *, const MSEdge * > > getOutgoingViaLanes() const
get the list of outgoing lanes
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
void removeTransportable(MSTransportable *p)
Removes a transportable from this stop.
double basePos(const MSEdge *edge) const
departure position where the vehicle fits fully onto the edge (if possible)
double myAcceleration
The current acceleration after dawdling in m/s.
MSLane * getOpposite() const
return the opposite direction lane for lane changing or 0
void fixPosition()
repair errors in vehicle position after changing between internal edges
bool myActionStep
The flag myActionStep indicates whether the current time step is an action point for the vehicle...
double myPreviousSpeed
the speed at the begin of the previous time step
render as a passenger vehicle
bool isFringe() const
return whether this edge is at the fringe of the network
void setShadowApproachingInformation(MSLink *link) const
set approach information for the shadow vehicle
SUMOTime myWaitingTime
The time the vehicle waits (is not faster than 0.1m/s) in seconds.
void setRemoteControlled(Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, const ConstMSEdgeVector &route, SUMOTime t)
LaneChangeMode mySpeedGainLC
lane changing to travel with higher speed
double maximumSafeStopSpeed(double gap, double currentSpeed, bool onInsertion=false, double headway=-1) const
Returns the maximum next velocity for stopping within gap.
bool isInternal() const
return whether this edge is an internal edge
double getMinimalArrivalSpeedEuler(double dist, double currentSpeed) const
Computes the minimal possible arrival speed after covering a given distance for Euler update...
The link is a partial right direction.
LaneChangeMode myCooperativeLC
lane changing with the intent to help other vehicles
const SUMOVTypeParameter & getParameter() const
bool lefthand() const
return whether the network was built for lefthand traffic
int getOccupancy() const
Returns the area occupancy.
std::vector< MSVehicle * > VehCont
Container for vehicles.
const MSLane * lane
The lane to stop at.
bool containerTriggered
whether an arriving container lets the vehicle continue
bool loadAnyWaiting(MSEdge *edge, SUMOVehicle *vehicle, const SUMOVehicleParameter::Stop &stop, SUMOTime &timeToLoadNextContainer, SUMOTime &stopDuration)
load any applicable containers Loads any container that is waiting on that edge for the given vehicle...
void move2side(double amount)
move position vector to side using certain ammount
static MSLinkCont::const_iterator succLinkSec(const SUMOVehicle &veh, int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane *> &conts)
bool allowsContinuation
Whether this lane allows to continue the drive.
const waitingIntervalList & getWaitingIntervals() const
Container that holds the vehicles driving state (position+speed).
Base class for objects which have an id.
void saveState(OutputDevice &out)
Saves the states of a vehicle.
void processLaneAdvances(std::vector< MSLane *> &passedLanes, bool &moved, std::string &emergencyReason)
This method checks if the vehicle has advanced over one or several lanes along its route and triggers...
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
double arrivalPos
(optional) The position the vehicle shall arrive on
double getOriginalSpeed() const
Returns the originally longitudinal speed to use.
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
double getRightSideOnEdge() const
void setBrakingSignals(double vNext)
sets the braking lights on/off
std::string lane
The lane to stop at.
bool myEmergencyBrakeRedLight
Whether red lights are a reason to brake.
double getCOEmissions() const
Returns CO emission of the current state.
std::vector< std::string > via
List of the via-edges the vehicle must visit.
static MSVehicleTransfer * getInstance()
Returns the instance of this object.
void removePassedDriveItems()
Erase passed drive items from myLFLinkLanes (and unregister approaching information for corresponding...
virtual void drawOutsideNetwork(bool)
register vehicle for drawing while outside the network
int numExpectedContainer
The number of still expected containers.
void removeShadowApproachingInformation() const
double slopeDegreeAtOffset(double pos) const
Returns the slope at the given length.
void updateOccupancyAndCurrentBestLane(const MSLane *startLane)
updates LaneQ::nextOccupation and myCurrentLaneInBestLanes
std::pair< const MSPerson *, double > PersonDist
void setEmergencyBlueLight(SUMOTime currentTime)
sets the blue flashing light for emergency vehicles
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
const int STOP_PARKING_SET
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
bool addTraciStop(MSLane *const lane, const double startPos, const double endPos, const SUMOTime duration, const SUMOTime until, const bool parking, const bool triggered, const bool containerTriggered, std::string &errorMsg)
virtual std::string toString() const
print a debugging representation
bool hasDriverState
Whether vehicles of this type are equipped with a driver (i.e. MSDriverState))
double departPos
(optional) The position the vehicle shall depart from
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
vehicle want's to change to left lane
int numExpectedPerson
The number of still expected persons.
std::pair< const MSVehicle *, double > CLeaderDist
The vehicle starts or ends parking.
virtual double getFloat(int id) const =0
Returns the double-value of the named (by its enum-value) attribute.
const int STOP_TRIGGER_SET
SUMOVehicleClass getVClass() const
Returns the vehicle's access class.
static double compute(const SUMOEmissionClass c, const EmissionType e, const double v, const double a, const double slope, const std::map< int, double > *param=0)
Returns the amount of the emitted pollutant given the vehicle type and state (in mg/s or ml/s for fue...
void addStops(const bool ignoreStopErrors)
Adds stops to the built vehicle.
Influencer & getInfluencer()
Returns the velocity/lane influencer.
int getPersonNumber() const
Returns the number of persons.
Structure representing possible vehicle parameter.
DriveItemVector::iterator myNextDriveItem
iterator pointing to the next item in myLFLinkLanes
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.
double getOppositePos(double pos) const
return the corresponding position on the opposite lane
double occupation
The overall vehicle sum on consecutive lanes which can be passed without a lane change.
LaneChangeMode mySublaneLC
changing to the prefered lateral alignment
std::pair< double, LinkDirection > myNextTurn
the upcoming turn for the vehicle
MSDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists or 0.
bool keepStopping(bool afterProcessing=false) const
Returns whether the vehicle is stopped and must continue to do so.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
void removeApproachingInformation(DriveItemVector &lfLinks) const
unregister approach from all upcoming links
double processNextStop(double currentVelocity)
Processes stops, returns the velocity needed to reach the stop.
void setNoShadowPartialOccupator(MSLane *lane)
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...
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...
void processLinkAproaches(double &vSafe, double &vSafeMin, double &vSafeMinDist)
This method iterates through the driveprocess items for the vehicle and adapts the given in/out param...
std::vector< std::pair< SUMOTime, double > > mySpeedTimeLine
The velocity time line to apply.
MSVehicleType * myType
This vehicle's type.
void passTime(SUMOTime dt, bool waiting)
void workOnMoveReminders(double oldPos, double newPos, double newSpeed)
Processes active move reminder.
double getEndPos(const SUMOVehicle &veh) const
return halting position for upcoming stop;
virtual double getHeadwayTime() const
Get the driver's desired headway [s].
The vehicle is blocked being overlapping.
void checkRewindLinkLanes(const double lengthsInFront, DriveItemVector &lfLinks) const
runs heuristic for keeping the intersection clear in case of downstream jamming
int mySignals
State of things of the vehicle that can be on or off.
bool isRemoteControlled() const
void passedJunction(const MSVehicle *vehicle) const
erase vehicle from myLinkLeaders of this links junction
void resetChanged()
reset the flag whether a vehicle already moved to false
ConstMSEdgeVector myRemoteRoute
std::vector< MSLane * > bestContinuations
MSStoppingPlace * chargingStation
(Optional) charging station if one is assigned to the stop
bool boardAnyWaiting(MSEdge *edge, SUMOVehicle *vehicle, const SUMOVehicleParameter::Stop &stop, SUMOTime &timeToBoardNextPerson, SUMOTime &stopDuration)
board any applicable persons Boards any people who wait on that edge for the given vehicle and remove...
std::shared_ptr< MSSimpleDriverState > myDriverState
This vehicle's driver state.
Definition of vehicle stop (position and duration)
void setRemoteState(Position xyPos)
sets position outside the road network
void checkLinkLeaderCurrentAndParallel(const MSLink *link, const MSLane *lane, double seen, DriveProcessItem *const lastLink, double &v, double &vLinkPass, double &vLinkWait, bool &setRequest) const
checks for link leaders of the current link as well as the parallel link (if there is one) ...
void scaleRelative(double factor)
enlarges/shrinks the polygon by a factor based at the centroid
MSStoppingPlace * containerstop
(Optional) container stop if one is assigned to the stop
void onDepart()
Called when the vehicle is inserted into the network.
double getMinimalArrivalSpeed(double dist, double currentSpeed) const
Computes the minimal possible arrival speed after covering a given distance.
double interpolateLanePosToGeometryPos(double lanePos) const
const MSEdge * getRerouteOrigin() const
Returns the starting point for reroutes (usually the current edge)
const std::string & getID() const
Returns the name of the vehicle type.
double getPMxEmissions() const
Returns PMx emission of the current state.
int index
at which position in the stops list
SUMOTime getMinimalArrivalTime(double dist, double currentSpeed, double arrivalSpeed) const
Computes the minimal time needed to cover a distance given the desired speed at arrival.
MSVehicle * getLastAnyVehicle() const
returns the last vehicle that is fully or partially on this lane
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
MSLane * getViaLaneOrLane() const
return the via lane if it exists and the lane otherwise
double getStopOffset(const MSVehicle *veh) const
Returns vehicle class specific stopOffset for the vehicle.
The arrival lane is given.
The vehicle ends to stop.
void activateReminders(const MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
"Activates" all current move reminder
LinkLeaders getLeaderInfo(const MSVehicle *ego, double dist, std::vector< const MSPerson *> *collectBlockers=0, bool isShadowLink=false) const
Returns all potential link leaders (vehicles on foeLanes) Valid during the planMove() phase...
void addReference() const
increments the reference counter for the route
void updateActionOffset(const SUMOTime oldActionStepLength, const SUMOTime newActionStepLength)
Process an updated action step length value (only affects the vehicle's action offset, The actionStepLength is stored in the (singular) vtype)
A device which collects info on the vehicle trip (mainly on departure and arrival) ...
int myNumberReroutes
The number of reroutings.
double getLength() const
Get vehicle's length [m].
SUMOTime cumulatedWaitingTime(SUMOTime memory=-1) const
void setLaneChangeMode(int value)
Sets lane changing behavior.
const MSLane * getBackLane() const
virtual void prepareStep()
bool allowsVehicleClass(SUMOVehicleClass vclass) const
double processTraCISpeedControl(double vSafe, double vNext)
Check for speed advices from the traci client and adjust the speed vNext in the current (euler) / aft...
static MSStopOut * getInstance()
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
double getTimeGapOnLane() const
Returns the time gap in seconds to the leader of the vehicle on the same lane.
waitingIntervalList myWaitingIntervals
std::vector< DriveProcessItem > DriveItemVector
Container for used Links/visited Lanes during planMove() and executeMove.
void updateWaitingTime(double vNext)
Updates the vehicle's waiting time counters (accumulated and consecutive)
void setSignals(int signals)
const MSEdgeWeightsStorage & getWeightsStorage() const
Returns the vehicle's internal edge travel times/efforts container.
bool isRemoteAffected(SUMOTime t) const
void setApproachingForAllLinks(DriveItemVector &lfLinks) const
registers computed approach information with all links
The action is due to a TraCI request.
double getBackPositionOnLane(const MSLane *lane) const
Get the vehicle's position relative to the given lane.
const std::vector< MSLane * > & getShadowFurtherLanes() const
double estimateSpeedAfterDistance(const double dist, const double v, const double accel) const
vehicle want's to keep the current lane
Static storage of an output device and its base (abstract) implementation.
double speed() const
Speed of this state.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
void changedToOpposite()
called when a vehicle changes between lanes in opposite directions
The vehicle needs another parking area.
void switchOffSignal(int signal)
Switches the given signal off.
static bool gSemiImplicitEulerUpdate
void switchOnSignal(int signal)
Switches the given signal on.
double getSlope() const
Returns the slope of the road at vehicle's position.
bool passingMinor() const
decide whether the vehicle is passing a minor link or has comitted to do so
void addPerson(MSTransportable *person)
Adds a passenger.
static std::vector< MSLane * > myEmptyLaneVector
void removeApproaching(const SUMOVehicle *veh)
removes the vehicle from myApproachingVehicles
MSRouteIterator myCurrEdge
Iterator to current route-edge.
bool isActionStep(SUMOTime t) const
Returns whether the next simulation step will be an action point for the vehicle. ...
MSDevice_Transportable * myContainerDevice
The containers this vehicle may have.
bool unsafeLinkAhead(const MSLane *lane) const
whether the vehicle may safely move to the given lane with regard to upcoming links ...
MSEdgeWeightsStorage & _getWeightsStorage() const
double arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
MSLane * getShadowLane() const
Returns the lane the vehicle's shadow is on during continuous/sublane lane change.
void setLaneTimeLine(const std::vector< std::pair< SUMOTime, int > > &laneTimeLine)
Sets a new lane timeline.
double getHCEmissions() const
Returns HC emission of the current state.
virtual ~MSVehicle()
Destructor.
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const MSEdgeVector &prohibited=MSEdgeVector()) const
bool isStopped() const
Returns whether the vehicle is at a stop.
No information given; use default.
bool willPass(const MSEdge *const edge) const
Returns whether the vehicle wil pass the given edge.
MSParkingArea * getNextParkingArea()
get the current parking area stop
std::vector< MSEdge * > MSEdgeVector
const Position getBackPosition() const
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
double getRightSideOnEdge(const MSLane *lane=0) const
Get the vehicle's lateral position on the edge of the given lane (or its current edge if lane == 0) ...
const std::vector< LaneQ > & getBestLanes() const
Returns the description of best lanes to use in order to continue the route.
const MSLane & getLane() const
Returns the lane this stop is located at.
virtual double getArrivalPos() const
Returns this vehicle's desired arrivalPos for its current route (may change on reroute) ...
bool isParking() const
Returns whether the vehicle is parking.
double getSpeed() const
Returns the vehicle's current speed.
State(double pos, double speed, double posLat, double backPos)
Constructor.
bool mySpeedAdaptationStarted
Whether influencing the speed has already started.
static SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const MSEdgeVector &prohibited=MSEdgeVector())
return the router instance
double estimateLeaveSpeed(const MSLink *const link, const double vLinkPass) const
estimate leaving speed when accelerating across a link
double getLastFreePos(const SUMOVehicle &forVehicle) const
Returns the last free position on this stop.
const std::vector< MSTransportable * > & getPersons() const
retrieve riding persons
int influenceChangeDecision(int state)
allow TraCI to influence a lane change decision
public emergency vehicles
render as a wagon passenger vehicle ("Combi")
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
static SUMOTime gLaneChangeDuration
virtual double followSpeed(const MSVehicle *const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle *const pred=0) const =0
Computes the vehicle's follow speed (no dawdling)
SUMOTime getLastAccessTimeStep() const
int influenceChangeDecision(const SUMOTime currentTime, const MSEdge ¤tEdge, const int currentLaneIndex, int state)
Applies stored LaneChangeMode information and laneTimeLine.
SUMOTime timeToLoadNextContainer
The time at which the vehicle is able to load another container.
static MSAbstractLaneChangeModel * build(LaneChangeModel lcm, MSVehicle &vehicle)
Factory method for instantiating new lane changing models.
const std::string & getID() const
Returns the name of the vehicle.
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
void addReminder(MSMoveReminder *rem)
Adds a MoveReminder dynamically.
Representation of a lane in the micro simulation.
std::vector< MSDevice * > myDevices
The devices this vehicle has.
double myBackPos
the stored back position
SUMOEmissionClass getEmissionClass() const
Get this vehicle type's emission class.
virtual void addContainer(MSTransportable *container)
Adds a container to this vehicle.
void adaptLaneEntering2MoveReminder(const MSLane &enteredLane)
Adapts the vehicle's entering of a new lane.
const std::vector< SUMOVehicleParameter::Stop > & getStops() const
Returns the stops.
LaneChangeMode myStrategicLC
lane changing which is necessary to follow the current route
void unregisterOneWaiting(const bool isPerson)
decreases the count of vehicles waiting for a transport to allow recognition of person / container re...
MSRouteIterator end() const
Returns the end of the list of edges to pass.
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
bool haveRed() const
Returns whether this link is blocked by a red (or redyellow) traffic light.
Interface for lane-change models.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
double mySpeed
the stored speed (should be >=0 at any time)
bool contains(const MSEdge *const edge) const
bool myConsiderSafeVelocity
Whether the safe velocity shall be regarded.
const std::vector< MSLane * > & getFurtherTargetLanes() const
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) ...
SUMOTime myDeparture
The real departure time.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
static const SUMOTime NOT_YET_DEPARTED
double getWidth() const
Returns the vehicle's width.
std::string id
The vehicle's id.
static const Position INVALID
used to indicate that a position is valid
double getSpeedWithoutTraciInfluence() const
Returns the uninfluenced velocity.
The vehicle is being teleported.
void removeWaiting(const MSEdge *const edge, const SUMOVehicle *vehicle)
Removes a vehicle from the list of waiting vehicles to a given edge.
MSLane * getParallelLane(int offset) const
Returns the lane with the given offset parallel to this one or 0 if it does not exist.
Definition of vehicle stop (position and duration)
The link has no direction (is a dead end link)
double pos() const
Position of this state.
void endLaneChangeManeuver(const MSMoveReminder::Notification reason=MSMoveReminder::NOTIFICATION_LANE_CHANGE)
void updateDriveItems()
Check whether the drive items (myLFLinkLanes) are up to date, and update them if required.
double getWidth() const
Returns the edges's width (sum over all lanes)