103 #define DEBUG_COND (isSelected())
105 #define DEBUG_COND2(obj) (obj->isSelected())
109 #define STOPPING_PLACE_OFFSET 0.5
111 #define CRLL_LOOK_AHEAD 5
113 #define JUNCTION_BLOCKAGE_TIME 5
116 #define DIST_TO_STOPLINE_EXPECT_PRIORITY 1.0
118 #define NUMERICAL_EPS_SPEED (0.1 * NUMERICAL_EPS * TS)
156 return (myPos != state.
myPos ||
166 myPos(pos), mySpeed(speed), myPosLat(posLat), myBackPos(backPos), myPreviousSpeed(speed), myLastCoveredDist(
SPEED2DIST(speed)) {}
178 assert(memorySpan <= myMemorySize);
179 if (memorySpan == -1) {
180 memorySpan = myMemorySize;
183 for (
const auto& interval : myWaitingIntervals) {
184 if (interval.second >= memorySpan) {
185 if (interval.first >= memorySpan) {
188 totalWaitingTime += memorySpan - interval.first;
191 totalWaitingTime += interval.second - interval.first;
194 return totalWaitingTime;
200 auto i = myWaitingIntervals.begin();
201 const auto end = myWaitingIntervals.end();
202 const bool startNewInterval = i == end || (i->first != 0);
205 if (i->first >= myMemorySize) {
213 auto d = std::distance(i, end);
215 myWaitingIntervals.pop_back();
221 }
else if (!startNewInterval) {
222 myWaitingIntervals.begin()->first = 0;
224 myWaitingIntervals.push_front(std::make_pair(0, dt));
232 std::ostringstream state;
233 state << myMemorySize <<
" " << myWaitingIntervals.size();
234 for (
const auto& interval : myWaitingIntervals) {
235 state <<
" " << interval.first <<
" " << interval.second;
243 std::istringstream is(state);
246 is >> myMemorySize >> numIntervals;
247 while (numIntervals-- > 0) {
249 myWaitingIntervals.emplace_back(begin, end);
268 if (GapControlState::refVehMap.find(msVeh) != end(GapControlState::refVehMap)) {
270 GapControlState::refVehMap[msVeh]->deactivate();
280 std::map<const MSVehicle*, MSVehicle::Influencer::GapControlState*>
287 tauOriginal(-1), tauCurrent(-1), tauTarget(-1), addGapCurrent(-1), addGapTarget(-1),
288 remainingDuration(-1), changeRate(-1), maxDecel(-1), referenceVeh(nullptr), active(false), gapAttained(false), prevLeader(nullptr),
289 lastUpdate(-1), timeHeadwayIncrement(0.0), spaceHeadwayIncrement(0.0) {}
303 WRITE_ERROR(
"MSVehicle::Influencer::GapControlState::init(): No MSNet instance found!")
320 tauOriginal = tauOrig;
321 tauCurrent = tauOrig;
324 addGapTarget = additionalGap;
325 remainingDuration = dur;
328 referenceVeh = refVeh;
331 prevLeader =
nullptr;
333 timeHeadwayIncrement = changeRate *
TS * (tauTarget - tauOriginal);
334 spaceHeadwayIncrement = changeRate *
TS * addGapTarget;
336 if (referenceVeh !=
nullptr) {
346 if (referenceVeh !=
nullptr) {
349 referenceVeh =
nullptr;
382 GapControlState::init();
387 GapControlState::cleanup();
392 mySpeedAdaptationStarted =
true;
393 mySpeedTimeLine = speedTimeLine;
398 if (myGapControlState ==
nullptr) {
399 myGapControlState = std::make_shared<GapControlState>();
401 myGapControlState->activate(originalTau, newTimeHeadway, newSpaceHeadway, duration, changeRate, maxDecel, refVeh);
406 if (myGapControlState !=
nullptr && myGapControlState->active) {
407 myGapControlState->deactivate();
413 myLaneTimeLine = laneTimeLine;
419 for (
auto& item : myLaneTimeLine) {
420 item.second += indexShift;
432 return (1 * myConsiderSafeVelocity +
433 2 * myConsiderMaxAcceleration +
434 4 * myConsiderMaxDeceleration +
435 8 * myRespectJunctionPriority +
436 16 * myEmergencyBrakeRedLight);
442 return (1 * myStrategicLC +
443 4 * myCooperativeLC +
445 64 * myRightDriveLC +
446 256 * myTraciLaneChangePriority +
453 for (std::vector<std::pair<SUMOTime, int>>::iterator i = myLaneTimeLine.begin(); i != myLaneTimeLine.end(); ++i) {
457 duration -= i->first;
465 if (!myLaneTimeLine.empty()) {
466 return myLaneTimeLine.back().first;
476 myOriginalSpeed = speed;
479 while (mySpeedTimeLine.size() == 1 || (mySpeedTimeLine.size() > 1 && currentTime > mySpeedTimeLine[1].first)) {
480 mySpeedTimeLine.erase(mySpeedTimeLine.begin());
483 if (!(mySpeedTimeLine.size() < 2 || currentTime < mySpeedTimeLine[0].first)) {
485 if (!mySpeedAdaptationStarted) {
486 mySpeedTimeLine[0].second = speed;
487 mySpeedAdaptationStarted =
true;
490 const double td =
STEPS2TIME(currentTime - mySpeedTimeLine[0].first) /
STEPS2TIME(mySpeedTimeLine[1].first +
DELTA_T - mySpeedTimeLine[0].first);
491 speed = mySpeedTimeLine[0].second - (mySpeedTimeLine[0].second - mySpeedTimeLine[1].second) * td;
492 if (myConsiderSafeVelocity) {
493 speed =
MIN2(speed, vSafe);
495 if (myConsiderMaxAcceleration) {
496 speed =
MIN2(speed, vMax);
498 if (myConsiderMaxDeceleration) {
499 speed =
MAX2(speed, vMin);
509 std::cout << currentTime <<
" Influencer::gapControlSpeed(): speed=" << speed
510 <<
", vSafe=" << vSafe
516 double gapControlSpeed = speed;
517 if (myGapControlState !=
nullptr && myGapControlState->active) {
519 const double currentSpeed = veh->
getSpeed();
521 assert(msVeh !=
nullptr);
522 const double desiredTargetTimeSpacing = myGapControlState->tauTarget * currentSpeed;
523 std::pair<const MSVehicle*, double> leaderInfo;
524 if (myGapControlState->referenceVeh ==
nullptr) {
526 leaderInfo = msVeh->
getLeader(
MAX2(desiredTargetTimeSpacing, myGapControlState->addGapCurrent) + 20.);
529 const MSVehicle* leader = myGapControlState->referenceVeh;
537 if (dist < -100000) {
539 std::cout <<
" Ego and reference vehicle are not in CF relation..." << std::endl;
541 std::cout <<
" Reference vehicle is behind ego..." << std::endl;
548 const double fakeDist =
MAX2(0.0, leaderInfo.second - myGapControlState->addGapCurrent);
551 const double desiredCurrentSpacing = myGapControlState->tauCurrent * currentSpeed;
552 std::cout <<
" Gap control active:"
553 <<
" currentSpeed=" << currentSpeed
554 <<
", desiredTargetTimeSpacing=" << desiredTargetTimeSpacing
555 <<
", desiredCurrentSpacing=" << desiredCurrentSpacing
556 <<
", leader=" << (leaderInfo.first ==
nullptr ?
"NULL" : leaderInfo.first->getID())
557 <<
", dist=" << leaderInfo.second
558 <<
", fakeDist=" << fakeDist
559 <<
",\n tauOriginal=" << myGapControlState->tauOriginal
560 <<
", tauTarget=" << myGapControlState->tauTarget
561 <<
", tauCurrent=" << myGapControlState->tauCurrent
565 if (leaderInfo.first !=
nullptr) {
566 if (myGapControlState->prevLeader !=
nullptr && myGapControlState->prevLeader != leaderInfo.first) {
570 myGapControlState->prevLeader = leaderInfo.first;
576 gapControlSpeed =
MIN2(gapControlSpeed,
577 cfm->
followSpeed(msVeh, currentSpeed, fakeDist, leaderInfo.first->
getSpeed(), leaderInfo.first->getCurrentApparentDecel(), leaderInfo.first));
581 std::cout <<
" -> gapControlSpeed=" << gapControlSpeed;
582 if (myGapControlState->maxDecel > 0) {
583 std::cout <<
", with maxDecel bound: " <<
MAX2(gapControlSpeed, currentSpeed -
TS * myGapControlState->maxDecel);
585 std::cout << std::endl;
588 if (myGapControlState->maxDecel > 0) {
589 gapControlSpeed =
MAX2(gapControlSpeed, currentSpeed -
TS * myGapControlState->maxDecel);
596 if (myGapControlState->lastUpdate < currentTime) {
599 std::cout <<
" Updating GapControlState." << std::endl;
602 if (myGapControlState->tauCurrent == myGapControlState->tauTarget && myGapControlState->addGapCurrent == myGapControlState->addGapTarget) {
603 if (!myGapControlState->gapAttained) {
605 myGapControlState->gapAttained = leaderInfo.first ==
nullptr || leaderInfo.second >
MAX2(desiredTargetTimeSpacing, myGapControlState->addGapTarget) - POSITION_EPS;
608 if (myGapControlState->gapAttained) {
609 std::cout <<
" Target gap was established." << std::endl;
615 myGapControlState->remainingDuration -=
TS;
618 std::cout <<
" Gap control remaining duration: " << myGapControlState->remainingDuration << std::endl;
621 if (myGapControlState->remainingDuration <= 0) {
624 std::cout <<
" Gap control duration expired, deactivating control." << std::endl;
628 myGapControlState->deactivate();
633 myGapControlState->tauCurrent =
MIN2(myGapControlState->tauCurrent + myGapControlState->timeHeadwayIncrement, myGapControlState->tauTarget);
634 myGapControlState->addGapCurrent =
MIN2(myGapControlState->addGapCurrent + myGapControlState->spaceHeadwayIncrement, myGapControlState->addGapTarget);
637 if (myConsiderSafeVelocity) {
638 gapControlSpeed =
MIN2(gapControlSpeed, vSafe);
640 if (myConsiderMaxAcceleration) {
641 gapControlSpeed =
MIN2(gapControlSpeed, vMax);
643 if (myConsiderMaxDeceleration) {
644 gapControlSpeed =
MAX2(gapControlSpeed, vMin);
646 return MIN2(speed, gapControlSpeed);
654 return mySpeedTimeLine.empty() ? -1 : myOriginalSpeed;
661 while (myLaneTimeLine.size() == 1 || (myLaneTimeLine.size() > 1 && currentTime > myLaneTimeLine[1].first)) {
662 myLaneTimeLine.erase(myLaneTimeLine.begin());
666 if (myLaneTimeLine.size() >= 2 && currentTime >= myLaneTimeLine[0].first) {
667 const int destinationLaneIndex = myLaneTimeLine[1].second;
668 if (destinationLaneIndex < (
int)currentEdge.
getLanes().size()) {
669 if (currentLaneIndex > destinationLaneIndex) {
671 }
else if (currentLaneIndex < destinationLaneIndex) {
676 }
else if (currentEdge.
getLanes().back()->getOpposite() !=
nullptr) {
685 if ((state &
LCA_TRACI) != 0 && myLatDist != 0) {
694 mode = myStrategicLC;
696 mode = myCooperativeLC;
698 mode = mySpeedGainLC;
700 mode = myRightDriveLC;
739 switch (changeRequest) {
755 assert(myLaneTimeLine.size() >= 2);
756 assert(currentTime >= myLaneTimeLine[0].first);
757 return STEPS2TIME(myLaneTimeLine[1].first - currentTime);
763 myConsiderSafeVelocity = ((speedMode & 1) != 0);
764 myConsiderMaxAcceleration = ((speedMode & 2) != 0);
765 myConsiderMaxDeceleration = ((speedMode & 4) != 0);
766 myRespectJunctionPriority = ((speedMode & 8) != 0);
767 myEmergencyBrakeRedLight = ((speedMode & 16) != 0);
784 myRemoteXYPos = xyPos;
787 myRemotePosLat = posLat;
788 myRemoteAngle = angle;
789 myRemoteEdgeOffset = edgeOffset;
790 myRemoteRoute = route;
791 myLastRemoteAccess = t;
803 return myLastRemoteAccess >= t -
TIME2STEPS(10);
808 const bool wasOnRoad = v->
isOnRoad();
809 const bool withinLane = myRemoteLane !=
nullptr && fabs(myRemotePosLat) < 0.5 * (myRemoteLane->getWidth() + v->
getVehicleType().
getWidth());
810 const bool keepLane = wasOnRoad && v->
getLane() == myRemoteLane;
811 if (v->
isOnRoad() && !(keepLane && withinLane)) {
815 if (myRemoteRoute.size() != 0) {
819 if (myRemoteLane !=
nullptr && myRemotePos > myRemoteLane->getLength()) {
820 myRemotePos = myRemoteLane->getLength();
822 if (myRemoteLane !=
nullptr && withinLane) {
830 myRemoteLane->forceVehicleInsertion(v, myRemotePos, notify, myRemotePosLat);
864 if (myRemoteLane !=
nullptr) {
870 if (distAlongRoute != std::numeric_limits<double>::max()) {
871 dist = distAlongRoute;
875 const double minSpeed = myConsiderMaxDeceleration ?
877 const double maxSpeed = (myRemoteLane !=
nullptr
878 ? myRemoteLane->getVehicleMaxSpeed(veh)
888 if (myRemoteLane ==
nullptr) {
932 myStopDist(std::numeric_limits<double>::max()),
946 (*i)->resetPartialOccupation(
this);
968 #ifdef DEBUG_ACTIONSTEPS
970 std::cout <<
SIMTIME <<
" Removing vehicle '" <<
getID() <<
"' (reason: " <<
toString(reason) <<
")" << std::endl;
991 if (!(*myCurrEdge)->isTazConnector()) {
993 if ((*myCurrEdge)->getDepartLane(*
this) ==
nullptr) {
994 msg =
"Invalid departlane definition for vehicle '" +
getID() +
"'.";
1003 if ((*myCurrEdge)->allowedLanes(
getVClass()) ==
nullptr) {
1004 msg =
"Vehicle '" +
getID() +
"' is not allowed to depart on any lane of edge '" + (*myCurrEdge)->getID() +
"'.";
1010 msg =
"Departure speed for vehicle '" +
getID() +
"' is too high for the vehicle type '" +
myType->
getID() +
"'.";
1035 updateBestLanes(
true, onInit ? (*myCurrEdge)->getLanes().front() : 0);
1053 if (!rem->first->notifyMove(*
this, oldPos + rem->second, newPos + rem->second,
MAX2(0., newSpeed))) {
1055 if (myTraceMoveReminders) {
1056 traceMoveReminder(
"notifyMove", rem->first, rem->second,
false);
1062 if (myTraceMoveReminders) {
1063 traceMoveReminder(
"notifyMove", rem->first, rem->second,
true);
1077 rem->first->notifyIdle(*
this);
1083 rem->notifyIdle(*
this);
1094 rem->second += oldLaneLength;
1098 if (myTraceMoveReminders) {
1099 traceMoveReminder(
"adaptedPos", rem->first, rem->second,
true);
1132 if (
myStops.begin()->parkingarea !=
nullptr) {
1133 return myStops.begin()->parkingarea->getVehiclePosition(*
this);
1143 if (offset == 0. && !changingLanes) {
1161 auto nextBestLane = bestLanes.begin();
1166 bool success =
true;
1168 while (offset > 0) {
1173 lane = lane->
getLinkCont()[0]->getViaLaneOrLane();
1175 if (lane ==
nullptr) {
1185 while (nextBestLane != bestLanes.end() && *nextBestLane ==
nullptr) {
1190 assert(lane == *nextBestLane);
1194 assert(nextBestLane == bestLanes.end() || *nextBestLane != 0);
1195 if (nextBestLane == bestLanes.end()) {
1200 assert(link !=
nullptr);
1222 int furtherIndex = 0;
1231 offset += lastLength;
1256 #ifdef DEBUG_FURTHER
1258 std::cout <<
SIMTIME <<
" veh '" <<
getID() <<
" setAngle(" << angle <<
") straightenFurther=" << straightenFurther << std::endl;
1266 if (further->
getLinkTo(next) !=
nullptr) {
1281 const bool newActionStepLength = actionStepLengthMillisecs != previousActionStepLength;
1282 if (newActionStepLength) {
1306 if (
myStops.begin()->parkingarea !=
nullptr) {
1307 return myStops.begin()->parkingarea->getVehicleAngle(*
this);
1332 double result = (p1 != p2 ? p2.
angleTo2D(p1) :
1337 #ifdef DEBUG_FURTHER
1355 #ifdef DEBUG_FURTHER
1362 #ifdef DEBUG_FURTHER
1378 if (parkingArea == 0) {
1379 errorMsg =
"new parkingArea is NULL";
1383 errorMsg =
"vehicle has no stops";
1386 if (
myStops.front().parkingarea == 0) {
1387 errorMsg =
"first stop is not at parkingArea";
1393 for (std::list<MSStop>::iterator iter = ++
myStops.begin(); iter !=
myStops.end();) {
1394 if (iter->parkingarea == parkingArea) {
1395 stopPar.
duration += iter->duration;
1422 return nextParkingArea;
1430 currentParkingArea =
myStops.begin()->parkingarea;
1432 return currentParkingArea;
1461 return myStops.front().duration;
1483 return currentVelocity;
1488 std::cout <<
"\nPROCESS_NEXT_STOP\n" <<
SIMTIME <<
" vehicle '" <<
getID() <<
"'" << std::endl;
1499 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' reached stop.\n"
1520 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' resumes from stopping." << std::endl;
1538 dev->notifyParking();
1545 WRITE_WARNING(
"Vehicle '" +
getID() +
"' ignores triggered stop on lane '" + stop.
lane->
getID() +
"' due to capacity constraints.");
1553 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' registers as waiting for person." << std::endl;
1559 WRITE_WARNING(
"Vehicle '" +
getID() +
"' ignores container triggered stop on lane '" + stop.
lane->
getID() +
"' due to capacity constraints.");
1567 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' registers as waiting for container." << std::endl;
1583 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' hasn't reached next stop." << std::endl;
1591 bool fitsOnStoppingPlace =
true;
1592 if (stop.
busstop !=
nullptr) {
1602 fitsOnStoppingPlace =
false;
1609 if (
myStops.empty() ||
myStops.front().parkingarea != oldParkingArea) {
1611 return currentVelocity;
1614 fitsOnStoppingPlace =
false;
1621 std::cout <<
" pos=" <<
myState.
pos() <<
" speed=" << currentVelocity <<
" targetPos=" << targetPos <<
" fits=" << fitsOnStoppingPlace <<
" reachedThresh=" << reachedThreshold <<
"\n";
1631 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' reached next stop." << std::endl;
1653 if (stop.
busstop !=
nullptr) {
1679 if (splitVeh ==
nullptr) {
1695 return currentVelocity;
1726 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' unregisters as waiting for person." << std::endl;
1739 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' unregisters as waiting for container." << std::endl;
1755 myStops.begin()->joinTriggered =
false;
1793 myStops.begin()->joinTriggered =
false;
1802 if (stop ==
nullptr) {
1806 if (s.busstop == stop
1807 || s.containerstop == stop
1808 || s.parkingarea == stop
1809 || s.chargingStation == stop) {
1819 if (&s.lane->getEdge() == edge) {
1852 if (timeSinceLastAction == 0) {
1854 timeSinceLastAction = oldActionStepLength;
1856 if (timeSinceLastAction >= newActionStepLength) {
1860 SUMOTime timeUntilNextAction = newActionStepLength - timeSinceLastAction;
1869 #ifdef DEBUG_PLAN_MOVE
1875 <<
" veh=" <<
getID()
1890 #ifdef DEBUG_ACTIONSTEPS
1892 std::cout <<
STEPS2TIME(t) <<
" vehicle '" <<
getID() <<
"' skips action." << std::endl;
1900 #ifdef DEBUG_ACTIONSTEPS
1902 std::cout <<
STEPS2TIME(t) <<
" vehicle = '" <<
getID() <<
"' takes action." << std::endl;
1907 #ifdef DEBUG_PLAN_MOVE
1909 DriveItemVector::iterator i;
1912 <<
" vPass=" << (*i).myVLinkPass
1913 <<
" vWait=" << (*i).myVLinkWait
1914 <<
" linkLane=" << ((*i).myLink == 0 ?
"NULL" : (*i).myLink->getViaLaneOrLane()->getID())
1915 <<
" request=" << (*i).mySetRequest
1936 myStopDist = std::numeric_limits<double>::max();
1944 double lateralShift = 0;
1948 laneMaxV =
MIN2(laneMaxV, l->getVehicleMaxSpeed(
this));
1949 #ifdef DEBUG_PLAN_MOVE
1951 std::cout <<
" laneMaxV=" << laneMaxV <<
" lane=" << l->getID() <<
"\n";
1957 laneMaxV =
MAX2(laneMaxV, vMinComfortable);
1959 laneMaxV = std::numeric_limits<double>::max();
1962 double v =
MIN2(maxV, laneMaxV);
1973 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" speedBeforeTraci=" << v;
1979 std::cout <<
" influencedSpeed=" << v;
1985 std::cout <<
" gapControlSpeed=" << v <<
"\n";
1993 #ifdef DEBUG_PLAN_MOVE
1995 std::cout <<
" dist=" << dist <<
" bestLaneConts=" <<
toString(bestLaneConts) <<
"\n";
1998 assert(bestLaneConts.size() > 0);
1999 bool hadNonInternal =
false;
2005 double seenNonInternal = 0;
2010 bool slowedDownForMinor =
false;
2015 #ifdef PARALLEL_STOPWATCH
2019 #pragma warning(push)
2020 #pragma warning(disable: 4127)
2024 #pragma warning(pop)
2035 if (leader.first != 0 && leader.first->getLane() == leaderLane && leader.first->myLaneChangeModel->isOpposite()) {
2039 adaptToLeaders(ahead, lateralShift, seen, lastLink, leaderLane, v, vLinkPass);
2040 if (lastLink !=
nullptr) {
2043 #ifdef DEBUG_PLAN_MOVE
2045 std::cout <<
"\nv = " << v <<
"\n";
2053 if (shadowLane !=
nullptr) {
2057 seen, lastLink, shadowLane, v, vLinkPass);
2062 const double relativePos = lane->
getLength() - seen;
2063 #ifdef DEBUG_PLAN_MOVE
2065 std::cout <<
SIMTIME <<
" adapt to pedestrians on lane=" << lane->
getID() <<
" relPos=" << relativePos <<
"\n";
2070 if (leader.first != 0) {
2072 v =
MIN2(v, stopSpeed);
2073 #ifdef DEBUG_PLAN_MOVE
2075 std::cout <<
SIMTIME <<
" pedLeader=" << leader.first->getID() <<
" dist=" << leader.second <<
" v=" << v <<
"\n";
2089 double endPos = stop.
getEndPos(*
this) + NUMERICAL_EPS;
2093 }
else if (isWaypoint && !stop.
reached) {
2108 myStopDist = std::numeric_limits<double>::max();
2112 if (lastLink !=
nullptr) {
2118 if (lastLink !=
nullptr) {
2122 v =
MIN2(v, stopSpeed);
2124 std::vector<MSLink*>::const_iterator exitLink =
MSLane::succLinkSec(*
this, view + 1, *lane, bestLaneConts);
2126 bool dummySetRequest;
2127 double dummyVLinkWait;
2131 #ifdef DEBUG_PLAN_MOVE
2133 std::cout <<
"\n" <<
SIMTIME <<
" next stop: distance = " <<
myStopDist <<
" requires stopSpeed = " << stopSpeed <<
"\n";
2145 std::vector<MSLink*>::const_iterator link =
MSLane::succLinkSec(*
this, view + 1, *lane, bestLaneConts);
2148 if (!encounteredTurn) {
2158 encounteredTurn =
true;
2159 #ifdef DEBUG_NEXT_TURN
2162 <<
" at " <<
myNextTurn.first <<
"m." << std::endl;
2176 const double va =
MAX2(NUMERICAL_EPS, cfModel.
freeSpeed(
this,
getSpeed(), distToArrival, arrivalSpeed));
2178 if (lastLink !=
nullptr) {
2186 ((*link)->getViaLane() ==
nullptr
2200 if (lastLink !=
nullptr) {
2208 #ifdef DEBUG_PLAN_MOVE
2210 std::cout <<
" braking for link end lane=" << lane->
getID() <<
" seen=" << seen
2216 lfLinks.emplace_back(v, seen);
2220 lateralShift += (*link)->getLateralShift();
2221 const bool yellowOrRed = (*link)->haveRed() || (*link)->haveYellow();
2232 double laneStopOffset;
2236 const bool canBrakeBeforeLaneEnd = seen >= brakeDist;
2237 const bool canBrakeBeforeStopLine = seen - lane->
getStopOffset(
this) >= brakeDist;
2240 laneStopOffset = majorStopOffset;
2241 }
else if ((*link)->havePriority()) {
2243 laneStopOffset =
MIN2((*link)->getFoeVisibilityDistance() - POSITION_EPS, majorStopOffset);
2246 laneStopOffset =
MIN2((*link)->getFoeVisibilityDistance() - POSITION_EPS, minorStopOffset);
2248 if (canBrakeBeforeLaneEnd) {
2250 laneStopOffset =
MIN2(laneStopOffset, seen - brakeDist);
2252 laneStopOffset =
MAX2(POSITION_EPS, laneStopOffset);
2253 double stopDist =
MAX2(0., seen - laneStopOffset);
2254 if (
myStopDist != std::numeric_limits<double>::max()) {
2257 #ifdef DEBUG_PLAN_MOVE
2259 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" effective stopOffset on lane '" << lane->
getID()
2260 <<
"' is " << laneStopOffset <<
" (-> stopDist=" << stopDist <<
")" << std::endl;
2269 v =
MIN2(v, vMustReverse);
2272 bool canReverseEventually =
false;
2273 const double vReverse =
checkReversal(canReverseEventually, laneMaxV, seen);
2274 v =
MIN2(v, vReverse);
2275 #ifdef DEBUG_PLAN_MOVE
2277 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" canReverseEventually=" << canReverseEventually <<
" v=" << v <<
"\n";
2290 assert(timeRemaining != 0);
2293 (seen - POSITION_EPS) / timeRemaining);
2294 #ifdef DEBUG_PLAN_MOVE
2296 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" slowing down to finish continuous change before"
2297 <<
" link=" << (*link)->getViaLaneOrLane()->getID()
2298 <<
" timeRemaining=" << timeRemaining
2311 const bool abortRequestAfterMinor = slowedDownForMinor && (*link)->getInternalLaneBefore() ==
nullptr;
2313 bool setRequest = (v >
NUMERICAL_EPS_SPEED && !abortRequestAfterMinor) || (leavingCurrentIntersection);
2316 #ifdef DEBUG_PLAN_MOVE
2319 <<
" stopDist=" << stopDist
2320 <<
" vLinkWait=" << vLinkWait
2321 <<
" brakeDist=" << brakeDist
2323 <<
" leaveIntersection=" << leavingCurrentIntersection
2324 <<
" setRequest=" << setRequest
2335 if (yellowOrRed && canBrakeBeforeStopLine && !
ignoreRed(*link, canBrakeBeforeStopLine) && !canReverseEventually) {
2344 lfLinks.push_back(
DriveProcessItem(*link, v, vLinkWait,
false, arrivalTime, vLinkWait, arrivalTime +
TIME2STEPS(30), 0, seen));
2349 if (
ignoreRed(*link, canBrakeBeforeStopLine) &&
STEPS2TIME(t - (*link)->getLastStateChange()) > 2) {
2354 #ifdef DEBUG_PLAN_MOVE
2356 <<
" ignoreRed spent=" <<
STEPS2TIME(t - (*link)->getLastStateChange())
2357 <<
" redSpeed=" << redSpeed
2367 if (lastLink !=
nullptr) {
2370 double arrivalSpeed = vLinkPass;
2376 const double visibilityDistance = (*link)->getFoeVisibilityDistance();
2377 const double determinedFoePresence = seen <= visibilityDistance;
2382 #ifdef DEBUG_PLAN_MOVE
2384 std::cout <<
" approaching link=" << (*link)->getViaLaneOrLane()->getID() <<
" prio=" << (*link)->havePriority() <<
" seen=" << seen <<
" visibilityDistance=" << visibilityDistance <<
" brakeDist=" << brakeDist <<
"\n";
2388 const bool couldBrakeForMinor = !(*link)->havePriority() && brakeDist < seen && !(*link)->lastWasContMajor();
2389 if (couldBrakeForMinor && !determinedFoePresence) {
2394 arrivalSpeed =
MIN2(vLinkPass, maxArrivalSpeed);
2395 slowedDownForMinor =
true;
2396 #ifdef DEBUG_PLAN_MOVE
2398 std::cout <<
" slowedDownForMinor maxSpeedAtVisDist=" << maxSpeedAtVisibilityDist <<
" maxArrivalSpeed=" << maxArrivalSpeed <<
" arrivalSpeed=" << arrivalSpeed <<
"\n";
2404 std::pair<const SUMOVehicle*, const MSLink*> blocker = (*link)->getFirstApproachingFoe(*link);
2407 while (blocker.second !=
nullptr && blocker.second != *link && n > 0) {
2408 blocker = blocker.second->getFirstApproachingFoe(*link);
2416 if (blocker.second == *link) {
2424 if (couldBrakeForMinor && (*link)->getLane()->getEdge().isRoundabout()) {
2425 slowedDownForMinor =
true;
2426 #ifdef DEBUG_PLAN_MOVE
2428 std::cout <<
" slowedDownForMinor at roundabout\n";
2448 double arrivalSpeedBraking = 0;
2455 arrivalSpeedBraking =
MIN2(arrivalSpeedBraking, arrivalSpeed);
2459 if (v + arrivalSpeedBraking <= 0.) {
2460 arrivalTimeBraking = std::numeric_limits<long long int>::max();
2462 arrivalTimeBraking =
MAX2(arrivalTime, t +
TIME2STEPS(seen / ((v + arrivalSpeedBraking) * 0.5)));
2466 arrivalTime, arrivalSpeed,
2467 arrivalTimeBraking, arrivalSpeedBraking,
2470 if ((*link)->getViaLane() ==
nullptr) {
2471 hadNonInternal =
true;
2474 #ifdef DEBUG_PLAN_MOVE
2476 std::cout <<
" checkAbort setRequest=" << setRequest <<
" v=" << v <<
" seen=" << seen <<
" dist=" << dist
2477 <<
" seenNonInternal=" << seenNonInternal
2478 <<
" seenInternal=" << seenInternal <<
" length=" << vehicleLength <<
"\n";
2482 if ((!setRequest || v <= 0 || seen > dist) && hadNonInternal && seenNonInternal >
MAX2(vehicleLength *
CRLL_LOOK_AHEAD, vehicleLength + seenInternal)) {
2486 lane = (*link)->getViaLaneOrLane();
2489 laneMaxV = std::numeric_limits<double>::max();
2503 leaderLane = opposite ? lane->
getOpposite() : lane;
2504 if (leaderLane ==
nullptr) {
2510 lastLink = &lfLinks.back();
2519 #ifdef PARALLEL_STOPWATCH
2528 const MSLane*
const lane,
double& v,
double& vLinkPass)
const {
2531 ahead.
getSubLanes(
this, latOffset, rightmost, leftmost);
2532 #ifdef DEBUG_PLAN_MOVE
2534 <<
"\nADAPT_TO_LEADERS\nveh=" <<
getID()
2535 <<
" lane=" << lane->
getID()
2536 <<
" latOffset=" << latOffset
2537 <<
" rm=" << rightmost
2538 <<
" lm=" << leftmost
2552 for (
int sublane = rightmost; sublane <= leftmost; ++sublane) {
2554 if (pred !=
nullptr && pred !=
this) {
2557 double gap = (lastLink ==
nullptr
2563 #ifdef DEBUG_PLAN_MOVE
2565 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";
2568 adaptToLeader(std::make_pair(pred, gap), seen, lastLink, lane, v, vLinkPass);
2577 const MSLane*
const lane,
double& v,
double& vLinkPass,
2578 double distToCrossing)
const {
2579 if (leaderInfo.first != 0) {
2580 const double vsafeLeader =
getSafeFollowSpeed(leaderInfo, seen, lane, distToCrossing);
2581 if (lastLink !=
nullptr) {
2584 v =
MIN2(v, vsafeLeader);
2585 vLinkPass =
MIN2(vLinkPass, vsafeLeader);
2587 #ifdef DEBUG_PLAN_MOVE
2591 <<
" veh=" <<
getID()
2592 <<
" lead=" << leaderInfo.first->getID()
2593 <<
" leadSpeed=" << leaderInfo.first->getSpeed()
2594 <<
" gap=" << leaderInfo.second
2595 <<
" leadLane=" << leaderInfo.first->getLane()->getID()
2596 <<
" predPos=" << leaderInfo.first->getPositionOnLane()
2598 <<
" lane=" << lane->
getID()
2600 <<
" dTC=" << distToCrossing
2602 <<
" vSafeLeader=" << vsafeLeader
2603 <<
" vLinkPass=" << vLinkPass
2612 DriveProcessItem*
const lastLink,
double& v,
double& vLinkPass,
double& vLinkWait,
bool& setRequest)
const {
2615 checkLinkLeader(link, lane, seen, lastLink, v, vLinkPass, vLinkWait, setRequest);
2618 if (parallelLink !=
nullptr) {
2619 checkLinkLeader(parallelLink, lane, seen, lastLink, v, vLinkPass, vLinkWait, setRequest,
true);
2628 DriveProcessItem*
const lastLink,
double& v,
double& vLinkPass,
double& vLinkWait,
bool& setRequest,
2629 bool isShadowLink)
const {
2630 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
2636 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
2641 for (MSLink::LinkLeaders::const_iterator it = linkLeaders.begin(); it != linkLeaders.end(); ++it) {
2643 const MSVehicle* leader = (*it).vehAndGap.first;
2644 if (leader ==
nullptr) {
2646 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
2648 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" is blocked on link to " << link->
getViaLaneOrLane()->
getID() <<
" by pedestrian. dist=" << it->distToCrossing <<
"\n";
2651 adaptToLeader(std::make_pair(
this, -1), seen, lastLink, lane, v, vLinkPass, it->distToCrossing);
2652 }
else if (
isLeader(link, leader) || (*it).inTheWay) {
2659 linkLeadersAhead.
addLeader(leader,
false, 0);
2663 #ifdef DEBUG_PLAN_MOVE
2667 <<
" isShadowLink=" << isShadowLink
2668 <<
" lane=" << lane->
getID()
2669 <<
" foe=" << leader->
getID()
2671 <<
" latOffset=" << latOffset
2673 <<
" linkLeadersAhead=" << linkLeadersAhead.
toString()
2678 #ifdef DEBUG_PLAN_MOVE
2687 adaptToLeader(it->vehAndGap, seen, lastLink, lane, v, vLinkPass, it->distToCrossing);
2689 if (lastLink !=
nullptr) {
2703 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
2705 std::cout <<
" aborting request\n";
2712 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
2714 std::cout <<
" aborting previous request\n";
2720 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
2723 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" ignoring leader " << leader->
getID()
2733 vLinkWait =
MIN2(vLinkWait, v);
2739 const double seen,
const MSLane*
const lane,
double distToCrossing)
const {
2740 assert(leaderInfo.first != 0);
2742 double vsafeLeader = 0;
2744 vsafeLeader = -std::numeric_limits<double>::max();
2746 if (leaderInfo.second >= 0) {
2747 vsafeLeader = cfModel.
followSpeed(
this,
getSpeed(), leaderInfo.second, leaderInfo.first->getSpeed(), leaderInfo.first->getCurrentApparentDecel(), leaderInfo.first);
2752 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
2754 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" stopping before junction: lane=" << lane->
getID() <<
" seen=" << seen
2756 <<
" stopDist=" << seen - lane->
getLength() - POSITION_EPS
2757 <<
" vsafeLeader=" << vsafeLeader
2758 <<
" distToCrossing=" << distToCrossing
2763 if (distToCrossing >= 0) {
2766 if (leaderInfo.first ==
this) {
2768 vsafeLeader = vStop;
2769 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
2771 std::cout <<
" breaking for pedestrian distToCrossing=" << distToCrossing <<
" vStop=" << vStop <<
"\n";
2774 }
else if (leaderInfo.second == -std::numeric_limits<double>::max()) {
2776 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
2778 std::cout <<
" stop at crossing point for critical leader\n";
2781 vsafeLeader =
MAX2(vsafeLeader, vStop);
2783 const double leaderBrakeGap = leaderInfo.first->getCarFollowModel().brakeGap(leaderInfo.first->getSpeed(), leaderInfo.first->getCarFollowModel().getMaxDecel(), 0);
2784 const double leaderDistToCrossing = distToCrossing - leaderInfo.second;
2785 const bool leaderClear = leaderDistToCrossing < leaderBrakeGap;
2786 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
2788 std::cout <<
" leaderDistToCrossing=" << leaderDistToCrossing <<
" leaderBrakeGap=" << leaderBrakeGap <<
" leaderClear=" << leaderClear <<
"\n";
2801 vsafeLeader =
MAX2(vsafeLeader,
MIN2(v2, vStop));
2802 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
2804 std::cout <<
" driving up to the crossing point (distToCrossing=" << distToCrossing <<
")"
2805 <<
" leaderPastCPTime=" << leaderPastCPTime
2806 <<
" vFinal=" << vFinal
2808 <<
" vStop=" << vStop
2809 <<
" vsafeLeader=" << vsafeLeader <<
"\n";
2844 double vSafeZipper = std::numeric_limits<double>::max();
2847 bool canBrakeVSafeMin =
false;
2852 MSLink*
const link = dpi.myLink;
2854 #ifdef DEBUG_EXEC_MOVE
2858 <<
" veh=" <<
getID()
2860 <<
" req=" << dpi.mySetRequest
2861 <<
" vP=" << dpi.myVLinkPass
2862 <<
" vW=" << dpi.myVLinkWait
2863 <<
" d=" << dpi.myDistance
2870 if (link !=
nullptr && dpi.mySetRequest) {
2879 const bool ignoreRedLink =
ignoreRed(link, canBrake) || beyondStopLine;
2880 if (yellow && canBrake && !ignoreRedLink) {
2881 vSafe = dpi.myVLinkWait;
2883 #ifdef DEBUG_CHECKREWINDLINKLANES
2885 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (yellow)\n";
2892 bool opened = (yellow || influencerPrio
2893 || link->
opened(dpi.myArrivalTime, dpi.myArrivalSpeed, dpi.getLeaveSpeed(),
2899 ignoreRedLink,
this));
2902 if (parallelLink !=
nullptr) {
2905 opened = yellow || influencerPrio || (opened && parallelLink->
opened(dpi.myArrivalTime, dpi.myArrivalSpeed, dpi.getLeaveSpeed(),
2909 ignoreRedLink,
this));
2910 #ifdef DEBUG_EXEC_MOVE
2913 <<
" veh=" <<
getID()
2917 <<
" opened=" << opened
2924 #ifdef DEBUG_EXEC_MOVE
2927 <<
" opened=" << opened
2928 <<
" influencerPrio=" << influencerPrio
2931 <<
" isCont=" << link->
isCont()
2932 <<
" ignoreRed=" << ignoreRedLink
2938 double determinedFoePresence = dpi.myDistance <= visibilityDistance;
2939 if (!determinedFoePresence && (canBrake || !yellow)) {
2940 vSafe = dpi.myVLinkWait;
2942 #ifdef DEBUG_CHECKREWINDLINKLANES
2944 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (minor)\n";
2960 vSafeMinDist = dpi.myDistance;
2962 vSafeMin =
MIN2((
double)
DIST2SPEED(vSafeMinDist + POSITION_EPS), dpi.myVLinkPass);
2966 canBrakeVSafeMin = canBrake;
2967 #ifdef DEBUG_EXEC_MOVE
2969 std::cout <<
" vSafeMin=" << vSafeMin <<
" vSafeMinDist=" << vSafeMinDist <<
" canBrake=" << canBrake <<
"\n";
2976 vSafe = dpi.myVLinkPass;
2980 #ifdef DEBUG_CHECKREWINDLINKLANES
2982 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (very slow)\n";
2987 vSafeZipper =
MIN2(vSafeZipper,
2988 link->
getZipperSpeed(
this, dpi.myDistance, dpi.myVLinkPass, dpi.myArrivalTime, &collectFoes));
2990 vSafe = dpi.myVLinkWait;
2992 #ifdef DEBUG_CHECKREWINDLINKLANES
2994 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (closed)\n";
2997 #ifdef DEBUG_EXEC_MOVE
3008 #ifdef DEBUG_EXEC_MOVE
3010 std::cout <<
SIMTIME <<
" reseting junctionEntryTime at junction '" << link->
getJunction()->
getID() <<
"' beause of non-request exitLink\n";
3017 vSafe = dpi.myVLinkWait;
3020 #ifdef DEBUG_CHECKREWINDLINKLANES
3022 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (no request, braking)\n";
3027 #ifdef DEBUG_CHECKREWINDLINKLANES
3029 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (no request, stopping)\n";
3055 #ifdef DEBUG_EXEC_MOVE
3057 std::cout <<
"vSafeMin Problem? vSafe=" << vSafe <<
" vSafeMin=" << vSafeMin <<
" vSafeMinDist=" << vSafeMinDist << std::endl;
3060 if (canBrakeVSafeMin && vSafe <
getSpeed()) {
3065 #ifdef DEBUG_CHECKREWINDLINKLANES
3067 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (vSafe=" << vSafe <<
" < vSafeMin=" << vSafeMin <<
")\n";
3085 vSafe =
MIN2(vSafe, vSafeZipper);
3094 std::cout <<
SIMTIME <<
" MSVehicle::processTraCISpeedControl() for vehicle '" <<
getID() <<
"'"
3095 <<
" vSafe=" << vSafe <<
" (init)vNext=" << vNext;
3104 vMin =
MAX2(0., vMin);
3109 std::cout <<
" (processed)vNext=" << vNext << std::endl;
3119 #ifdef DEBUG_ACTIONSTEPS
3121 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" removePassedDriveItems()\n"
3122 <<
" Current items: ";
3124 if (j.myLink == 0) {
3125 std::cout <<
"\n Stop at distance " << j.myDistance;
3127 const MSLane* to = j.myLink->getViaLaneOrLane();
3128 const MSLane* from = j.myLink->getLaneBefore();
3129 std::cout <<
"\n Link at distance " << j.myDistance <<
": '"
3130 << (from == 0 ?
"NONE" : from->
getID()) <<
"' -> '" << (to == 0 ?
"NONE" : to->
getID()) <<
"'";
3133 std::cout <<
"\n myNextDriveItem: ";
3140 std::cout <<
"\n Link at distance " <<
myNextDriveItem->myDistance <<
": '"
3141 << (from == 0 ?
"NONE" : from->
getID()) <<
"' -> '" << (to == 0 ?
"NONE" : to->
getID()) <<
"'";
3144 std::cout << std::endl;
3148 #ifdef DEBUG_ACTIONSTEPS
3150 std::cout <<
" Removing item: ";
3151 if (j->myLink == 0) {
3152 std::cout <<
"Stop at distance " << j->myDistance;
3154 const MSLane* to = j->myLink->getViaLaneOrLane();
3155 const MSLane* from = j->myLink->getLaneBefore();
3156 std::cout <<
"Link at distance " << j->myDistance <<
": '"
3157 << (from == 0 ?
"NONE" : from->
getID()) <<
"' -> '" << (to == 0 ?
"NONE" : to->
getID()) <<
"'";
3159 std::cout << std::endl;
3162 if (j->myLink !=
nullptr) {
3163 j->myLink->removeApproaching(
this);
3173 #ifdef DEBUG_ACTIONSTEPS
3175 std::cout <<
SIMTIME <<
" updateDriveItems(), veh='" <<
getID() <<
"' (lane: '" <<
getLane()->
getID() <<
"')\nCurrent drive items:" << std::endl;
3176 DriveItemVector::iterator i;
3179 <<
" vPass=" << dpi.myVLinkPass
3180 <<
" vWait=" << dpi.myVLinkWait
3181 <<
" linkLane=" << (dpi.myLink == 0 ?
"NULL" : dpi.myLink->getViaLaneOrLane()->getID())
3182 <<
" request=" << dpi.mySetRequest
3185 std::cout <<
" myNextDriveItem's linked lane: " << (
myNextDriveItem->myLink == 0 ?
"NULL" :
myNextDriveItem->myLink->getViaLaneOrLane()->getID()) << std::endl;
3192 const MSLink* nextPlannedLink =
nullptr;
3195 while (i !=
myLFLinkLanes.end() && nextPlannedLink ==
nullptr) {
3196 nextPlannedLink = i->myLink;
3200 if (nextPlannedLink ==
nullptr) {
3202 #ifdef DEBUG_ACTIONSTEPS
3204 std::cout <<
"Found no link-related drive item." << std::endl;
3212 #ifdef DEBUG_ACTIONSTEPS
3214 std::cout <<
"Continuing on planned lane sequence, no update required." << std::endl;
3236 #ifdef DEBUG_ACTIONSTEPS
3238 std::cout <<
"Changed lane. Drive items will be updated along the current lane continuation." << std::endl;
3250 MSLink* newLink =
nullptr;
3252 if (driveItemIt->myLink ==
nullptr) {
3262 #ifdef DEBUG_ACTIONSTEPS
3264 std::cout <<
"Reached end of the new continuation sequence. Erasing leftover link-items." << std::endl;
3268 if (driveItemIt->myLink ==
nullptr) {
3279 const MSLane*
const target = *bestLaneIt;
3283 if (link->getLane() == target) {
3289 if (newLink == driveItemIt->myLink) {
3291 #ifdef DEBUG_ACTIONSTEPS
3293 std::cout <<
"Old and new continuation sequences merge at link\n"
3295 <<
"\nNo update beyond merge required." << std::endl;
3301 #ifdef DEBUG_ACTIONSTEPS
3303 std::cout <<
"lane=" << lane->
getID() <<
"\nUpdating link\n '" << driveItemIt->myLink->getLaneBefore()->getID() <<
"'->'" << driveItemIt->myLink->getViaLaneOrLane()->getID() <<
"'"
3307 newLink->
setApproaching(
this, driveItemIt->myLink->getApproaching(
this));
3308 driveItemIt->myLink->removeApproaching(
this);
3309 driveItemIt->myLink = newLink;
3316 #ifdef DEBUG_ACTIONSTEPS
3318 std::cout <<
"Updated drive items:" << std::endl;
3319 DriveItemVector::iterator i;
3322 <<
" vPass=" << dpi.myVLinkPass
3323 <<
" vWait=" << dpi.myVLinkWait
3324 <<
" linkLane=" << (dpi.myLink == 0 ?
"NULL" : dpi.myLink->getViaLaneOrLane()->getID())
3325 <<
" request=" << dpi.mySetRequest
3342 brakelightsOn =
true;
3378 #ifdef DEBUG_REVERSE_BIDI
3382 <<
" speedThreshold=" << speedThreshold
3405 #ifdef DEBUG_REVERSE_BIDI
3417 #ifdef DEBUG_REVERSE_BIDI
3428 const double stopPos =
myStops.front().getEndPos(*
this);
3431 if (newPos > stopPos) {
3432 #ifdef DEBUG_REVERSE_BIDI
3437 if (seen >
MAX2(brakeDist, 1.0)) {
3440 #ifdef DEBUG_REVERSE_BIDI
3442 std::cout <<
" train is too long, skipping stop at " << stopPos <<
" cannot be avoided\n";
3453 if (!further->getEdge().isInternal()) {
3454 if (further->getEdge().getBidiEdge() != *(
myCurrEdge + view)) {
3455 #ifdef DEBUG_REVERSE_BIDI
3457 std::cout <<
" noBidi view=" << view <<
" further=" << further->getID() <<
" furtherBidi=" <<
Named::getIDSecure(further->getEdge().getBidiEdge()) <<
" future=" << (*(
myCurrEdge + view))->getID() <<
"\n";
3464 const double stopPos =
myStops.front().getEndPos(*
this);
3466 if (newPos > stopPos) {
3467 #ifdef DEBUG_REVERSE_BIDI
3469 std::cout <<
" reversal would go past stop on further-opposite lane " << further->getBidiLane()->getID() <<
"\n";
3472 if (seen >
MAX2(brakeDist, 1.0)) {
3476 #ifdef DEBUG_REVERSE_BIDI
3478 std::cout <<
" train is too long, skipping stop at " << stopPos <<
" cannot be avoided\n";
3489 #ifdef DEBUG_REVERSE_BIDI
3491 std::cout <<
SIMTIME <<
" seen=" << seen <<
" vReverseOK=" << vMinComfortable <<
"\n";
3495 return vMinComfortable;
3504 passedLanes.push_back(*i);
3506 if (passedLanes.size() == 0 || passedLanes.back() !=
myLane) {
3507 passedLanes.push_back(
myLane);
3510 bool reverseTrain =
false;
3516 #ifdef DEBUG_REVERSE_BIDI
3541 if (link !=
nullptr) {
3547 emergencyReason =
" because it must reverse direction";
3548 approachedLane =
nullptr;
3564 if (link->
haveRed() && !
ignoreRed(link,
false) && !beyondStopLine && !reverseTrain) {
3565 emergencyReason =
" because of a red traffic light";
3569 if (reverseTrain && approachedLane->
isInternal()) {
3577 }
else if (reverseTrain) {
3578 approachedLane = (*(
myCurrEdge + 1))->getLanes()[0];
3586 emergencyReason =
" because there is no connection to the next edge";
3587 approachedLane =
nullptr;
3590 if (approachedLane !=
myLane && approachedLane !=
nullptr) {
3608 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
3624 WRITE_WARNING(
"Vehicle '" +
getID() +
"' could not finish continuous lane change (turn lane) time=" +
3633 passedLanes.push_back(approachedLane);
3638 #ifdef DEBUG_ACTIONSTEPS
3640 std::cout <<
"Updated drive items:" << std::endl;
3643 <<
" vPass=" << (*i).myVLinkPass
3644 <<
" vWait=" << (*i).myVLinkWait
3645 <<
" linkLane=" << ((*i).myLink == 0 ?
"NULL" : (*i).myLink->getViaLaneOrLane()->getID())
3646 <<
" request=" << (*i).mySetRequest
3663 #ifdef DEBUG_EXEC_MOVE
3665 std::cout <<
"\nEXECUTE_MOVE\n"
3667 <<
" veh=" <<
getID()
3675 double vSafe = std::numeric_limits<double>::max();
3677 double vSafeMin = -std::numeric_limits<double>::max();
3680 double vSafeMinDist = 0;
3685 #ifdef DEBUG_ACTIONSTEPS
3687 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"'\n"
3688 " vsafe from processLinkApproaches(): vsafe " << vSafe << std::endl;
3694 #ifdef DEBUG_ACTIONSTEPS
3696 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' skips processLinkApproaches()\n"
3698 <<
"speed: " <<
getSpeed() <<
" -> " << vSafe << std::endl;
3712 double vNext = vSafe;
3716 vNext =
MAX2(vNext, vSafeMin);
3724 #ifdef DEBUG_EXEC_MOVE
3726 std::cout <<
SIMTIME <<
" finalizeSpeed vSafe=" << vSafe <<
" vSafeMin=" << (vSafeMin == -std::numeric_limits<double>::max() ?
"-Inf" :
toString(vSafeMin))
3727 <<
" vNext=" << vNext <<
" (i.e. accel=" <<
SPEED2ACCEL(vNext -
getSpeed()) <<
")" << std::endl;
3744 vNext =
MAX2(vNext, 0.);
3754 if (elecHybridOfVehicle !=
nullptr) {
3755 elecHybridOfVehicle->
setConsum(elecHybridOfVehicle->
consumption(*
this, (vNext - this->getSpeed()) /
TS, vNext));
3757 if (elecHybridOfVehicle->
getConsum() > maxPower) {
3760 vNext =
MAX2(vNext, 0.);
3761 elecHybridOfVehicle->
setConsum(elecHybridOfVehicle->
consumption(*
this, (vNext - this->getSpeed()) /
TS, vNext));
3772 std::vector<MSLane*> passedLanes;
3776 std::string emergencyReason =
" for unknown reasons";
3785 +
"'" + emergencyReason
3797 passedLanes.clear();
3799 #ifdef DEBUG_ACTIONSTEPS
3801 std::cout <<
SIMTIME <<
" veh '" <<
getID() <<
"' updates further lanes." << std::endl;
3828 #ifdef DEBUG_ACTIONSTEPS
3830 std::cout <<
SIMTIME <<
" veh '" <<
getID() <<
"' skips LCM->prepareStep()." << std::endl;
3837 #ifdef DEBUG_EXEC_MOVE
3857 return myLane != oldLane;
3869 for (
int i = 0; i < (int)lanes.size(); i++) {
3871 if (i + 1 < (
int)lanes.size()) {
3872 const MSLane*
const to = lanes[i + 1];
3874 for (
MSLink*
const l : lanes[i]->getLinkCont()) {
3875 if ((
internal && l->getViaLane() == to) || (!
internal && l->getLane() == to)) {
3884 std::vector<MSLane*> passedLanes;
3886 std::string emergencyReason =
" for unknown reasons";
3887 if (lanes.size() > 1) {
3892 if (lanes.size() > 1) {
3914 #ifdef DEBUG_EXEC_MOVE
3916 std::cout <<
SIMTIME <<
" updateState() for veh '" <<
getID() <<
"': deltaPos=" << deltaPos
3921 if (decelPlus > 0) {
3925 decelPlus += 2 * NUMERICAL_EPS;
3931 +
" severity=" +
toString(emergencyFraction)
3976 const std::vector<MSLane*>& passedLanes) {
3977 #ifdef DEBUG_SETFURTHER
3979 <<
" updateFurtherLanes oldFurther=" <<
toString(furtherLanes)
3980 <<
" oldFurtherPosLat=" <<
toString(furtherLanesPosLat)
3981 <<
" passed=" <<
toString(passedLanes)
3984 for (std::vector<MSLane*>::iterator i = furtherLanes.begin(); i != furtherLanes.end(); ++i) {
3985 (*i)->resetPartialOccupation(
this);
3988 std::vector<MSLane*> newFurther;
3989 std::vector<double> newFurtherPosLat;
3992 if (passedLanes.size() > 1) {
3994 std::vector<MSLane*>::const_iterator fi = furtherLanes.begin();
3995 std::vector<double>::const_iterator fpi = furtherLanesPosLat.begin();
3996 for (
auto pi = passedLanes.rbegin() + 1; pi != passedLanes.rend() && backPosOnPreviousLane < 0; ++pi) {
3998 newFurther.push_back(*pi);
3999 backPosOnPreviousLane += (*pi)->setPartialOccupation(
this);
4000 if (fi != furtherLanes.end() && *pi == *fi) {
4002 newFurtherPosLat.push_back(*fpi);
4010 if (newFurtherPosLat.size() == 0) {
4017 newFurtherPosLat.push_back(newFurtherPosLat.back());
4020 #ifdef DEBUG_SETFURTHER
4022 std::cout <<
SIMTIME <<
" updateFurtherLanes \n"
4023 <<
" further lane '" << (*pi)->getID() <<
"' backPosOnPreviousLane=" << backPosOnPreviousLane
4028 furtherLanes = newFurther;
4029 furtherLanesPosLat = newFurtherPosLat;
4031 furtherLanes.clear();
4032 furtherLanesPosLat.clear();
4034 #ifdef DEBUG_SETFURTHER
4036 <<
" newFurther=" <<
toString(furtherLanes)
4037 <<
" newFurtherPosLat=" <<
toString(furtherLanesPosLat)
4038 <<
" newBackPos=" << backPosOnPreviousLane
4041 return backPosOnPreviousLane;
4047 #ifdef DEBUG_FURTHER
4050 <<
" getBackPositionOnLane veh=" <<
getID()
4081 leftLength -= (*i)->getLength();
4092 leftLength -= (*i)->getLength();
4103 auto j = furtherTargetLanes.begin();
4104 while (leftLength > 0 && j != furtherTargetLanes.end()) {
4105 leftLength -= (*i)->getLength();
4116 #pragma warning(push)
4117 #pragma warning(disable: 4127)
4121 #pragma warning(pop)
4144 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
4150 foundStopped =
true;
4156 lengths += (*i)->getVehicleType().getLengthWithGap();
4166 double seenSpace = -lengthsInFront;
4167 #ifdef DEBUG_CHECKREWINDLINKLANES
4169 std::cout <<
"\nCHECK_REWIND_LINKLANES\n" <<
" veh=" <<
getID() <<
" lengthsInFront=" << lengthsInFront <<
"\n";
4172 bool foundStopped =
false;
4175 for (
int i = 0; i < (int)lfLinks.size(); ++i) {
4178 #ifdef DEBUG_CHECKREWINDLINKLANES
4181 <<
" foundStopped=" << foundStopped;
4183 if (item.
myLink ==
nullptr || foundStopped) {
4184 if (!foundStopped) {
4189 #ifdef DEBUG_CHECKREWINDLINKLANES
4198 if (approachedLane !=
nullptr) {
4201 if (approachedLane ==
myLane) {
4208 #ifdef DEBUG_CHECKREWINDLINKLANES
4210 <<
" approached=" << approachedLane->
getID()
4213 <<
" seenSpace=" << seenSpace
4215 <<
" lengthsInFront=" << lengthsInFront
4222 if (last ==
nullptr || last ==
this) {
4225 seenSpace += approachedLane->
getLength();
4228 #ifdef DEBUG_CHECKREWINDLINKLANES
4234 bool foundStopped2 =
false;
4236 seenSpace += spaceTillLastStanding;
4237 if (foundStopped2) {
4238 foundStopped =
true;
4243 foundStopped =
true;
4246 #ifdef DEBUG_CHECKREWINDLINKLANES
4248 <<
" approached=" << approachedLane->
getID()
4249 <<
" last=" << last->
getID()
4256 <<
" stls=" << spaceTillLastStanding
4258 <<
" seenSpace=" << seenSpace
4259 <<
" foundStopped=" << foundStopped
4260 <<
" foundStopped2=" << foundStopped2
4267 for (
int i = ((
int)lfLinks.size() - 1); i > 0; --i) {
4271 const bool opened = (item.
myLink !=
nullptr
4272 && (canLeaveJunction || (
4283 #ifdef DEBUG_CHECKREWINDLINKLANES
4286 <<
" canLeave=" << canLeaveJunction
4287 <<
" opened=" << opened
4288 <<
" allowsContinuation=" << allowsContinuation
4289 <<
" foundStopped=" << foundStopped
4292 if (!opened && item.
myLink !=
nullptr) {
4293 foundStopped =
true;
4297 allowsContinuation =
true;
4301 if (allowsContinuation) {
4303 #ifdef DEBUG_CHECKREWINDLINKLANES
4313 int removalBegin = -1;
4314 for (
int i = 0; foundStopped && i < (int)lfLinks.size() && removalBegin < 0; ++i) {
4317 if (item.
myLink ==
nullptr) {
4328 #ifdef DEBUG_CHECKREWINDLINKLANES
4331 <<
" veh=" <<
getID()
4334 <<
" leftSpace=" << leftSpace
4337 if (leftSpace < 0/* && item.myLink->willHaveBlockedFoe()*/) {
4338 double impatienceCorrection = 0;
4345 if (leftSpace < -impatienceCorrection / 10. &&
keepClear(item.
myLink)) {
4353 while (removalBegin < (
int)(lfLinks.size())) {
4355 lfLinks[removalBegin].myVLinkPass = lfLinks[removalBegin].myVLinkWait;
4356 #ifdef DEBUG_CHECKREWINDLINKLANES
4358 std::cout <<
" removalBegin=" << removalBegin <<
" brakeGap=" << brakeGap <<
" dist=" << lfLinks[removalBegin].myDistance <<
" speed=" <<
myState.
mySpeed <<
" a2s=" <<
ACCEL2SPEED(
getCarFollowModel().getMaxDecel()) <<
"\n";
4362 lfLinks[removalBegin].mySetRequest =
false;
4378 if (dpi.myLink !=
nullptr) {
4382 dpi.myLink->setApproaching(
this, dpi.myArrivalTime, dpi.myArrivalSpeed, dpi.getLeaveSpeed(),
4383 dpi.mySetRequest, dpi.myArrivalTimeBraking, dpi.myArrivalSpeedBraking,
getWaitingTime(), dpi.myDistance);
4389 if (dpi.myLink !=
nullptr) {
4391 if (parallelLink !=
nullptr) {
4392 parallelLink->
setApproaching(
this, dpi.myArrivalTime, dpi.myArrivalSpeed, dpi.getLeaveSpeed(),
4393 dpi.mySetRequest, dpi.myArrivalTimeBraking, dpi.myArrivalSpeedBraking,
getWaitingTime(), dpi.myDistance);
4399 #ifdef DEBUG_PLAN_MOVE
4402 <<
" veh=" <<
getID()
4403 <<
" after checkRewindLinkLanes\n";
4406 <<
" vPass=" << dpi.myVLinkPass
4407 <<
" vWait=" << dpi.myVLinkWait
4408 <<
" linkLane=" << (dpi.myLink == 0 ?
"NULL" : dpi.myLink->getViaLaneOrLane()->getID())
4409 <<
" request=" << dpi.mySetRequest
4410 <<
" atime=" << dpi.myArrivalTime
4411 <<
" atimeB=" << dpi.myArrivalTimeBraking
4422 if (rem->first->getLane() !=
nullptr && rem->second > 0.) {
4424 if (myTraceMoveReminders) {
4425 traceMoveReminder(
"notifyEnter_skipped", rem->first, rem->second,
true);
4430 if (rem->first->notifyEnter(*
this, reason, enteredLane)) {
4432 if (myTraceMoveReminders) {
4433 traceMoveReminder(
"notifyEnter", rem->first, rem->second,
true);
4439 if (myTraceMoveReminders) {
4440 traceMoveReminder(
"notifyEnter", rem->first, rem->second,
false);
4477 if (!onTeleporting) {
4481 assert(oldLane !=
nullptr);
4483 if (link !=
nullptr) {
4520 if (lane !=
nullptr) {
4523 if (lane !=
nullptr) {
4524 #ifdef DEBUG_SETFURTHER
4526 std::cout <<
SIMTIME <<
" enterLaneAtLaneChange \n";
4532 #ifdef DEBUG_SETFURTHER
4534 std::cout <<
SIMTIME <<
" enterLaneAtLaneChange \n";
4537 leftLength -= (lane)->setPartialOccupation(
this);
4545 #ifdef DEBUG_SETFURTHER
4578 MSLane* clane = enteredLane;
4580 while (leftLength > 0) {
4588 if (ili.lane->getEdge().getNormalBefore() == fromRouteEdge) {
4604 leftLength -= (clane)->setPartialOccupation(
this);
4610 #ifdef DEBUG_FURTHER
4612 std::cout <<
SIMTIME <<
" enterLaneAtInsertion \n";
4615 (*i)->resetPartialOccupation(
this);
4636 if (rem->first->notifyLeave(*
this,
myState.
myPos + rem->second, reason, approachedLane)) {
4638 if (myTraceMoveReminders) {
4639 traceMoveReminder(
"notifyLeave", rem->first, rem->second,
true);
4645 if (myTraceMoveReminders) {
4646 traceMoveReminder(
"notifyLeave", rem->first, rem->second,
false);
4659 #ifdef DEBUG_FURTHER
4661 std::cout <<
SIMTIME <<
" leaveLane \n";
4664 (*i)->resetPartialOccupation(
this);
4678 if (
myStops.front().pars.speed <= 0) {
4684 if (!
myStops.front().reached) {
4688 myStops.front().reached =
true;
4692 myStopDist = std::numeric_limits<double>::max();
4710 const std::vector<MSVehicle::LaneQ>&
4718 #ifdef DEBUG_BESTLANES
4723 if (startLane ==
nullptr) {
4726 assert(startLane != 0);
4731 bool startLaneIsOpposite = (startLane->
isInternal()
4734 if (startLaneIsOpposite) {
4736 assert(startLane != 0);
4741 #ifdef DEBUG_BESTLANES
4743 std::cout <<
" only updateOccupancyAndCurrentBestLane\n";
4754 #ifdef DEBUG_BESTLANES
4756 std::cout <<
" nothing to do on internal\n";
4766 std::vector<LaneQ>& lanes = *it;
4767 assert(lanes.size() > 0);
4768 if (&(lanes[0].lane->getEdge()) == nextEdge) {
4770 std::vector<LaneQ> oldLanes = lanes;
4772 const std::vector<MSLane*>& sourceLanes = startLane->
getEdge().
getLanes();
4773 for (std::vector<MSLane*>::const_iterator it_source = sourceLanes.begin(); it_source != sourceLanes.end(); ++it_source) {
4774 for (std::vector<LaneQ>::iterator it_lane = oldLanes.begin(); it_lane != oldLanes.end(); ++it_lane) {
4775 if ((*it_source)->getLinkCont()[0]->getLane() == (*it_lane).lane) {
4776 lanes.push_back(*it_lane);
4783 for (
int i = 0; i < (int)lanes.size(); ++i) {
4784 if (i + lanes[i].bestLaneOffset < 0) {
4785 lanes[i].bestLaneOffset = -i;
4787 if (i + lanes[i].bestLaneOffset >= (
int)lanes.size()) {
4788 lanes[i].bestLaneOffset = (int)lanes.size() - i - 1;
4790 assert(i + lanes[i].bestLaneOffset >= 0);
4791 assert(i + lanes[i].bestLaneOffset < (
int)lanes.size());
4792 if (lanes[i].bestContinuations[0] != 0) {
4794 lanes[i].bestContinuations.insert(lanes[i].bestContinuations.begin(), (
MSLane*)
nullptr);
4796 if (startLane->
getLinkCont()[0]->getLane() == lanes[i].lane) {
4799 assert(&(lanes[i].lane->getEdge()) == nextEdge);
4803 #ifdef DEBUG_BESTLANES
4805 std::cout <<
" updated for internal\n";
4822 const MSLane* nextStopLane =
nullptr;
4823 double nextStopPos = 0;
4824 bool nextStopIsWaypoint =
false;
4827 nextStopLane = nextStop.
lane;
4828 nextStopEdge = nextStop.
edge;
4830 nextStopIsWaypoint = nextStop.
pars.
speed > 0;
4840 nextStopPos =
MAX2(POSITION_EPS,
MIN2((
double)nextStopPos, (
double)(nextStopLane->
getLength() - 2 * POSITION_EPS)));
4843 nextStopPos = (*nextStopEdge)->getLength();
4852 double seenLength = 0;
4853 bool progress =
true;
4856 std::vector<LaneQ> currentLanes;
4857 const std::vector<MSLane*>* allowed =
nullptr;
4858 const MSEdge* nextEdge =
nullptr;
4860 nextEdge = *(ce + 1);
4863 const std::vector<MSLane*>& lanes = (*ce)->getLanes();
4864 for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
4872 q.
allowsContinuation = allowed ==
nullptr || std::find(allowed->begin(), allowed->end(), cl) != allowed->end();
4875 currentLanes.push_back(q);
4878 if (nextStopEdge == ce
4881 if (!nextStopLane->
isInternal() && !continueAfterStop) {
4885 for (std::vector<LaneQ>::iterator q = currentLanes.begin(); q != currentLanes.end(); ++q) {
4886 if (nextStopLane !=
nullptr && normalStopLane != (*q).lane) {
4887 (*q).allowsContinuation =
false;
4888 (*q).length = nextStopPos;
4889 (*q).currentLength = (*q).length;
4896 seenLength += currentLanes[0].lane->getLength();
4898 progress &= (seen <= 4 || seenLength <
MAX2(maxBrakeDist, 3000.0));
4899 progress &= (seen <= 8 || seenLength <
MAX2(maxBrakeDist, 200.0));
4910 double bestLength = -1;
4911 int bestThisIndex = 0;
4914 for (std::vector<LaneQ>::iterator j = last.begin(); j != last.end(); ++j, ++index) {
4915 if ((*j).length > bestLength) {
4916 bestLength = (*j).length;
4917 bestThisIndex = index;
4921 for (std::vector<LaneQ>::iterator j = last.begin(); j != last.end(); ++j, ++index) {
4922 if ((*j).length < bestLength) {
4923 (*j).bestLaneOffset = bestThisIndex - index;
4927 #ifdef DEBUG_BESTLANES
4929 std::cout <<
" last edge:\n";
4931 for (std::vector<LaneQ>::iterator j = laneQs.begin(); j != laneQs.end(); ++j) {
4932 std::cout <<
" lane=" << (*j).lane->getID() <<
" length=" << (*j).length <<
" bestOffset=" << (*j).bestLaneOffset <<
"\n";
4938 for (std::vector<std::vector<LaneQ> >::reverse_iterator i =
myBestLanes.rbegin() + 1; i !=
myBestLanes.rend(); ++i) {
4939 std::vector<LaneQ>& nextLanes = (*(i - 1));
4940 std::vector<LaneQ>& clanes = (*i);
4941 MSEdge& cE = clanes[0].lane->getEdge();
4943 double bestConnectedLength = -1;
4944 double bestLength = -1;
4945 for (std::vector<LaneQ>::iterator j = nextLanes.begin(); j != nextLanes.end(); ++j, ++index) {
4946 if ((*j).lane->isApproachedFrom(&cE) && bestConnectedLength < (*j).length) {
4947 bestConnectedLength = (*j).length;
4949 if (bestLength < (*j).length) {
4950 bestLength = (*j).length;
4954 int bestThisIndex = 0;
4955 if (bestConnectedLength > 0) {
4957 for (std::vector<LaneQ>::iterator j = clanes.begin(); j != clanes.end(); ++j, ++index) {
4958 LaneQ bestConnectedNext;
4959 bestConnectedNext.
length = -1;
4960 if ((*j).allowsContinuation) {
4961 for (std::vector<LaneQ>::const_iterator m = nextLanes.begin(); m != nextLanes.end(); ++m) {
4962 if ((*m).lane->isApproachedFrom(&cE, (*j).lane)) {
4963 if (bestConnectedNext.
length < (*m).length || (bestConnectedNext.
length == (*m).length && abs(bestConnectedNext.
bestLaneOffset) > abs((*m).bestLaneOffset))) {
4964 bestConnectedNext = *m;
4968 if (bestConnectedNext.
length == bestConnectedLength && abs(bestConnectedNext.
bestLaneOffset) < 2) {
4969 (*j).
length += bestLength;
4971 (*j).length += bestConnectedNext.
length;
4976 if (clanes[bestThisIndex].length < (*j).length
4977 || (clanes[bestThisIndex].length == (*j).length && abs(clanes[bestThisIndex].bestLaneOffset) > abs((*j).bestLaneOffset))
4978 || (clanes[bestThisIndex].length == (*j).length && abs(clanes[bestThisIndex].bestLaneOffset) == abs((*j).bestLaneOffset) &&
4981 bestThisIndex = index;
4988 for (std::vector<LaneQ>::iterator j = clanes.begin(); j != clanes.end(); ++j, ++index) {
4990 if (overheadWireSegmentID !=
"") {
4991 bestThisIndex = index;
4996 #ifdef DEBUG_BESTLANES
4998 std::cout <<
" edge=" << cE.
getID() <<
"\n";
4999 std::vector<LaneQ>& laneQs = clanes;
5000 for (std::vector<LaneQ>::iterator j = laneQs.begin(); j != laneQs.end(); ++j) {
5001 std::cout <<
" lane=" << (*j).lane->getID() <<
" length=" << (*j).length <<
" bestOffset=" << (*j).bestLaneOffset <<
"\n";
5008 int bestNextIndex = 0;
5009 int bestDistToNeeded = (int) clanes.size();
5011 for (std::vector<LaneQ>::iterator j = clanes.begin(); j != clanes.end(); ++j, ++index) {
5012 if ((*j).allowsContinuation) {
5014 for (std::vector<LaneQ>::const_iterator m = nextLanes.begin(); m != nextLanes.end(); ++m, ++nextIndex) {
5015 if ((*m).lane->isApproachedFrom(&cE, (*j).lane)) {
5016 if (bestDistToNeeded > abs((*m).bestLaneOffset)) {
5017 bestDistToNeeded = abs((*m).bestLaneOffset);
5018 bestThisIndex = index;
5019 bestNextIndex = nextIndex;
5025 clanes[bestThisIndex].length += nextLanes[bestNextIndex].length;
5026 copy(nextLanes[bestNextIndex].bestContinuations.begin(), nextLanes[bestNextIndex].bestContinuations.end(), back_inserter(clanes[bestThisIndex].bestContinuations));
5031 for (std::vector<LaneQ>::iterator j = clanes.begin(); j != clanes.end(); ++j, ++index) {
5032 if ((*j).length < clanes[bestThisIndex].length
5033 || ((*j).length == clanes[bestThisIndex].length && abs((*j).bestLaneOffset) > abs(clanes[bestThisIndex].bestLaneOffset))
5036 (*j).bestLaneOffset = bestThisIndex - index;
5039 (*j).length = (*j).currentLength;
5042 (*j).bestLaneOffset = 0;
5050 if (overheadWireID !=
"") {
5051 for (std::vector<LaneQ>::iterator j = clanes.begin(); j != clanes.end(); ++j, ++index) {
5052 (*j).bestLaneOffset = bestThisIndex - index;
5058 #ifdef DEBUG_BESTLANES
5069 if (conts.size() < 2) {
5072 const MSLink*
const link = conts[0]->getLinkTo(conts[1]);
5073 if (link !=
nullptr) {
5085 std::vector<LaneQ>& currLanes = *
myBestLanes.begin();
5086 std::vector<LaneQ>::iterator i;
5087 for (i = currLanes.begin(); i != currLanes.end(); ++i) {
5088 double nextOccupation = 0;
5089 for (std::vector<MSLane*>::const_iterator j = (*i).bestContinuations.begin() + 1; j != (*i).bestContinuations.end(); ++j) {
5090 nextOccupation += (*j)->getBruttoVehLenSum();
5092 (*i).nextOccupation = nextOccupation;
5093 #ifdef DEBUG_BESTLANES
5095 std::cout <<
" lane=" << (*i).lane->getID() <<
" nextOccupation=" << nextOccupation <<
"\n";
5098 if ((*i).lane == startLane) {
5105 const std::vector<MSLane*>&
5110 return (*myCurrentLaneInBestLanes).bestContinuations;
5114 const std::vector<MSLane*>&
5126 if ((*i).lane == lane) {
5127 return (*i).bestContinuations;
5133 const std::vector<const MSLane*>
5135 std::vector<const MSLane*> lanes;
5137 if (distance <= 0.) {
5138 WRITE_WARNINGF(
"MSVehicle::getUpcomingLanesUntil(): distance ('%') should be greater than 0.", distance);
5144 while (lane->
isInternal() && (distance > 0.)) {
5145 lanes.insert(lanes.end(), lane);
5147 lane = lane->
getLinkCont().front()->getViaLaneOrLane();
5151 if (contLanes.empty()) {
5154 auto contLanesIt = contLanes.begin();
5156 while (distance > 0.) {
5158 if (contLanesIt != contLanes.end()) {
5161 assert(l->
getEdge().
getID() == (*routeIt)->getLanes().front()->getEdge().getID());
5172 l = (*routeIt)->getLanes().back();
5178 assert(l !=
nullptr);
5182 while ((internalLane !=
nullptr) && internalLane->
isInternal() && (distance > 0.)) {
5183 lanes.insert(lanes.end(), internalLane);
5185 internalLane = internalLane->
getLinkCont().front()->getViaLaneOrLane();
5187 if (distance <= 0.) {
5191 lanes.insert(lanes.end(), l);
5198 const std::vector<const MSLane*>
5200 std::vector<const MSLane*> lanes;
5202 if (distance <= 0.) {
5203 WRITE_WARNINGF(
"MSVehicle::getPastLanesUntil(): distance ('%') should be greater than 0.", distance);
5210 while (lane->
isInternal() && (distance > 0.)) {
5211 lanes.insert(lanes.end(), lane);
5216 while (distance > 0.) {
5218 MSLane* l = (*routeIt)->getLanes().back();
5222 const MSLane* internalLane = internalEdge !=
nullptr ? internalEdge->
getLanes().front() :
nullptr;
5223 std::vector<const MSLane*> internalLanes;
5224 while ((internalLane !=
nullptr) && internalLane->
isInternal()) {
5225 internalLanes.insert(internalLanes.begin(), internalLane);
5226 internalLane = internalLane->
getLinkCont().front()->getViaLaneOrLane();
5228 for (
auto it = internalLanes.begin(); (it != internalLanes.end()) && (distance > 0.); ++it) {
5229 lanes.insert(lanes.end(), *it);
5230 distance -= (*it)->getLength();
5232 if (distance <= 0.) {
5236 lanes.insert(lanes.end(), l);
5256 return (*myCurrentLaneInBestLanes).bestLaneOffset;
5263 std::vector<MSVehicle::LaneQ>& preb =
myBestLanes.front();
5264 assert(laneIndex < (
int)preb.size());
5265 preb[laneIndex].occupation = density + preb[laneIndex].nextOccupation;
5276 std::pair<const MSLane*, double>
5278 if (distance == 0) {
5283 for (
const MSLane* lane : lanes) {
5284 if (lane->getLength() > distance) {
5285 return std::make_pair(lane, distance);
5287 distance -= lane->getLength();
5289 return std::make_pair(
nullptr, -1);
5295 double distance = std::numeric_limits<double>::max();
5296 if (
isOnRoad() && destEdge !=
nullptr) {
5310 std::pair<const MSVehicle* const, double>
5313 return std::make_pair(
static_cast<const MSVehicle*
>(
nullptr), -1);
5322 MSLane::VehCont::const_iterator it = std::find(vehs.begin(), vehs.end(),
this);
5323 if (it != vehs.end() && it + 1 != vehs.end()) {
5326 if (lead !=
nullptr) {
5327 std::pair<const MSVehicle* const, double> result(
5340 std::pair<const MSVehicle* const, double>
5343 return std::make_pair(
static_cast<const MSVehicle*
>(
nullptr), -1);
5355 std::pair<const MSVehicle* const, double> leaderInfo =
getLeader(-1);
5356 if (leaderInfo.first ==
nullptr ||
getSpeed() == 0) {
5368 if (
myStops.front().triggered &&
myStops.front().numExpectedPerson > 0) {
5369 myStops.front().numExpectedPerson -= (int)
myStops.front().pars.awaitedPersons.count(transportable->
getID());
5372 if (
myStops.front().pars.containerTriggered &&
myStops.front().numExpectedContainer > 0) {
5373 myStops.front().numExpectedContainer -= (int)
myStops.front().pars.awaitedContainers.count(transportable->
getID());
5385 const bool blinkerManoeuvre = (((state &
LCA_SUBLANE) == 0) && (
5391 std::swap(left, right);
5393 if ((state &
LCA_LEFT) != 0 && blinkerManoeuvre) {
5395 }
else if ((state &
LCA_RIGHT) != 0 && blinkerManoeuvre) {
5407 switch ((*link)->getDirection()) {
5424 && (
myStops.begin()->reached ||
5427 if (
myStops.begin()->lane->getIndex() > 0 &&
myStops.begin()->lane->getParallelLane(-1)->allowsVehicleClass(
getVClass())) {
5430 }
else if (!
myStops.begin()->reached &&
myStops.begin()->pars.parking) {
5445 if (currentTime % 1000 == 0) {
5498 #ifdef DEBUG_FURTHER
5508 for (
int i = 0; i < (int)shadowFurther.size(); ++i) {
5510 if (shadowFurther[i] == lane) {
5533 #ifdef DEBUG_FURTHER
5541 #ifdef DEBUG_FURTHER
5548 for (
int i = 0; i < (int)shadowFurther.size(); ++i) {
5549 if (shadowFurther[i] == lane) {
5550 #ifdef DEBUG_FURTHER
5553 <<
" lane=" << lane->
getID()
5568 MSLane* targetLane = furtherTargets[i];
5569 if (targetLane == lane) {
5572 #ifdef DEBUG_TARGET_LANE
5574 std::cout <<
" getLatOffset veh=" <<
getID()
5580 <<
" targetDir=" << targetDir
5581 <<
" latOffset=" << latOffset
5598 assert(offset == 0 || offset == 1 || offset == -1);
5599 assert(
myLane !=
nullptr);
5602 const double halfVehWidth = 0.5 * (
getWidth() + NUMERICAL_EPS);
5604 double leftLimit = halfCurrentLaneWidth - halfVehWidth - latPos;
5605 double rightLimit = -halfCurrentLaneWidth + halfVehWidth - latPos;
5606 double latLaneDist = 0;
5608 if (latPos + halfVehWidth > halfCurrentLaneWidth) {
5610 latLaneDist = halfCurrentLaneWidth - latPos - halfVehWidth;
5611 }
else if (latPos - halfVehWidth < - halfCurrentLaneWidth) {
5613 latLaneDist = halfCurrentLaneWidth - latPos + halfVehWidth;
5615 }
else if (offset == -1) {
5616 latLaneDist = rightLimit - (
getWidth() + NUMERICAL_EPS);
5617 }
else if (offset == 1) {
5618 latLaneDist = leftLimit + (
getWidth() + NUMERICAL_EPS);
5620 #ifdef DEBUG_ACTIONSTEPS
5623 <<
" veh=" <<
getID()
5624 <<
" halfCurrentLaneWidth=" << halfCurrentLaneWidth
5625 <<
" halfVehWidth=" << halfVehWidth
5626 <<
" latPos=" << latPos
5627 <<
" latLaneDist=" << latLaneDist
5628 <<
" leftLimit=" << leftLimit
5629 <<
" rightLimit=" << rightLimit
5653 if (dpi.myLink !=
nullptr) {
5654 dpi.myLink->removeApproaching(
this);
5672 std::vector<MSLink*>::const_iterator link =
MSLane::succLinkSec(*
this, view, *lane, bestLaneConts);
5674 while (!lane->
isLinkEnd(link) && seen <= dist) {
5677 || !(*link)->havePriority())) {
5681 if ((*di).myLink !=
nullptr) {
5682 const MSLane* diPredLane = (*di).myLink->getLaneBefore();
5683 if (diPredLane !=
nullptr) {
5694 const SUMOTime leaveTime = (*link)->getLeaveTime((*di).myArrivalTime, (*di).myArrivalSpeed,
5696 if ((*link)->hasApproachingFoe((*di).myArrivalTime, leaveTime, (*di).myArrivalSpeed,
getCarFollowModel().getMaxDecel())) {
5703 lane = (*link)->getViaLaneOrLane();
5720 centerLine.push_back(lane->getShape().back());
5749 result.push_back(line1[0]);
5750 result.push_back(line2[0]);
5751 result.push_back(line2[1]);
5752 result.push_back(line1[1]);
5755 result.push_back(line1[1]);
5756 result.push_back(line2[1]);
5757 result.push_back(line2[0]);
5758 result.push_back(line1[0]);
5770 if (&(*i)->getEdge() == edge) {
5787 if (destParkArea ==
nullptr) {
5789 errorMsg =
"Vehicle " +
getID() +
" is not driving to a parking area so it cannot be rerouted.";
5802 if (newParkingArea ==
nullptr) {
5803 errorMsg =
"Parking area ID " +
toString(parkingAreaID) +
" not found in the network.";
5816 if (!newDestination) {
5827 if (edgesFromPark.size() > 0) {
5828 edges.insert(edges.end(), edgesFromPark.begin() + 1, edgesFromPark.end());
5831 if (newDestination) {
5854 for (std::list<MSStop>::iterator iter =
myStops.begin(); iter !=
myStops.end(); iter++) {
5855 if (iter->lane->getID() == stop.
lane && fabs(iter->pars.endPos - stop.
endPos) < POSITION_EPS) {
5857 if (stop.
duration == 0 && stop.
until < 0 && !iter->reached) {
5871 const bool result =
addStop(stop, errorMsg);
5885 const int n = (int)
myStops.size();
5886 if (nextStopIndex < 0 || nextStopIndex >= n) {
5887 errorMsg = (
"Invalid nextStopIndex '" +
toString(nextStopIndex) +
"' for " +
toString(n) +
" remaining stops");
5895 errorMsg = (
"Disallowed stop lane '" + stopLane->
getID() +
"'");
5902 double startPos = nextStopIndex == 0 ?
getPositionOnLane() : stops[nextStopIndex - 1].pars.endPos;
5903 MSRouteIterator itEnd = nextStopIndex == n - 1 ? oldEdges.end() - 1 : stops[nextStopIndex + 1].edge;
5904 auto endPos = nextStopIndex == n - 1 ?
getArrivalPos() : stops[nextStopIndex + 1].pars.endPos;
5907 bool newDestination = nextStopIndex == n - 1 && stops[nextStopIndex].edge == oldEdges.end() - 1;
5910 router.
compute(*itStart, startPos, stopEdge, stop.
endPos,
this, t, toNewStop,
true);
5911 if (toNewStop.size() == 0) {
5912 errorMsg =
"No route found from edge '" + (*itStart)->getID() +
"' to stop edge '" + stopEdge->
getID() +
"'";
5917 if (!newDestination) {
5918 router.
compute(stopEdge, stop.
endPos, *itEnd, endPos,
this, t, fromNewStop,
true);
5919 if (fromNewStop.size() == 0) {
5920 errorMsg =
"No route found from stop edge '" + stopEdge->
getID() +
"' to edge '" + (*itEnd)->getID() +
"'";
5925 auto itStop =
myStops.begin();
5926 std::advance(itStop, nextStopIndex);
5927 MSStop& replacedStop = *itStop;
5931 replacedStop.
lane = stopLane;
5935 newEdges.insert(newEdges.end(),
myCurrEdge, itStart);
5936 newEdges.insert(newEdges.end(), toNewStop.begin(), toNewStop.end() - 1);
5937 if (!newDestination) {
5938 newEdges.insert(newEdges.end(), fromNewStop.begin(), fromNewStop.end() - 1);
5939 newEdges.insert(newEdges.end(), itEnd, oldEdges.end());
5941 newEdges.push_back(toNewStop.back());
5950 const double routeCost = router.
recomputeCosts(newEdges,
this, t);
5951 const double previousCost = router.
recomputeCosts(oldRemainingEdges,
this, t);
5952 const double savings = previousCost - routeCost;
5978 errorMsg = errorMsgStart +
" for vehicle '" +
myParameter->
id +
"' on lane '" + stop.
pars.
lane +
"' is too close to brake.";
5998 if (
myStops.front().busstop !=
nullptr) {
6000 myStops.front().busstop->leaveFrom(
this);
6003 if (
myStops.front().containerstop !=
nullptr) {
6005 myStops.front().containerstop->leaveFrom(
this);
6007 if (
myStops.front().parkingarea !=
nullptr) {
6009 myStops.front().parkingarea->leaveFrom(
this);
6011 if (
myStops.front().chargingStation !=
nullptr) {
6013 myStops.front().chargingStation->leaveFrom(
this);
6018 if (vehroutes !=
nullptr) {
6141 #ifdef DEBUG_IGNORE_RED
6146 if (ignoreRedTime < 0) {
6148 if (ignoreYellowTime > 0 && link->
haveYellow()) {
6152 return !canBrake || ignoreYellowTime > yellowDuration;
6162 #ifdef DEBUG_IGNORE_RED
6166 <<
" ignoreRedTime=" << ignoreRedTime
6167 <<
" spentRed=" << redDuration
6168 <<
" canBrake=" << canBrake <<
"\n";
6172 return !canBrake || ignoreRedTime > redDuration;
6198 if (veh ==
nullptr) {
6218 assert(logic !=
nullptr);
6227 response = foeEntry->
haveRed();
6241 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
6244 <<
" foeLane=" << foeLane->
getID()
6246 <<
" linkIndex=" << link->
getIndex()
6247 <<
" foeLinkIndex=" << foeLink->
getIndex()
6250 <<
" response=" << response
6251 <<
" response2=" << response2
6259 }
else if (response && response2) {
6265 if (egoET == foeET) {
6269 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
6271 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" equal ET " << egoET <<
" with foe " << veh->
getID()
6272 <<
" foeIsLeaderByID=" << (
getID() < veh->
getID()) <<
"\n";
6277 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
6279 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" equal ET " << egoET <<
" with foe " << veh->
getID()
6289 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
6291 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" egoET " << egoET <<
" with foe " << veh->
getID()
6292 <<
" foeET=" << foeET <<
" isLeader=" << (egoET > foeET) <<
"\n";
6295 return egoET > foeET;
6311 std::vector<std::string> internals;
6328 stop.write(out,
false);
6340 dev->saveState(out);
6348 throw ProcessError(
"Error: Invalid vehicles in state (may be a meso state)!");
6367 while (pastStops > 0) {
6393 SUMOTime arrivalTime,
double arrivalSpeed,
6394 SUMOTime arrivalTimeBraking,
double arrivalSpeedBraking,
6395 double dist,
double leaveSpeed) {
6398 arrivalTime, arrivalSpeed, arrivalTimeBraking, arrivalSpeedBraking, dist, leaveSpeed));
6403 std::shared_ptr<MSSimpleDriverState>
6457 return (myGUIIncrement);
6462 return (myManoeuvreType);
6478 myManoeuvreType = mType;
6493 if (abs(GUIAngle) < 0.1) {
6496 myManoeuvreVehicleID = veh->
getID();
6499 myManoeuvreStartTime = currentTime;
6501 myGUIIncrement = GUIAngle / ((myManoeuvreCompleteTime - myManoeuvreStartTime) / (
TS * 1000.));
6505 std::cout <<
"ENTRY manoeuvre start: vehicle=" << veh->
getID() <<
" Manoeuvre Angle=" << manoeuverAngle <<
" Rotation angle=" <<
RAD2DEG(GUIAngle) <<
" Road Angle" <<
RAD2DEG(veh->
getAngle()) <<
" increment=" <<
RAD2DEG(myGUIIncrement) <<
" currentTime=" << currentTime <<
6506 " endTime=" << myManoeuvreCompleteTime <<
" manoeuvre time=" << myManoeuvreCompleteTime - currentTime <<
" parkArea=" << myManoeuvreStop << std::endl;
6531 if (abs(GUIAngle) < 0.1) {
6535 myManoeuvreVehicleID = veh->
getID();
6538 myManoeuvreStartTime = currentTime;
6540 myGUIIncrement = (-GUIAngle) / ((myManoeuvreCompleteTime - myManoeuvreStartTime) / (
TS * 1000.));
6547 std::cout <<
"EXIT manoeuvre start: vehicle=" << veh->
getID() <<
" Manoeuvre Angle=" << manoeuverAngle <<
" increment=" <<
RAD2DEG(myGUIIncrement) <<
" currentTime=" << currentTime
6548 <<
" endTime=" << myManoeuvreCompleteTime <<
" manoeuvre time=" << myManoeuvreCompleteTime - currentTime <<
" parkArea=" << myManoeuvreStop << std::endl;
6565 if (configureEntryManoeuvre(veh)) {
6582 if (checkType != myManoeuvreType) {
6613 travelTime += (*it)->getMinimumTravelTime(
this);
6614 dist += (*it)->getLength();
6619 dist += stopEdgeDist;
6626 const double d = dist;
6632 const double maxVD =
MAX2(c, ((sqrt(
MAX2(0.0, pow(2 * c * b, 2) + (4 * ((b * ((a * (2 * d * (b + a) + (vs * vs) - (c * c))) - (b * (c * c))))
6633 + pow((a * vs), 2))))) * 0.5) + (c * b)) / (b + a));
6637 double timeLossAccel = 0;
6638 double timeLossDecel = 0;
6639 double timeLossLength = 0;
6641 double v =
MIN2(maxVD, (*it)->getVehicleMaxSpeed(
this));
6643 if (edgeLength <= len && v0Stable && v0 < v) {
6644 const double lengthDist =
MIN2(len, edgeLength);
6645 const double dTL = lengthDist / v0 - lengthDist / v;
6647 timeLossLength += dTL;
6649 if (edgeLength > len) {
6650 const double dv = v - v0;
6653 const double dTA = dv / a - dv * (v + v0) / (2 * a * v);
6655 timeLossAccel += dTA;
6657 }
else if (dv < 0) {
6659 const double dTD = -dv / b + dv * (v + v0) / (2 * b * v0);
6661 timeLossDecel += dTD;
6670 const double dv = v - v0;
6673 const double dTA = dv / a - dv * (v + v0) / (2 * a * v);
6675 timeLossAccel += dTA;
6677 }
else if (dv < 0) {
6679 const double dTD = -dv / b + dv * (v + v0) / (2 * b * v0);
6681 timeLossDecel += dTD;
6683 const double result = travelTime + timeLossAccel + timeLossDecel + timeLossLength;
6686 return MAX2(0.0, result);
std::vector< const MSEdge * > ConstMSEdgeVector
std::vector< MSEdge * > MSEdgeVector
std::pair< const MSVehicle *, double > CLeaderDist
std::pair< const MSPerson *, double > PersonDist
ConstMSEdgeVector::const_iterator MSRouteIterator
#define NUMERICAL_EPS_SPEED
#define STOPPING_PLACE_OFFSET
#define JUNCTION_BLOCKAGE_TIME
#define DIST_TO_STOPLINE_EXPECT_PRIORITY
#define WRITE_WARNINGF(...)
#define WRITE_WARNING(msg)
std::string time2string(SUMOTime t)
convert SUMOTime to string
bool isRailway(SVCPermissions permissions)
Returns whether an edge with the given permission is a railway edge.
@ SVC_RAIL_CLASSES
classes which drive on tracks
@ SVC_EMERGENCY
public emergency vehicles
@ SVS_PASSENGER_HATCHBACK
render as a hatchback passenger vehicle ("Fliessheck")
@ SVS_PASSENGER
render as a passenger vehicle
@ SVS_PASSENGER_SEDAN
render as a sedan passenger vehicle ("Stufenheck")
@ SVS_PASSENGER_WAGON
render as a wagon passenger vehicle ("Combi")
@ SVS_PASSENGER_VAN
render as a van
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
@ GIVEN
The lane is given.
@ GIVEN
The speed is given.
@ GIVEN
The arrival lane is given.
@ GIVEN
The speed is given.
const int VEHPARS_FORCE_REROUTE
@ GIVEN
The arrival position is given.
@ SUMO_TAG_PARKING_AREA
A parking area.
@ SUMO_TAG_PARKING_ZONE_REROUTE
entry for an alternative parking zone
@ SUMO_TAG_OVERHEAD_WIRE_SEGMENT
An overhead wire segment.
LinkDirection
The different directions a link between two lanes may take (or a stream between two edges)....
@ PARTLEFT
The link is a partial left direction.
@ RIGHT
The link is a (hard) right direction.
@ TURN
The link is a 180 degree turn.
@ LEFT
The link is a (hard) left direction.
@ STRAIGHT
The link is a straight direction.
@ TURN_LEFTHAND
The link is a 180 degree turn (left-hand network)
@ PARTRIGHT
The link is a partial right direction.
@ NODIR
The link has no direction (is a dead end link)
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic,...
@ LINKSTATE_ALLWAY_STOP
This is an uncontrolled, all-way stop link.
@ LINKSTATE_EQUAL
This is an uncontrolled, right-before-left link.
@ LINKSTATE_ZIPPER
This is an uncontrolled, zipper-merge link.
@ LCA_KEEPRIGHT
The action is due to the default of keeping right "Rechtsfahrgebot".
@ LCA_BLOCKED
blocked in all directions
@ LCA_URGENT
The action is urgent (to be defined by lc-model)
@ LCA_STAY
Needs to stay on the current lane.
@ LCA_SUBLANE
used by the sublane model
@ LCA_WANTS_LANECHANGE_OR_STAY
lane can change or stay
@ LCA_COOPERATIVE
The action is done to help someone else.
@ LCA_OVERLAPPING
The vehicle is blocked being overlapping.
@ LCA_LEFT
Wants go to the left.
@ LCA_STRATEGIC
The action is needed to follow the route (navigational lc)
@ LCA_TRACI
The action is due to a TraCI request.
@ LCA_SPEEDGAIN
The action is due to the wish to be faster (tactical lc)
@ LCA_RIGHT
Wants go to the right.
@ SUMO_ATTR_JM_IGNORE_KEEPCLEAR_TIME
@ SUMO_ATTR_MAXIMUMPOWER
Maximum Power.
@ SUMO_ATTR_JM_STOPLINE_GAP
@ SUMO_ATTR_JM_DRIVE_AFTER_RED_TIME
@ SUMO_ATTR_JM_DRIVE_AFTER_YELLOW_TIME
@ SUMO_ATTR_STATE
The state of a link.
@ SUMO_ATTR_JM_DRIVE_RED_SPEED
int gPrecision
the precision for floating point outputs
bool gDebugFlag1
global utility flags for debugging
const double INVALID_DOUBLE
const double SUMO_const_laneWidth
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
#define SOFT_ASSERT(expr)
define SOFT_ASSERT raise an assertion in debug mode everywhere except on the windows test server
static double naviDegree(const double angle)
static double fromNaviDegree(const double angle)
Interface for lane-change models.
MSLane * updateTargetLane()
const std::vector< double > & getShadowFurtherLanesPosLat() const
double getCommittedSpeed() const
double getManeuverDist() const
Returns the remaining unblocked distance for the current maneuver. (only used by sublane model)
int getLaneChangeDirection() const
return the direction of the current lane change maneuver
virtual void prepareStep()
void resetChanged()
reset the flag whether a vehicle already moved to false
MSLane * getShadowLane() const
Returns the lane the vehicle's shadow is on during continuous/sublane lane change.
void endLaneChangeManeuver(const MSMoveReminder::Notification reason=MSMoveReminder::NOTIFICATION_LANE_CHANGE)
const std::vector< MSLane * > & getShadowFurtherLanes() const
void setNoShadowPartialOccupator(MSLane *lane)
SUMOTime remainingTime() const
Compute the remaining time until LC completion.
void setShadowApproachingInformation(MSLink *link) const
set approach information for the shadow vehicle
const std::vector< MSLane * > & getFurtherTargetLanes() const
static MSAbstractLaneChangeModel * build(LaneChangeModel lcm, MSVehicle &vehicle)
Factory method for instantiating new lane changing models.
void changedToOpposite()
called when a vehicle changes between lanes in opposite directions
int getShadowDirection() const
return the direction in which the current shadow lane lies
MSLane * getTargetLane() const
Returns the lane the vehicle has committed to enter during a sublane lane change.
double getAngleOffset() const
return the angle offset during a continuous change maneuver
bool isChangingLanes() const
return true if the vehicle currently performs a lane change maneuver
void removeShadowApproachingInformation() const
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const int rngIndex, SUMOVehicleClass svc) const
The base class for microscopic and mesoscopic vehicles.
double getMaxSpeed() const
Returns the maximum speed.
MSVehicleDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists or 0.
virtual bool isSelected() const
whether this vehicle is selected in the GUI
std::list< MSStop > myStops
The vehicle's list of stops.
double getImpatience() const
Returns this vehicles impatience.
const std::vector< MSTransportable * > & getPersons() const
retrieve riding persons
virtual void initDevices()
virtual double getArrivalPos() const
Returns this vehicle's desired arrivalPos for its current route (may change on reroute)
MSVehicleType * myType
This vehicle's type.
MoveReminderCont myMoveReminders
Currently relevant move reminders.
double myDepartPos
The real depart position.
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
void addReminder(MSMoveReminder *rem)
Adds a MoveReminder dynamically.
bool replaceRouteEdges(ConstMSEdgeVector &edges, double cost, double savings, const std::string &info, bool onInit=false, bool check=false, bool removeStops=true)
Replaces the current route by the given edges.
void replaceParameter(const SUMOVehicleParameter *newParameter)
replace the vehicle parameter (deleting the old one)
std::vector< MSVehicleDevice * > myDevices
The devices this vehicle has.
virtual 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.
virtual void addTransportable(MSTransportable *transportable)
Adds a person or container to this vehicle.
MSVehicleType & getSingularType()
Replaces the current vehicle type with a new one used by this vehicle only.
double getLength() const
Returns the vehicle's length.
bool isParking() const
Returns whether the vehicle is parking.
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
int getPersonNumber() const
Returns the number of persons.
std::mt19937 * getRNG() const
MSRouteIterator myCurrEdge
Iterator to current route-edge.
bool hasDeparted() const
Returns whether this vehicle has already departed.
double getWidth() const
Returns the vehicle's width.
SUMOTime getDeparture() const
Returns this vehicle's real departure time.
void calculateArrivalParams()
(Re-)Calculates the arrival position and lane from the vehicle parameters
const MSRouteIterator & getCurrentRouteEdge() const
Returns an iterator pointing to the current edge in this vehicles route.
const MSRoute * myRoute
This vehicle's route.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
bool hasStops() const
Returns whether the vehicle has to stop somewhere.
@ ROUTE_START_INVALID_LANE
@ ROUTE_START_INVALID_PERMISSIONS
SUMOVehicleClass getVClass() const
Returns the vehicle's access class.
int myArrivalLane
The destination lane where the vehicle stops.
SUMOTime myDeparture
The real departure time.
bool isStoppedTriggered() const
Returns whether the vehicle is on a triggered stop.
bool addStop(const SUMOVehicleParameter::Stop &stopPar, std::string &errorMsg, SUMOTime untilOffset=0, bool collision=false, MSRouteIterator *searchStart=nullptr)
Adds a stop.
std::vector< SUMOVehicleParameter::Stop > myPastStops
The list of stops that the vehicle has already reached.
void onDepart()
Called when the vehicle is inserted into the network.
bool haveValidStopEdges() const
check whether all stop.edge MSRouteIterators are valid and in order
int getRoutePosition() const
return index of edge within route
static const SUMOTime NOT_YET_DEPARTED
const SUMOVehicleParameter * myParameter
This vehicle's parameter.
int myRouteValidity
status of the current vehicle route
const MSRoute & getRoute() const
Returns the current route.
bool isStopped() const
Returns whether the vehicle is at a stop.
int myNumberReroutes
The number of reroutings.
double myArrivalPos
The position on the destination lane where the vehicle stops.
virtual void saveState(OutputDevice &out)
Saves the (common) state of a vehicle.
double myOdometer
A simple odometer to keep track of the length of the route already driven.
int getContainerNumber() const
Returns the number of containers.
The car-following model abstraction.
double estimateSpeedAfterDistance(const double dist, const double v, const double accel) const
virtual double maxNextSpeed(double speed, const MSVehicle *const veh) const
Returns the maximum speed given the current speed.
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 getMinimalArrivalSpeed(double dist, double currentSpeed) const
Computes the minimal possible arrival speed after covering a given distance.
virtual void setHeadwayTime(double headwayTime)
Sets a new value for desired headway [s].
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...
SUMOTime getMinimalArrivalTime(double dist, double currentSpeed, double arrivalSpeed) const
Computes the minimal time needed to cover a distance given the desired speed at arrival.
virtual double finalizeSpeed(MSVehicle *const veh, double vPos) const
Applies interaction with stops and lane changing model influences. Called at most once per simulation...
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.
virtual VehicleVariables * createVehicleVariables() const
Returns model specific values which are stored inside a vehicle and must be used with casting.
double maximumSafeStopSpeed(double gap, double currentSpeed, bool onInsertion=false, double headway=-1) const
Returns the maximum next velocity for stopping within gap.
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)
double getApparentDecel() const
Get the vehicle type's apparent deceleration [m/s^2] (the one regarded by its followers.
double getMaxAccel() const
Get the vehicle type's maximum acceleration [m/s^2].
double brakeGap(const double speed) const
Returns the distance the vehicle needs to halt including driver's reaction time tau (i....
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
double getMinimalArrivalSpeedEuler(double dist, double currentSpeed) const
Computes the minimal possible arrival speed after covering a given distance for Euler update.
virtual double stopSpeed(const MSVehicle *const veh, const double speed, double gap) const =0
Computes the vehicle's safe speed for approaching a non-moving obstacle (no dawdling)
virtual double getHeadwayTime() const
Get the driver's desired headway [s].
The ToC Device controls transition of control between automated and manual driving.
std::shared_ptr< MSSimpleDriverState > getDriverState() const
return internal state
void update()
update internal state
A device which collects info on the vehicle trip (mainly on departure and arrival)
double consumption(SUMOVehicle &veh, double a, double newSpeed)
double getParameterDouble(const std::string &key) const
void setConsum(const double consumption)
double acceleration(SUMOVehicle &veh, double power, double oldSpeed)
double getConsum() const
Get consum.
A device which collects info on the vehicle trip (mainly on departure and arrival)
void stopEnded(const SUMOVehicleParameter::Stop &stop)
void checkCollisionForInactive(MSLane *l)
trigger collision checking for inactive lane
A road/street connecting two junctions.
const MSEdge * getInternalFollowingEdge(const MSEdge *followerAfterInternal) const
bool isFringe() const
return whether this edge is at the fringe of the network
const std::set< MSTransportable * > & getPersons() const
Returns this edge's persons set.
bool isNormal() const
return whether this edge is an internal edge
const std::vector< MSLane * > * allowedLanes(const MSEdge &destination, SUMOVehicleClass vclass=SVC_IGNORING) const
Get the allowed lanes to reach the destination-edge.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
double getSpeedLimit() const
Returns the speed limit of the edge @caution The speed limit of the first lane is retured; should pro...
const MSJunction * getFromJunction() const
double getMinimumTravelTime(const SUMOVehicle *const veh) const
returns the minimum travel time for the given vehicle
bool isRoundabout() const
bool isInternal() const
return whether this edge is an internal edge
double getWidth() const
Returns the edges's width (sum over all lanes)
bool isVaporizing() const
Returns whether vehicles on this edge shall be vaporized.
void addWaiting(SUMOVehicle *vehicle) const
Adds a vehicle to the list of waiting vehicles.
const MSJunction * getToJunction() const
void removeWaiting(const SUMOVehicle *vehicle) const
Removes a vehicle from the list of waiting vehicles.
const MSEdge * getBidiEdge() const
return opposite superposable/congruent edge, if it exist and 0 else
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
static bool gModelParkingManoeuver
whether parking simulation includes manoeuver time and any associated lane blocking
static double gLateralResolution
static bool gSemiImplicitEulerUpdate
static bool gLefthand
Whether lefthand-drive is being simulated.
static SUMOTime gLaneChangeDuration
static double gEmergencyDecelWarningThreshold
treshold for warning about strong deceleration
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
void add(SUMOVehicle *veh)
Adds a single vehicle for departure.
virtual const MSJunctionLogic * getLogic() const
virtual const MSLogicJunction::LinkBits & getResponseFor(int linkIndex) const
Returns the response for the given link.
Representation of a lane in the micro simulation.
const std::vector< MSLink * > & getLinkCont() const
returns the container with all links !!!
MSLane * getParallelLane(int offset, bool includeOpposite=true) const
Returns the lane with the given offset parallel to this one or 0 if it does not exist.
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
int getVehicleNumber() const
Returns the number of vehicles on this lane (for which this lane is responsible)
int getVehicleNumberWithPartials() const
Returns the number of vehicles on this lane (including partial occupators)
double getBruttoVehLenSum() const
Returns the sum of lengths of vehicles, including their minGaps, which were on the lane during the la...
static std::vector< MSLink * >::const_iterator succLinkSec(const SUMOVehicle &veh, int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane * > &conts)
std::pair< const MSPerson *, double > nextBlocking(double minPos, double minRight, double maxLeft, double stopTime=0) const
This is just a wrapper around MSPModel::nextBlocking. You should always check using hasPedestrians be...
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
const MSLink * getLinkTo(const MSLane *const) const
returns the link to the given lane or nullptr, if it is not connected
void forceVehicleInsertion(MSVehicle *veh, double pos, MSMoveReminder::Notification notification, double posLat=0)
Inserts the given vehicle at the given position.
std::vector< MSVehicle * > VehCont
Container for vehicles.
std::pair< MSVehicle *const, double > getFollower(const MSVehicle *ego, double egoPos, double dist, bool ignoreMinorLinks) const
Find follower vehicle for the given ego vehicle (which may be on the opposite direction lane)
std::vector< StopWatch< std::chrono::nanoseconds > > & getStopWatch()
const MSEdge * getNextNormal() const
Returns the lane's follower if it is an internal lane, the edge of the lane otherwise.
double getLength() const
Returns the lane's length.
const MSLane * getInternalFollowingLane(const MSLane *const) const
returns the internal lane leading to the given lane or nullptr, if there is none
const MSLeaderInfo getLastVehicleInformation(const MSVehicle *ego, double latOffset, double minPos=0, bool allowCached=true) const
Returns the last vehicles on the lane.
double getStopOffset(const MSVehicle *veh) const
Returns vehicle class specific stopOffset for the vehicle.
bool isLinkEnd(std::vector< MSLink * >::const_iterator &i) const
bool allowsVehicleClass(SUMOVehicleClass vclass) const
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
double getRightSideOnEdge() const
bool hasPedestrians() const
whether the lane has pedestrians on it
int getIndex() const
Returns the lane's index.
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
double getOppositePos(double pos) const
return the corresponding position on the opposite lane
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
double getCenterOnEdge() const
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
MSVehicle * getLastAnyVehicle() const
returns the last vehicle that is fully or partially on this lane
MSEdge & getEdge() const
Returns the lane's edge.
const PositionVector & getShape() const
Returns this lane's shape.
MSLane * getOpposite() const
return the opposite direction lane for lane changing or 0
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
bool mustCheckJunctionCollisions() const
whether this lane must check for junction collisions
double interpolateLanePosToGeometryPos(double lanePos) const
MSLane * getBidiLane() const
retrieve bidirectional lane or nullptr
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.
std::pair< MSVehicle *const, double > getOppositeLeader(const MSVehicle *ego, double dist, bool oppositeDir) const
const MSLane * getNormalPredecessorLane() const
get normal lane leading to this internal lane, for normal lanes, the lane itself is returned
const std::vector< MSMoveReminder * > & getMoveReminders() const
Return the list of this lane's move reminders.
double getWidth() const
Returns the lane's width.
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
static CollisionAction getCollisionAction()
virtual int addLeader(const MSVehicle *veh, bool beyond, double latOffset=0)
virtual std::string toString() const
print a debugging representation
virtual void clear()
discard all information
void getSubLanes(const MSVehicle *veh, double latOffset, int &rightmost, int &leftmost) const
bool fromInternalLane() const
return whether the fromLane of this link is an internal lane
LinkState getState() const
Returns the current state of the link.
MSLane * getViaLane() const
Returns the following inner lane.
SUMOTime getLastStateChange() const
MSLane * getLane() const
Returns the connected lane.
MSLane * getViaLaneOrLane() const
return the via lane if it exists and the lane otherwise
bool isConflictEntryLink() const
return whether this link enters the conflict area (not a continuation link)
int getIndex() const
Returns the respond index (for visualization)
std::vector< const SUMOVehicle * > BlockingFoes
bool havePriority() const
Returns whether this link is a major link.
double getZipperSpeed(const MSVehicle *ego, const double dist, double vSafe, SUMOTime arrivalTime, BlockingFoes *collectFoes) const
return the speed at which ego vehicle must approach the zipper link
const 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.
bool isEntryLink() const
return whether the toLane of this link is an internal lane and fromLane is a normal lane
const MSLane * getLaneBefore() const
return the internalLaneBefore if it exists and the laneBefore otherwise
bool isInternalJunctionLink() const
return whether the fromLane and the toLane of this link are internal lanes
bool isExitLink() const
return whether the fromLane of this link is an internal lane and toLane is a normal lane
std::vector< LinkLeader > LinkLeaders
bool hasFoes() const
Returns whether this link belongs to a junction where more than one edge is incoming.
const MSLink * getCorrespondingEntryLink() const
returns the corresponding entry link for exitLinks to a junction.
void removeApproaching(const SUMOVehicle *veh)
removes the vehicle from myApproachingVehicles
MSLink * getParallelLink(int direction) const
return the link that is parallel to this lane or 0
double getLateralShift() const
return lateral shift that must be applied when passing this link
const MSTrafficLightLogic * getTLLogic() const
Returns the TLS index.
bool opened(SUMOTime arrivalTime, double arrivalSpeed, double leaveSpeed, double vehicleLength, double impatience, double decel, SUMOTime waitingTime, double posLat=0, BlockingFoes *collectFoes=nullptr, bool ignoreRed=false, const SUMOTrafficObject *ego=nullptr) const
Returns the information whether the link may be passed.
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.
double getFoeVisibilityDistance() const
Returns the distance on the approaching lane from which an approaching vehicle is able to see all rel...
bool lastWasContMajor() const
whether this is a link past an internal junction which currently has priority
static const double ZIPPER_ADAPT_DIST
MSJunction * getJunction() const
LinkDirection getDirection() const
Returns the direction the vehicle passing this link take.
bool keepClear() const
whether the junction after this link must be kept clear
const MSLane * getInternalLaneBefore() const
return myInternalLaneBefore (always 0 when compiled without internal lanes)
bool haveRed() const
Returns whether this link is blocked by a red (or redyellow) traffic light.
Something on a lane to be noticed about vehicle movement.
Notification
Definition of a vehicle state.
@ NOTIFICATION_TELEPORT_ARRIVED
The vehicle was teleported out of the net.
@ NOTIFICATION_PARKING_REROUTE
The vehicle needs another parking area.
@ NOTIFICATION_DEPARTED
The vehicle has departed (was inserted into the network)
@ NOTIFICATION_LANE_CHANGE
The vehicle changes lanes (micro only)
@ NOTIFICATION_VAPORIZED_VAPORIZER
The vehicle got vaporized with a vaporizer.
@ NOTIFICATION_JUNCTION
The vehicle arrived at a junction.
@ NOTIFICATION_PARKING
The vehicle starts or ends parking.
@ NOTIFICATION_TELEPORT
The vehicle is being teleported.
Interface for objects listening to vehicle state changes.
The simulated network and simulation perfomer.
void removeVehicleStateListener(VehicleStateListener *listener)
Removes a vehicle states listener.
VehicleState
Definition of a vehicle state.
@ VEHICLE_STATE_STARTING_PARKING
The vehicles starts to park.
@ VEHICLE_STATE_MANEUVERING
Vehicle maneuvering either entering or exiting a parking space.
@ VEHICLE_STATE_ENDING_STOP
The vehicle ends to stop.
@ VEHICLE_STATE_ARRIVED
The vehicle arrived at his destination (is deleted)
@ VEHICLE_STATE_EMERGENCYSTOP
The vehicle had to brake harder than permitted.
@ VEHICLE_STATE_STARTING_TELEPORT
The vehicle started to teleport.
@ VEHICLE_STATE_STARTING_STOP
The vehicles starts to stop.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
virtual MSTransportableControl & getContainerControl()
Returns the container control.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
std::string getStoppingPlaceID(const MSLane *lane, const double pos, const SumoXMLTag category) const
Returns the stop of the given category close to the given position.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
static bool hasInstance()
Returns whether the network was already constructed.
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
void addVehicleStateListener(VehicleStateListener *listener)
Adds a vehicle states listener.
MSEdgeControl & getEdgeControl()
Returns the edge control.
bool hasContainers() const
Returns whether containers are simulated.
MSInsertionControl & getInsertionControl()
Returns the insertion control.
void informVehicleStateListener(const SUMOVehicle *const vehicle, VehicleState to, const std::string &info="")
Informs all added listeners about a vehicle's state change.
bool hasPersons() const
Returns whether persons are simulated.
virtual MSTransportableControl & getPersonControl()
Returns the person control.
A lane area vehicles can halt at.
int getCapacity() const
Returns the area capacity.
void enter(SUMOVehicle *veh)
Called if a vehicle enters this stop.
int getLastFreeLotAngle() const
Return the angle of myLastFreeLot - the next parking lot only expected to be called after we have est...
int getOccupancyIncludingBlocked() const
Returns the area occupancy.
double getLastFreeLotGUIAngle() const
Return the GUI angle of myLastFreeLot - the angle the GUI uses to rotate into the next parking lot as...
int getManoeuverAngle(const SUMOVehicle &forVehicle) const
Return the manoeuver angle of the lot where the vehicle is parked.
int getOccupancy() const
Returns the area occupancy.
double getLastFreePosWithReservation(SUMOTime t, const SUMOVehicle &forVehicle)
Returns the last free position on this stop including reservatiosn from the current lane and time ste...
double getGUIAngle(const SUMOVehicle &forVehicle) const
Return the GUI angle of the lot where the vehicle is parked.
MSRouteIterator end() const
Returns the end of the list of edges to pass.
const MSEdge * getLastEdge() const
returns the destination edge
double getDistanceBetween(double fromPos, double toPos, const MSEdge *fromEdge, const MSEdge *toEdge, bool includeInternal=true, int routePosition=0) const
Compute the distance between 2 given edges on this route, including the length of internal lanes....
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
const ConstMSEdgeVector & getEdges() const
const MSLane * lane
The lane to stop at (microsim only)
bool triggered
whether an arriving person lets the vehicle continue
bool containerTriggered
whether an arriving container lets the vehicle continue
SUMOTime timeToLoadNextContainer
The time at which the vehicle is able to load another container.
MSStoppingPlace * containerstop
(Optional) container stop if one is assigned to the stop
bool joinTriggered
whether coupling another vehicle (train) the vehicle continue
void initPars(const SUMOVehicleParameter::Stop &stopPar)
initialize attributes from the given stop parameters
int numExpectedContainer
The number of still expected containers.
bool reached
Information whether the stop has been reached.
MSRouteIterator edge
The edge in the route to stop at.
SUMOTime timeToBoardNextPerson
The time at which the vehicle is able to board another person.
SUMOTime endBoarding
the maximum time at which persons may board this vehicle
double getEndPos(const SUMOVehicle &veh) const
return halting position for upcoming stop;
int numExpectedPerson
The number of still expected persons.
MSParkingArea * parkingarea
(Optional) parkingArea if one is assigned to the stop
MSStoppingPlace * chargingStation
(Optional) charging station if one is assigned to the stop
SUMOTime duration
The stopping duration.
const SUMOVehicleParameter::Stop pars
The stop parameter.
MSStoppingPlace * busstop
(Optional) bus stop if one is assigned to the stop
static MSStopOut * getInstance()
void stopEnded(const SUMOVehicle *veh, const SUMOVehicleParameter::Stop &stop, const std::string &laneOrEdgeID)
void stopStarted(const SUMOVehicle *veh, int numPersons, int numContainers, SUMOTime time)
A lane area vehicles can halt at.
double getBeginLanePosition() const
Returns the begin position of this stop.
bool fits(double pos, const SUMOVehicle &veh) const
return whether the given vehicle fits at the given position
double getEndLanePosition() const
Returns the end position of this stop.
void enter(SUMOVehicle *veh, bool parking)
Called if a vehicle enters this stop.
const MSLane & getLane() const
Returns the lane this stop is located at.
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...
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...
bool isPerson() const
Whether it is a person.
A static instance of this class in GapControlState deactivates gap control for vehicles whose referen...
void vehicleStateChanged(const SUMOVehicle *const vehicle, MSNet::VehicleState to, const std::string &info="")
Called if a vehicle changes its state.
Changes the wished vehicle speed / lanes.
void setLaneChangeMode(int value)
Sets lane changing behavior.
TraciLaneChangePriority myTraciLaneChangePriority
flags for determining the priority of traci lane change requests
bool getEmergencyBrakeRedLight() const
Returns whether red lights shall be a reason to brake.
SUMOTime getLaneTimeLineEnd()
void adaptLaneTimeLine(int indexShift)
Adapts lane timeline when moving to a new lane and the lane index changes.
void setRemoteControlled(Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, const ConstMSEdgeVector &route, SUMOTime t)
bool isRemoteAffected(SUMOTime t) const
int getSpeedMode() const
return the current speed mode
void deactivateGapController()
Deactivates the gap control.
void setSpeedMode(int speedMode)
Sets speed-constraining behaviors.
std::shared_ptr< GapControlState > myGapControlState
The gap control state.
bool considerSafeVelocity() const
Returns whether safe velocities shall be considered.
bool myConsiderMaxDeceleration
Whether the maximum deceleration shall be regarded.
void setLaneTimeLine(const std::vector< std::pair< SUMOTime, int > > &laneTimeLine)
Sets a new lane timeline.
double myOriginalSpeed
The velocity before influence.
double implicitDeltaPosRemote(const MSVehicle *veh)
return the change in longitudinal position that is implicit in the new remote position
double implicitSpeedRemote(const MSVehicle *veh, double oldSpeed)
return the speed that is implicit in the new remote position
void postProcessRemoteControl(MSVehicle *v)
double gapControlSpeed(SUMOTime currentTime, const SUMOVehicle *veh, double speed, double vSafe, double vMin, double vMax)
Applies gap control logic on the speed.
void setSublaneChange(double latDist)
Sets a new sublane-change request.
double getOriginalSpeed() const
Returns the originally longitudinal speed to use.
SUMOTime myLastRemoteAccess
LaneChangeMode myStrategicLC
lane changing which is necessary to follow the current route
LaneChangeMode mySpeedGainLC
lane changing to travel with higher speed
static void init()
Static initalization.
LaneChangeMode mySublaneLC
changing to the prefered lateral alignment
bool getRespectJunctionPriority() const
Returns whether junction priority rules shall be respected.
static void cleanup()
Static cleanup.
int getLaneChangeMode() const
return the current lane change mode
SUMOTime getLaneTimeLineDuration()
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.
bool myConsiderSafeVelocity
Whether the safe velocity shall be regarded.
bool mySpeedAdaptationStarted
Whether influencing the speed has already started.
void setSignals(int signals)
double myLatDist
The requested lateral change.
bool myEmergencyBrakeRedLight
Whether red lights are a reason to brake.
LaneChangeMode myRightDriveLC
changing to the rightmost lane
void setSpeedTimeLine(const std::vector< std::pair< SUMOTime, double > > &speedTimeLine)
Sets a new velocity timeline.
SUMOTime getLastAccessTimeStep() const
bool myConsiderMaxAcceleration
Whether the maximum acceleration shall be regarded.
LaneChangeMode myCooperativeLC
lane changing with the intent to help other vehicles
bool isRemoteControlled() const
bool myRespectJunctionPriority
Whether the junction priority rules are respected.
int influenceChangeDecision(const SUMOTime currentTime, const MSEdge ¤tEdge, const int currentLaneIndex, int state)
Applies stored LaneChangeMode information and laneTimeLine.
void activateGapController(double originalTau, double newTimeHeadway, double newSpaceHeadway, double duration, double changeRate, double maxDecel, MSVehicle *refVeh=nullptr)
Activates the gap control with the given parameters,.
Container for manouevering time associated with stopping.
SUMOTime myManoeuvreCompleteTime
Time at which this manoeuvre should complete.
MSVehicle::ManoeuvreType getManoeuvreType() const
Accessor (get) for manoeuvre type.
std::string myManoeuvreStop
The name of the stop associated with the Manoeuvre - for debug output.
bool manoeuvreIsComplete() const
Check if any manoeuver is ongoing and whether the completion time is beyond currentTime.
bool configureExitManoeuvre(MSVehicle *veh)
Setup the myManoeuvre for exiting (Sets completion time and manoeuvre type)
void setManoeuvreType(const MSVehicle::ManoeuvreType mType)
Accessor (set) for manoeuvre type.
Manoeuvre & operator=(const Manoeuvre &manoeuvre)
Assignment operator.
ManoeuvreType myManoeuvreType
Manoeuvre type - currently entry, exit or none.
double getGUIIncrement() const
Accessor for GUI rotation step when parking (radians)
SUMOTime myManoeuvreStartTime
Time at which the Manoeuvre for this stop started.
bool operator!=(const Manoeuvre &manoeuvre)
Operator !=.
bool entryManoeuvreIsComplete(MSVehicle *veh)
Configure an entry manoeuvre if nothing is configured - otherwise check if complete.
bool manoeuvreIsComplete(const ManoeuvreType checkType) const
Check if specific manoeuver is ongoing and whether the completion time is beyond currentTime.
bool configureEntryManoeuvre(MSVehicle *veh)
Setup the entry manoeuvre for this vehicle (Sets completion time and manoeuvre type)
Container that holds the vehicles driving state (position+speed).
double myPosLat
the stored lateral position
double myPreviousSpeed
the speed at the begin of the previous time step
double myPos
the stored position
bool operator!=(const State &state)
Operator !=.
double mySpeed
the stored speed (should be >=0 at any time)
State & operator=(const State &state)
Assignment operator.
double pos() const
Position of this state.
State(double pos, double speed, double posLat, double backPos)
Constructor.
double myBackPos
the stored back position
void passTime(SUMOTime dt, bool waiting)
const std::string getState() const
SUMOTime cumulatedWaitingTime(SUMOTime memory=-1) const
void setState(const std::string &state)
WaitingTimeCollector(SUMOTime memory=MSGlobals::gWaitingTimeMemory)
Constructor.
void registerOneWaiting(const bool isPerson)
increases the count of vehicles waiting for a transport to allow recognition of person / container re...
void registerEmergencyStop()
register emergency stop
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
void registerStopEnded()
register emergency stop
void removeVType(const MSVehicleType *vehType)
void unregisterOneWaiting(const bool isPerson)
decreases the count of vehicles waiting for a transport to allow recognition of person / container re...
void registerStopStarted()
register emergency stop
Abstract in-vehicle device.
Representation of a vehicle in the micro simulation.
void setManoeuvreType(const MSVehicle::ManoeuvreType mType)
accessor function to myManoeuvre equivalent
TraciLaneChangePriority
modes for prioritizing traci lane change requests
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)
bool wasRemoteControlled(SUMOTime lookBack=DELTA_T) const
Returns the information whether the vehicle is fully controlled via TraCI within the lookBack time.
void processLinkApproaches(double &vSafe, double &vSafeMin, double &vSafeMinDist)
This method iterates through the driveprocess items for the vehicle and adapts the given in/out param...
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
void checkRewindLinkLanes(const double lengthsInFront, DriveItemVector &lfLinks) const
runs heuristic for keeping the intersection clear in case of downstream jamming
double estimateLeaveSpeed(const MSLink *const link, const double vLinkPass) const
estimate leaving speed when accelerating across a link
bool willStop() const
Returns whether the vehicle will stop on the current edge.
double getSafeFollowSpeed(const std::pair< const MSVehicle *, double > leaderInfo, const double seen, const MSLane *const lane, double distToCrossing) const
compute safe speed for following the given leader
void 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
bool hasDriverState() const
Whether this vehicle is equipped with a MSDriverState.
static int nextLinkPriority(const std::vector< MSLane * > &conts)
get a numerical value for the priority of the upcoming link
double getTimeGapOnLane() const
Returns the time gap in seconds to the leader of the vehicle on the same lane.
void updateBestLanes(bool forceRebuild=false, const MSLane *startLane=0)
computes the best lanes to use in order to continue the route
bool myAmIdling
Whether the vehicle is trying to enter the network (eg after parking so engine is running)
SUMOTime myWaitingTime
The time the vehicle waits (is not faster than 0.1m/s) in seconds.
bool enterLaneAtMove(MSLane *enteredLane, bool onTeleporting=false)
Update when the vehicle enters a new lane in the move step.
double getStopDelay() const
Returns the public transport stop delay in seconds.
double computeAngle() const
compute the current vehicle angle
double myTimeLoss
the time loss in seconds due to driving with less than maximum speed
SUMOTime myLastActionTime
Action offset (actions are taken at time myActionOffset + N*getActionStepLength()) Initialized to 0,...
bool replaceParkingArea(MSParkingArea *parkingArea, std::string &errorMsg)
replace the current parking area stop with a new stop with merge duration
void boardTransportables(MSStop &stop)
board persons and load transportables at the given stop
const std::vector< const MSLane * > getUpcomingLanesUntil(double distance) const
Returns the upcoming (best followed by default 0) sequence of lanes to continue the route starting at...
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
void adaptLaneEntering2MoveReminder(const MSLane &enteredLane)
Adapts the vehicle's entering of a new lane.
void addTransportable(MSTransportable *transportable)
Adds a person or container to this vehicle.
MSParkingArea * getNextParkingArea()
get the upcoming parking area stop or nullptr
SUMOTime myJunctionConflictEntryTime
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...
SUMOTime getWaitingTime() const
Returns the SUMOTime waited (speed was lesser than 0.1m/s)
const std::vector< MSLane * > & getFurtherLanes() const
void workOnMoveReminders(double oldPos, double newPos, double newSpeed)
Processes active move reminder.
bool replaceStop(int nextStopIndex, SUMOVehicleParameter::Stop stop, const std::string &info, std::string &errorMsg)
bool isStoppedOnLane() const
double myAcceleration
The current acceleration after dawdling in m/s.
void adaptToLeaders(const MSLeaderInfo &ahead, double latOffset, const double seen, DriveProcessItem *const lastLink, const MSLane *const lane, double &v, double &vLinkPass) const
const MSLane * getBackLane() const
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.
std::pair< double, LinkDirection > myNextTurn
the upcoming turn for the vehicle
double getBackPositionOnLane() const
Get the vehicle's position relative to its current lane.
double getAccumulatedWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s) within the last millisecs.
bool isFrontOnLane(const MSLane *lane) const
Returns the information whether the front of the vehicle is on the given lane.
virtual ~MSVehicle()
Destructor.
double getSpaceTillLastStanding(const MSLane *l, bool &foundStopped) const
bool myAmRegisteredAsWaitingForPerson
Whether this vehicle is registered as waiting for a person (for deadlock-recognition)
bool stopsAt(MSStoppingPlace *stop) const
Returns whether the vehicle stops at the given stopping place.
void processLaneAdvances(std::vector< MSLane * > &passedLanes, std::string &emergencyReason)
This method checks if the vehicle has advanced over one or several lanes along its route and triggers...
MSAbstractLaneChangeModel & getLaneChangeModel()
void setEmergencyBlueLight(SUMOTime currentTime)
sets the blue flashing light for emergency vehicles
bool isActionStep(SUMOTime t) const
Returns whether the next simulation step will be an action point for the vehicle.
MSAbstractLaneChangeModel * myLaneChangeModel
Position getPositionAlongBestLanes(double offset) const
Return the (x,y)-position, which the vehicle would reach if it continued along its best continuation ...
bool hasValidRouteStart(std::string &msg)
checks wether the vehicle can depart on the first edge
std::vector< MSLane * > myFurtherLanes
The information into which lanes the vehicle laps into.
bool signalSet(int which) const
Returns whether the given signal is on.
MSLane * getMutableLane() const
Returns the lane the vehicle is on Non const version indicates that something volatile is going on.
MSCFModel::VehicleVariables * myCFVariables
The per vehicle variables of the car following model.
bool addTraciStop(SUMOVehicleParameter::Stop stop, std::string &errorMsg)
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)
int influenceChangeDecision(int state)
allow TraCI to influence a lane change decision
bool isRemoteControlled() const
Returns the information whether the vehicle is fully controlled via TraCI.
bool myAmOnNet
Whether the vehicle is on the network (not parking, teleported, vaporized, or arrived)
void adaptBestLanesOccupation(int laneIndex, double density)
update occupation from MSLaneChanger
void loadPreviousApproaching(MSLink *link, bool setRequest, SUMOTime arrivalTime, double arrivalSpeed, SUMOTime arrivalTimeBraking, double arrivalSpeedBraking, double dist, double leaveSpeed)
void setAngle(double angle, bool straightenFurther=false)
Set a custom vehicle angle in rad, optionally updates furtherLanePosLat.
std::vector< LaneQ >::iterator myCurrentLaneInBestLanes
double getDeltaPos(const double accel) const
calculates the distance covered in the next integration step given an acceleration and assuming the c...
const MSLane * myLastBestLanesInternalLane
void updateOccupancyAndCurrentBestLane(const MSLane *startLane)
updates LaneQ::nextOccupation and myCurrentLaneInBestLanes
WaitingTimeCollector myWaitingTimeCollector
void setRemoteState(Position xyPos)
sets position outside the road network
void fixPosition()
repair errors in vehicle position after changing between internal edges
double getAcceleration() const
Returns the vehicle's acceleration in m/s (this is computed as the last step's mean acceleration in c...
double getSpeedWithoutTraciInfluence() const
Returns the uninfluenced velocity.
bool ignoreCollision()
whether this vehicle is except from collision checks
ManoeuvreType
flag identifying which, if any, manoeuvre is in progress
@ MANOEUVRE_ENTRY
Manoeuvre into stopping place.
@ MANOEUVRE_NONE
not manouevring
@ MANOEUVRE_EXIT
Manoeuvre out of stopping place.
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.
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
void setBrakingSignals(double vNext)
sets the braking lights on/off
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the best sequence of lanes to continue the route starting at myLane.
double estimateTimeToNextStop() const
MSParkingArea * getCurrentParkingArea()
get the current parking area stop or nullptr
const MSEdge * myLastBestLanesEdge
PositionVector getBoundingPoly() const
get bounding polygon
Influencer * myInfluencer
An instance of a velocity/lane influencing instance; built in "getInfluencer".
void saveState(OutputDevice &out)
Saves the states of a vehicle.
void onRemovalFromNet(const MSMoveReminder::Notification reason)
Called when the vehicle is removed from the network.
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....
PositionVector getBoundingBox() const
get bounding rectangle
bool resumeFromStopping()
int getBestLaneOffset() const
double lateralDistanceToLane(const int offset) const
Get the minimal lateral distance required to move fully onto the lane at given offset.
bool stopsAtEdge(const MSEdge *edge) const
Returns whether the vehicle stops at the given edge.
double getBackPositionOnLane(const MSLane *lane) const
Get the vehicle's position relative to the given lane.
void resetActionOffset(const SUMOTime timeUntilNextAction=0)
Resets the action offset for the vehicle.
std::vector< DriveProcessItem > DriveItemVector
Container for used Links/visited Lanes during planMove() and executeMove.
void setBlinkerInformation()
sets the blue flashing light for emergency vehicles
DriveItemVector::iterator myNextDriveItem
iterator pointing to the next item in myLFLinkLanes
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.
bool isIdling() const
Returns whether a sim vehicle is waiting to enter a lane (after parking has completed)
std::shared_ptr< MSSimpleDriverState > getDriverState() const
Returns the vehicle driver's state.
const SUMOVehicleParameter::Stop * getNextStopParameter() const
return parameters for the next stop (SUMOVehicle Interface)
void removeApproachingInformation(const DriveItemVector &lfLinks) const
unregister approach from all upcoming links
SUMOTime myJunctionEntryTimeNeverYield
double getLatOffset(const MSLane *lane) const
Get the offset that that must be added to interpret myState.myPosLat for the given lane.
bool rerouteParkingArea(const std::string &parkingAreaID, std::string &errorMsg)
bool hasArrived() const
Returns whether this vehicle has already arived (reached the arrivalPosition on its final edge)
const MSEdge * getRerouteOrigin() const
Returns the starting point for reroutes (usually the current edge)
void switchOffSignal(int signal)
Switches the given signal off.
void updateState(double vNext)
updates the vehicles state, given a next value for its speed. This value can be negative in case of t...
double getStopArrivalDelay() const
Returns the estimated public transport stop arrival delay in seconds.
int mySignals
State of things of the vehicle that can be on or off.
bool setExitManoeuvre()
accessor function to myManoeuvre equivalent
double myStopDist
distance to the next stop or doubleMax if there is none
double getBrakeGap() const
get distance for coming to a stop (used for rerouting checks)
bool myAmRegisteredAsWaitingForContainer
Whether this vehicle is registered as waiting for a container (for deadlock-recognition)
Signalling
Some boolean values which describe the state of some vehicle parts.
@ VEH_SIGNAL_BLINKER_RIGHT
Right blinker lights are switched on.
@ VEH_SIGNAL_BRAKELIGHT
The brake lights are on.
@ VEH_SIGNAL_EMERGENCY_BLUE
A blue emergency light is on.
@ VEH_SIGNAL_BLINKER_LEFT
Left blinker lights are switched on.
bool isLeader(const MSLink *link, const MSVehicle *veh) const
whether the given vehicle must be followed at the given junction
SUMOTime getActionStepLength() const
Returns the vehicle's action step length in millisecs, i.e. the interval between two action points.
bool myHaveToWaitOnNextLink
SUMOTime collisionStopTime() const
Returns the remaining time a vehicle needs to stop due to a collision. A negative value indicates tha...
const std::vector< const MSLane * > getPastLanesUntil(double distance) const
Returns the sequence of past lanes (right-most on edge) based on the route starting at the current la...
std::pair< const MSVehicle *const, double > getLeader(double dist=0) const
Returns the leader of the vehicle looking for a fixed distance.
bool executeMove()
Executes planned vehicle movements with regards to right-of-way.
std::pair< const MSVehicle *const, double > getFollower(double dist=0) const
Returns the follower of the vehicle looking for a fixed distance.
ChangeRequest
Requests set via TraCI.
@ REQUEST_HOLD
vehicle want's to keep the current lane
@ REQUEST_LEFT
vehicle want's to change to left lane
@ REQUEST_NONE
vehicle doesn't want to change
@ REQUEST_RIGHT
vehicle want's to change to right lane
std::pair< const MSLane *, double > getLanePosAfterDist(double distance) const
return lane and position along bestlanes at the given distance
SUMOTime myCollisionImmunity
amount of time for which the vehicle is immune from collisions
bool passingMinor() const
decide whether the vehicle is passing a minor link or has comitted to do so
void updateWaitingTime(double vNext)
Updates the vehicle's waiting time counters (accumulated and consecutive)
void enterLaneAtLaneChange(MSLane *enteredLane)
Update when the vehicle enters a new lane in the laneChange step.
BaseInfluencer & getBaseInfluencer()
Returns the velocity/lane influencer.
Influencer & getInfluencer()
double getRightSideOnLane() const
Get the vehicle's lateral position on the lane:
bool unsafeLinkAhead(const MSLane *lane) const
whether the vehicle may safely move to the given lane with regard to upcoming links
double getCurrentApparentDecel() const
get apparent deceleration based on vType parameters and current acceleration
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
DriveItemVector myLFLinkLanesPrev
planned speeds from the previous step for un-registering from junctions after the new container is fi...
std::vector< std::vector< LaneQ > > myBestLanes
void setActionStepLength(double actionStepLength, bool resetActionOffset=true)
Sets the action steplength of the vehicle.
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
double getSlope() const
Returns the slope of the road at vehicle's position in degrees.
bool myActionStep
The flag myActionStep indicates whether the current time step is an action point for the vehicle.
const Position getBackPosition() const
void loadState(const SUMOSAXAttributes &attrs, const SUMOTime offset)
Loads the state of this vehicle from the given description.
double getSpeed() const
Returns the vehicle's current speed.
void setApproachingForAllLinks(const SUMOTime t)
Register junction approaches for all link items in the current plan.
SUMOTime remainingStopDuration() const
Returns the remaining stop duration for a stopped vehicle or 0.
bool keepStopping(bool afterProcessing=false) const
Returns whether the vehicle is stopped and must continue to do so.
void workOnIdleReminders()
cycle through vehicle devices invoking notifyIdle
static std::vector< MSLane * > myEmptyLaneVector
Position myCachedPosition
MSVehicle::ManoeuvreType getManoeuvreType() const
accessor function to myManoeuvre equivalent
double checkReversal(bool &canReverse, double speedThreshold=SUMO_const_haltingSpeed, double seen=0) const
void removePassedDriveItems()
Erase passed drive items from myLFLinkLanes (and unregister approaching information for corresponding...
const std::vector< LaneQ > & getBestLanes() const
Returns the description of best lanes to use in order to continue the route.
std::vector< double > myFurtherLanesPosLat
lateral positions on further lanes
bool checkActionStep(const SUMOTime t)
Returns whether the vehicle is supposed to take action in the current simulation step Updates myActio...
Position validatePosition(Position result, double offset=0) const
ensure that a vehicle-relative position is not invalid
bool keepClear(const MSLink *link) const
decide whether the given link must be kept clear
bool manoeuvreIsComplete() const
accessor function to myManoeuvre equivalent
double processNextStop(double currentVelocity)
Processes stops, returns the velocity needed to reach the stop.
double myAngle
the angle in radians (
bool ignoreRed(const MSLink *link, bool canBrake) const
decide whether a red (or yellow light) may be ignore
double getPositionOnLane() const
Get the vehicle's position along the lane.
const MSLane * getLane() const
Returns the lane the vehicle is on.
void updateTimeLoss(double vNext)
Updates the vehicle's time loss.
MSDevice_DriverState * myDriverState
This vehicle's driver state.
bool joinTrainPart(MSVehicle *veh)
try joining the given vehicle to the rear of this one (to resolve joinTriggered)
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
MSLane * myLane
The lane the vehicle is on.
bool onFurtherEdge(const MSEdge *edge) const
whether this vehicle has its back (and no its front) on the given edge
double processTraCISpeedControl(double vSafe, double vNext)
Check for speed advices from the traci client and adjust the speed vNext in the current (euler) / aft...
double getLateralOverlap() const
return the amount by which the vehicle extends laterally outside it's primary lane
double getAngle() const
Returns the vehicle's direction in radians.
bool hasInfluencer() const
double getPreviousSpeed() const
Returns the vehicle's speed before the previous time step.
MSVehicle()
invalidated default constructor
bool joinTrainPartFront(MSVehicle *veh)
try joining the given vehicle to the front of this one (to resolve joinTriggered)
void updateActionOffset(const SUMOTime oldActionStepLength, const SUMOTime newActionStepLength)
Process an updated action step length value (only affects the vehicle's action offset,...
void executeFractionalMove(double dist)
move vehicle forward by the given distance during insertion
LaneChangeMode
modes for resolving conflicts between external control (traci) and vehicle control over lane changing...
virtual void drawOutsideNetwork(bool)
register vehicle for drawing while outside the network
State myState
This Vehicles driving state (pos and speed)
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)
void activateReminders(const MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
"Activates" all current move reminder
double getDistanceToPosition(double destPos, const MSEdge *destEdge) const
void planMoveInternal(const SUMOTime t, MSLeaderInfo ahead, DriveItemVector &lfLinks, double &myStopDist, std::pair< double, LinkDirection > &myNextTurn) const
void switchOnSignal(int signal)
Switches the given signal on.
void updateParkingState()
update state while parking
bool handleCollisionStop(MSStop &stop, const bool collision, const double distToStop, const std::string &errorMsgStart, std::string &errorMsg)
DriveItemVector myLFLinkLanes
container for the planned speeds in the current step
void updateDriveItems()
Check whether the drive items (myLFLinkLanes) are up to date, and update them if required.
SUMOTime myJunctionEntryTime
time at which the current junction was entered
static MSVehicleTransfer * getInstance()
Returns the instance of this object.
void remove(MSVehicle *veh)
Remove a vehicle from this transfer object.
The car-following model and parameter.
double getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
double getMaxSpeed() const
Get vehicle's maximum speed [m/s].
double getMinGap() const
Get the free space in front of vehicles of this class.
LaneChangeModel getLaneChangeModel() const
void setLength(const double &length)
Set a new value for this type's length.
SUMOTime getExitManoeuvreTime(const int angle) const
Accessor function for parameter equivalent returning exit time for a specific manoeuver angle.
bool isVehicleSpecific() const
Returns whether this type belongs to a single vehicle only (was modified)
const std::string & getID() const
Returns the name of the vehicle type.
void setActionStepLength(const SUMOTime actionStepLength, bool resetActionOffset)
Set a new value for this type's action step length.
double getLength() const
Get vehicle's length [m].
SUMOVehicleShape getGuiShape() const
Get this vehicle type's shape.
const MSCFModel & getCarFollowModel() const
Returns the vehicle type's car following model definition (const version)
SUMOTime getEntryManoeuvreTime(const int angle) const
Accessor function for parameter equivalent returning entry time for a specific manoeuver angle.
const SUMOVTypeParameter & getParameter() const
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
const std::string & getID() const
Returns the id.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
A point in 2D or 3D with translation and scaling methods.
static const Position INVALID
used to indicate that a position is valid
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position
void append(const PositionVector &v, double sameThreshold=2.0)
double rotationAtOffset(double pos) const
Returns the rotation at the given length.
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
void move2side(double amount, double maxExtension=100)
move position vector to side using certain ammount
double slopeDegreeAtOffset(double pos) const
Returns the slope at the given length.
void scaleRelative(double factor)
enlarges/shrinks the polygon by a factor based at the centroid
PositionVector reverse() const
reverse position vector
static double rand(std::mt19937 *rng=nullptr)
Returns a random real number in [0, 1)
double recomputeCosts(const std::vector< const E * > &edges, const V *const v, SUMOTime msTime, double *lengthp=nullptr) const
virtual bool compute(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E * > &into, bool silent=false)=0
Builds the route between the given edges using the minimum effort at the given time The definition of...
Encapsulated SAX-Attributes.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
virtual double getSpeed() const =0
Returns the object's current speed.
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.
Representation of a vehicle.
Definition of vehicle stop (position and duration)
std::string lane
The lane to stop at.
SUMOTime extension
The maximum time extension for boarding / loading.
SUMOTime depart
the time at which this stop was ended
double speed
the speed at which this stop counts as reached (waypoint mode)
std::string parkingarea
(Optional) parking area if one is assigned to the stop
std::string split
the id of the vehicle (train portion) that splits of upon reaching this stop
double startPos
The stopping position start.
std::string line
the new line id of the trip within a cyclical public transport route
std::string join
the id of the vehicle (train portion) to which this vehicle shall be joined
SUMOTime actualArrival
the time at which this stop was reached
SUMOTime until
The time at which the vehicle may continue its journey.
bool triggered
whether an arriving person lets the vehicle continue
double endPos
The stopping position end.
bool parking
whether the vehicle is removed from the net while stopping
std::string tripId
id of the trip within a cyclical public transport route
bool containerTriggered
whether an arriving container lets the vehicle continue
SUMOTime arrival
The (expected) time at which the vehicle reaches the stop.
SUMOTime duration
The stopping duration.
Structure representing possible vehicle parameter.
int parametersSet
Information for the router which parameter were set, TraCI may modify this (when changing color)
int departLane
(optional) The lane the vehicle shall depart from (index in edge)
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle's end speed shall be chosen.
double departSpeed
(optional) The initial speed of the vehicle
std::vector< std::string > via
List of the via-edges the vehicle must visit.
ArrivalLaneDefinition arrivalLaneProcedure
Information how the vehicle shall choose the lane to arrive on.
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
double arrivalPos
(optional) The position the vehicle shall arrive on
std::string id
The vehicle's id.
std::vector< Stop > stops
List of the stops the vehicle will make, TraCI may add entries here.
bool wasSet(int what) const
Returns whether the given parameter was set.
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
double arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
static SUMOTime processActionStepLength(double given)
Checks and converts given value for the action step length from seconds to miliseconds assuring it be...
Drive process items represent bounds on the safe velocity corresponding to the upcoming links.
double getLeaveSpeed() const
void adaptLeaveSpeed(const double v)
static std::map< const MSVehicle *, GapControlState * > refVehMap
stores reference vehicles currently in use by a gapController
static GapControlVehStateListener vehStateListener
void activate(double tauOriginal, double tauTarget, double additionalGap, double duration, double changeRate, double maxDecel, const MSVehicle *refVeh)
Start gap control with given params.
static void cleanup()
Static cleanup (removes vehicle state listener)
virtual ~GapControlState()
void deactivate()
Stop gap control.
static void init()
Static initalization (adds vehicle state listener)
A structure representing the best lanes for continuing the current route starting at 'lane'.
double length
The overall length which may be driven when using this lane without a lane change.
bool allowsContinuation
Whether this lane allows to continue the drive.
double nextOccupation
As occupation, but without the first lane.
std::vector< MSLane * > bestContinuations
MSLane * lane
The described lane.
double currentLength
The length which may be driven on this lane.
int bestLaneOffset
The (signed) number of lanes to be crossed to get to the lane which allows to continue the drive.
double occupation
The overall vehicle sum on consecutive lanes which can be passed without a lane change.