112#define DEBUG_COND (isSelected())
114#define DEBUG_COND2(obj) (obj->isSelected())
119#define STOPPING_PLACE_OFFSET 0.5
121#define CRLL_LOOK_AHEAD 5
123#define JUNCTION_BLOCKAGE_TIME 5
126#define DIST_TO_STOPLINE_EXPECT_PRIORITY 1.0
128#define NUMERICAL_EPS_SPEED (0.1 * NUMERICAL_EPS * TS)
166 return (myPos != state.
myPos ||
176 myPos(pos), mySpeed(speed), myPosLat(posLat), myBackPos(backPos), myPreviousSpeed(previousSpeed), myLastCoveredDist(
SPEED2DIST(speed)) {}
188 assert(memorySpan <= myMemorySize);
189 if (memorySpan == -1) {
190 memorySpan = myMemorySize;
193 for (
const auto& interval : myWaitingIntervals) {
194 if (interval.second >= memorySpan) {
195 if (interval.first >= memorySpan) {
198 totalWaitingTime += memorySpan - interval.first;
201 totalWaitingTime += interval.second - interval.first;
204 return totalWaitingTime;
210 auto i = myWaitingIntervals.begin();
211 const auto end = myWaitingIntervals.end();
212 const bool startNewInterval = i == end || (i->first != 0);
215 if (i->first >= myMemorySize) {
223 auto d = std::distance(i, end);
225 myWaitingIntervals.pop_back();
231 }
else if (!startNewInterval) {
232 myWaitingIntervals.begin()->first = 0;
234 myWaitingIntervals.push_front(std::make_pair(0, dt));
242 std::ostringstream state;
243 state << myMemorySize <<
" " << myWaitingIntervals.size();
244 for (
const auto& interval : myWaitingIntervals) {
245 state <<
" " << interval.first <<
" " << interval.second;
253 std::istringstream is(state);
256 is >> myMemorySize >> numIntervals;
257 while (numIntervals-- > 0) {
259 myWaitingIntervals.emplace_back(begin, end);
278 if (GapControlState::refVehMap.find(msVeh) != end(GapControlState::refVehMap)) {
280 GapControlState::refVehMap[msVeh]->deactivate();
290std::map<const MSVehicle*, MSVehicle::Influencer::GapControlState*>
296 tauOriginal(-1), tauCurrent(-1), tauTarget(-1), addGapCurrent(-1), addGapTarget(-1),
297 remainingDuration(-1), changeRate(-1), maxDecel(-1), referenceVeh(nullptr), active(false), gapAttained(false), prevLeader(nullptr),
298 lastUpdate(-1), timeHeadwayIncrement(0.0), spaceHeadwayIncrement(0.0) {}
308 if (myVehStateListener ==
nullptr) {
314 WRITE_ERROR(
"MSVehicle::Influencer::GapControlState::init(): No MSNet instance found!")
320 if (myVehStateListener !=
nullptr) {
322 delete myVehStateListener;
323 myVehStateListener =
nullptr;
334 tauOriginal = tauOrig;
335 tauCurrent = tauOrig;
338 addGapTarget = additionalGap;
339 remainingDuration = dur;
342 referenceVeh = refVeh;
345 prevLeader =
nullptr;
347 timeHeadwayIncrement = changeRate *
TS * (tauTarget - tauOriginal);
348 spaceHeadwayIncrement = changeRate *
TS * addGapTarget;
350 if (referenceVeh !=
nullptr) {
360 if (referenceVeh !=
nullptr) {
363 referenceVeh =
nullptr;
398 GapControlState::init();
403 GapControlState::cleanup();
408 mySpeedAdaptationStarted =
true;
409 mySpeedTimeLine = speedTimeLine;
414 if (myGapControlState ==
nullptr) {
415 myGapControlState = std::make_shared<GapControlState>();
418 myGapControlState->activate(originalTau, newTimeHeadway, newSpaceHeadway, duration, changeRate, maxDecel, refVeh);
423 if (myGapControlState !=
nullptr && myGapControlState->active) {
424 myGapControlState->deactivate();
430 myLaneTimeLine = laneTimeLine;
436 for (
auto& item : myLaneTimeLine) {
437 item.second += indexShift;
449 return (1 * myConsiderSafeVelocity +
450 2 * myConsiderMaxAcceleration +
451 4 * myConsiderMaxDeceleration +
452 8 * myRespectJunctionPriority +
453 16 * myEmergencyBrakeRedLight +
454 32 * !myRespectJunctionLeaderPriority +
455 64 * !myConsiderSpeedLimit
462 return (1 * myStrategicLC +
463 4 * myCooperativeLC +
465 64 * myRightDriveLC +
466 256 * myTraciLaneChangePriority +
473 for (std::vector<std::pair<SUMOTime, int>>::iterator i = myLaneTimeLine.begin(); i != myLaneTimeLine.end(); ++i) {
477 duration -= i->first;
485 if (!myLaneTimeLine.empty()) {
486 return myLaneTimeLine.back().first;
496 while (mySpeedTimeLine.size() == 1 || (mySpeedTimeLine.size() > 1 && currentTime > mySpeedTimeLine[1].first)) {
497 mySpeedTimeLine.erase(mySpeedTimeLine.begin());
500 if (!(mySpeedTimeLine.size() < 2 || currentTime < mySpeedTimeLine[0].first)) {
502 if (!mySpeedAdaptationStarted) {
503 mySpeedTimeLine[0].second = speed;
504 mySpeedAdaptationStarted =
true;
507 const double td =
MIN2(1.0,
STEPS2TIME(currentTime - mySpeedTimeLine[0].first) /
MAX2(
TS,
STEPS2TIME(mySpeedTimeLine[1].first - mySpeedTimeLine[0].first)));
509 speed = mySpeedTimeLine[0].second - (mySpeedTimeLine[0].second - mySpeedTimeLine[1].second) * td;
510 if (myConsiderSafeVelocity) {
511 speed =
MIN2(speed, vSafe);
513 if (myConsiderMaxAcceleration) {
514 speed =
MIN2(speed, vMax);
516 if (myConsiderMaxDeceleration) {
517 speed =
MAX2(speed, vMin);
527 std::cout << currentTime <<
" Influencer::gapControlSpeed(): speed=" << speed
528 <<
", vSafe=" << vSafe
534 double gapControlSpeed = speed;
535 if (myGapControlState !=
nullptr && myGapControlState->active) {
537 const double currentSpeed = veh->
getSpeed();
539 assert(msVeh !=
nullptr);
540 const double desiredTargetTimeSpacing = myGapControlState->tauTarget * currentSpeed;
541 std::pair<const MSVehicle*, double> leaderInfo;
542 if (myGapControlState->referenceVeh ==
nullptr) {
545 leaderInfo = msVeh->
getLeader(
MAX2(desiredTargetTimeSpacing, myGapControlState->addGapCurrent) +
MAX2(brakeGap, 20.0));
548 std::cout <<
" --- no refVeh; myGapControlState->addGapCurrent: " << myGapControlState->addGapCurrent <<
", brakeGap: " << brakeGap <<
" in simstep: " <<
SIMSTEP << std::endl;
553 const MSVehicle* leader = myGapControlState->referenceVeh;
561 if (dist < -100000) {
563 std::cout <<
" Ego and reference vehicle are not in CF relation..." << std::endl;
565 std::cout <<
" Reference vehicle is behind ego..." << std::endl;
572 const double fakeDist =
MAX2(0.0, leaderInfo.second - myGapControlState->addGapCurrent);
575 const double desiredCurrentSpacing = myGapControlState->tauCurrent * currentSpeed;
576 std::cout <<
" Gap control active:"
577 <<
" currentSpeed=" << currentSpeed
578 <<
", desiredTargetTimeSpacing=" << desiredTargetTimeSpacing
579 <<
", desiredCurrentSpacing=" << desiredCurrentSpacing
580 <<
", leader=" << (leaderInfo.first ==
nullptr ?
"NULL" : leaderInfo.first->getID())
581 <<
", dist=" << leaderInfo.second
582 <<
", fakeDist=" << fakeDist
583 <<
",\n tauOriginal=" << myGapControlState->tauOriginal
584 <<
", tauTarget=" << myGapControlState->tauTarget
585 <<
", tauCurrent=" << myGapControlState->tauCurrent
589 if (leaderInfo.first !=
nullptr) {
590 if (myGapControlState->prevLeader !=
nullptr && myGapControlState->prevLeader != leaderInfo.first) {
594 myGapControlState->prevLeader = leaderInfo.first;
600 gapControlSpeed =
MIN2(gapControlSpeed,
601 cfm->
followSpeed(msVeh, currentSpeed, fakeDist, leaderInfo.first->
getSpeed(), leaderInfo.first->getCurrentApparentDecel(), leaderInfo.first));
605 std::cout <<
" -> gapControlSpeed=" << gapControlSpeed;
606 if (myGapControlState->maxDecel > 0) {
607 std::cout <<
", with maxDecel bound: " <<
MAX2(gapControlSpeed, currentSpeed -
TS * myGapControlState->maxDecel);
609 std::cout << std::endl;
612 if (myGapControlState->maxDecel > 0) {
613 gapControlSpeed =
MAX2(gapControlSpeed, currentSpeed -
TS * myGapControlState->maxDecel);
620 if (myGapControlState->lastUpdate < currentTime) {
623 std::cout <<
" Updating GapControlState." << std::endl;
626 if (myGapControlState->tauCurrent == myGapControlState->tauTarget && myGapControlState->addGapCurrent == myGapControlState->addGapTarget) {
627 if (!myGapControlState->gapAttained) {
629 myGapControlState->gapAttained = leaderInfo.first ==
nullptr || leaderInfo.second >
MAX2(desiredTargetTimeSpacing, myGapControlState->addGapTarget) - POSITION_EPS;
632 if (myGapControlState->gapAttained) {
633 std::cout <<
" Target gap was established." << std::endl;
639 myGapControlState->remainingDuration -=
TS;
642 std::cout <<
" Gap control remaining duration: " << myGapControlState->remainingDuration << std::endl;
645 if (myGapControlState->remainingDuration <= 0) {
648 std::cout <<
" Gap control duration expired, deactivating control." << std::endl;
652 myGapControlState->deactivate();
657 myGapControlState->tauCurrent =
MIN2(myGapControlState->tauCurrent + myGapControlState->timeHeadwayIncrement, myGapControlState->tauTarget);
658 myGapControlState->addGapCurrent =
MIN2(myGapControlState->addGapCurrent + myGapControlState->spaceHeadwayIncrement, myGapControlState->addGapTarget);
661 if (myConsiderSafeVelocity) {
662 gapControlSpeed =
MIN2(gapControlSpeed, vSafe);
664 if (myConsiderMaxAcceleration) {
665 gapControlSpeed =
MIN2(gapControlSpeed, vMax);
667 if (myConsiderMaxDeceleration) {
668 gapControlSpeed =
MAX2(gapControlSpeed, vMin);
670 return MIN2(speed, gapControlSpeed);
678 return myOriginalSpeed;
683 myOriginalSpeed = speed;
690 while (myLaneTimeLine.size() == 1 || (myLaneTimeLine.size() > 1 && currentTime > myLaneTimeLine[1].first)) {
691 myLaneTimeLine.erase(myLaneTimeLine.begin());
695 if (myLaneTimeLine.size() >= 2 && currentTime >= myLaneTimeLine[0].first) {
696 const int destinationLaneIndex = myLaneTimeLine[1].second;
697 if (destinationLaneIndex < (
int)currentEdge.
getLanes().size()) {
698 if (currentLaneIndex > destinationLaneIndex) {
700 }
else if (currentLaneIndex < destinationLaneIndex) {
705 }
else if (currentEdge.
getLanes().back()->getOpposite() !=
nullptr) {
714 if ((state &
LCA_TRACI) != 0 && myLatDist != 0) {
723 mode = myStrategicLC;
725 mode = myCooperativeLC;
727 mode = mySpeedGainLC;
729 mode = myRightDriveLC;
739 state &= ~LCA_WANTS_LANECHANGE_OR_STAY;
740 state &= ~LCA_URGENT;
743 state &= ~LCA_CHANGE_REASONS |
LCA_TRACI;
751 state &= ~LCA_WANTS_LANECHANGE_OR_STAY;
752 state &= ~LCA_URGENT;
772 switch (changeRequest) {
788 assert(myLaneTimeLine.size() >= 2);
789 assert(currentTime >= myLaneTimeLine[0].first);
790 return STEPS2TIME(myLaneTimeLine[1].first - currentTime);
796 myConsiderSafeVelocity = ((speedMode & 1) != 0);
797 myConsiderMaxAcceleration = ((speedMode & 2) != 0);
798 myConsiderMaxDeceleration = ((speedMode & 4) != 0);
799 myRespectJunctionPriority = ((speedMode & 8) != 0);
800 myEmergencyBrakeRedLight = ((speedMode & 16) != 0);
801 myRespectJunctionLeaderPriority = ((speedMode & 32) == 0);
802 myConsiderSpeedLimit = ((speedMode & 64) == 0);
819 myRemoteXYPos = xyPos;
822 myRemotePosLat = posLat;
823 myRemoteAngle = angle;
824 myRemoteEdgeOffset = edgeOffset;
825 myRemoteRoute = route;
826 myLastRemoteAccess = t;
838 return myLastRemoteAccess >= t -
TIME2STEPS(10);
844 if (myRemoteRoute.size() != 0 && myRemoteRoute != v->
getRoute().
getEdges()) {
847#ifdef DEBUG_REMOTECONTROL
860 const bool wasOnRoad = v->
isOnRoad();
861 const bool withinLane = myRemoteLane !=
nullptr && fabs(myRemotePosLat) < 0.5 * (myRemoteLane->getWidth() + v->
getVehicleType().
getWidth());
862 const bool keepLane = wasOnRoad && v->
getLane() == myRemoteLane;
863 if (v->
isOnRoad() && !(keepLane && withinLane)) {
864 if (myRemoteLane !=
nullptr && &v->
getLane()->
getEdge() == &myRemoteLane->getEdge()) {
871 if (myRemoteRoute.size() != 0 && myRemoteRoute != v->
getRoute().
getEdges()) {
873#ifdef DEBUG_REMOTECONTROL
874 std::cout <<
SIMSTEP <<
" postProcessRemoteControl veh=" << v->
getID()
878 <<
" newRoute=" <<
toString(myRemoteRoute)
879 <<
" newRouteEdge=" << myRemoteRoute[myRemoteEdgeOffset]->getID()
885 myRemoteRoute.clear();
888 if (myRemoteLane !=
nullptr && myRemotePos > myRemoteLane->getLength()) {
889 myRemotePos = myRemoteLane->getLength();
891 if (myRemoteLane !=
nullptr && withinLane) {
897 if (needFurtherUpdate) {
907 myRemoteLane->forceVehicleInsertion(v, myRemotePos, notify, myRemotePosLat);
914 myRemoteLane->requireCollisionCheck();
942 if (myRemoteLane !=
nullptr) {
948 if (distAlongRoute != std::numeric_limits<double>::max()) {
949 dist = distAlongRoute;
953 const double minSpeed = myConsiderMaxDeceleration ?
955 const double maxSpeed = (myRemoteLane !=
nullptr
956 ? myRemoteLane->getVehicleMaxSpeed(veh)
967 if (myRemoteLane ==
nullptr) {
977 if (dist == std::numeric_limits<double>::max()) {
981 WRITE_WARNINGF(
TL(
"Vehicle '%' moved by TraCI from % to % (dist %) with implied speed of % (exceeding maximum speed %). time=%."),
1047 further->resetPartialOccupation(
this);
1048 if (further->getBidiLane() !=
nullptr
1049 && (!
isRailway(
getVClass()) || (further->getPermissions() & ~SVC_RAIL_CLASSES) != 0)) {
1050 further->getBidiLane()->resetPartialOccupation(
this);
1067#ifdef DEBUG_ACTIONSTEPS
1069 std::cout <<
SIMTIME <<
" Removing vehicle '" <<
getID() <<
"' (reason: " <<
toString(reason) <<
")" << std::endl;
1094 if (!(*myCurrEdge)->isTazConnector()) {
1097 if ((*myCurrEdge)->getDepartLane(*
this) ==
nullptr) {
1098 msg =
"Invalid departLane definition for vehicle '" +
getID() +
"'.";
1108 msg =
"Vehicle '" +
getID() +
"' is not allowed to depart on any lane of edge '" + (*myCurrEdge)->
getID() +
"'.";
1114 msg =
"Departure speed for vehicle '" +
getID() +
"' is too high for the vehicle type '" +
myType->
getID() +
"'.";
1145 updateBestLanes(
true, onInit ? (*myCurrEdge)->getLanes().front() : 0);
1148 myStopDist = std::numeric_limits<double>::max();
1166 if (!rem->first->notifyMove(*
this, oldPos + rem->second, newPos + rem->second,
MAX2(0., newSpeed))) {
1168 if (myTraceMoveReminders) {
1169 traceMoveReminder(
"notifyMove", rem->first, rem->second,
false);
1175 if (myTraceMoveReminders) {
1176 traceMoveReminder(
"notifyMove", rem->first, rem->second,
true);
1195 rem.first->notifyIdle(*
this);
1200 rem->notifyIdle(*
this);
1211 rem.second += oldLaneLength;
1215 if (myTraceMoveReminders) {
1216 traceMoveReminder(
"adaptedPos", rem.first, rem.second,
true);
1230 return getStops().begin()->parkingarea->getVehicleSlope(*
this);
1238 int furtherIndex = 0;
1239 while (centerPos < 0 && furtherIndex < (
int)
myFurtherLanes.size()) {
1279 if (
myStops.begin()->parkingarea !=
nullptr) {
1280 return myStops.begin()->parkingarea->getVehiclePosition(*
this);
1290 if (offset == 0. && !changingLanes) {
1313 double relOffset = fabs(posLat) / centerDist;
1314 double newZ = (1 - relOffset) * pos.
z() + relOffset * shadowPos.
z();
1325 return MAX2(0.0, result);
1343 auto nextBestLane = bestLanes.begin();
1348 bool success =
true;
1350 while (offset > 0) {
1355 lane = lane->
getLinkCont()[0]->getViaLaneOrLane();
1357 if (lane ==
nullptr) {
1367 while (nextBestLane != bestLanes.end() && *nextBestLane ==
nullptr) {
1372 assert(lane == *nextBestLane);
1376 assert(nextBestLane == bestLanes.end() || *nextBestLane != 0);
1377 if (nextBestLane == bestLanes.end()) {
1382 assert(link !=
nullptr);
1413 int furtherIndex = 0;
1422 offset += lastLength;
1432ConstMSEdgeVector::const_iterator
1458 return angleDiff == 0
1459 ? std::numeric_limits<double>::max()
1468 std::cout <<
SIMTIME <<
" veh '" <<
getID() <<
" setAngle(" << angle <<
") straightenFurther=" << straightenFurther << std::endl;
1477 if (link !=
nullptr) {
1492 const bool newActionStepLength = actionStepLengthMillisecs != previousActionStepLength;
1493 if (newActionStepLength) {
1523 if (
myStops.begin()->parkingarea !=
nullptr) {
1524 return myStops.begin()->parkingarea->getVehicleAngle(*
this);
1561 double result = (p1 != p2 ? p2.
angleTo2D(p1) :
1628 ||
myStops.front().pars.breakDown || (
myStops.front().getSpeed() > 0
1640 return myStops.front().duration;
1668 return currentVelocity;
1673 std::cout <<
"\nPROCESS_NEXT_STOP\n" <<
SIMTIME <<
" vehicle '" <<
getID() <<
"'" << std::endl;
1683 if (stop.
busstop !=
nullptr) {
1702 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' reached stop.\n"
1736 if (taxiDevice !=
nullptr) {
1740 return currentVelocity;
1746 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' resumes from stopping." << std::endl;
1770 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' registers as waiting for person." << std::endl;
1785 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' registers as waiting for container." << std::endl;
1808 return currentVelocity;
1824 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' hasn't reached next stop." << std::endl;
1834 if (noExits && noEntries) {
1845 bool fitsOnStoppingPlace =
true;
1847 if (stop.
busstop !=
nullptr) {
1857 fitsOnStoppingPlace =
false;
1861 if (rem->isParkingRerouter()) {
1865 if (
myStops.empty() ||
myStops.front().parkingarea != oldParkingArea) {
1867 return currentVelocity;
1870 fitsOnStoppingPlace =
false;
1872 fitsOnStoppingPlace =
false;
1885 std::cout <<
" pos=" <<
myState.
pos() <<
" speed=" << currentVelocity <<
" targetPos=" << targetPos <<
" fits=" << fitsOnStoppingPlace
1886 <<
" reachedThresh=" << reachedThreshold
1887 <<
" posReached=" << posReached
1904 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' reached next stop." << std::endl;
1931 if (stop.
busstop !=
nullptr) {
1957 if (splitVeh ==
nullptr) {
1988 return currentVelocity;
2011 bool unregister =
false;
2041 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' unregisters as waiting for transportable." << std::endl;
2056 myStops.begin()->joinTriggered =
false;
2075 double skippedLaneLengths = 0;
2090 std::string warn =
TL(
"Cannot join vehicle '%' to vehicle '%' due to incompatible routes. time=%.");
2097 std::string warn =
TL(
"Cannot join vehicle '%' to vehicle '%' due to incompatible routes. time=%.");
2110 myStops.begin()->joinTriggered =
false;
2147 if (timeSinceLastAction == 0) {
2149 timeSinceLastAction = oldActionStepLength;
2151 if (timeSinceLastAction >= newActionStepLength) {
2155 SUMOTime timeUntilNextAction = newActionStepLength - timeSinceLastAction;
2164#ifdef DEBUG_PLAN_MOVE
2170 <<
" veh=" <<
getID()
2186#ifdef DEBUG_ACTIONSTEPS
2188 std::cout <<
STEPS2TIME(t) <<
" vehicle '" <<
getID() <<
"' skips action." << std::endl;
2196#ifdef DEBUG_ACTIONSTEPS
2198 std::cout <<
STEPS2TIME(t) <<
" vehicle = '" <<
getID() <<
"' takes action." << std::endl;
2206#ifdef DEBUG_PLAN_MOVE
2208 DriveItemVector::iterator i;
2211 <<
" vPass=" << (*i).myVLinkPass
2212 <<
" vWait=" << (*i).myVLinkWait
2213 <<
" linkLane=" << ((*i).myLink == 0 ?
"NULL" : (*i).myLink->getViaLaneOrLane()->getID())
2214 <<
" request=" << (*i).mySetRequest
2243 const bool result = (
overlap > POSITION_EPS
2260#ifdef DEBUG_PLAN_MOVE
2268 <<
" result=" << result <<
"\n";
2279 newStopDist = std::numeric_limits<double>::max();
2289 double lateralShift = 0;
2293 laneMaxV =
MIN2(laneMaxV, l->getVehicleMaxSpeed(
this, maxVD));
2294#ifdef DEBUG_PLAN_MOVE
2296 std::cout <<
" laneMaxV=" << laneMaxV <<
" lane=" << l->getID() <<
"\n";
2302 laneMaxV =
MAX2(laneMaxV, vMinComfortable);
2304 laneMaxV = std::numeric_limits<double>::max();
2318 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" speedBeforeTraci=" << v;
2324 std::cout <<
" influencedSpeed=" << v;
2330 std::cout <<
" gapControlSpeed=" << v <<
"\n";
2338#ifdef DEBUG_PLAN_MOVE
2340 std::cout <<
" dist=" << dist <<
" bestLaneConts=" <<
toString(bestLaneConts)
2341 <<
"\n maxV=" << maxV <<
" laneMaxV=" << laneMaxV <<
" v=" << v <<
"\n";
2344 assert(bestLaneConts.size() > 0);
2345 bool hadNonInternal =
false;
2348 nextTurn.first = seen;
2349 nextTurn.second =
nullptr;
2351 double seenNonInternal = 0;
2356 bool slowedDownForMinor =
false;
2357 double mustSeeBeforeReversal = 0;
2362 bool foundRailSignal = !
isRail();
2363 bool planningToStop =
false;
2364#ifdef PARALLEL_STOPWATCH
2370 if (v > vMinComfortable &&
hasStops() &&
myStops.front().pars.arrival >= 0 && sfp > 0
2372 && !
myStops.front().reached) {
2374 v =
MIN2(v, vSlowDown);
2376 auto stopIt =
myStops.begin();
2387 const double gapOffset = leaderLane ==
myLane ? 0 : seen - leaderLane->
getLength();
2393 if (cand.first != 0) {
2394 if ((cand.first->myLaneChangeModel->isOpposite() && cand.first->getLaneChangeModel().getShadowLane() != leaderLane)
2395 || (!cand.first->myLaneChangeModel->isOpposite() && cand.first->getLaneChangeModel().getShadowLane() == leaderLane)) {
2397 oppositeLeaders.
addLeader(cand.first, cand.second + gapOffset -
getVehicleType().getMinGap() + cand.first->getVehicleType().
getMinGap() - cand.first->getVehicleType().getLength());
2400 const bool assumeStopped = cand.first->isStopped() || cand.first->getWaitingSeconds() > 1;
2401 const double predMaxDist = cand.first->getSpeed() + (assumeStopped ? 0 : cand.first->getCarFollowModel().getMaxAccel()) * minTimeToLeaveLane;
2402 if (cand.second >= 0 && (cand.second - v * minTimeToLeaveLane - predMaxDist < 0 || assumeStopped)) {
2408#ifdef DEBUG_PLAN_MOVE
2410 std::cout <<
" leaderLane=" << leaderLane->
getID() <<
" gapOffset=" << gapOffset <<
" minTimeToLeaveLane=" << minTimeToLeaveLane
2411 <<
" cands=" << cands.
toString() <<
" oppositeLeaders=" << oppositeLeaders.
toString() <<
"\n";
2419 const bool outsideLeft = leftOL > lane->
getWidth();
2420#ifdef DEBUG_PLAN_MOVE
2422 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" lane=" << lane->
getID() <<
" rightOL=" << rightOL <<
" leftOL=" << leftOL <<
"\n";
2425 if (rightOL < 0 || outsideLeft) {
2429 int sublaneOffset = 0;
2436#ifdef DEBUG_PLAN_MOVE
2438 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" lane=" << lane->
getID() <<
" sublaneOffset=" << sublaneOffset <<
" outsideLeft=" << outsideLeft <<
"\n";
2443 && ((!outsideLeft && cand->getLeftSideOnEdge() < 0)
2444 || (outsideLeft && cand->getLeftSideOnEdge() > lane->
getEdge().
getWidth()))) {
2446#ifdef DEBUG_PLAN_MOVE
2448 std::cout <<
" outsideLeader=" << cand->getID() <<
" ahead=" << outsideLeaders.
toString() <<
"\n";
2455 adaptToLeaders(outsideLeaders, lateralShift, seen, lastLink, leaderLane, v, vLinkPass);
2459 adaptToLeaders(ahead, lateralShift, seen, lastLink, leaderLane, v, vLinkPass);
2461 if (lastLink !=
nullptr) {
2464#ifdef DEBUG_PLAN_MOVE
2466 std::cout <<
"\nv = " << v <<
"\n";
2474 if (shadowLane !=
nullptr
2488#ifdef DEBUG_PLAN_MOVE
2490 std::cout <<
SIMTIME <<
" opposite veh=" <<
getID() <<
" shadowLane=" << shadowLane->
getID() <<
" latOffset=" << latOffset <<
" shadowLeaders=" << shadowLeaders.
toString() <<
"\n";
2498 adaptToLeaders(shadowLeaders, latOffset, seen - turningDifference, lastLink, shadowLane, v, vLinkPass);
2503 const double latOffset = 0;
2504#ifdef DEBUG_PLAN_MOVE
2506 std::cout <<
SIMTIME <<
" opposite shadows veh=" <<
getID() <<
" shadowLane=" << shadowLane->
getID()
2507 <<
" latOffset=" << latOffset <<
" shadowLeaders=" << shadowLeaders.
toString() <<
"\n";
2511#ifdef DEBUG_PLAN_MOVE
2513 std::cout <<
" shadowLeadersFixed=" << shadowLeaders.
toString() <<
"\n";
2522 const double relativePos = lane->
getLength() - seen;
2523#ifdef DEBUG_PLAN_MOVE
2525 std::cout <<
SIMTIME <<
" adapt to pedestrians on lane=" << lane->
getID() <<
" relPos=" << relativePos <<
"\n";
2531 if (leader.first != 0) {
2533 v =
MIN2(v, stopSpeed);
2534#ifdef DEBUG_PLAN_MOVE
2536 std::cout <<
SIMTIME <<
" pedLeader=" << leader.first->getID() <<
" dist=" << leader.second <<
" v=" << v <<
"\n";
2545 const double relativePos = seen;
2546#ifdef DEBUG_PLAN_MOVE
2548 std::cout <<
SIMTIME <<
" adapt to pedestrians on lane=" << lane->
getID() <<
" relPos=" << relativePos <<
"\n";
2555 if (leader.first != 0) {
2557 v =
MIN2(v, stopSpeed);
2558#ifdef DEBUG_PLAN_MOVE
2560 std::cout <<
SIMTIME <<
" pedLeader=" << leader.first->getID() <<
" dist=" << leader.second <<
" v=" << v <<
"\n";
2569#ifdef DEBUG_PLAN_MOVE
2571 std::cout <<
SIMTIME <<
" applying cooperativeHelpSpeed v=" << vHelp <<
"\n";
2578 bool foundRealStop =
false;
2579 while (stopIt !=
myStops.end()
2580 && ((&stopIt->lane->getEdge() == &lane->
getEdge())
2581 || (stopIt->isOpposite && stopIt->lane->getEdge().getOppositeEdge() == &lane->
getEdge()))
2584 double stopDist = std::numeric_limits<double>::max();
2585 const MSStop& stop = *stopIt;
2586 const bool isFirstStop = stopIt ==
myStops.begin();
2590 bool isWaypoint = stop.
getSpeed() > 0;
2591 double endPos = stop.
getEndPos(*
this) + NUMERICAL_EPS;
2596 }
else if (isWaypoint && !stop.
reached) {
2599 stopDist = seen + endPos - lane->
getLength();
2602 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" stopDist=" << stopDist <<
" stopLane=" << stop.
lane->
getID() <<
" stopEndPos=" << endPos <<
"\n";
2605 double stopSpeed = laneMaxV;
2607 bool waypointWithStop =
false;
2620 if (stop.
getUntil() > t + time2end) {
2622 double distToEnd = stopDist;
2627 waypointWithStop =
true;
2629 const_cast<MSStop&
>(stop).waypointWithStop =
true;
2636 stopDist = std::numeric_limits<double>::max();
2643 if (lastLink !=
nullptr) {
2651 stopSpeed =
MAX2(stopSpeed, vMinComfortable);
2653 std::vector<std::pair<SUMOTime, double> > speedTimeLine;
2655 speedTimeLine.push_back(std::make_pair(
SIMSTEP +
DELTA_T, stopSpeed));
2658 if (lastLink !=
nullptr) {
2664 newStopSpeed =
MIN2(newStopSpeed, stopSpeed);
2667 newStopSpeed = std::numeric_limits<double>::max();
2669 v =
MIN2(v, stopSpeed);
2671 std::vector<MSLink*>::const_iterator exitLink =
MSLane::succLinkSec(*
this, view + 1, *lane, bestLaneConts);
2673 bool dummySetRequest;
2674 double dummyVLinkWait;
2678#ifdef DEBUG_PLAN_MOVE
2680 std::cout <<
"\n" <<
SIMTIME <<
" next stop: distance = " << stopDist <<
" requires stopSpeed = " << stopSpeed <<
"\n";
2685 newStopDist = stopDist;
2689 planningToStop =
true;
2691 lfLinks.emplace_back(v, stopDist);
2692 foundRealStop =
true;
2699 if (foundRealStop) {
2705 std::vector<MSLink*>::const_iterator link =
MSLane::succLinkSec(*
this, view + 1, *lane, bestLaneConts);
2708 const int currentIndex = lane->
getIndex();
2709 const MSLane* bestJump =
nullptr;
2711 if (preb.allowsContinuation &&
2712 (bestJump ==
nullptr
2713 || abs(currentIndex - preb.lane->getIndex()) < abs(currentIndex - bestJump->
getIndex()))) {
2714 bestJump = preb.lane;
2717 if (bestJump !=
nullptr) {
2719 for (
auto cand_it = bestJump->
getLinkCont().begin(); cand_it != bestJump->
getLinkCont().end(); cand_it++) {
2720 if (&(*cand_it)->getLane()->getEdge() == nextEdge) {
2729 if (!encounteredTurn) {
2737 nextTurn.first = seen;
2738 nextTurn.second = *link;
2739 encounteredTurn =
true;
2740#ifdef DEBUG_NEXT_TURN
2743 <<
" at " << nextTurn.first <<
"m." << std::endl;
2758 const double va =
MAX2(NUMERICAL_EPS, cfModel.
freeSpeed(
this,
getSpeed(), distToArrival, arrivalSpeed));
2760 if (lastLink !=
nullptr) {
2769 || (opposite && (*link)->getViaLaneOrLane()->getParallelOpposite() ==
nullptr
2772 if (lastLink !=
nullptr) {
2780#ifdef DEBUG_PLAN_MOVE
2782 std::cout <<
" braking for link end lane=" << lane->
getID() <<
" seen=" << seen
2788 lfLinks.emplace_back(v, seen);
2792 lateralShift += (*link)->getLateralShift();
2793 const bool yellowOrRed = (*link)->haveRed() || (*link)->haveYellow();
2802 double laneStopOffset;
2807 const bool canBrakeBeforeLaneEnd = seen >= brakeDist;
2811 laneStopOffset = majorStopOffset;
2812 }
else if ((*link)->havePriority()) {
2814 laneStopOffset =
MIN2((*link)->getFoeVisibilityDistance() - POSITION_EPS, majorStopOffset);
2818#ifdef DEBUG_PLAN_MOVE
2820 std::cout <<
" minorStopOffset=" << minorStopOffset <<
" distToFoePedCrossing=" << (*link)->getDistToFoePedCrossing() <<
"\n";
2829 laneStopOffset =
MIN2((*link)->getFoeVisibilityDistance() - POSITION_EPS, minorStopOffset);
2831#ifdef DEBUG_PLAN_MOVE
2833 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" desired stopOffset on lane '" << lane->
getID() <<
"' is " << laneStopOffset <<
"\n";
2836 if (canBrakeBeforeLaneEnd) {
2838 laneStopOffset =
MIN2(laneStopOffset, seen - brakeDist);
2840 laneStopOffset =
MAX2(POSITION_EPS, laneStopOffset);
2841 double stopDist =
MAX2(0., seen - laneStopOffset);
2845 stopDist = std::numeric_limits<double>::max();
2847 if (newStopDist != std::numeric_limits<double>::max()) {
2848 stopDist =
MAX2(stopDist, newStopDist);
2850#ifdef DEBUG_PLAN_MOVE
2852 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" effective stopOffset on lane '" << lane->
getID()
2853 <<
"' is " << laneStopOffset <<
" (-> stopDist=" << stopDist <<
")" << std::endl;
2862 mustSeeBeforeReversal = 2 * seen +
getLength();
2864 v =
MIN2(v, vMustReverse);
2867 foundRailSignal |= ((*link)->getTLLogic() !=
nullptr
2872 if (!planningToStop) {
2874 bool canReverseEventually =
false;
2875 const double vReverse =
checkReversal(canReverseEventually, laneMaxV, seen);
2876 v =
MIN2(v, vReverse);
2877#ifdef DEBUG_PLAN_MOVE
2879 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" canReverseEventually=" << canReverseEventually <<
" v=" << v <<
"\n";
2893 assert(timeRemaining != 0);
2896 (seen - POSITION_EPS) / timeRemaining);
2897#ifdef DEBUG_PLAN_MOVE
2899 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" slowing down to finish continuous change before"
2900 <<
" link=" << (*link)->getViaLaneOrLane()->getID()
2901 <<
" timeRemaining=" << timeRemaining
2914 const bool abortRequestAfterMinor = slowedDownForMinor && (*link)->getInternalLaneBefore() ==
nullptr;
2916 bool setRequest = (v >
NUMERICAL_EPS_SPEED && !abortRequestAfterMinor) || (leavingCurrentIntersection);
2919 double vLinkWait =
MIN2(v, stopSpeed);
2920#ifdef DEBUG_PLAN_MOVE
2923 <<
" stopDist=" << stopDist
2924 <<
" stopDecel=" << stopDecel
2925 <<
" vLinkWait=" << vLinkWait
2926 <<
" brakeDist=" << brakeDist
2928 <<
" leaveIntersection=" << leavingCurrentIntersection
2929 <<
" setRequest=" << setRequest
2938 if (yellowOrRed && canBrakeBeforeStopLine && !
ignoreRed(*link, canBrakeBeforeStopLine) && seen >= mustSeeBeforeReversal) {
2945 lfLinks.push_back(
DriveProcessItem(*link, v, vLinkWait,
false, arrivalTime, vLinkWait, 0, seen, -1));
2956#ifdef DEBUG_PLAN_MOVE
2958 <<
" ignoreRed spent=" <<
STEPS2TIME(t - (*link)->getLastStateChange())
2959 <<
" redSpeed=" << redSpeed
2968 if (lastLink !=
nullptr) {
2971 double arrivalSpeed = vLinkPass;
2977 const double visibilityDistance = (*link)->getFoeVisibilityDistance();
2978 const double determinedFoePresence = seen <= visibilityDistance;
2983#ifdef DEBUG_PLAN_MOVE
2985 std::cout <<
" approaching link=" << (*link)->getViaLaneOrLane()->getID() <<
" prio=" << (*link)->havePriority() <<
" seen=" << seen <<
" visibilityDistance=" << visibilityDistance <<
" brakeDist=" << brakeDist <<
"\n";
2989 const bool couldBrakeForMinor = !(*link)->havePriority() && brakeDist < seen && !(*link)->lastWasContMajor();
2990 if (couldBrakeForMinor && !determinedFoePresence) {
2995 arrivalSpeed =
MIN2(vLinkPass, maxArrivalSpeed);
2996 slowedDownForMinor =
true;
2997#ifdef DEBUG_PLAN_MOVE
2999 std::cout <<
" slowedDownForMinor maxSpeedAtVisDist=" << maxSpeedAtVisibilityDist <<
" maxArrivalSpeed=" << maxArrivalSpeed <<
" arrivalSpeed=" << arrivalSpeed <<
"\n";
3005 std::pair<const SUMOVehicle*, const MSLink*> blocker = (*link)->getFirstApproachingFoe(*link);
3008 while (blocker.second !=
nullptr && blocker.second != *link && n > 0) {
3009 blocker = blocker.second->getFirstApproachingFoe(*link);
3017 if (blocker.second == *link) {
3027 if (couldBrakeForMinor && determinedFoePresence && (*link)->getLane()->getEdge().isRoundabout()) {
3028 const bool wasOpened = (*link)->opened(arrivalTime, arrivalSpeed, arrivalSpeed,
3032 nullptr,
false,
this);
3034 slowedDownForMinor =
true;
3036#ifdef DEBUG_PLAN_MOVE
3038 std::cout <<
" slowedDownForMinor at roundabout=" << (!wasOpened) <<
"\n";
3045 double arrivalSpeedBraking = 0;
3046 const double bGap = cfModel.
brakeGap(v);
3047 if (seen < bGap && !
isStopped() && !planningToStop) {
3052 arrivalSpeedBraking =
MIN2(arrivalSpeedBraking, arrivalSpeed);
3061 const double estimatedLeaveSpeed =
MIN2((*link)->getViaLaneOrLane()->getVehicleMaxSpeed(
this, maxVD),
3064 arrivalTime, arrivalSpeed,
3065 arrivalSpeedBraking,
3066 seen, estimatedLeaveSpeed));
3067 if ((*link)->getViaLane() ==
nullptr) {
3068 hadNonInternal =
true;
3071#ifdef DEBUG_PLAN_MOVE
3073 std::cout <<
" checkAbort setRequest=" << setRequest <<
" v=" << v <<
" seen=" << seen <<
" dist=" << dist
3074 <<
" seenNonInternal=" << seenNonInternal
3075 <<
" seenInternal=" << seenInternal <<
" length=" << vehicleLength <<
"\n";
3079 if ((!setRequest || v <= 0 || seen > dist) && hadNonInternal && seenNonInternal >
MAX2(vehicleLength *
CRLL_LOOK_AHEAD, vehicleLength + seenInternal) && foundRailSignal) {
3083 lane = (*link)->getViaLaneOrLane();
3086 laneMaxV = std::numeric_limits<double>::max();
3092 const double va =
MAX2(cfModel.
freeSpeed(
this,
getSpeed(), seen, laneMaxV), vMinComfortable - NUMERICAL_EPS);
3094#ifdef DEBUG_PLAN_MOVE
3096 std::cout <<
" laneMaxV=" << laneMaxV <<
" freeSpeed=" << va <<
" v=" << v <<
"\n";
3106 if (leaderLane ==
nullptr) {
3113 lastLink = &lfLinks.back();
3122#ifdef PARALLEL_STOPWATCH
3146 const double s = timeDist.second;
3153 const double radicand = 4 * t * t * b * b - 8 * s * b;
3154 const double x = radicand >= 0 ? t * b - sqrt(radicand) * 0.5 : vSlowDownMin;
3155 double vSlowDown = x < vSlowDownMin ? vSlowDownMin : x;
3156#ifdef DEBUG_PLAN_MOVE
3158 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" ad=" << arrivalDelay <<
" t=" << t <<
" vsm=" << vSlowDownMin
3159 <<
" r=" << radicand <<
" vs=" << vSlowDown <<
"\n";
3193 const MSLane*
const lane,
double& v,
double& vLinkPass)
const {
3196 ahead.
getSubLanes(
this, latOffset, rightmost, leftmost);
3197#ifdef DEBUG_PLAN_MOVE
3199 <<
"\nADAPT_TO_LEADERS\nveh=" <<
getID()
3200 <<
" lane=" << lane->
getID()
3201 <<
" latOffset=" << latOffset
3202 <<
" rm=" << rightmost
3203 <<
" lm=" << leftmost
3218 for (
int sublane = rightmost; sublane <= leftmost; ++sublane) {
3220 if (pred !=
nullptr && pred !=
this) {
3223 double gap = (lastLink ==
nullptr
3226 bool oncoming =
false;
3230 gap = (lastLink ==
nullptr
3235 gap = (lastLink ==
nullptr
3244#ifdef DEBUG_PLAN_MOVE
3246 std::cout <<
" fixedGap=" << gap <<
" predMaxDist=" << predMaxDist <<
"\n";
3256#ifdef DEBUG_PLAN_MOVE
3258 std::cout <<
" pred=" << pred->
getID() <<
" predLane=" << pred->
getLane()->
getID() <<
" predPos=" << pred->
getPositionOnLane() <<
" gap=" << gap <<
" predBack=" << predBack <<
" seen=" << seen <<
" lane=" << lane->
getID() <<
" myLane=" <<
myLane->
getID() <<
" lastLink=" << (lastLink ==
nullptr ?
"NULL" : lastLink->
myLink->
getDescription()) <<
" oncoming=" << oncoming <<
"\n";
3261 if (oncoming && gap >= 0) {
3264 adaptToLeader(std::make_pair(pred, gap), seen, lastLink, v, vLinkPass);
3274 double& v,
double& vLinkPass)
const {
3277 ahead.
getSubLanes(
this, latOffset, rightmost, leftmost);
3278#ifdef DEBUG_PLAN_MOVE
3280 <<
"\nADAPT_TO_LEADERS_DISTANCE\nveh=" <<
getID()
3281 <<
" latOffset=" << latOffset
3282 <<
" rm=" << rightmost
3283 <<
" lm=" << leftmost
3287 for (
int sublane = rightmost; sublane <= leftmost; ++sublane) {
3290 if (pred !=
nullptr && pred !=
this) {
3291#ifdef DEBUG_PLAN_MOVE
3293 std::cout <<
" pred=" << pred->
getID() <<
" predLane=" << pred->
getLane()->
getID() <<
" predPos=" << pred->
getPositionOnLane() <<
" gap=" << predDist.second <<
"\n";
3306 double& v,
double& vLinkPass)
const {
3307 if (leaderInfo.first != 0) {
3309#ifdef DEBUG_PLAN_MOVE_LEADERINFO
3311 std::cout <<
" foe ignored\n";
3317 double vsafeLeader = 0;
3319 vsafeLeader = -std::numeric_limits<double>::max();
3321 bool backOnRoute =
true;
3322 if (leaderInfo.second < 0 && lastLink !=
nullptr && lastLink->
myLink !=
nullptr) {
3323 backOnRoute =
false;
3328 if (leaderInfo.first->getBackLane() == current) {
3332 if (lane == current) {
3335 if (leaderInfo.first->getBackLane() == lane) {
3340#ifdef DEBUG_PLAN_MOVE
3342 std::cout <<
SIMTIME <<
" current=" << current->
getID() <<
" leaderBackLane=" << leaderInfo.first->getBackLane()->getID() <<
" backOnRoute=" << backOnRoute <<
"\n";
3346 double stopDist = seen - current->
getLength() - POSITION_EPS;
3355 vsafeLeader = cfModel.
followSpeed(
this,
getSpeed(), leaderInfo.second, leaderInfo.first->getSpeed(), leaderInfo.first->getCurrentApparentDecel(), leaderInfo.first);
3357 if (lastLink !=
nullptr) {
3360#ifdef DEBUG_PLAN_MOVE
3362 std::cout <<
" vlinkpass=" << lastLink->
myVLinkPass <<
" futureVSafe=" << futureVSafe <<
"\n";
3366 v =
MIN2(v, vsafeLeader);
3367 vLinkPass =
MIN2(vLinkPass, vsafeLeader);
3368#ifdef DEBUG_PLAN_MOVE
3372 <<
" veh=" <<
getID()
3373 <<
" lead=" << leaderInfo.first->getID()
3374 <<
" leadSpeed=" << leaderInfo.first->getSpeed()
3375 <<
" gap=" << leaderInfo.second
3376 <<
" leadLane=" << leaderInfo.first->getLane()->getID()
3377 <<
" predPos=" << leaderInfo.first->getPositionOnLane()
3380 <<
" vSafeLeader=" << vsafeLeader
3381 <<
" vLinkPass=" << vLinkPass
3391 const MSLane*
const lane,
double& v,
double& vLinkPass,
3392 double distToCrossing)
const {
3393 if (leaderInfo.first != 0) {
3395#ifdef DEBUG_PLAN_MOVE_LEADERINFO
3397 std::cout <<
" junction foe ignored\n";
3403 double vsafeLeader = 0;
3405 vsafeLeader = -std::numeric_limits<double>::max();
3407 if (leaderInfo.second >= 0) {
3409 vsafeLeader = cfModel.
followSpeed(
this,
getSpeed(), leaderInfo.second, leaderInfo.first->getSpeed(), leaderInfo.first->getCurrentApparentDecel(), leaderInfo.first);
3412 vsafeLeader = cfModel.
insertionFollowSpeed(
this,
getSpeed(), leaderInfo.second, leaderInfo.first->getSpeed(), leaderInfo.first->getCurrentApparentDecel(), leaderInfo.first);
3414 }
else if (leaderInfo.first !=
this) {
3418#ifdef DEBUG_PLAN_MOVE_LEADERINFO
3420 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" stopping before junction: lane=" << lane->
getID() <<
" seen=" << seen
3422 <<
" stopDist=" << seen - lane->
getLength() - POSITION_EPS
3423 <<
" vsafeLeader=" << vsafeLeader
3424 <<
" distToCrossing=" << distToCrossing
3429 if (distToCrossing >= 0) {
3432 if (leaderInfo.first ==
this) {
3434 const double vStopCrossing = cfModel.
stopSpeed(
this,
getSpeed(), distToCrossing);
3435 vsafeLeader = vStopCrossing;
3436#ifdef DEBUG_PLAN_MOVE_LEADERINFO
3438 std::cout <<
" breaking for pedestrian distToCrossing=" << distToCrossing <<
" vStopCrossing=" << vStopCrossing <<
"\n";
3441 if (lastLink !=
nullptr) {
3444 }
else if (leaderInfo.second == -std::numeric_limits<double>::max()) {
3446#ifdef DEBUG_PLAN_MOVE_LEADERINFO
3448 std::cout <<
" stop at crossing point for critical leader vStop=" << vStop <<
"\n";
3451 vsafeLeader =
MAX2(vsafeLeader, vStop);
3453 const double leaderDistToCrossing = distToCrossing - leaderInfo.second;
3461 vsafeLeader =
MAX2(vsafeLeader,
MIN2(v2, vStop));
3462#ifdef DEBUG_PLAN_MOVE_LEADERINFO
3464 std::cout <<
" driving up to the crossing point (distToCrossing=" << distToCrossing <<
")"
3465 <<
" leaderPastCPTime=" << leaderPastCPTime
3466 <<
" vFinal=" << vFinal
3468 <<
" vStop=" << vStop
3469 <<
" vsafeLeader=" << vsafeLeader <<
"\n";
3474 if (lastLink !=
nullptr) {
3477 v =
MIN2(v, vsafeLeader);
3478 vLinkPass =
MIN2(vLinkPass, vsafeLeader);
3479#ifdef DEBUG_PLAN_MOVE
3483 <<
" veh=" <<
getID()
3484 <<
" lead=" << leaderInfo.first->getID()
3485 <<
" leadSpeed=" << leaderInfo.first->getSpeed()
3486 <<
" gap=" << leaderInfo.second
3487 <<
" leadLane=" << leaderInfo.first->getLane()->getID()
3488 <<
" predPos=" << leaderInfo.first->getPositionOnLane()
3490 <<
" lane=" << lane->
getID()
3492 <<
" dTC=" << distToCrossing
3494 <<
" vSafeLeader=" << vsafeLeader
3495 <<
" vLinkPass=" << vLinkPass
3505 double& v,
double& vLinkPass)
const {
3506 if (leaderInfo.first != 0) {
3508#ifdef DEBUG_PLAN_MOVE_LEADERINFO
3510 std::cout <<
" oncoming foe ignored\n";
3516 const MSVehicle* lead = leaderInfo.first;
3521 const double gapSum = leaderBrakeGap + egoBrakeGap;
3525 double gap = leaderInfo.second;
3526 if (egoExit + leaderExit < gap) {
3527 gap -= egoExit + leaderExit;
3532 const double freeGap =
MAX2(0.0, gap - gapSum);
3533 const double splitGap =
MIN2(gap, gapSum);
3535 const double gapRatio = gapSum > 0 ? egoBrakeGap / gapSum : 0.5;
3536 const double vsafeLeader = cfModel.
stopSpeed(
this,
getSpeed(), splitGap * gapRatio + egoExit + 0.5 * freeGap);
3537 if (lastLink !=
nullptr) {
3540#ifdef DEBUG_PLAN_MOVE
3542 std::cout <<
" vlinkpass=" << lastLink->
myVLinkPass <<
" futureVSafe=" << futureVSafe <<
"\n";
3546 v =
MIN2(v, vsafeLeader);
3547 vLinkPass =
MIN2(vLinkPass, vsafeLeader);
3548#ifdef DEBUG_PLAN_MOVE
3552 <<
" veh=" <<
getID()
3553 <<
" oncomingLead=" << lead->
getID()
3554 <<
" leadSpeed=" << lead->
getSpeed()
3555 <<
" gap=" << leaderInfo.second
3557 <<
" gapRatio=" << gapRatio
3562 <<
" vSafeLeader=" << vsafeLeader
3563 <<
" vLinkPass=" << vLinkPass
3572 DriveProcessItem*
const lastLink,
double& v,
double& vLinkPass,
double& vLinkWait,
bool& setRequest)
const {
3575 checkLinkLeader(link, lane, seen, lastLink, v, vLinkPass, vLinkWait, setRequest);
3578 if (parallelLink !=
nullptr) {
3579 checkLinkLeader(parallelLink, lane, seen, lastLink, v, vLinkPass, vLinkWait, setRequest,
true);
3588 DriveProcessItem*
const lastLink,
double& v,
double& vLinkPass,
double& vLinkWait,
bool& setRequest,
3589 bool isShadowLink)
const {
3590#ifdef DEBUG_PLAN_MOVE_LEADERINFO
3596#ifdef DEBUG_PLAN_MOVE_LEADERINFO
3601 for (MSLink::LinkLeaders::const_iterator it = linkLeaders.begin(); it != linkLeaders.end(); ++it) {
3603 const MSVehicle* leader = (*it).vehAndGap.first;
3604 if (leader ==
nullptr) {
3606#ifdef DEBUG_PLAN_MOVE_LEADERINFO
3608 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" is blocked on link to " << link->
getViaLaneOrLane()->
getID() <<
" by pedestrian. dist=" << it->distToCrossing <<
"\n";
3613#ifdef DEBUG_PLAN_MOVE
3615 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" is ignoring pedestrian (jmIgnoreJunctionFoeProb)\n";
3620 adaptToJunctionLeader(std::make_pair(
this, -1), seen, lastLink, lane, v, vLinkPass, it->distToCrossing);
3624#ifdef DEBUG_PLAN_MOVE_LEADERINFO
3626 std::cout <<
" aborting request\n";
3630 }
else if (
isLeader(link, leader, (*it).vehAndGap.second) || (*it).inTheWay()) {
3633#ifdef DEBUG_PLAN_MOVE
3635 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" is ignoring linkLeader=" << leader->
getID() <<
" (jmIgnoreJunctionFoeProb)\n";
3646 linkLeadersAhead.
addLeader(leader,
false, 0);
3650#ifdef DEBUG_PLAN_MOVE
3654 <<
" isShadowLink=" << isShadowLink
3655 <<
" lane=" << lane->
getID()
3656 <<
" foe=" << leader->
getID()
3658 <<
" latOffset=" << latOffset
3660 <<
" linkLeadersAhead=" << linkLeadersAhead.
toString()
3665#ifdef DEBUG_PLAN_MOVE
3667 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" linkLeader=" << leader->
getID() <<
" gap=" << it->vehAndGap.second
3676 if (lastLink !=
nullptr) {
3690#ifdef DEBUG_PLAN_MOVE_LEADERINFO
3692 std::cout <<
" aborting request\n";
3699#ifdef DEBUG_PLAN_MOVE_LEADERINFO
3701 std::cout <<
" aborting previous request\n";
3707#ifdef DEBUG_PLAN_MOVE_LEADERINFO
3710 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" ignoring leader " << leader->
getID() <<
" gap=" << (*it).vehAndGap.second <<
" dtC=" << (*it).distToCrossing
3720 vLinkWait =
MIN2(vLinkWait, v);
3751 double vSafeZipper = std::numeric_limits<double>::max();
3754 bool canBrakeVSafeMin =
false;
3759 MSLink*
const link = dpi.myLink;
3761#ifdef DEBUG_EXEC_MOVE
3765 <<
" veh=" <<
getID()
3767 <<
" req=" << dpi.mySetRequest
3768 <<
" vP=" << dpi.myVLinkPass
3769 <<
" vW=" << dpi.myVLinkWait
3770 <<
" d=" << dpi.myDistance
3777 if (link !=
nullptr && dpi.mySetRequest) {
3786 const bool ignoreRedLink =
ignoreRed(link, canBrake) || beyondStopLine;
3787 if (yellow && canBrake && !ignoreRedLink) {
3788 vSafe = dpi.myVLinkWait;
3790#ifdef DEBUG_CHECKREWINDLINKLANES
3792 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (yellow)\n";
3799 bool opened = (yellow || influencerPrio
3800 || link->
opened(dpi.myArrivalTime, dpi.myArrivalSpeed, dpi.getLeaveSpeed(),
3806 ignoreRedLink,
this, dpi.myDistance));
3809 if (parallelLink !=
nullptr) {
3812 opened = yellow || influencerPrio || (opened && parallelLink->
opened(dpi.myArrivalTime, dpi.myArrivalSpeed, dpi.getLeaveSpeed(),
3817 ignoreRedLink,
this, dpi.myDistance));
3818#ifdef DEBUG_EXEC_MOVE
3821 <<
" veh=" <<
getID()
3825 <<
" opened=" << opened
3832#ifdef DEBUG_EXEC_MOVE
3835 <<
" opened=" << opened
3836 <<
" influencerPrio=" << influencerPrio
3839 <<
" isCont=" << link->
isCont()
3840 <<
" ignoreRed=" << ignoreRedLink
3841 <<
" canBrake=" << canBrake
3846 bool determinedFoePresence = dpi.myDistance <= visibilityDistance;
3848 if (!determinedFoePresence && (canBrake || !yellow)) {
3849 vSafe = dpi.myVLinkWait;
3851#ifdef DEBUG_CHECKREWINDLINKLANES
3853 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (minor)\n";
3869 vSafeMinDist = dpi.myDistance;
3875 canBrakeVSafeMin = canBrake;
3876#ifdef DEBUG_EXEC_MOVE
3878 std::cout <<
" vSafeMin=" << vSafeMin <<
" vSafeMinDist=" << vSafeMinDist <<
" canBrake=" << canBrake <<
"\n";
3885 vSafe = dpi.myVLinkPass;
3889#ifdef DEBUG_CHECKREWINDLINKLANES
3891 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (very slow)\n";
3899 vSafeZipper =
MIN2(vSafeZipper,
3900 link->
getZipperSpeed(
this, dpi.myDistance, dpi.myVLinkPass, dpi.myArrivalTime, &collectFoes));
3901 }
else if (!canBrake
3906#ifdef DEBUG_EXEC_MOVE
3908 std::cout <<
SIMTIME <<
" too fast to brake for closed link\n";
3911 vSafe = dpi.myVLinkPass;
3913 vSafe = dpi.myVLinkWait;
3915#ifdef DEBUG_CHECKREWINDLINKLANES
3917 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (closed)\n";
3920#ifdef DEBUG_EXEC_MOVE
3936#ifdef DEBUG_EXEC_MOVE
3938 std::cout <<
SIMTIME <<
" resetting junctionEntryTime at junction '" << link->
getJunction()->
getID() <<
"' beause of non-request exitLink\n";
3945 vSafe = dpi.myVLinkWait;
3949#ifdef DEBUG_CHECKREWINDLINKLANES
3951 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (no request, braking) vSafe=" << vSafe <<
"\n";
3956#ifdef DEBUG_CHECKREWINDLINKLANES
3958 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (no request, stopping)\n";
3994#ifdef DEBUG_EXEC_MOVE
3996 std::cout <<
"vSafeMin Problem? vSafe=" << vSafe <<
" vSafeMin=" << vSafeMin <<
" vSafeMinDist=" << vSafeMinDist << std::endl;
3999 if (canBrakeVSafeMin && vSafe <
getSpeed()) {
4005#ifdef DEBUG_CHECKREWINDLINKLANES
4007 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (vSafe=" << vSafe <<
" < vSafeMin=" << vSafeMin <<
")\n";
4025 vSafe =
MIN2(vSafe, vSafeZipper);
4035 std::cout <<
SIMTIME <<
" MSVehicle::processTraCISpeedControl() for vehicle '" <<
getID() <<
"'"
4036 <<
" vSafe=" << vSafe <<
" (init)vNext=" << vNext <<
" keepStopping=" <<
keepStopping();
4045 vMin =
MAX2(0., vMin);
4054 std::cout <<
" (processed)vNext=" << vNext << std::endl;
4064#ifdef DEBUG_ACTIONSTEPS
4066 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" removePassedDriveItems()\n"
4067 <<
" Current items: ";
4069 if (j.myLink == 0) {
4070 std::cout <<
"\n Stop at distance " << j.myDistance;
4072 const MSLane* to = j.myLink->getViaLaneOrLane();
4073 const MSLane* from = j.myLink->getLaneBefore();
4074 std::cout <<
"\n Link at distance " << j.myDistance <<
": '"
4075 << (from == 0 ?
"NONE" : from->
getID()) <<
"' -> '" << (to == 0 ?
"NONE" : to->
getID()) <<
"'";
4078 std::cout <<
"\n myNextDriveItem: ";
4085 std::cout <<
"\n Link at distance " <<
myNextDriveItem->myDistance <<
": '"
4086 << (from == 0 ?
"NONE" : from->
getID()) <<
"' -> '" << (to == 0 ?
"NONE" : to->
getID()) <<
"'";
4089 std::cout << std::endl;
4093#ifdef DEBUG_ACTIONSTEPS
4095 std::cout <<
" Removing item: ";
4096 if (j->myLink == 0) {
4097 std::cout <<
"Stop at distance " << j->myDistance;
4099 const MSLane* to = j->myLink->getViaLaneOrLane();
4100 const MSLane* from = j->myLink->getLaneBefore();
4101 std::cout <<
"Link at distance " << j->myDistance <<
": '"
4102 << (from == 0 ?
"NONE" : from->
getID()) <<
"' -> '" << (to == 0 ?
"NONE" : to->
getID()) <<
"'";
4104 std::cout << std::endl;
4107 if (j->myLink !=
nullptr) {
4108 j->myLink->removeApproaching(
this);
4118#ifdef DEBUG_ACTIONSTEPS
4120 std::cout <<
SIMTIME <<
" updateDriveItems(), veh='" <<
getID() <<
"' (lane: '" <<
getLane()->
getID() <<
"')\nCurrent drive items:" << std::endl;
4123 <<
" vPass=" << dpi.myVLinkPass
4124 <<
" vWait=" << dpi.myVLinkWait
4125 <<
" linkLane=" << (dpi.myLink == 0 ?
"NULL" : dpi.myLink->getViaLaneOrLane()->getID())
4126 <<
" request=" << dpi.mySetRequest
4129 std::cout <<
" myNextDriveItem's linked lane: " << (
myNextDriveItem->myLink == 0 ?
"NULL" :
myNextDriveItem->myLink->getViaLaneOrLane()->getID()) << std::endl;
4136 const MSLink* nextPlannedLink =
nullptr;
4139 while (i !=
myLFLinkLanes.end() && nextPlannedLink ==
nullptr) {
4140 nextPlannedLink = i->myLink;
4144 if (nextPlannedLink ==
nullptr) {
4146#ifdef DEBUG_ACTIONSTEPS
4148 std::cout <<
"Found no link-related drive item." << std::endl;
4156#ifdef DEBUG_ACTIONSTEPS
4158 std::cout <<
"Continuing on planned lane sequence, no update required." << std::endl;
4180#ifdef DEBUG_ACTIONSTEPS
4182 std::cout <<
"Changed lane. Drive items will be updated along the current lane continuation." << std::endl;
4194 MSLink* newLink =
nullptr;
4196 if (driveItemIt->myLink ==
nullptr) {
4206#ifdef DEBUG_ACTIONSTEPS
4208 std::cout <<
"Reached end of the new continuation sequence. Erasing leftover link-items." << std::endl;
4212 if (driveItemIt->myLink ==
nullptr) {
4223 const MSLane*
const target = *bestLaneIt;
4227 if (link->getLane() == target) {
4233 if (newLink == driveItemIt->myLink) {
4235#ifdef DEBUG_ACTIONSTEPS
4237 std::cout <<
"Old and new continuation sequences merge at link\n"
4239 <<
"\nNo update beyond merge required." << std::endl;
4245#ifdef DEBUG_ACTIONSTEPS
4247 std::cout <<
"lane=" << lane->
getID() <<
"\nUpdating link\n '" << driveItemIt->myLink->getLaneBefore()->getID() <<
"'->'" << driveItemIt->myLink->getViaLaneOrLane()->getID() <<
"'"
4251 newLink->
setApproaching(
this, driveItemIt->myLink->getApproaching(
this));
4252 driveItemIt->myLink->removeApproaching(
this);
4253 driveItemIt->myLink = newLink;
4260#ifdef DEBUG_ACTIONSTEPS
4262 std::cout <<
"Updated drive items:" << std::endl;
4265 <<
" vPass=" << dpi.myVLinkPass
4266 <<
" vWait=" << dpi.myVLinkWait
4267 <<
" linkLane=" << (dpi.myLink == 0 ?
"NULL" : dpi.myLink->getViaLaneOrLane()->getID())
4268 <<
" request=" << dpi.mySetRequest
4285 brakelightsOn =
true;
4327#ifdef DEBUG_REVERSE_BIDI
4331 <<
" speedThreshold=" << speedThreshold
4333 <<
" isRail=" <<
isRail()
4339 <<
" stopOk=" << stopOk
4358 if (remainingRoute < neededFutureRoute) {
4359#ifdef DEBUG_REVERSE_BIDI
4371#ifdef DEBUG_REVERSE_BIDI
4382 const double stopPos =
myStops.front().getEndPos(*
this);
4385 if (newPos > stopPos) {
4386#ifdef DEBUG_REVERSE_BIDI
4391 if (seen >
MAX2(brakeDist, 1.0)) {
4394#ifdef DEBUG_REVERSE_BIDI
4396 std::cout <<
" train is too long, skipping stop at " << stopPos <<
" cannot be avoided\n";
4410 if (!further->getEdge().isInternal()) {
4411 if (further->getEdge().getBidiEdge() != *(
myCurrEdge + view)) {
4412#ifdef DEBUG_REVERSE_BIDI
4414 std::cout <<
" noBidi view=" << view <<
" further=" << further->
getID() <<
" furtherBidi=" <<
Named::getIDSecure(further->getEdge().getBidiEdge()) <<
" future=" << (*(
myCurrEdge + view))->getID() <<
"\n";
4421 if (toNext ==
nullptr) {
4426#ifdef DEBUG_REVERSE_BIDI
4428 std::cout <<
" do not reverse on a red signal\n";
4436 const double stopPos =
myStops.front().getEndPos(*
this);
4438 if (newPos > stopPos) {
4439#ifdef DEBUG_REVERSE_BIDI
4441 std::cout <<
" reversal would go past stop on further-opposite lane " << further->getBidiLane()->getID() <<
"\n";
4444 if (seen >
MAX2(brakeDist, 1.0)) {
4448#ifdef DEBUG_REVERSE_BIDI
4450 std::cout <<
" train is too long, skipping stop at " << stopPos <<
" cannot be avoided\n";
4461#ifdef DEBUG_REVERSE_BIDI
4463 std::cout <<
SIMTIME <<
" seen=" << seen <<
" vReverseOK=" << vMinComfortable <<
"\n";
4467 return vMinComfortable;
4476 passedLanes.push_back(*i);
4478 if (passedLanes.size() == 0 || passedLanes.back() !=
myLane) {
4479 passedLanes.push_back(
myLane);
4482 bool reverseTrain =
false;
4490#ifdef DEBUG_REVERSE_BIDI
4515 if (link !=
nullptr) {
4521 emergencyReason =
" because it must reverse direction";
4522 approachedLane =
nullptr;
4538 if (link->
haveRed() && !
ignoreRed(link,
false) && !beyondStopLine && !reverseTrain) {
4539 emergencyReason =
" because of a red traffic light";
4543 if (reverseTrain && approachedLane->
isInternal()) {
4551 }
else if (reverseTrain) {
4552 approachedLane = (*(
myCurrEdge + 1))->getLanes()[0];
4560 emergencyReason =
" because there is no connection to the next edge";
4561 approachedLane =
nullptr;
4564 if (approachedLane !=
myLane && approachedLane !=
nullptr) {
4585#ifdef DEBUG_PLAN_MOVE_LEADERINFO
4609 passedLanes.push_back(approachedLane);
4614#ifdef DEBUG_ACTIONSTEPS
4616 std::cout <<
"Updated drive items:" << std::endl;
4619 <<
" vPass=" << (*i).myVLinkPass
4620 <<
" vWait=" << (*i).myVLinkWait
4621 <<
" linkLane=" << ((*i).myLink == 0 ?
"NULL" : (*i).myLink->getViaLaneOrLane()->getID())
4622 <<
" request=" << (*i).mySetRequest
4639#ifdef DEBUG_EXEC_MOVE
4641 std::cout <<
"\nEXECUTE_MOVE\n"
4643 <<
" veh=" <<
getID()
4651 double vSafe = std::numeric_limits<double>::max();
4653 double vSafeMin = -std::numeric_limits<double>::max();
4656 double vSafeMinDist = 0;
4661#ifdef DEBUG_ACTIONSTEPS
4663 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"'\n"
4664 " vsafe from processLinkApproaches(): vsafe " << vSafe << std::endl;
4670#ifdef DEBUG_ACTIONSTEPS
4672 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' skips processLinkApproaches()\n"
4674 <<
"speed: " <<
getSpeed() <<
" -> " << vSafe << std::endl;
4688 double vNext = vSafe;
4708 vNext =
MAX2(vNext, vSafeMin);
4717#ifdef DEBUG_EXEC_MOVE
4719 std::cout <<
SIMTIME <<
" finalizeSpeed vSafe=" << vSafe <<
" vSafeMin=" << (vSafeMin == -std::numeric_limits<double>::max() ?
"-Inf" :
toString(vSafeMin))
4720 <<
" vNext=" << vNext <<
" (i.e. accel=" <<
SPEED2ACCEL(vNext -
getSpeed()) <<
")" << std::endl;
4737 vNext =
MAX2(vNext, 0.);
4747 if (elecHybridOfVehicle !=
nullptr) {
4749 elecHybridOfVehicle->
setConsum(elecHybridOfVehicle->
consumption(*
this, (vNext - this->getSpeed()) /
TS, vNext));
4753 if (elecHybridOfVehicle->
getConsum() /
TS > maxPower) {
4758 vNext =
MAX2(vNext, 0.);
4760 elecHybridOfVehicle->
setConsum(elecHybridOfVehicle->
consumption(*
this, (vNext - this->getSpeed()) /
TS, vNext));
4778 std::vector<MSLane*> passedLanes;
4782 std::string emergencyReason;
4790 if (emergencyReason ==
"") {
4791 emergencyReason =
TL(
" for unknown reasons");
4793 WRITE_WARNINGF(
TL(
"Vehicle '%' performs emergency stop at the end of lane '%'% (decel=%, offset=%), time=%."),
4804 passedLanes.clear();
4806#ifdef DEBUG_ACTIONSTEPS
4808 std::cout <<
SIMTIME <<
" veh '" <<
getID() <<
"' updates further lanes." << std::endl;
4812 if (passedLanes.size() > 1 &&
isRail()) {
4813 for (
auto pi = passedLanes.rbegin(); pi != passedLanes.rend(); ++pi) {
4845#ifdef DEBUG_ACTIONSTEPS
4847 std::cout <<
SIMTIME <<
" veh '" <<
getID() <<
"' skips LCM->prepareStep()." << std::endl;
4855#ifdef DEBUG_EXEC_MOVE
4863 MSLane* newOpposite =
nullptr;
4865 if (newOppositeEdge !=
nullptr) {
4867#ifdef DEBUG_EXEC_MOVE
4869 std::cout <<
SIMTIME <<
" newOppositeEdge=" << newOppositeEdge->
getID() <<
" oldLaneOffset=" << oldLaneOffset <<
" leftMost=" << newOppositeEdge->
getNumLanes() - 1 <<
" newOpposite=" <<
Named::getIDSecure(newOpposite) <<
"\n";
4873 if (newOpposite ==
nullptr) {
4876 WRITE_WARNINGF(
TL(
"Unexpected end of opposite lane for vehicle '%' at lane '%', time=%."),
4883 if (oldOpposite !=
nullptr) {
4896 oldLane = oldLaneMaybeOpposite;
4909 return myLane != oldLane;
4920 for (
int i = 0; i < (int)lanes.size(); i++) {
4922 if (i + 1 < (
int)lanes.size()) {
4923 const MSLane*
const to = lanes[i + 1];
4925 for (
MSLink*
const l : lanes[i]->getLinkCont()) {
4926 if ((internal && l->getViaLane() == to) || (!internal && l->getLane() == to)) {
4935 std::vector<MSLane*> passedLanes;
4937 if (lanes.size() > 1) {
4940 std::string emergencyReason;
4942#ifdef DEBUG_EXTRAPOLATE_DEPARTPOS
4944 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" executeFractionalMove dist=" << dist
4945 <<
" passedLanes=" <<
toString(passedLanes) <<
" lanes=" <<
toString(lanes)
4953 if (lanes.size() > 1) {
4957 std::cout <<
SIMTIME <<
" leaveLane \n";
4960 (*i)->resetPartialOccupation(
this);
4985#ifdef DEBUG_EXEC_MOVE
4987 std::cout <<
SIMTIME <<
" updateState() for veh '" <<
getID() <<
"': deltaPos=" << deltaPos
4992 if (decelPlus > 0) {
4996 decelPlus += 2 * NUMERICAL_EPS;
4999 WRITE_WARNINGF(
TL(
"Vehicle '%' performs emergency braking on lane '%' with decel=%, wished=%, severity=%, time=%."),
5036 dev->notifyParking();
5061 const std::vector<MSLane*>& passedLanes) {
5062#ifdef DEBUG_SETFURTHER
5064 <<
" updateFurtherLanes oldFurther=" <<
toString(furtherLanes)
5065 <<
" oldFurtherPosLat=" <<
toString(furtherLanesPosLat)
5066 <<
" passed=" <<
toString(passedLanes)
5069 for (
MSLane* further : furtherLanes) {
5071 if (further->getBidiLane() !=
nullptr
5072 && (!
isRailway(
getVClass()) || (further->getPermissions() & ~SVC_RAIL_CLASSES) != 0)) {
5073 further->getBidiLane()->resetPartialOccupation(
this);
5077 std::vector<MSLane*> newFurther;
5078 std::vector<double> newFurtherPosLat;
5081 if (passedLanes.size() > 1) {
5083 std::vector<MSLane*>::const_iterator fi = furtherLanes.begin();
5084 std::vector<double>::const_iterator fpi = furtherLanesPosLat.begin();
5085 for (
auto pi = passedLanes.rbegin() + 1; pi != passedLanes.rend() && backPosOnPreviousLane < 0; ++pi) {
5088 newFurther.push_back(further);
5094 if (fi != furtherLanes.end() && further == *fi) {
5096 newFurtherPosLat.push_back(*fpi);
5104 if (newFurtherPosLat.size() == 0) {
5111 newFurtherPosLat.push_back(newFurtherPosLat.back());
5114#ifdef DEBUG_SETFURTHER
5116 std::cout <<
SIMTIME <<
" updateFurtherLanes \n"
5117 <<
" further lane '" << further->
getID() <<
"' backPosOnPreviousLane=" << backPosOnPreviousLane
5122 furtherLanes = newFurther;
5123 furtherLanesPosLat = newFurtherPosLat;
5125 furtherLanes.clear();
5126 furtherLanesPosLat.clear();
5128#ifdef DEBUG_SETFURTHER
5130 <<
" newFurther=" <<
toString(furtherLanes)
5131 <<
" newFurtherPosLat=" <<
toString(furtherLanesPosLat)
5132 <<
" newBackPos=" << backPosOnPreviousLane
5135 return backPosOnPreviousLane;
5144 <<
" getBackPositionOnLane veh=" <<
getID()
5146 <<
" cbgP=" << calledByGetPosition
5201 leftLength -= (*i)->getLength();
5214 leftLength -= (*i)->getLength();
5227 auto j = furtherTargetLanes.begin();
5228 while (leftLength > 0 && j != furtherTargetLanes.end()) {
5229 leftLength -= (*i)->getLength();
5239 WRITE_WARNINGF(
"Request backPos of vehicle '%' for invalid lane '%' time=%.",
5262 double seenSpace = -lengthsInFront;
5263#ifdef DEBUG_CHECKREWINDLINKLANES
5265 std::cout <<
"\nCHECK_REWIND_LINKLANES\n" <<
" veh=" <<
getID() <<
" lengthsInFront=" << lengthsInFront <<
"\n";
5268 bool foundStopped =
false;
5271 for (
int i = 0; i < (int)lfLinks.size(); ++i) {
5274#ifdef DEBUG_CHECKREWINDLINKLANES
5277 <<
" foundStopped=" << foundStopped;
5279 if (item.
myLink ==
nullptr || foundStopped) {
5280 if (!foundStopped) {
5285#ifdef DEBUG_CHECKREWINDLINKLANES
5294 if (approachedLane !=
nullptr) {
5297 if (approachedLane ==
myLane) {
5304#ifdef DEBUG_CHECKREWINDLINKLANES
5306 <<
" approached=" << approachedLane->
getID()
5309 <<
" seenSpace=" << seenSpace
5311 <<
" lengthsInFront=" << lengthsInFront
5318 if (last ==
nullptr || last ==
this) {
5321 seenSpace += approachedLane->
getLength();
5324#ifdef DEBUG_CHECKREWINDLINKLANES
5330 bool foundStopped2 =
false;
5336 const double oncomingBGap = oncomingVeh->
getBrakeGap(
true);
5339 const double spaceTillOncoming = oncomingGap - oncomingBGap - oncomingMove;
5340 spaceTillLastStanding =
MIN2(spaceTillLastStanding, spaceTillOncoming);
5342 foundStopped =
true;
5344#ifdef DEBUG_CHECKREWINDLINKLANES
5346 std::cout <<
" oVeh=" << oncomingVeh->
getID()
5347 <<
" oGap=" << oncomingGap
5348 <<
" bGap=" << oncomingBGap
5349 <<
" mGap=" << oncomingMove
5350 <<
" sto=" << spaceTillOncoming;
5355 seenSpace += spaceTillLastStanding;
5356 if (foundStopped2) {
5357 foundStopped =
true;
5362 foundStopped =
true;
5365#ifdef DEBUG_CHECKREWINDLINKLANES
5367 <<
" approached=" << approachedLane->
getID()
5368 <<
" last=" << last->
getID()
5375 <<
" stls=" << spaceTillLastStanding
5377 <<
" seenSpace=" << seenSpace
5378 <<
" foundStopped=" << foundStopped
5379 <<
" foundStopped2=" << foundStopped2
5386 for (
int i = ((
int)lfLinks.size() - 1); i > 0; --i) {
5390 const bool opened = (item.
myLink !=
nullptr
5391 && (canLeaveJunction || (
5402#ifdef DEBUG_CHECKREWINDLINKLANES
5405 <<
" canLeave=" << canLeaveJunction
5406 <<
" opened=" << opened
5407 <<
" allowsContinuation=" << allowsContinuation
5408 <<
" foundStopped=" << foundStopped
5411 if (!opened && item.
myLink !=
nullptr) {
5412 foundStopped =
true;
5416 allowsContinuation =
true;
5420 if (allowsContinuation) {
5422#ifdef DEBUG_CHECKREWINDLINKLANES
5432 int removalBegin = -1;
5433 for (
int i = 0; foundStopped && i < (int)lfLinks.size() && removalBegin < 0; ++i) {
5436 if (item.
myLink ==
nullptr) {
5447#ifdef DEBUG_CHECKREWINDLINKLANES
5450 <<
" veh=" <<
getID()
5453 <<
" leftSpace=" << leftSpace
5456 if (leftSpace < 0/* && item.myLink->willHaveBlockedFoe()*/) {
5457 double impatienceCorrection = 0;
5464 if (leftSpace < -impatienceCorrection / 10. &&
keepClear(item.
myLink)) {
5473 while (removalBegin < (
int)(lfLinks.size())) {
5475 if (dpi.
myLink ==
nullptr) {
5479#ifdef DEBUG_CHECKREWINDLINKLANES
5484 if (dpi.
myDistance >= brakeGap + POSITION_EPS) {
5486 if (!dpi.
myLink->
isExitLink() || !lfLinks[removalBegin - 1].mySetRequest) {
5503 auto approaches = [](
const DriveItemVector & items, DriveItemVector::const_iterator end,
const MSLink * link) {
5504 for (DriveItemVector::const_iterator it = items.begin(); it != end; ++it) {
5505 if (it->myLink == link) {
5513 dpi.myLink->removeApproaching(
this);
5519 if (dpi.
myLink !=
nullptr) {
5535 if (dpi.myLink !=
nullptr && dpi.myLink->getTLLogic() !=
nullptr && dpi.myLink->getTLLogic()->getLogicType() ==
TrafficLightType::RAIL_SIGNAL) {
5543 if (dpi.myLink !=
nullptr) {
5549 if (parallelLink !=
nullptr) {
5551 parallelLink->
setApproaching(
this, dpi.myArrivalTime, dpi.myArrivalSpeed, dpi.getLeaveSpeed(),
5552 dpi.mySetRequest, dpi.myArrivalSpeedBraking,
getWaitingTimeFor(dpi.myLink), dpi.myDistance,
5559#ifdef DEBUG_PLAN_MOVE
5562 <<
" veh=" <<
getID()
5563 <<
" after checkRewindLinkLanes\n";
5566 <<
" vPass=" << dpi.myVLinkPass
5567 <<
" vWait=" << dpi.myVLinkWait
5568 <<
" linkLane=" << (dpi.myLink == 0 ?
"NULL" : dpi.myLink->getViaLaneOrLane()->getID())
5569 <<
" request=" << dpi.mySetRequest
5570 <<
" atime=" << dpi.myArrivalTime
5616 if (!onTeleporting) {
5621 assert(oldLane !=
nullptr);
5623 if (link !=
nullptr) {
5668 int deleteFurther = 0;
5669#ifdef DEBUG_SETFURTHER
5680 if (lane !=
nullptr) {
5683#ifdef DEBUG_SETFURTHER
5685 std::cout <<
" enterLaneAtLaneChange i=" << i <<
" lane=" <<
Named::getIDSecure(lane) <<
" leftLength=" << leftLength <<
"\n";
5688 if (leftLength > 0) {
5689 if (lane !=
nullptr) {
5705#ifdef DEBUG_SETFURTHER
5718#ifdef DEBUG_SETFURTHER
5733 if (deleteFurther > 0) {
5734#ifdef DEBUG_SETFURTHER
5736 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" shortening myFurtherLanes by " << deleteFurther <<
"\n";
5742#ifdef DEBUG_SETFURTHER
5757 MSLane* clane = enteredLane;
5759 while (leftLength > 0) {
5760 bool guessed =
false;
5764 const MSEdge* fromRouteEdge =
myRoute->getEdges()[routeIndex];
5768 if (ili.lane->getEdge().getNormalBefore() == fromRouteEdge) {
5796#ifdef DEBUG_SETFURTHER
5804#ifdef DEBUG_SETFURTHER
5806 std::cout <<
SIMTIME <<
" opposite: resetPartialOccupation " << further->getID() <<
" \n";
5809 further->resetPartialOccupation(
this);
5810 if (further->getBidiLane() !=
nullptr
5811 && (!
isRailway(
getVClass()) || (further->getPermissions() & ~SVC_RAIL_CLASSES) != 0)) {
5812 further->getBidiLane()->resetPartialOccupation(
this);
5831 if (enteredLane->
getIncomingLanes().front().viaLink->isConflictEntryLink()) {
5856 &&
myStops.front().pars.endPos < pos) {
5882 if (further->mustCheckJunctionCollisions()) {
5893 if (rem->first->notifyLeave(*
this,
myState.
myPos + rem->second, reason, approachedLane)) {
5895 if (myTraceMoveReminders) {
5896 traceMoveReminder(
"notifyLeave", rem->first, rem->second,
true);
5902 if (myTraceMoveReminders) {
5903 traceMoveReminder(
"notifyLeave", rem->first, rem->second,
false);
5925 std::cout <<
SIMTIME <<
" leaveLane \n";
5928 further->resetPartialOccupation(
this);
5929 if (further->getBidiLane() !=
nullptr
5930 && (!
isRailway(
getVClass()) || (further->getPermissions() & ~SVC_RAIL_CLASSES) != 0)) {
5931 further->getBidiLane()->resetPartialOccupation(
this);
5942 myStopDist = std::numeric_limits<double>::max();
5949 if (
myStops.front().getSpeed() <= 0) {
5967 if (stop.
busstop !=
nullptr) {
5983 myStopDist = std::numeric_limits<double>::max();
5992 if (rem->first->notifyLeaveBack(*
this, reason, leftLane)) {
5994 if (myTraceMoveReminders) {
5995 traceMoveReminder(
"notifyLeaveBack", rem->first, rem->second,
true);
6001 if (myTraceMoveReminders) {
6002 traceMoveReminder(
"notifyLeaveBack", rem->first, rem->second,
false);
6008#ifdef DEBUG_MOVEREMINDERS
6010 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" myReminders:";
6012 std::cout << rem.first->getDescription() <<
" ";
6038const std::vector<MSVehicle::LaneQ>&
6046#ifdef DEBUG_BESTLANES
6051 if (startLane ==
nullptr) {
6054 assert(startLane != 0);
6062 assert(startLane != 0);
6063#ifdef DEBUG_BESTLANES
6065 std::cout <<
" startLaneIsOpposite newStartLane=" << startLane->
getID() <<
"\n";
6076#ifdef DEBUG_BESTLANES
6078 std::cout <<
" only updateOccupancyAndCurrentBestLane\n";
6089#ifdef DEBUG_BESTLANES
6091 std::cout <<
" nothing to do on internal\n";
6101 std::vector<LaneQ>& lanes = *it;
6102 assert(lanes.size() > 0);
6103 if (&(lanes[0].lane->getEdge()) == nextEdge) {
6105 std::vector<LaneQ> oldLanes = lanes;
6107 const std::vector<MSLane*>& sourceLanes = startLane->
getEdge().
getLanes();
6108 for (std::vector<MSLane*>::const_iterator it_source = sourceLanes.begin(); it_source != sourceLanes.end(); ++it_source) {
6109 for (std::vector<LaneQ>::iterator it_lane = oldLanes.begin(); it_lane != oldLanes.end(); ++it_lane) {
6110 if ((*it_source)->getLinkCont()[0]->getLane() == (*it_lane).lane) {
6111 lanes.push_back(*it_lane);
6118 for (
int i = 0; i < (int)lanes.size(); ++i) {
6119 if (i + lanes[i].bestLaneOffset < 0) {
6120 lanes[i].bestLaneOffset = -i;
6122 if (i + lanes[i].bestLaneOffset >= (
int)lanes.size()) {
6123 lanes[i].bestLaneOffset = (int)lanes.size() - i - 1;
6125 assert(i + lanes[i].bestLaneOffset >= 0);
6126 assert(i + lanes[i].bestLaneOffset < (
int)lanes.size());
6127 if (lanes[i].bestContinuations[0] != 0) {
6129 lanes[i].bestContinuations.insert(lanes[i].bestContinuations.begin(), (
MSLane*)
nullptr);
6131 if (startLane->
getLinkCont()[0]->getLane() == lanes[i].lane) {
6134 assert(&(lanes[i].lane->getEdge()) == nextEdge);
6138#ifdef DEBUG_BESTLANES
6140 std::cout <<
" updated for internal\n";
6158 const MSLane* nextStopLane =
nullptr;
6159 double nextStopPos = 0;
6162 nextStopLane = nextStop.
lane;
6167 nextStopEdge = nextStop.
edge;
6172 nextStopEdge = (
myRoute->end() - 1);
6176 if (nextStopEdge !=
myRoute->end()) {
6179 nextStopPos =
MAX2(POSITION_EPS,
MIN2((
double)nextStopPos, (
double)(nextStopLane->
getLength() - 2 * POSITION_EPS)));
6182 nextStopPos = (*nextStopEdge)->getLength();
6191 double seenLength = 0;
6192 bool progress =
true;
6197 std::vector<LaneQ> currentLanes;
6198 const std::vector<MSLane*>* allowed =
nullptr;
6199 const MSEdge* nextEdge =
nullptr;
6201 nextEdge = *(ce + 1);
6204 const std::vector<MSLane*>& lanes = (*ce)->getLanes();
6205 for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
6214 q.
allowsContinuation = allowed ==
nullptr || std::find(allowed->begin(), allowed->end(), cl) != allowed->end();
6217 currentLanes.push_back(q);
6220 if (nextStopEdge == ce
6224 for (std::vector<LaneQ>::iterator q = currentLanes.begin(); q != currentLanes.end(); ++q) {
6225 if (nextStopLane !=
nullptr && normalStopLane != (*q).lane) {
6226 (*q).allowsContinuation =
false;
6227 (*q).length = nextStopPos;
6228 (*q).currentLength = (*q).length;
6235 seenLength += currentLanes[0].lane->
getLength();
6237 if (lookahead >= 0) {
6238 progress &= (seen <= 2 || seenLength < lookahead);
6240 progress &= (seen <= 4 || seenLength <
MAX2(maxBrakeDist, 3000.0));
6243 progress &= ce !=
myRoute->end();
6253 double bestLength = -1;
6255 int bestThisIndex = 0;
6256 int bestThisMaxIndex = 0;
6259 for (std::vector<LaneQ>::iterator j = last.begin(); j != last.end(); ++j, ++index) {
6260 if ((*j).length > bestLength) {
6261 bestLength = (*j).length;
6262 bestThisIndex = index;
6263 bestThisMaxIndex = index;
6264 }
else if ((*j).length == bestLength) {
6265 bestThisMaxIndex = index;
6269 bool requiredChangeRightForbidden =
false;
6270 int requireChangeToLeftForbidden = -1;
6271 for (std::vector<LaneQ>::iterator j = last.begin(); j != last.end(); ++j, ++index) {
6272 if ((*j).length < bestLength) {
6273 if (abs(bestThisIndex - index) < abs(bestThisMaxIndex - index)) {
6274 (*j).bestLaneOffset = bestThisIndex - index;
6276 (*j).bestLaneOffset = bestThisMaxIndex - index;
6278 if (!(*j).allowsContinuation) {
6279 if ((*j).bestLaneOffset < 0 && (!(*j).lane->allowsChangingRight(
getVClass())
6280 || !(*j).lane->getParallelLane(-1,
false)->allowsVehicleClass(
getVClass())
6281 || requiredChangeRightForbidden)) {
6283 requiredChangeRightForbidden =
true;
6285 }
else if ((*j).bestLaneOffset > 0 && (!(*j).lane->allowsChangingLeft(
getVClass())
6286 || !(*j).lane->getParallelLane(1,
false)->allowsVehicleClass(
getVClass()))) {
6288 requireChangeToLeftForbidden = (*j).lane->getIndex();
6293 for (
int i = requireChangeToLeftForbidden; i >= 0; i--) {
6294 if (last[i].bestLaneOffset > 0) {
6298#ifdef DEBUG_BESTLANES
6300 std::cout <<
" last edge=" << last.front().lane->getEdge().getID() <<
" (bestIndex=" << bestThisIndex <<
" bestMaxIndex=" << bestThisMaxIndex <<
"):\n";
6302 for (std::vector<LaneQ>::iterator j = laneQs.begin(); j != laneQs.end(); ++j) {
6303 std::cout <<
" lane=" << (*j).lane->getID() <<
" length=" << (*j).length <<
" bestOffset=" << (*j).bestLaneOffset <<
"\n";
6310 for (std::vector<std::vector<LaneQ> >::reverse_iterator i =
myBestLanes.rbegin() + 1; i !=
myBestLanes.rend(); ++i) {
6311 std::vector<LaneQ>& nextLanes = (*(i - 1));
6312 std::vector<LaneQ>& clanes = (*i);
6313 MSEdge*
const cE = &clanes[0].lane->getEdge();
6315 double bestConnectedLength = -1;
6316 double bestLength = -1;
6317 for (
const LaneQ& j : nextLanes) {
6318 if (j.lane->isApproachedFrom(cE) && bestConnectedLength < j.length) {
6319 bestConnectedLength = j.length;
6321 if (bestLength < j.length) {
6322 bestLength = j.length;
6326 int bestThisIndex = 0;
6327 int bestThisMaxIndex = 0;
6328 if (bestConnectedLength > 0) {
6330 for (
LaneQ& j : clanes) {
6331 const LaneQ* bestConnectedNext =
nullptr;
6332 if (j.allowsContinuation) {
6333 for (
const LaneQ& m : nextLanes) {
6334 if ((m.lane->allowsVehicleClass(
getVClass()) || m.lane->hadPermissionChanges())
6335 && m.lane->isApproachedFrom(j.lane,
getVClass())) {
6337 bestConnectedNext = &m;
6341 if (bestConnectedNext !=
nullptr) {
6342 if (bestConnectedNext->
length == bestConnectedLength && abs(bestConnectedNext->
bestLaneOffset) < 2) {
6345 j.length += bestConnectedNext->
length;
6353 j.allowsContinuation =
false;
6355 if (clanes[bestThisIndex].length < j.length
6356 || (clanes[bestThisIndex].length == j.length && abs(clanes[bestThisIndex].bestLaneOffset) > abs(j.bestLaneOffset))
6357 || (clanes[bestThisIndex].length == j.length && abs(clanes[bestThisIndex].bestLaneOffset) == abs(j.bestLaneOffset) &&
6360 bestThisIndex = index;
6361 bestThisMaxIndex = index;
6362 }
else if (clanes[bestThisIndex].length == j.length
6363 && abs(clanes[bestThisIndex].bestLaneOffset) == abs(j.bestLaneOffset)
6365 bestThisMaxIndex = index;
6373 for (
const LaneQ& j : clanes) {
6375 if (overheadWireSegmentID !=
"") {
6376 bestThisIndex = index;
6377 bestThisMaxIndex = index;
6385 int bestNextIndex = 0;
6386 int bestDistToNeeded = (int) clanes.size();
6388 for (std::vector<LaneQ>::iterator j = clanes.begin(); j != clanes.end(); ++j, ++index) {
6389 if ((*j).allowsContinuation) {
6391 for (std::vector<LaneQ>::const_iterator m = nextLanes.begin(); m != nextLanes.end(); ++m, ++nextIndex) {
6392 if ((*m).lane->isApproachedFrom((*j).lane,
getVClass())) {
6393 if (bestDistToNeeded > abs((*m).bestLaneOffset)) {
6394 bestDistToNeeded = abs((*m).bestLaneOffset);
6395 bestThisIndex = index;
6396 bestThisMaxIndex = index;
6397 bestNextIndex = nextIndex;
6403 clanes[bestThisIndex].length += nextLanes[bestNextIndex].length;
6404 copy(nextLanes[bestNextIndex].bestContinuations.begin(), nextLanes[bestNextIndex].bestContinuations.end(), back_inserter(clanes[bestThisIndex].bestContinuations));
6409 bool requiredChangeRightForbidden =
false;
6410 int requireChangeToLeftForbidden = -1;
6411 for (std::vector<LaneQ>::iterator j = clanes.begin(); j != clanes.end(); ++j, ++index) {
6412 if ((*j).length < clanes[bestThisIndex].length
6413 || ((*j).length == clanes[bestThisIndex].length && abs((*j).bestLaneOffset) > abs(clanes[bestThisIndex].bestLaneOffset))
6416 if (abs(bestThisIndex - index) < abs(bestThisMaxIndex - index)) {
6417 (*j).bestLaneOffset = bestThisIndex - index;
6419 (*j).bestLaneOffset = bestThisMaxIndex - index;
6423 (*j).length = (*j).currentLength;
6425 if (!(*j).allowsContinuation) {
6426 if ((*j).bestLaneOffset < 0 && (!(*j).lane->allowsChangingRight(
getVClass())
6427 || !(*j).lane->getParallelLane(-1,
false)->allowsVehicleClass(
getVClass())
6428 || requiredChangeRightForbidden)) {
6430 requiredChangeRightForbidden =
true;
6431 if ((*j).length == (*j).currentLength) {
6434 }
else if ((*j).bestLaneOffset > 0 && (!(*j).lane->allowsChangingLeft(
getVClass())
6435 || !(*j).lane->getParallelLane(1,
false)->allowsVehicleClass(
getVClass()))) {
6437 requireChangeToLeftForbidden = (*j).lane->getIndex();
6441 (*j).bestLaneOffset = 0;
6444 for (
int idx = requireChangeToLeftForbidden; idx >= 0; idx--) {
6445 if (clanes[idx].length == clanes[idx].currentLength) {
6446 clanes[idx].length = 0;
6454 if (overheadWireID !=
"") {
6455 for (std::vector<LaneQ>::iterator j = clanes.begin(); j != clanes.end(); ++j, ++index) {
6456 (*j).bestLaneOffset = bestThisIndex - index;
6461#ifdef DEBUG_BESTLANES
6463 std::cout <<
" edge=" << cE->
getID() <<
" (bestIndex=" << bestThisIndex <<
" bestMaxIndex=" << bestThisMaxIndex <<
"):\n";
6464 std::vector<LaneQ>& laneQs = clanes;
6465 for (std::vector<LaneQ>::iterator j = laneQs.begin(); j != laneQs.end(); ++j) {
6466 std::cout <<
" lane=" << (*j).lane->getID() <<
" length=" << (*j).length <<
" bestOffset=" << (*j).bestLaneOffset <<
" allowCont=" << (*j).allowsContinuation <<
"\n";
6472 if (
myBestLanes.front().front().lane->isInternal()) {
6482#ifdef DEBUG_BESTLANES
6498 if (bestConnectedNext ==
nullptr) {
6525 if (conts.size() < 2) {
6528 const MSLink*
const link = conts[0]->getLinkTo(conts[1]);
6529 if (link !=
nullptr) {
6541 std::vector<LaneQ>& currLanes = *
myBestLanes.begin();
6542 std::vector<LaneQ>::iterator i;
6546 for (i = currLanes.begin(); i != currLanes.end(); ++i) {
6547 double nextOccupation = 0;
6548 for (std::vector<MSLane*>::const_iterator j = (*i).bestContinuations.begin() + 1; j != (*i).bestContinuations.end(); ++j) {
6549 nextOccupation += (*j)->getBruttoVehLenSum();
6551 (*i).nextOccupation = nextOccupation;
6552#ifdef DEBUG_BESTLANES
6554 std::cout <<
" lane=" << (*i).lane->getID() <<
" nextOccupation=" << nextOccupation <<
"\n";
6557 if ((*i).lane == startLane) {
6570const std::vector<MSLane*>&
6575 return (*myCurrentLaneInBestLanes).bestContinuations;
6579const std::vector<MSLane*>&
6591 if ((*i).lane == lane) {
6592 return (*i).bestContinuations;
6598const std::vector<const MSLane*>
6600 std::vector<const MSLane*> lanes;
6613 while (lane->
isInternal() && (distance > 0.)) {
6614 lanes.insert(lanes.end(), lane);
6616 lane = lane->
getLinkCont().front()->getViaLaneOrLane();
6620 if (contLanes.empty()) {
6623 auto contLanesIt = contLanes.begin();
6625 while (distance > 0.) {
6627 if (contLanesIt != contLanes.end()) {
6630 assert(l->
getEdge().
getID() == (*routeIt)->getLanes().front()->getEdge().getID());
6639 }
else if (routeIt !=
myRoute->end()) {
6641 l = (*routeIt)->getLanes().back();
6647 assert(l !=
nullptr);
6651 while ((internalLane !=
nullptr) && internalLane->
isInternal() && (distance > 0.)) {
6652 lanes.insert(lanes.end(), internalLane);
6654 internalLane = internalLane->
getLinkCont().front()->getViaLaneOrLane();
6656 if (distance <= 0.) {
6660 lanes.insert(lanes.end(), l);
6667const std::vector<const MSLane*>
6669 std::vector<const MSLane*> lanes;
6671 if (distance <= 0.) {
6683 while (lane->
isInternal() && (distance > 0.)) {
6684 lanes.insert(lanes.end(), lane);
6689 while (distance > 0.) {
6691 MSLane* l = (*routeIt)->getLanes().back();
6695 const MSLane* internalLane = internalEdge !=
nullptr ? internalEdge->
getLanes().front() :
nullptr;
6696 std::vector<const MSLane*> internalLanes;
6697 while ((internalLane !=
nullptr) && internalLane->
isInternal()) {
6698 internalLanes.insert(internalLanes.begin(), internalLane);
6699 internalLane = internalLane->
getLinkCont().front()->getViaLaneOrLane();
6701 for (
auto it = internalLanes.begin(); (it != internalLanes.end()) && (distance > 0.); ++it) {
6702 lanes.insert(lanes.end(), *it);
6703 distance -= (*it)->getLength();
6705 if (distance <= 0.) {
6709 lanes.insert(lanes.end(), l);
6714 if (routeIt !=
myRoute->begin()) {
6725const std::vector<MSLane*>
6728 std::vector<MSLane*> result;
6729 for (
const MSLane* lane : routeLanes) {
6731 if (opposite !=
nullptr) {
6732 result.push_back(opposite);
6746 return (*myCurrentLaneInBestLanes).bestLaneOffset;
6755 return (*myCurrentLaneInBestLanes).length;
6763 std::vector<MSVehicle::LaneQ>& preb =
myBestLanes.front();
6764 assert(laneIndex < (
int)preb.size());
6765 preb[laneIndex].occupation = density + preb[laneIndex].nextOccupation;
6776std::pair<const MSLane*, double>
6778 if (distance == 0) {
6783 for (
const MSLane* lane : lanes) {
6784 if (lane->getLength() > distance) {
6785 return std::make_pair(lane, distance);
6787 distance -= lane->getLength();
6789 return std::make_pair(
nullptr, -1);
6795 if (
isOnRoad() && destLane !=
nullptr) {
6798 return std::numeric_limits<double>::max();
6802std::pair<const MSVehicle* const, double>
6805 return std::make_pair(
static_cast<const MSVehicle*
>(
nullptr), -1);
6814 MSLane::VehCont::const_iterator it = std::find(vehs.begin(), vehs.end(),
this);
6815 if (it != vehs.end() && it + 1 != vehs.end()) {
6818 if (lead !=
nullptr) {
6819 std::pair<const MSVehicle* const, double> result(
6832std::pair<const MSVehicle* const, double>
6835 return std::make_pair(
static_cast<const MSVehicle*
>(
nullptr), -1);
6847 std::pair<const MSVehicle* const, double> leaderInfo =
getLeader(-1);
6848 if (leaderInfo.first ==
nullptr ||
getSpeed() == 0) {
6860 if (
myStops.front().triggered &&
myStops.front().numExpectedPerson > 0) {
6861 myStops.front().numExpectedPerson -= (int)
myStops.front().pars.awaitedPersons.count(transportable->
getID());
6864 if (
myStops.front().pars.containerTriggered &&
myStops.front().numExpectedContainer > 0) {
6865 myStops.front().numExpectedContainer -= (int)
myStops.front().pars.awaitedContainers.count(transportable->
getID());
6877 const bool blinkerManoeuvre = (((state &
LCA_SUBLANE) == 0) && (
6885 if ((state &
LCA_LEFT) != 0 && blinkerManoeuvre) {
6887 }
else if ((state &
LCA_RIGHT) != 0 && blinkerManoeuvre) {
6899 switch ((*link)->getDirection()) {
6916 && (
myStops.begin()->reached ||
6919 if (
myStops.begin()->lane->getIndex() > 0 &&
myStops.begin()->lane->getParallelLane(-1)->allowsVehicleClass(
getVClass())) {
6937 if (currentTime % 1000 == 0) {
7034 for (
int i = 0; i < (int)shadowFurther.size(); ++i) {
7036 if (shadowFurther[i] == lane) {
7040 }
else if (shadowFurther[i]->getBidiLane() == lane) {
7087 for (
int i = 0; i < (int)shadowFurther.size(); ++i) {
7088 if (shadowFurther[i] == lane) {
7092 <<
" lane=" << lane->
getID()
7100 }
else if (shadowFurther[i]->getBidiLane() == lane) {
7113 MSLane* targetLane = furtherTargets[i];
7114 if (targetLane == lane) {
7117#ifdef DEBUG_TARGET_LANE
7119 std::cout <<
" getLatOffset veh=" <<
getID()
7125 <<
" targetDir=" << targetDir
7126 <<
" latOffset=" << latOffset
7131 }
else if (targetLane !=
nullptr && targetLane->
getBidiLane() == lane) {
7139 return -2 * latOffset;
7152 assert(offset == 0 || offset == 1 || offset == -1);
7153 assert(
myLane !=
nullptr);
7156 const double halfVehWidth = 0.5 * (
getWidth() + NUMERICAL_EPS);
7159 double leftLimit = halfCurrentLaneWidth - halfVehWidth - oppositeSign * latPos;
7160 double rightLimit = -halfCurrentLaneWidth + halfVehWidth - oppositeSign * latPos;
7161 double latLaneDist = 0;
7163 if (latPos + halfVehWidth > halfCurrentLaneWidth) {
7165 latLaneDist = halfCurrentLaneWidth - latPos - halfVehWidth;
7166 }
else if (latPos - halfVehWidth < -halfCurrentLaneWidth) {
7168 latLaneDist = -halfCurrentLaneWidth - latPos + halfVehWidth;
7170 latLaneDist *= oppositeSign;
7171 }
else if (offset == -1) {
7172 latLaneDist = rightLimit - (
getWidth() + NUMERICAL_EPS);
7173 }
else if (offset == 1) {
7174 latLaneDist = leftLimit + (
getWidth() + NUMERICAL_EPS);
7176#ifdef DEBUG_ACTIONSTEPS
7179 <<
" veh=" <<
getID()
7180 <<
" halfCurrentLaneWidth=" << halfCurrentLaneWidth
7181 <<
" halfVehWidth=" << halfVehWidth
7182 <<
" latPos=" << latPos
7183 <<
" latLaneDist=" << latLaneDist
7184 <<
" leftLimit=" << leftLimit
7185 <<
" rightLimit=" << rightLimit
7213 if (dpi.myLink !=
nullptr) {
7214 dpi.myLink->removeApproaching(
this);
7232 std::vector<MSLink*>::const_iterator link =
MSLane::succLinkSec(*
this, view, *lane, bestLaneConts);
7234 while (!lane->
isLinkEnd(link) && seen <= dist) {
7236 && (((*link)->getState() ==
LINKSTATE_ZIPPER && seen < (*link)->getFoeVisibilityDistance())
7237 || !(*link)->havePriority()))
7242 if ((*di).myLink !=
nullptr) {
7243 const MSLane* diPredLane = (*di).myLink->getLaneBefore();
7244 if (diPredLane !=
nullptr) {
7255 const SUMOTime leaveTime = (*link)->getLeaveTime((*di).myArrivalTime, (*di).myArrivalSpeed,
7268 lane = (*link)->getViaLaneOrLane();
7284 centerLine.push_back(pos);
7293 centerLine.push_back(lane->getShape().back());
7305 backPos = pos +
Position(l * cos(a), l * sin(a));
7307 centerLine.push_back(backPos);
7340 result.push_back(line1[0]);
7341 result.push_back(line2[0]);
7342 result.push_back(line2[1]);
7343 result.push_back(line1[1]);
7346 result.push_back(line1[1]);
7347 result.push_back(line2[1]);
7348 result.push_back(line2[0]);
7349 result.push_back(line1[0]);
7361 if (&(*i)->getEdge() == edge) {
7387 if (destParkArea ==
nullptr) {
7389 errorMsg =
"Vehicle " +
getID() +
" is not driving to a parking area so it cannot be rerouted.";
7402 if (newParkingArea ==
nullptr) {
7403 errorMsg =
"Parking area ID " +
toString(parkingAreaID) +
" not found in the network.";
7416 if (!newDestination) {
7427 if (edgesFromPark.size() > 0) {
7428 edges.insert(edges.end(), edgesFromPark.begin() + 1, edgesFromPark.end());
7442 const bool onInit =
myLane ==
nullptr;
7445 WRITE_WARNINGF(
"Vehicle '%' could not reroute to new parkingArea '%' reason=%, time=%.",
7455 const int numStops = (int)
myStops.size();
7500 if (stop.
busstop !=
nullptr) {
7529 rem.first->notifyStopEnded();
7538 const bool wasWaypoint = stop.
getSpeed() > 0;
7542 myStopDist = std::numeric_limits<double>::max();
7552 return !wasWaypoint;
7642#ifdef DEBUG_IGNORE_RED
7647 if (ignoreRedTime < 0) {
7649 if (ignoreYellowTime > 0 && link->
haveYellow()) {
7653 return !canBrake || ignoreYellowTime > yellowDuration;
7663#ifdef DEBUG_IGNORE_RED
7667 <<
" ignoreRedTime=" << ignoreRedTime
7668 <<
" spentRed=" << redDuration
7669 <<
" canBrake=" << canBrake <<
"\n";
7673 return !canBrake || ignoreRedTime > redDuration;
7690 if (
id == foe->
getID()) {
7716 if (veh ==
nullptr) {
7743 assert(logic !=
nullptr);
7760#ifdef DEBUG_PLAN_MOVE_LEADERINFO
7762 std::cout <<
" foeGap=" << foeGap <<
" foeBGap=" << foeBrakeGap <<
"\n";
7766 if (foeGap < foeBrakeGap) {
7790#ifdef DEBUG_PLAN_MOVE_LEADERINFO
7793 <<
" foeLane=" << foeLane->
getID()
7795 <<
" linkIndex=" << link->
getIndex()
7796 <<
" foeLinkIndex=" << foeLink->
getIndex()
7799 <<
" response=" << response
7800 <<
" response2=" << response2
7808 }
else if (response && response2) {
7814 if (egoET == foeET) {
7818#ifdef DEBUG_PLAN_MOVE_LEADERINFO
7820 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" equal ET " << egoET <<
" with foe " << veh->
getID()
7821 <<
" foeIsLeaderByID=" << (
getID() < veh->
getID()) <<
"\n";
7826#ifdef DEBUG_PLAN_MOVE_LEADERINFO
7828 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" equal ET " << egoET <<
" with foe " << veh->
getID()
7838#ifdef DEBUG_PLAN_MOVE_LEADERINFO
7840 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" egoET " << egoET <<
" with foe " << veh->
getID()
7841 <<
" foeET=" << foeET <<
" isLeader=" << (egoET > foeET) <<
"\n";
7844 return egoET > foeET;
7860 std::vector<std::string> internals;
7886 stop.write(out,
false);
7904 dev->saveState(out);
7915 throw ProcessError(
TL(
"Error: Invalid vehicles in state (may be a meso state)!"));
7932 bis >> stopDuration;
7949 while (pastStops > 0) {
7959 rem.first->notifyStopEnded();
7971 myLane = (*myCurrEdge)->getLanes()[0];
7991 myStops.front().startedFromState =
true;
7992 if (entryPos != realPos) {
7993 myStops.front().entryPos = entryPos;
8004 myStops.front().duration = stopDuration;
8016 SUMOTime arrivalTime,
double arrivalSpeed,
8017 double arrivalSpeedBraking,
8018 double dist,
double leaveSpeed) {
8021 arrivalTime, arrivalSpeed, arrivalSpeedBraking, dist, leaveSpeed));
8026std::shared_ptr<MSSimpleDriverState>
8042 if (prevAcceleration != std::numeric_limits<double>::min()) {
8102 return (myGUIIncrement);
8108 return (myManoeuvreType);
8126 myManoeuvreType = mType;
8141 if (abs(GUIAngle) < 0.1) {
8144 myManoeuvreVehicleID = veh->
getID();
8147 myManoeuvreStartTime = currentTime;
8149 myGUIIncrement = GUIAngle / (
STEPS2TIME(myManoeuvreCompleteTime - myManoeuvreStartTime) /
TS);
8153 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 <<
8154 " endTime=" << myManoeuvreCompleteTime <<
" manoeuvre time=" << myManoeuvreCompleteTime - currentTime <<
" parkArea=" << myManoeuvreStop << std::endl;
8180 if (abs(GUIAngle) < 0.1) {
8184 myManoeuvreVehicleID = veh->
getID();
8187 myManoeuvreStartTime = currentTime;
8189 myGUIIncrement = -GUIAngle / (
STEPS2TIME(myManoeuvreCompleteTime - myManoeuvreStartTime) /
TS);
8196 std::cout <<
"EXIT manoeuvre start: vehicle=" << veh->
getID() <<
" Manoeuvre Angle=" << manoeuverAngle <<
" increment=" <<
RAD2DEG(myGUIIncrement) <<
" currentTime=" << currentTime
8197 <<
" endTime=" << myManoeuvreCompleteTime <<
" manoeuvre time=" << myManoeuvreCompleteTime - currentTime <<
" parkArea=" << myManoeuvreStop << std::endl;
8215 if (configureEntryManoeuvre(veh)) {
8232 if (checkType != myManoeuvreType) {
8256std::pair<double, double>
8260 if (lane ==
nullptr) {
8271 travelTime += (*it)->getMinimumTravelTime(
this);
8272 dist += (*it)->getLength();
8277 dist += stopEdgeDist;
8284 const double d = dist;
8290 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))))
8291 + pow((a * vs), 2))))) * 0.5) + (c * b)) / (b + a));
8295 double timeLossAccel = 0;
8296 double timeLossDecel = 0;
8297 double timeLossLength = 0;
8299 double v =
MIN2(maxVD, (*it)->getVehicleMaxSpeed(
this));
8301 if (edgeLength <= len && v0Stable && v0 < v) {
8302 const double lengthDist =
MIN2(len, edgeLength);
8303 const double dTL = lengthDist / v0 - lengthDist / v;
8305 timeLossLength += dTL;
8307 if (edgeLength > len) {
8308 const double dv = v - v0;
8311 const double dTA = dv / a - dv * (v + v0) / (2 * a * v);
8313 timeLossAccel += dTA;
8315 }
else if (dv < 0) {
8317 const double dTD = -dv / b + dv * (v + v0) / (2 * b * v0);
8319 timeLossDecel += dTD;
8328 const double dv = v - v0;
8331 const double dTA = dv / a - dv * (v + v0) / (2 * a * v);
8333 timeLossAccel += dTA;
8335 }
else if (dv < 0) {
8337 const double dTD = -dv / b + dv * (v + v0) / (2 * b * v0);
8339 timeLossDecel += dTD;
8341 const double result = travelTime + timeLossAccel + timeLossDecel + timeLossLength;
8344 return {
MAX2(0.0, result), dist};
8405 return nextInternal ? nextInternal : nextNormal;
8417 bool resultInternal;
8420 if (furtherIndex % 2 == 0) {
8421 routeIndex -= (furtherIndex + 0) / 2;
8422 resultInternal =
false;
8424 routeIndex -= (furtherIndex + 1) / 2;
8425 resultInternal =
false;
8428 if (furtherIndex % 2 != 0) {
8429 routeIndex -= (furtherIndex + 1) / 2;
8430 resultInternal =
false;
8432 routeIndex -= (furtherIndex + 2) / 2;
8433 resultInternal =
true;
8437 routeIndex -= furtherIndex;
8438 resultInternal =
false;
8441 if (routeIndex >= 0) {
8442 if (resultInternal) {
8445 for (
MSLink* link : cand->getLinkCont()) {
8446 if (link->getLane() == current) {
8447 if (link->getViaLane() !=
nullptr) {
8448 return link->getViaLane();
8450 return const_cast<MSLane*
>(link->getLaneBefore());
8456 return myRoute->getEdges()[routeIndex]->getLanes()[0];
8472 bool diverged =
false;
8476 if (dpi.myLink !=
nullptr) {
8478 const MSEdge* next = route[ri + 1];
8479 if (&dpi.myLink->getLane()->getEdge() != next) {
8482 if (dpi.myLink->getViaLane() ==
nullptr) {
8488 dpi.myLink->removeApproaching(
this);
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(...)
std::shared_ptr< const MSRoute > ConstMSRoutePtr
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
constexpr SUMOTime TIME2STEPS(double x)
bool isRailway(SVCPermissions permissions)
Returns whether an edge with the given permissions is a (exclusive) railway edge.
@ RAIL_CARGO
render as a cargo train
@ PASSENGER_VAN
render as a van
@ PASSENGER
render as a passenger vehicle
@ RAIL_CAR
render as a (city) rail without locomotive
@ PASSENGER_HATCHBACK
render as a hatchback passenger vehicle ("Fliessheck")
@ BUS_FLEXIBLE
render as a flexible city bus
@ TRUCK_1TRAILER
render as a transport vehicle with one trailer
@ PASSENGER_SEDAN
render as a sedan passenger vehicle ("Stufenheck")
@ PASSENGER_WAGON
render as a wagon passenger vehicle ("Combi")
@ TRUCK_SEMITRAILER
render as a semi-trailer transport vehicle ("Sattelschlepper")
@ SVC_RAIL_CLASSES
classes which drive on tracks
@ SVC_EMERGENCY
public emergency vehicles
const long long int VEHPARS_FORCE_REROUTE
@ GIVEN
The lane is given.
@ DEFAULT
No information given; use default.
@ GIVEN
The speed is given.
@ SPLIT_FRONT
depart position for a split vehicle is in front of the continuing vehicle
const long long int VEHPARS_CFMODEL_PARAMS_SET
@ GIVEN
The arrival lane is given.
@ GIVEN
The speed is given.
@ GIVEN
The arrival position is given.
@ DEFAULT
No information given; use default.
const int STOP_STARTED_SET
@ SUMO_TAG_PARKING_AREA_REROUTE
entry for an alternative parking zone
@ SUMO_TAG_PARKING_AREA
A parking area.
@ 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_STOPLINE_GAP_MINOR
@ SUMO_ATTR_JM_STOPLINE_CROSSING_GAP
@ SUMO_ATTR_JM_IGNORE_KEEPCLEAR_TIME
@ SUMO_ATTR_MAXIMUMPOWER
Maximum Power.
@ SUMO_ATTR_CF_IGNORE_IDS
@ SUMO_ATTR_JM_STOPLINE_GAP
@ SUMO_ATTR_JM_DRIVE_AFTER_RED_TIME
@ SUMO_ATTR_JM_DRIVE_AFTER_YELLOW_TIME
@ SUMO_ATTR_LCA_CONTRIGHT
@ SUMO_ATTR_CF_IGNORE_TYPES
@ SUMO_ATTR_ARRIVALPOS_RANDOMIZED
@ SUMO_ATTR_JM_IGNORE_JUNCTION_FOE_PROB
@ 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
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
double getDoubleOptional(SumoXMLAttr attr, const double def) const
Returns the value for a given key with an optional default. SUMO_ATTR_MASS and SUMO_ATTR_FRONTSURFACE...
void setDynamicValues(const SUMOTime stopDuration, const bool parking, const SUMOTime waitingTime, const double angleDiff)
Sets the values which change possibly in every simulation step and are relevant for emsssion calculat...
static double naviDegree(const double angle)
static double fromNaviDegree(const double angle)
static double angleDiff(const double angle1, const double angle2)
Returns the difference of the second angle to the first angle in radiants.
Interface for lane-change models.
double getLaneChangeCompletion() const
Get the current lane change completion ratio.
MSLane * updateTargetLane()
bool hasBlueLight() const
const std::vector< double > & getShadowFurtherLanesPosLat() const
double getCommittedSpeed() const
virtual void resetSpeedLat()
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
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.
virtual void saveState(OutputDevice &out) const
Save the state of the laneChangeModel.
void endLaneChangeManeuver(const MSMoveReminder::Notification reason=MSMoveReminder::NOTIFICATION_LANE_CHANGE)
void setNoShadowPartialOccupator(MSLane *lane)
MSLane * getTargetLane() const
Returns the lane the vehicle has committed to enter during a sublane lane change.
double getStrategicLookahead() const
SUMOTime remainingTime() const
Compute the remaining time until LC completion.
void setShadowApproachingInformation(MSLink *link) const
set approach information for the shadow vehicle
double getCooperativeHelpSpeed(const MSLane *lane, double distToLaneEnd) const
return speed for helping a vehicle that is blocked from changing
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
virtual void loadState(const SUMOSAXAttributes &attrs)
Loads the state of the laneChangeModel from the given attributes.
double calcAngleOffset()
return the angle offset during a continuous change maneuver
void setPreviousAngleOffset(const double angleOffset)
set the angle offset of the previous time step
const std::vector< MSLane * > & getFurtherTargetLanes() const
virtual void resetState()
double getAngleOffset() const
return the angle offset resulting from lane change and sigma
virtual void prepareStep(SumoRNG *rng)
rng belongs to the lane that moves the vehicle (not the lane it just entered)
const std::vector< MSLane * > & getShadowFurtherLanes() const
bool isChangingLanes() const
return true if the vehicle currently performs a lane change maneuver
void removeShadowApproachingInformation() const
void setExtraImpatience(double value)
Sets routing behavior.
The base class for microscopic and mesoscopic vehicles.
double getMaxSpeed() const
Returns the maximum speed (the minimum of desired and technical maximum speed)
bool haveValidStopEdges(bool silent=false) const
check whether all stop.edge MSRouteIterators are valid and in order
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()
const MSEdge * succEdge(int nSuccs) const
Returns the nSuccs'th successor of edge the vehicle is currently at.
void calculateArrivalParams(bool onInit)
(Re-)Calculates the arrival position and lane from the vehicle parameters
virtual double getArrivalPos() const
Returns this vehicle's desired arrivalPos for its current route (may change on reroute)
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 replaceParameter(const SUMOVehicleParameter *newParameter)
replace the vehicle parameter (deleting the old one)
double getChosenSpeedFactor() const
Returns the precomputed factor by which the driver wants to be faster than the speed limit.
std::vector< MSVehicleDevice * > myDevices
The devices this vehicle has.
virtual void addTransportable(MSTransportable *transportable)
Adds a person or container to this vehicle.
const SUMOVehicleParameter::Stop * getNextStopParameter() const
return parameters for the next stop (SUMOVehicle Interface)
virtual bool replaceRoute(ConstMSRoutePtr route, const std::string &info, bool onInit=false, int offset=0, bool addRouteStops=true, bool removeStops=true, std::string *msgReturn=nullptr)
Replaces the current route by the given one.
MSVehicleType & getSingularType()
Replaces the current vehicle type with a new one used by this vehicle only.
const MSVehicleType * myType
This vehicle's type.
void cleanupParkingReservation()
unregisters from a parking reservation when changing or skipping stops
double getLength() const
Returns the vehicle's length.
bool isParking() const
Returns whether the vehicle is parking.
MSParkingArea * getCurrentParkingArea()
get the current parking area stop or nullptr
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
int getPersonNumber() const
Returns the number of persons.
MSRouteIterator myCurrEdge
Iterator to current route-edge.
StopParVector myPastStops
The list of stops that the vehicle has already reached.
bool hasDeparted() const
Returns whether this vehicle has already departed.
bool ignoreTransientPermissions() const
Returns whether this object is ignoring transient permission changes (during routing)
ConstMSRoutePtr myRoute
This vehicle's route.
double getWidth() const
Returns the vehicle's width.
MSDevice_Transportable * myContainerDevice
The containers this vehicle may have.
const std::list< MSStop > & getStops() const
double getDesiredMaxSpeed() const
void addReminder(MSMoveReminder *rem, double pos=0)
Adds a MoveReminder dynamically.
SUMOTime getDeparture() const
Returns this vehicle's real departure time.
EnergyParams * getEmissionParameters() const
retrieve parameters for the energy consumption model
MSDevice_Transportable * myPersonDevice
The passengers this vehicle may have.
bool hasStops() const
Returns whether the vehicle has to stop somewhere.
virtual void activateReminders(const MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
"Activates" all current move reminder
const MSStop & getNextStop() const
@ ROUTE_START_INVALID_LANE
@ ROUTE_START_INVALID_PERMISSIONS
void addStops(const bool ignoreStopErrors, MSRouteIterator *searchStart=nullptr, bool addRouteStops=true)
Adds stops to the built vehicle.
SUMOVehicleClass getVClass() const
Returns the vehicle's access class.
MSParkingArea * getNextParkingArea()
get the upcoming parking area stop or nullptr
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.
void onDepart()
Called when the vehicle is inserted into the network.
virtual bool addTraciStop(SUMOVehicleParameter::Stop stop, std::string &errorMsg)
const MSRoute & getRoute() const
Returns the current route.
int getRoutePosition() const
return index of edge within route
bool replaceParkingArea(MSParkingArea *parkingArea, std::string &errorMsg)
replace the current parking area stop with a new stop with merge duration
static const SUMOTime NOT_YET_DEPARTED
bool myAmRegisteredAsWaiting
Whether this vehicle is registered as waiting for a person or container (for deadlock-recognition)
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT() const
returns the router according to the current routing mode of the vehicle
EnergyParams * myEnergyParams
The emission parameters this vehicle may have.
const SUMOVehicleParameter * myParameter
This vehicle's parameter.
int myRouteValidity
status of the current vehicle route
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
bool isStopped() const
Returns whether the vehicle is at a stop.
MSDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists, nullptr otherwise.
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.
virtual void replaceVehicleType(const MSVehicleType *type)
Replaces the current vehicle type by the one given.
double myOdometer
A simple odometer to keep track of the length of the route already driven.
int getContainerNumber() const
Returns the number of containers.
bool replaceRouteEdges(ConstMSEdgeVector &edges, double cost, double savings, const std::string &info, bool onInit=false, bool check=false, bool removeStops=true, std::string *msgReturn=nullptr)
Replaces the current route by the given edges.
virtual void saveState(OutputDevice &out, const MSCFModel &cfm) const
Saves the vehicle variables.
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 ...
virtual VehicleVariables * createVehicleVariables() const
Returns model specific values which are stored inside a vehicle and must be used with casting.
double getEmergencyDecel() const
Get the vehicle type's maximal physically possible deceleration [m/s^2].
SUMOTime getStartupDelay() const
Get the vehicle type's startupDelay.
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 freeSpeed(const MSVehicle *const veh, double speed, double seen, double maxSpeed, const bool onInsertion=false, const CalcReason usage=CalcReason::CURRENT) const
Computes the vehicle's safe speed without a leader.
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...
virtual double insertionFollowSpeed(const MSVehicle *const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle *const pred=0) const
Computes the vehicle's safe speed (no dawdling) This method is used during the insertion stage....
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 bool startupDelayStopped() const
whether startupDelay should be applied after stopping
@ FUTURE
the return value is used for calculating future speeds
@ CURRENT_WAIT
the return value is used for calculating junction stop speeds
virtual double maxNextSafeMin(double speed, const MSVehicle *const veh=0) const
Returns the maximum speed given the current speed and regarding driving dynamics.
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....
virtual double maximumLaneSpeedCF(const MSVehicle *const veh, double maxSpeed, double maxSpeedLane) const
Returns the maximum velocity the CF-model wants to achieve in the next step.
double maximumSafeStopSpeed(double gap, double decel, double currentSpeed, bool onInsertion=false, double headway=-1, bool relaxEmergency=true) const
Returns the maximum next velocity for stopping within gap.
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 followSpeed(const MSVehicle *const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle *const pred=0, const CalcReason usage=CalcReason::CURRENT) const =0
Computes the vehicle's follow speed (no dawdling)
double stopSpeed(const MSVehicle *const veh, const double speed, double gap, const CalcReason usage=CalcReason::CURRENT) const
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)
return energy consumption in Wh (power multiplied by TS)
void setConsum(const double consumption)
double acceleration(SUMOVehicle &veh, double power, double oldSpeed)
double getConsum() const
Get consum.
A device which collects info on current friction Coefficient on the road.
double getMeasuredFriction()
A device which collects info on the vehicle trip (mainly on departure and arrival)
A device which collects info on the vehicle trip (mainly on departure and arrival)
void cancelCurrentCustomers()
remove the persons the taxi is currently waiting for from reservations
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Checks whether the vehicle is at a stop and transportable action is needed.
bool anyLeavingAtStop(const MSStop &stop) const
void transferAtSplitOrJoin(MSBaseVehicle *otherVeh)
transfers transportables that want to continue in the other train part (without boarding/loading dela...
void checkCollisionForInactive(MSLane *l)
trigger collision checking for inactive lane
A road/street connecting two junctions.
static void clear()
Clears the dictionary.
static DepartLaneDefinition & getDefaultDepartLaneDefinition()
const std::set< MSTransportable *, ComparatorNumericalIdLess > & getPersons() const
Returns this edge's persons set.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
const MSEdge * getOppositeEdge() const
Returns the opposite direction edge if on exists else a nullptr.
bool isFringe() const
return whether this edge is at the fringe of the network
const MSEdge * getNormalSuccessor() const
if this edge is an internal edge, return its first normal successor, otherwise the edge itself
const std::vector< MSLane * > * allowedLanes(const MSEdge &destination, SUMOVehicleClass vclass=SVC_IGNORING, bool ignoreTransientPermissions=false) const
Get the allowed lanes to reach the destination-edge.
const MSEdge * getBidiEdge() const
return opposite superposable/congruent edge, if it exist and 0 else
bool isNormal() const
return whether this edge is an internal edge
double getSpeedLimit() const
Returns the speed limit of the edge @caution The speed limit of the first lane is returned; should pr...
bool hasChangeProhibitions(SUMOVehicleClass svc, int index) const
return whether this edge prohibits changing for the given vClass when starting on the given lane inde...
bool hasLaneChanger() const
const MSJunction * getToJunction() const
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 MSEdge * getInternalFollowingEdge(const MSEdge *followerAfterInternal, SUMOVehicleClass vClass) const
void removeWaiting(const SUMOVehicle *vehicle) const
Removes a vehicle from the list of waiting vehicles.
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 bool gUseStopStarted
static SUMOTime gStartupWaitThreshold
The minimum waiting time before applying startupDelay.
static double gTLSYellowMinDecel
The minimum deceleration at a yellow traffic light (only overruled by emergencyDecel)
static double gLateralResolution
static bool gSemiImplicitEulerUpdate
static bool gSlopeCentered
whether to use a simplified slope computation (for compatibility with other simulations)
static bool gLefthand
Whether lefthand-drive is being simulated.
static bool gSublane
whether sublane simulation is enabled (sublane model or continuous lanechanging)
static SUMOTime gLaneChangeDuration
static bool gUseStopEnded
whether the simulation should replay previous stop times
static double gEmergencyDecelWarningThreshold
threshold 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.
std::vector< StopWatch< std::chrono::nanoseconds > > & getStopWatch()
const std::vector< MSMoveReminder * > & getMoveReminders() const
Return the list of this lane's move reminders.
std::pair< const MSPerson *, double > nextBlocking(double minPos, double minRight, double maxLeft, double stopTime=0, bool bidi=false) const
This is just a wrapper around MSPModel::nextBlocking. You should always check using hasPedestrians be...
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)
MSVehicle * getFirstAnyVehicle() const
returns the first vehicle that is fully or partially on this lane
const MSLink * getEntryLink() const
Returns the entry link if this is an internal lane, else nullptr.
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...
std::pair< MSVehicle *const, double > getFollower(const MSVehicle *ego, double egoPos, double dist, MinorLinkMode mLinkMode, bool maxSearchDist=false) const
Find follower vehicle for the given ego vehicle (which may be on the opposite direction lane)
static std::vector< MSLink * >::const_iterator succLinkSec(const SUMOVehicle &veh, int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane * > &conts)
void markRecalculateBruttoSum()
Set a flag to recalculate the brutto (including minGaps) occupancy of this lane (used if mingap is ch...
const MSLink * getLinkTo(const MSLane *const) const
returns the link to the given lane or nullptr, if it is not connected
const MSLeaderInfo getLastVehicleInformation(const MSVehicle *ego, double latOffset, double minPos=0, bool allowCached=true, const MSVehicle *ignore=nullptr) const
Returns the last vehicles on the lane.
MSLeaderDistanceInfo getFollowersOnConsecutive(const MSVehicle *ego, double backOffset, bool allSublanes, double searchDist=-1, MinorLinkMode mLinkMode=FOLLOW_ALWAYS, bool maxSearchDist=false) const
return the sublane followers with the largest missing rear gap among all predecessor lanes (within di...
void forceVehicleInsertion(MSVehicle *veh, double pos, MSMoveReminder::Notification notification, double posLat=0)
Inserts the given vehicle at the given position.
double getVehicleStopOffset(const MSVehicle *veh) const
Returns vehicle class specific stopOffset for the vehicle.
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
std::vector< MSVehicle * > VehCont
Container for vehicles.
const MSEdge * getNextNormal() const
Returns the lane's follower if it is an internal lane, the edge of the lane otherwise.
SVCPermissions getPermissions() const
Returns the vehicle class permissions for this lane.
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
MSLane * getCanonicalPredecessorLane() const
double getLength() const
Returns the lane's length.
double getMaximumBrakeDist() const
compute maximum braking distance on this lane
const MSLane * getInternalFollowingLane(const MSLane *const) const
returns the internal lane leading to the given lane or nullptr, if there is none
std::pair< MSVehicle *const, double > getLeaderOnConsecutive(double dist, double seen, double speed, const MSVehicle &veh, const std::vector< MSLane * > &bestLaneConts, bool considerCrossingFoes=true) const
Returns the immediate leader and the distance to him.
bool isLinkEnd(std::vector< MSLink * >::const_iterator &i) const
bool allowsVehicleClass(SUMOVehicleClass vclass) const
virtual double setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
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.
MSLane * getCanonicalSuccessorLane() const
double getOppositePos(double pos) const
return the corresponding position on the opposite lane
MSLane * getLogicalPredecessorLane() const
get the most likely predecessor lane (sorted using by_connections_to_sorter). The result is cached in...
double getCenterOnEdge() const
MSVehicle * getLastAnyVehicle() const
returns the last vehicle that is fully or partially on this lane
virtual void resetPartialOccupation(MSVehicle *v)
Removes the information about a vehicle lapping into this lane.
SumoRNG * getRNG() const
return the associated RNG
MSLane * getOpposite() const
return the neighboring opposite direction lane for lane changing or nullptr
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
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
virtual const PositionVector & getShape(bool) const
MSLane * getParallelOpposite() const
return the opposite direction lane of this lanes edge or nullptr
MSEdge & getEdge() const
Returns the lane's edge.
double getSpaceTillLastStanding(const MSVehicle *ego, bool &foundStopped) const
return the empty space up to the last standing vehicle or the empty space on the whole lane if no veh...
const MSLane * getNormalPredecessorLane() const
get normal lane leading to this internal lane, for normal lanes, the lane itself is returned
double getWidth() const
Returns the lane's width.
const std::vector< MSLink * > & getLinkCont() const
returns the container with all links !!!
MSVehicle * getFirstFullVehicle() const
returns the first vehicle for which this lane is responsible or 0
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
static CollisionAction getCollisionAction()
saves leader/follower vehicles and their distances relative to an ego vehicle
virtual std::string toString() const
print a debugging representation
void fixOppositeGaps(bool isFollower)
subtract vehicle length from all gaps if the leader vehicle is driving in the opposite direction
virtual int addLeader(const MSVehicle *veh, double gap, double latOffset=0, int sublane=-1)
void setSublaneOffset(int offset)
set number of sublanes by which to shift positions
void removeOpposite(const MSLane *lane)
remove vehicles that are driving in the opposite direction (fully or partially) on the given lane
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
int getSublaneOffset() const
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
bool isIndirect() const
whether this link is the start of an indirect turn
const MSLane * getInternalLaneBefore() const
return myInternalLaneBefore (always 0 when compiled without internal lanes)
LinkState getState() const
Returns the current state of the link.
bool hasApproachingFoe(SUMOTime arrivalTime, SUMOTime leaveTime, double speed, double decel) const
Returns the information whether a vehicle is approaching on one of the link's foe streams.
MSJunction * getJunction() const
void setApproaching(const SUMOVehicle *approaching, const SUMOTime arrivalTime, const double arrivalSpeed, const double leaveSpeed, const bool setRequest, const double arrivalSpeedBraking, const SUMOTime waitingTime, double dist, double latOffset)
Sets the information about an approaching vehicle.
SUMOTime getLastStateChange() const
MSLane * getLane() const
Returns the connected lane.
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, double dist=-1) const
Returns the information whether the link may be passed.
bool isConflictEntryLink() const
return whether this link enters the conflict area (not a continuation link)
int getIndex() const
Returns the respond index (for visualization)
bool havePriority() const
Returns whether this link is a major link.
void updateApproaching(const SUMOVehicle *approaching, const SUMOTime arrivalTime, const double arrivalSpeed, const double leaveSpeed, const bool setRequest, const double arrivalSpeedBraking, const SUMOTime waitingTime, double dist, double latOffset)
like setApproaching but overwrites an existing entry in place (no erase and insert)
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
MSLane * getViaLane() const
Returns the following inner lane.
std::string getDescription() const
get string description for this link
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
bool isExitLinkAfterInternalJunction() const
return whether the fromLane of this link is an internal lane and its incoming lane is also an interna...
MSLink * getParallelLink(int direction) const
return the link that is parallel to this link or 0
MSLane * getViaLaneOrLane() const
return the via lane if it exists and the lane otherwise
std::vector< const SUMOTrafficObject * > BlockingFoes
double getLateralShift() const
return lateral shift that must be applied when passing this link
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
const MSTrafficLightLogic * getTLLogic() const
Returns the TLS index.
double getZipperSpeed(const MSVehicle *ego, const double dist, double vSafe, SUMOTime arrivalTime, const BlockingFoes *foes) const
return the speed at which ego vehicle must approach the zipper link
MSLink * getOppositeDirectionLink() const
return the link that is the opposite entry link to this one
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
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_VAPORIZED_COLLISION
The vehicle got removed by a collision.
@ NOTIFICATION_LOAD_STATE
The vehicle has been loaded from a state file.
@ NOTIFICATION_TELEPORT
The vehicle is being teleported.
@ NOTIFICATION_TELEPORT_CONTINUATION
The vehicle continues being teleported past an edge.
The simulated network and simulation perfomer.
void removeVehicleStateListener(VehicleStateListener *listener)
Removes a vehicle states listener.
VehicleState
Definition of a vehicle state.
@ STARTING_STOP
The vehicles starts to stop.
@ STARTING_PARKING
The vehicles starts to park.
@ STARTING_TELEPORT
The vehicle started to teleport.
@ ENDING_STOP
The vehicle ends to stop.
@ ARRIVED
The vehicle arrived at his destination (is deleted)
@ EMERGENCYSTOP
The vehicle had to brake harder than permitted.
@ MANEUVERING
Vehicle maneuvering either entering or exiting a parking space.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
virtual MSTransportableControl & getContainerControl()
Returns the container 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.
bool hasContainers() const
Returns whether containers are simulated.
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.
MSInsertionControl & getInsertionControl()
Returns the insertion control.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
virtual MSTransportableControl & getPersonControl()
Returns the person control.
MSEdgeControl & getEdgeControl()
Returns the edge control.
bool hasInternalLinks() const
return whether the network contains internal links
bool hasElevation() const
return whether the network contains elevation data
static const double SAFETY_GAP
A lane area vehicles can halt at.
int getOccupancyIncludingReservations(const SUMOVehicle *forVehicle) const
void enter(SUMOVehicle *veh, const bool parking) override
Called if a vehicle enters this stop.
void leaveFrom(SUMOVehicle *what) override
Called if a vehicle leaves this stop.
int getCapacity() const
Returns the area capacity.
int getLotIndex(const SUMOVehicle *veh) const
compute lot for this vehicle
int getLastFreeLotAngle() const
Return the angle of myLastFreeLot - the next parking lot only expected to be called after we have est...
bool parkOnRoad() const
whether vehicles park on the road
double getLastFreePosWithReservation(SUMOTime t, const SUMOVehicle &forVehicle, double brakePos)
Returns the last free position on this stop including reservations from the current lane and time ste...
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 getGUIAngle(const SUMOVehicle &forVehicle) const
Return the GUI angle of the lot where the vehicle is parked.
void notifyApproach(const MSLink *link)
switch rail signal to active
static MSRailSignalControl & getInstance()
const ConstMSEdgeVector & getEdges() const
const MSEdge * getLastEdge() const
returns the destination edge
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
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
double getSpeed() const
return speed for passing waypoint / skipping on-demand stop
bool joinTriggered
whether coupling another vehicle (train) the vehicle continue
bool isOpposite
whether this an opposite-direction stop
SUMOTime getMinDuration(SUMOTime time) const
return minimum stop duration when starting stop at time
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.
bool skipOnDemand
whether the decision to skip this stop has been made
const MSEdge * getEdge() const
double entryPos
the exact position when entering the stop (for state saving)
double getReachedThreshold() const
return startPos taking into account opposite stopping
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
bool startedFromState
whether the 'started' value was loaded from simulaton state
MSStoppingPlace * chargingStation
(Optional) charging station if one is assigned to the stop
SUMOTime duration
The stopping duration.
SUMOTime getUntil() const
return until / ended time
const SUMOVehicleParameter::Stop pars
The stop parameter.
MSStoppingPlace * busstop
(Optional) bus stop if one is assigned to the stop
void stopBlocked(const SUMOVehicle *veh, SUMOTime time)
void stopNotStarted(const SUMOVehicle *veh)
void stopStarted(const SUMOVehicle *veh, int numPersons, int numContainers, SUMOTime time)
static MSStopOut * getInstance()
void stopEnded(const SUMOVehicle *veh, const MSStop &stop, bool simEnd=false)
double getBeginLanePosition() const
Returns the begin position of this stop.
virtual void enter(SUMOVehicle *veh, const bool parking)
Called if a vehicle enters 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.
const MSLane & getLane() const
Returns the lane this stop is located at.
virtual void leaveFrom(SUMOVehicle *what)
Called if a vehicle leaves this stop.
bool hasAnyWaiting(const MSEdge *edge, SUMOVehicle *vehicle) const
check whether any transportables are waiting for the given vehicle
bool loadAnyWaiting(const MSEdge *edge, SUMOVehicle *vehicle, SUMOTime &timeToLoadNext, SUMOTime &stopDuration, MSTransportable *const force=nullptr)
load any applicable transportables Loads any person / container that is waiting on that edge for the ...
bool isPerson() const override
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 myConsiderMaxDeceleration
Whether the maximum deceleration shall be regarded.
void setLaneTimeLine(const std::vector< std::pair< SUMOTime, int > > &laneTimeLine)
Sets a new lane timeline.
bool hasSpeedTimeLine(SUMOTime t) const
bool myRespectJunctionLeaderPriority
Whether the junction priority rules are respected (within)
void setOriginalSpeed(double speed)
Stores the originally longitudinal speed.
double myOriginalSpeed
The velocity before influence.
bool myConsiderSpeedLimit
Whether the speed limit shall be regarded.
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)
update position from remote control
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
bool getRespectJunctionLeaderPriority() const
Returns whether junction priority rules within the junction shall be respected (concerns vehicles wit...
LaneChangeMode myStrategicLC
lane changing which is necessary to follow the current route
LaneChangeMode mySpeedGainLC
lane changing to travel with higher speed
void init()
Static initalization.
LaneChangeMode mySublaneLC
changing to the prefered lateral alignment
bool getRespectJunctionPriority() const
Returns whether junction priority rules shall be respected (concerns approaching vehicles outside the...
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 considerSpeedLimit() const
Returns whether speed limits shall be considered.
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.
void updateRemoteControlRoute(MSVehicle *v)
update route if provided by remote control
bool considerMaxDeceleration() const
Returns whether safe velocities shall be considered.
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 (approaching)
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
State(double pos, double speed, double posLat, double backPos, double previousSpeed)
Constructor.
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.
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 registerEmergencyStop()
register emergency stop
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
void registerStopEnded()
register emergency stop
void registerEmergencyBraking()
register emergency stop
void removeVType(const MSVehicleType *vehType)
void registerOneWaiting()
increases the count of vehicles waiting for a transport to allow recognition of person / container re...
void unregisterOneWaiting()
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...
const MSLane * getPreviousLane(const MSLane *current, int &furtherIndex) const
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
bool willStop() const
Returns whether the vehicle will stop on the current edge.
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.
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,...
ConstMSEdgeVector::const_iterator getRerouteOrigin() const
Returns the starting point for reroutes (usually the current edge)
bool hasArrivedInternal(bool oppositeTransformed=true) const
Returns whether this vehicle has already arived (reached the arrivalPosition on its final edge) metho...
double getFriction() const
Returns the current friction on the road as perceived by the friction device.
bool ignoreFoe(const SUMOTrafficObject *foe) const
decide whether a given foe object may be ignored
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...
double getCurveRadius() const
Returns the vehicle's current curve radius in m.
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.
SUMOTime myJunctionConflictEntryTime
double getLeftSideOnEdge(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)
PositionVector getBoundingPoly(double offset=0) const
get bounding polygon
void setTentativeLaneAndPosition(MSLane *lane, double pos, double posLat=0)
set tentative lane and position during insertion to ensure that all cfmodels work (some of them requi...
bool brakeForOverlap(const MSLink *link, const MSLane *lane) const
handle width transitions
void workOnMoveReminders(double oldPos, double newPos, double newSpeed)
Processes active move reminder.
bool isStoppedOnLane() const
double getDistanceToPosition(double destPos, const MSLane *destLane) const
bool brokeDown() const
Returns how long the vehicle has been stopped already due to lack of energy.
double myAcceleration
The current acceleration after dawdling in m/s.
void registerInsertionApproach(MSLink *link, double dist)
register approach on insertion
void cleanupFurtherLanes()
remove vehicle from further lanes (on leaving the network)
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
Returns the lane the where the rear of the object is currently at.
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.
double getBackPositionOnLane() const
Get the vehicle's position relative to its current lane.
double myStopSpeed
the speed that is needed for a scheduled stop or waypoint
void setPreviousSpeed(double prevSpeed, double prevAcceleration)
Sets the influenced previous speed.
double myRawAngle
the angle in radians before lane changing
SUMOTime getArrivalTime(SUMOTime t, double seen, double v, double arrivalSpeed) const
double getAccumulatedWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s) within the last millisecs.
SUMOTime getWaitingTime(const bool accumulated=false) const
Returns the SUMOTime waited (speed was lesser than 0.1m/s)
bool isFrontOnLane(const MSLane *lane) const
Returns the information whether the front of the vehicle is on the given lane.
virtual ~MSVehicle()
Destructor.
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 whether the vehicle can depart on the first edge
double getLeftSideOnLane() const
Get the lateral position of the vehicles left side on the lane:
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.
MSCFModel::VehicleVariables * myCFVariables
The per vehicle variables of the car following model.
bool betterContinuation(const LaneQ *bestConnectedNext, const LaneQ &m) const
comparison between different continuations from the same lane
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)
std::pair< double, const MSLink * > myNextTurn
the upcoming turn for the vehicle
double getDistanceToLeaveJunction() const
get the distance from the start of this lane to the start of the next normal lane (or 0 if this lane ...
int influenceChangeDecision(int state)
allow TraCI to influence a lane change decision
double getMaxSpeedOnLane() const
Returns the maximal speed for the vehicle on its current lane (including speed factor and deviation,...
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 enterLaneAtMove(MSLane *enteredLane, bool onTeleporting=false)
Update when the vehicle enters a new lane in the move step.
double myLastAngle
the angle in radians from the previous simulation step (for computing curve radius)
void adaptBestLanesOccupation(int laneIndex, double density)
update occupation from MSLaneChanger
std::pair< double, double > estimateTimeToNextStop() const
return time (s) and distance to the next stop
double accelThresholdForWaiting() const
maximum acceleration to consider a vehicle as 'waiting' at low speed
void setAngle(double angle, bool straightenFurther=false)
Set a custom vehicle angle in rad, optionally updates furtherLanePosLat.
std::vector< LaneQ >::iterator myCurrentLaneInBestLanes
void setApproachingForAllLinks()
Register junction approaches for all link items in the current plan.
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
const std::vector< MSLane * > getUpstreamOppositeLanes() const
Returns the sequence of opposite lanes corresponding to past lanes.
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.
PositionVector getBoundingBox(double offset=0) const
get bounding rectangle
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.
const MSEdge * getNextEdgePtr() const
returns the next edge (possibly an internal edge)
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.
const MSEdge * myLastBestLanesEdge
bool ignoreCollision() const
whether this vehicle is except from collision checks
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....
bool resumeFromStopping()
int getBestLaneOffset() const
void adaptToJunctionLeader(const std::pair< const MSVehicle *, double > leaderInfo, const double seen, DriveProcessItem *const lastLink, const MSLane *const lane, double &v, double &vLinkPass, double distToCrossing=-1) const
double lateralDistanceToLane(const int offset) const
Get the minimal lateral distance required to move fully onto the lane at given offset.
double getBackPositionOnLane(const MSLane *lane) const
Get the vehicle's position relative to the given lane.
void leaveLaneBack(const MSMoveReminder::Notification reason, const MSLane *leftLane)
Update of reminders if vehicle back leaves a lane during (during forward movement.
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 interpolateLateralZ(Position &pos, double offset, double posLat) const
perform lateral z interpolation in elevated networks
void setBlinkerInformation()
sets the blue flashing light for emergency vehicles
const MSEdge * getCurrentEdge() const
Returns the edge the vehicle is currently at (possibly an internal edge or nullptr)
void adaptToLeaderDistance(const MSLeaderDistanceInfo &ahead, double latOffset, double seen, DriveProcessItem *const lastLink, double &v, double &vLinkPass) const
DriveItemVector::iterator myNextDriveItem
iterator pointing to the next item in myLFLinkLanes
bool unsafeLinkAhead(const MSLane *lane, double zipperDist) const
whether the vehicle may safely move to the given lane with regard to upcoming links
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.
const MSLink * myHaveStoppedFor
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.
void removeApproachingInformation(const DriveItemVector &lfLinks) const
unregister approach from all upcoming links
double getAngleDiff() const
get the change in angle from the last simulation step
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 arrived (reached the arrivalPosition on its final edge)
void switchOffSignal(int signal)
Switches the given signal off.
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
bool isOppositeLane(const MSLane *lane) const
whether the give lane is reverse direction of the current route or not
double myStopDist
distance to the next stop or doubleMax if there is none
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.
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...
double getBestLaneDist() const
returns the distance that can be driven without lane change
void replaceVehicleType(const MSVehicleType *type)
Replaces the current vehicle type by the one given.
void updateState(double vNext, bool parking=false)
updates the vehicles state, given a next value for its speed. This value can be negative in case of t...
double slowDownForSchedule(double vMinComfortable) const
optionally return an upper bound on speed to stay within the schedule
bool executeMove()
Executes planned vehicle movements with regards to right-of-way.
const MSLane * getLane() const
Returns the lane the vehicle is on.
std::pair< const MSVehicle *const, double > getFollower(double dist=0) const
Returns the follower of the vehicle looking for a fixed distance.
SUMOTime getWaitingTimeFor(const MSLink *link) const
getWaitingTime, but taking into account having stopped for a stop-link
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
bool isLeader(const MSLink *link, const MSVehicle *veh, const double gap) const
whether the given vehicle must be followed at the given junction
void resetApproachOnReroute()
reset rail signal approach information
void computeFurtherLanes(MSLane *enteredLane, double pos, bool collision=false)
updates myFurtherLanes on lane insertion or after collision
MSLane * getMutableLane() const
Returns the lane the vehicle is on Non const version indicates that something volatile is going on.
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()
bool isBidiOn(const MSLane *lane) const
whether this vehicle is driving against lane
double getRightSideOnLane() const
Get the lateral position of the vehicles right side on the lane:
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.
SUMOTime myTimeSinceStartup
duration of driving (speed > SUMO_const_haltingSpeed) after the last halting episode
double getSpeed() const
Returns the vehicle's current speed.
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
bool replaceRoute(ConstMSRoutePtr route, const std::string &info, bool onInit=false, int offset=0, bool addStops=true, bool removeStops=true, std::string *msgReturn=nullptr)
Replaces the current route by the given one.
MSVehicle::ManoeuvreType getManoeuvreType() const
accessor function to myManoeuvre equivalent
double checkReversal(bool &canReverse, double speedThreshold=SUMO_const_haltingSpeed, double seen=0) const
void updateLaneBruttoSum()
Update the lane brutto occupancy after a change in minGap.
void removePassedDriveItems()
Erase passed drive items from myLFLinkLanes (and unregister approaching information for corresponding...
const std::vector< MSLane * > & getFurtherLanes() const
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...
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
Position validatePosition(Position result, double offset=0) const
ensure that a vehicle-relative position is not invalid
void loadPreviousApproaching(MSLink *link, bool setRequest, SUMOTime arrivalTime, double arrivalSpeed, double arrivalSpeedBraking, double dist, double leaveSpeed)
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 ignored
double getPositionOnLane() const
Get the vehicle's position along the lane.
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)
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 handleCollisionStop(MSStop &stop, const double distToStop)
bool hasInfluencer() const
whether the vehicle is individually influenced (via TraCI or special parameters)
MSDevice_Friction * myFrictionDevice
This vehicle's friction perception.
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,...
double getBrakeGap(bool delayed=false) const
get distance for coming to a stop (used for rerouting checks)
std::pair< const MSVehicle *const, double > getLeader(double dist=0, bool considerFoes=true) const
Returns the leader of the vehicle looking for a fixed distance.
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
void adaptToOncomingLeader(const std::pair< const MSVehicle *, double > leaderInfo, DriveProcessItem *const lastLink, double &v, double &vLinkPass) const
void planMoveInternal(const SUMOTime t, MSLeaderInfo ahead, DriveItemVector &lfLinks, double &myStopDist, double &newStopSpeed, std::pair< double, const MSLink * > &myNextTurn) const
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 adaptToLeader(const std::pair< const MSVehicle *, double > leaderInfo, double seen, DriveProcessItem *const lastLink, double &v, double &vLinkPass) const
bool instantStopping() const
whether instant stopping is permitted
void switchOnSignal(int signal)
Switches the given signal on.
static bool overlap(const MSVehicle *veh1, const MSVehicle *veh2)
void updateParkingState()
update state while parking
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 (technical) maximum speed [m/s].
const std::string & getID() const
Returns the name of the vehicle type.
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.
const MSCFModel & getCarFollowModel() const
Returns the vehicle type's car following model definition (const version)
bool isVehicleSpecific() const
Returns whether this type belongs to a single vehicle only (was modified)
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.
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 ATTR_TYPE &attr, const T &val, const bool isNull=false, const bool escape=false)
writes a named attribute
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
bool hasParameter(const std::string &key) const
Returns whether the parameter is set.
virtual const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
A point in 2D or 3D with translation and scaling methods.
double slopeTo2D(const Position &other) const
returns the slope of the vector pointing from here to the other position (in radians between -M_PI an...
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
void setz(double z)
set position z
double z() const
Returns the z-position.
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position (in radians bet...
double length2D() const
Returns the length.
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 amount
double slopeDegreeAtOffset(double pos) const
Returns the slope at the given length.
void extrapolate2D(const double val, const bool onlyFirst=false)
extrapolate position vector in two dimensions (Z is ignored)
void scaleRelative(double factor)
enlarges/shrinks the polygon by a factor based at the centroid
PositionVector reverse() const
reverse position vector
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)
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...
virtual double recomputeCosts(const std::vector< const E * > &edges, const V *const v, SUMOTime msTime, double *lengthp=nullptr) const
Encapsulated SAX-Attributes.
virtual std::string getString(int id, bool *isPresent=nullptr) const =0
Returns the string-value of the named (by its enum-value) attribute.
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue=T(), bool report=true) const
Tries to read given attribute assuming it is an int.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
double getFloat(int id) const
Returns the double-value of the named (by its enum-value) attribute.
Representation of a vehicle, person, or container.
virtual const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
virtual double getSpeed() const =0
Returns the object's current speed.
double locomotiveLength
the length of the locomotive
double speedFactorPremature
the possible speed reduction when a train is ahead of schedule
double getLCParam(const SumoXMLAttr attr, const double defaultValue) const
Returns the named value from the map, or the default if it is not contained there.
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)
SUMOTime started
the time at which this stop was reached
ParkingType parking
whether the vehicle is removed from the net while stopping
SUMOTime extension
The maximum time extension for boarding / loading.
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
double posLat
the lateral offset when stopping
bool onDemand
whether the stop may be skipped
int parametersSet
Information for the output which parameter were set.
std::string join
the id of the vehicle (train portion) to which this vehicle shall be joined
SUMOTime until
The time at which the vehicle may continue its journey.
SUMOTime ended
the time at which this stop was ended
double endPos
The stopping position end.
SUMOTime waitUntil
The earliest pickup time for a taxi stop.
std::string tripId
id of the trip within a cyclical public transport route
bool collision
Whether this stop was triggered by a collision.
SUMOTime arrival
The (expected) time at which the vehicle reaches the stop.
SUMOTime duration
The stopping duration.
Structure representing possible vehicle parameter.
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.
long long int parametersSet
Information for the router which parameter were set, TraCI may modify this (when changing color)
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
bool wasSet(long long int what) const
Returns whether the given parameter was set.
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
double arrivalPos
(optional) The position the vehicle shall arrive on
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
double arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
int arrivalEdge
(optional) The final edge within the route of the vehicle
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
static SUMOTime processActionStepLength(double given)
Checks and converts given value for the action step length from seconds to miliseconds assuring it be...
std::vector< std::string > getVector()
return vector of strings
static OutputDevice & writeParams(OutputDevice &device, const Parameterised ¶ms)
write the parameters of the given object as param tags
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name, cert-dcl58-cpp) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression, cppcoreguidelines-noexcept-swap, performance-noexcept-swap) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
Drive process items represent bounds on the safe velocity corresponding to the upcoming links.
void adaptStopSpeed(const double v)
double getLeaveSpeed() const
void adaptLeaveSpeed(const double v)
double myArrivalSpeedBraking
static std::map< const MSVehicle *, GapControlState * > refVehMap
stores reference vehicles currently in use by a gapController
static GapControlVehStateListener * myVehStateListener
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.