105#define DEBUG_COND (isSelected())
107#define DEBUG_COND2(obj) (obj->isSelected())
112#define STOPPING_PLACE_OFFSET 0.5
114#define CRLL_LOOK_AHEAD 5
116#define JUNCTION_BLOCKAGE_TIME 5
119#define DIST_TO_STOPLINE_EXPECT_PRIORITY 1.0
121#define NUMERICAL_EPS_SPEED (0.1 * NUMERICAL_EPS * TS)
159 return (myPos != state.
myPos ||
169 myPos(pos), mySpeed(speed), myPosLat(posLat), myBackPos(backPos), myPreviousSpeed(previousSpeed), myLastCoveredDist(
SPEED2DIST(speed)) {}
181 assert(memorySpan <= myMemorySize);
182 if (memorySpan == -1) {
183 memorySpan = myMemorySize;
186 for (
const auto& interval : myWaitingIntervals) {
187 if (interval.second >= memorySpan) {
188 if (interval.first >= memorySpan) {
191 totalWaitingTime += memorySpan - interval.first;
194 totalWaitingTime += interval.second - interval.first;
197 return totalWaitingTime;
203 auto i = myWaitingIntervals.begin();
204 const auto end = myWaitingIntervals.end();
205 const bool startNewInterval = i == end || (i->first != 0);
208 if (i->first >= myMemorySize) {
216 auto d = std::distance(i, end);
218 myWaitingIntervals.pop_back();
224 }
else if (!startNewInterval) {
225 myWaitingIntervals.begin()->first = 0;
227 myWaitingIntervals.push_front(std::make_pair(0, dt));
235 std::ostringstream state;
236 state << myMemorySize <<
" " << myWaitingIntervals.size();
237 for (
const auto& interval : myWaitingIntervals) {
238 state <<
" " << interval.first <<
" " << interval.second;
246 std::istringstream is(state);
249 is >> myMemorySize >> numIntervals;
250 while (numIntervals-- > 0) {
252 myWaitingIntervals.emplace_back(begin, end);
271 if (GapControlState::refVehMap.find(msVeh) != end(GapControlState::refVehMap)) {
273 GapControlState::refVehMap[msVeh]->deactivate();
283std::map<const MSVehicle*, MSVehicle::Influencer::GapControlState*>
290 tauOriginal(-1), tauCurrent(-1), tauTarget(-1), addGapCurrent(-1), addGapTarget(-1),
291 remainingDuration(-1), changeRate(-1), maxDecel(-1), referenceVeh(nullptr), active(false), gapAttained(false), prevLeader(nullptr),
292 lastUpdate(-1), timeHeadwayIncrement(0.0), spaceHeadwayIncrement(0.0) {}
306 WRITE_ERROR(
"MSVehicle::Influencer::GapControlState::init(): No MSNet instance found!")
323 tauOriginal = tauOrig;
324 tauCurrent = tauOrig;
327 addGapTarget = additionalGap;
328 remainingDuration = dur;
331 referenceVeh = refVeh;
334 prevLeader =
nullptr;
336 timeHeadwayIncrement = changeRate *
TS * (tauTarget - tauOriginal);
337 spaceHeadwayIncrement = changeRate *
TS * addGapTarget;
339 if (referenceVeh !=
nullptr) {
349 if (referenceVeh !=
nullptr) {
352 referenceVeh =
nullptr;
386 GapControlState::init();
391 GapControlState::cleanup();
396 mySpeedAdaptationStarted =
true;
397 mySpeedTimeLine = speedTimeLine;
402 if (myGapControlState ==
nullptr) {
403 myGapControlState = std::make_shared<GapControlState>();
405 myGapControlState->activate(originalTau, newTimeHeadway, newSpaceHeadway, duration, changeRate, maxDecel, refVeh);
410 if (myGapControlState !=
nullptr && myGapControlState->active) {
411 myGapControlState->deactivate();
417 myLaneTimeLine = laneTimeLine;
423 for (
auto& item : myLaneTimeLine) {
424 item.second += indexShift;
436 return (1 * myConsiderSafeVelocity +
437 2 * myConsiderMaxAcceleration +
438 4 * myConsiderMaxDeceleration +
439 8 * myRespectJunctionPriority +
440 16 * myEmergencyBrakeRedLight +
441 32 * !myRespectJunctionLeaderPriority
448 return (1 * myStrategicLC +
449 4 * myCooperativeLC +
451 64 * myRightDriveLC +
452 256 * myTraciLaneChangePriority +
459 for (std::vector<std::pair<SUMOTime, int>>::iterator i = myLaneTimeLine.begin(); i != myLaneTimeLine.end(); ++i) {
463 duration -= i->first;
471 if (!myLaneTimeLine.empty()) {
472 return myLaneTimeLine.back().first;
482 while (mySpeedTimeLine.size() == 1 || (mySpeedTimeLine.size() > 1 && currentTime > mySpeedTimeLine[1].first)) {
483 mySpeedTimeLine.erase(mySpeedTimeLine.begin());
486 if (!(mySpeedTimeLine.size() < 2 || currentTime < mySpeedTimeLine[0].first)) {
488 if (!mySpeedAdaptationStarted) {
489 mySpeedTimeLine[0].second = speed;
490 mySpeedAdaptationStarted =
true;
493 const double td =
STEPS2TIME(currentTime - mySpeedTimeLine[0].first) /
STEPS2TIME(mySpeedTimeLine[1].first +
DELTA_T - mySpeedTimeLine[0].first);
494 speed = mySpeedTimeLine[0].second - (mySpeedTimeLine[0].second - mySpeedTimeLine[1].second) * td;
495 if (myConsiderSafeVelocity) {
496 speed =
MIN2(speed, vSafe);
498 if (myConsiderMaxAcceleration) {
499 speed =
MIN2(speed, vMax);
501 if (myConsiderMaxDeceleration) {
502 speed =
MAX2(speed, vMin);
512 std::cout << currentTime <<
" Influencer::gapControlSpeed(): speed=" << speed
513 <<
", vSafe=" << vSafe
519 double gapControlSpeed = speed;
520 if (myGapControlState !=
nullptr && myGapControlState->active) {
522 const double currentSpeed = veh->
getSpeed();
524 assert(msVeh !=
nullptr);
525 const double desiredTargetTimeSpacing = myGapControlState->tauTarget * currentSpeed;
526 std::pair<const MSVehicle*, double> leaderInfo;
527 if (myGapControlState->referenceVeh ==
nullptr) {
529 leaderInfo = msVeh->
getLeader(
MAX2(desiredTargetTimeSpacing, myGapControlState->addGapCurrent) + 20.);
532 const MSVehicle* leader = myGapControlState->referenceVeh;
540 if (dist < -100000) {
542 std::cout <<
" Ego and reference vehicle are not in CF relation..." << std::endl;
544 std::cout <<
" Reference vehicle is behind ego..." << std::endl;
551 const double fakeDist =
MAX2(0.0, leaderInfo.second - myGapControlState->addGapCurrent);
554 const double desiredCurrentSpacing = myGapControlState->tauCurrent * currentSpeed;
555 std::cout <<
" Gap control active:"
556 <<
" currentSpeed=" << currentSpeed
557 <<
", desiredTargetTimeSpacing=" << desiredTargetTimeSpacing
558 <<
", desiredCurrentSpacing=" << desiredCurrentSpacing
559 <<
", leader=" << (leaderInfo.first ==
nullptr ?
"NULL" : leaderInfo.first->getID())
560 <<
", dist=" << leaderInfo.second
561 <<
", fakeDist=" << fakeDist
562 <<
",\n tauOriginal=" << myGapControlState->tauOriginal
563 <<
", tauTarget=" << myGapControlState->tauTarget
564 <<
", tauCurrent=" << myGapControlState->tauCurrent
568 if (leaderInfo.first !=
nullptr) {
569 if (myGapControlState->prevLeader !=
nullptr && myGapControlState->prevLeader != leaderInfo.first) {
573 myGapControlState->prevLeader = leaderInfo.first;
579 gapControlSpeed =
MIN2(gapControlSpeed,
580 cfm->
followSpeed(msVeh, currentSpeed, fakeDist, leaderInfo.first->
getSpeed(), leaderInfo.first->getCurrentApparentDecel(), leaderInfo.first));
584 std::cout <<
" -> gapControlSpeed=" << gapControlSpeed;
585 if (myGapControlState->maxDecel > 0) {
586 std::cout <<
", with maxDecel bound: " <<
MAX2(gapControlSpeed, currentSpeed -
TS * myGapControlState->maxDecel);
588 std::cout << std::endl;
591 if (myGapControlState->maxDecel > 0) {
592 gapControlSpeed =
MAX2(gapControlSpeed, currentSpeed -
TS * myGapControlState->maxDecel);
599 if (myGapControlState->lastUpdate < currentTime) {
602 std::cout <<
" Updating GapControlState." << std::endl;
605 if (myGapControlState->tauCurrent == myGapControlState->tauTarget && myGapControlState->addGapCurrent == myGapControlState->addGapTarget) {
606 if (!myGapControlState->gapAttained) {
608 myGapControlState->gapAttained = leaderInfo.first ==
nullptr || leaderInfo.second >
MAX2(desiredTargetTimeSpacing, myGapControlState->addGapTarget) - POSITION_EPS;
611 if (myGapControlState->gapAttained) {
612 std::cout <<
" Target gap was established." << std::endl;
618 myGapControlState->remainingDuration -=
TS;
621 std::cout <<
" Gap control remaining duration: " << myGapControlState->remainingDuration << std::endl;
624 if (myGapControlState->remainingDuration <= 0) {
627 std::cout <<
" Gap control duration expired, deactivating control." << std::endl;
631 myGapControlState->deactivate();
636 myGapControlState->tauCurrent =
MIN2(myGapControlState->tauCurrent + myGapControlState->timeHeadwayIncrement, myGapControlState->tauTarget);
637 myGapControlState->addGapCurrent =
MIN2(myGapControlState->addGapCurrent + myGapControlState->spaceHeadwayIncrement, myGapControlState->addGapTarget);
640 if (myConsiderSafeVelocity) {
641 gapControlSpeed =
MIN2(gapControlSpeed, vSafe);
643 if (myConsiderMaxAcceleration) {
644 gapControlSpeed =
MIN2(gapControlSpeed, vMax);
646 if (myConsiderMaxDeceleration) {
647 gapControlSpeed =
MAX2(gapControlSpeed, vMin);
649 return MIN2(speed, gapControlSpeed);
657 return myOriginalSpeed;
662 myOriginalSpeed = speed;
669 while (myLaneTimeLine.size() == 1 || (myLaneTimeLine.size() > 1 && currentTime > myLaneTimeLine[1].first)) {
670 myLaneTimeLine.erase(myLaneTimeLine.begin());
674 if (myLaneTimeLine.size() >= 2 && currentTime >= myLaneTimeLine[0].first) {
675 const int destinationLaneIndex = myLaneTimeLine[1].second;
676 if (destinationLaneIndex < (
int)currentEdge.
getLanes().size()) {
677 if (currentLaneIndex > destinationLaneIndex) {
679 }
else if (currentLaneIndex < destinationLaneIndex) {
684 }
else if (currentEdge.
getLanes().back()->getOpposite() !=
nullptr) {
693 if ((state &
LCA_TRACI) != 0 && myLatDist != 0) {
702 mode = myStrategicLC;
704 mode = myCooperativeLC;
706 mode = mySpeedGainLC;
708 mode = myRightDriveLC;
718 state &= ~LCA_WANTS_LANECHANGE_OR_STAY;
719 state &= ~LCA_URGENT;
726 state &= ~LCA_WANTS_LANECHANGE_OR_STAY;
727 state &= ~LCA_URGENT;
747 switch (changeRequest) {
763 assert(myLaneTimeLine.size() >= 2);
764 assert(currentTime >= myLaneTimeLine[0].first);
765 return STEPS2TIME(myLaneTimeLine[1].first - currentTime);
771 myConsiderSafeVelocity = ((speedMode & 1) != 0);
772 myConsiderMaxAcceleration = ((speedMode & 2) != 0);
773 myConsiderMaxDeceleration = ((speedMode & 4) != 0);
774 myRespectJunctionPriority = ((speedMode & 8) != 0);
775 myEmergencyBrakeRedLight = ((speedMode & 16) != 0);
776 myRespectJunctionLeaderPriority = ((speedMode & 32) == 0);
793 myRemoteXYPos = xyPos;
796 myRemotePosLat = posLat;
797 myRemoteAngle = angle;
798 myRemoteEdgeOffset = edgeOffset;
799 myRemoteRoute = route;
800 myLastRemoteAccess = t;
812 return myLastRemoteAccess >= t -
TIME2STEPS(10);
818 if (myRemoteRoute.size() != 0 && myRemoteRoute != v->
getRoute().
getEdges()) {
821#ifdef DEBUG_REMOTECONTROL
833 const bool wasOnRoad = v->
isOnRoad();
834 const bool withinLane = myRemoteLane !=
nullptr && fabs(myRemotePosLat) < 0.5 * (myRemoteLane->getWidth() + v->
getVehicleType().
getWidth());
835 const bool keepLane = wasOnRoad && v->
getLane() == myRemoteLane;
836 if (v->
isOnRoad() && !(keepLane && withinLane)) {
837 if (myRemoteLane !=
nullptr && &v->
getLane()->
getEdge() == &myRemoteLane->getEdge()) {
844 if (myRemoteRoute.size() != 0 && myRemoteRoute != v->
getRoute().
getEdges()) {
846#ifdef DEBUG_REMOTECONTROL
847 std::cout <<
SIMSTEP <<
" postProcessRemoteControl veh=" << v->
getID()
851 <<
" newRoute=" <<
toString(myRemoteRoute)
852 <<
" newRouteEdge=" << myRemoteRoute[myRemoteEdgeOffset]->getID()
860 if (myRemoteLane !=
nullptr && myRemotePos > myRemoteLane->getLength()) {
861 myRemotePos = myRemoteLane->getLength();
863 if (myRemoteLane !=
nullptr && withinLane) {
871 myRemoteLane->forceVehicleInsertion(v, myRemotePos, notify, myRemotePosLat);
878 myRemoteLane->requireCollisionCheck();
906 if (myRemoteLane !=
nullptr) {
912 if (distAlongRoute != std::numeric_limits<double>::max()) {
913 dist = distAlongRoute;
917 const double minSpeed = myConsiderMaxDeceleration ?
919 const double maxSpeed = (myRemoteLane !=
nullptr
920 ? myRemoteLane->getVehicleMaxSpeed(veh)
930 if (myRemoteLane ==
nullptr) {
940 if (dist == std::numeric_limits<double>::max()) {
944 WRITE_WARNINGF(
TL(
"Vehicle '%' moved by TraCI from % to % (dist %) with implied speed of % (exceeding maximum speed %). time=%."),
1005 (*i)->resetPartialOccupation(
this);
1021#ifdef DEBUG_ACTIONSTEPS
1023 std::cout <<
SIMTIME <<
" Removing vehicle '" <<
getID() <<
"' (reason: " <<
toString(reason) <<
")" << std::endl;
1048 if (!(*myCurrEdge)->isTazConnector()) {
1050 if ((*myCurrEdge)->getDepartLane(*
this) ==
nullptr) {
1051 msg =
"Invalid departlane definition for vehicle '" +
getID() +
"'.";
1060 if ((*myCurrEdge)->allowedLanes(
getVClass()) ==
nullptr) {
1061 msg =
"Vehicle '" +
getID() +
"' is not allowed to depart on any lane of edge '" + (*myCurrEdge)->getID() +
"'.";
1067 msg =
"Departure speed for vehicle '" +
getID() +
"' is too high for the vehicle type '" +
myType->
getID() +
"'.";
1098 updateBestLanes(
true, onInit ? (*myCurrEdge)->getLanes().front() : 0);
1116 if (!rem->first->notifyMove(*
this, oldPos + rem->second, newPos + rem->second,
MAX2(0., newSpeed))) {
1118 if (myTraceMoveReminders) {
1119 traceMoveReminder(
"notifyMove", rem->first, rem->second,
false);
1125 if (myTraceMoveReminders) {
1126 traceMoveReminder(
"notifyMove", rem->first, rem->second,
true);
1141 if (duration >= 0) {
1156 rem.first->notifyIdle(*
this);
1161 rem->notifyIdle(*
this);
1172 rem.second += oldLaneLength;
1176 if (myTraceMoveReminders) {
1177 traceMoveReminder(
"adaptedPos", rem.first, rem.second,
true);
1191 return getStops().begin()->parkingarea->getVehicleSlope(*
this);
1226 if (
myStops.begin()->parkingarea !=
nullptr) {
1227 return myStops.begin()->parkingarea->getVehiclePosition(*
this);
1237 if (offset == 0. && !changingLanes) {
1255 auto nextBestLane = bestLanes.begin();
1260 bool success =
true;
1262 while (offset > 0) {
1267 lane = lane->
getLinkCont()[0]->getViaLaneOrLane();
1269 if (lane ==
nullptr) {
1279 while (nextBestLane != bestLanes.end() && *nextBestLane ==
nullptr) {
1284 assert(lane == *nextBestLane);
1288 assert(nextBestLane == bestLanes.end() || *nextBestLane != 0);
1289 if (nextBestLane == bestLanes.end()) {
1294 assert(link !=
nullptr);
1325 int furtherIndex = 0;
1334 offset += lastLength;
1344ConstMSEdgeVector::const_iterator
1361 std::cout <<
SIMTIME <<
" veh '" <<
getID() <<
" setAngle(" << angle <<
") straightenFurther=" << straightenFurther << std::endl;
1370 if (link !=
nullptr) {
1385 const bool newActionStepLength = actionStepLengthMillisecs != previousActionStepLength;
1386 if (newActionStepLength) {
1416 if (
myStops.begin()->parkingarea !=
nullptr) {
1417 return myStops.begin()->parkingarea->getVehicleAngle(*
this);
1454 double result = (p1 != p2 ? p2.
angleTo2D(p1) :
1504 if (parkingArea == 0) {
1505 errorMsg =
"new parkingArea is NULL";
1509 errorMsg =
"vehicle has no stops";
1512 if (
myStops.front().parkingarea == 0) {
1513 errorMsg =
"first stop is not at parkingArea";
1519 for (std::list<MSStop>::iterator iter = ++
myStops.begin(); iter !=
myStops.end();) {
1520 if (iter->parkingarea == parkingArea) {
1521 stopPar.
duration += iter->duration;
1548 return nextParkingArea;
1556 currentParkingArea =
myStops.begin()->parkingarea;
1558 return currentParkingArea;
1577 || (
myStops.front().getSpeed() > 0
1589 return myStops.front().duration;
1611 return currentVelocity;
1616 std::cout <<
"\nPROCESS_NEXT_STOP\n" <<
SIMTIME <<
" vehicle '" <<
getID() <<
"'" << std::endl;
1627 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' reached stop.\n"
1653 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' resumes from stopping." << std::endl;
1678 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' registers as waiting for person." << std::endl;
1693 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' registers as waiting for container." << std::endl;
1716 return currentVelocity;
1732 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' hasn't reached next stop." << std::endl;
1742 if (noExits && noEntries) {
1752 bool fitsOnStoppingPlace =
true;
1753 if (stop.
busstop !=
nullptr) {
1763 fitsOnStoppingPlace =
false;
1770 if (
myStops.empty() ||
myStops.front().parkingarea != oldParkingArea) {
1772 return currentVelocity;
1775 fitsOnStoppingPlace =
false;
1777 fitsOnStoppingPlace =
false;
1784 std::cout <<
" pos=" <<
myState.
pos() <<
" speed=" << currentVelocity <<
" targetPos=" << targetPos <<
" fits=" << fitsOnStoppingPlace
1785 <<
" reachedThresh=" << reachedThreshold
1800 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' reached next stop." << std::endl;
1820 if (stop.
busstop !=
nullptr) {
1846 if (splitVeh ==
nullptr) {
1865 return currentVelocity;
1888 bool unregister =
false;
1918 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' unregisters as waiting for transportable." << std::endl;
1933 myStops.begin()->joinTriggered =
false;
1975 myStops.begin()->joinTriggered =
false;
2012 if (timeSinceLastAction == 0) {
2014 timeSinceLastAction = oldActionStepLength;
2016 if (timeSinceLastAction >= newActionStepLength) {
2020 SUMOTime timeUntilNextAction = newActionStepLength - timeSinceLastAction;
2029#ifdef DEBUG_PLAN_MOVE
2035 <<
" veh=" <<
getID()
2050#ifdef DEBUG_ACTIONSTEPS
2052 std::cout <<
STEPS2TIME(t) <<
" vehicle '" <<
getID() <<
"' skips action." << std::endl;
2060#ifdef DEBUG_ACTIONSTEPS
2062 std::cout <<
STEPS2TIME(t) <<
" vehicle = '" <<
getID() <<
"' takes action." << std::endl;
2070#ifdef DEBUG_PLAN_MOVE
2072 DriveItemVector::iterator i;
2075 <<
" vPass=" << (*i).myVLinkPass
2076 <<
" vWait=" << (*i).myVLinkWait
2077 <<
" linkLane=" << ((*i).myLink == 0 ?
"NULL" : (*i).myLink->getViaLaneOrLane()->getID())
2078 <<
" request=" << (*i).mySetRequest
2107 const bool result = (
overlap > POSITION_EPS
2120#ifdef DEBUG_PLAN_MOVE
2135 newStopDist = std::numeric_limits<double>::max();
2143 double lateralShift = 0;
2147 laneMaxV =
MIN2(laneMaxV, l->getVehicleMaxSpeed(
this));
2148#ifdef DEBUG_PLAN_MOVE
2150 std::cout <<
" laneMaxV=" << laneMaxV <<
" lane=" << l->getID() <<
"\n";
2156 laneMaxV =
MAX2(laneMaxV, vMinComfortable);
2158 laneMaxV = std::numeric_limits<double>::max();
2172 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" speedBeforeTraci=" << v;
2178 std::cout <<
" influencedSpeed=" << v;
2184 std::cout <<
" gapControlSpeed=" << v <<
"\n";
2192#ifdef DEBUG_PLAN_MOVE
2194 std::cout <<
" dist=" << dist <<
" bestLaneConts=" <<
toString(bestLaneConts)
2195 <<
"\n maxV=" << maxV <<
" laneMaxV=" << laneMaxV <<
" v=" << v <<
"\n";
2198 assert(bestLaneConts.size() > 0);
2199 bool hadNonInternal =
false;
2202 nextTurn.first = seen;
2203 nextTurn.second =
nullptr;
2205 double seenNonInternal = 0;
2210 bool slowedDownForMinor =
false;
2211 double mustSeeBeforeReversal = 0;
2217#ifdef PARALLEL_STOPWATCH
2223 if (v > vMinComfortable &&
hasStops() &&
myStops.front().pars.arrival >= 0 && sfp > 0
2225 && !
myStops.front().reached) {
2227 v =
MIN2(v, vSlowDown);
2239 const double gapOffset = leaderLane ==
myLane ? 0 : seen - leaderLane->
getLength();
2245 if (cand.first != 0) {
2246 if ((cand.first->myLaneChangeModel->isOpposite() && cand.first->getLaneChangeModel().getShadowLane() != leaderLane)
2247 || (!cand.first->myLaneChangeModel->isOpposite() && cand.first->getLaneChangeModel().getShadowLane() == leaderLane)) {
2249 oppositeLeaders.
addLeader(cand.first, cand.second + gapOffset -
getVehicleType().getMinGap() + cand.first->getVehicleType().
getMinGap() - cand.first->getVehicleType().getLength());
2252 const bool assumeStopped = cand.first->isStopped() || cand.first->getWaitingSeconds() > 1;
2253 const double predMaxDist = cand.first->getSpeed() + (assumeStopped ? 0 : cand.first->getCarFollowModel().getMaxAccel()) * minTimeToLeaveLane;
2254 if (cand.second >= 0 && (cand.second - v * minTimeToLeaveLane - predMaxDist < 0 || assumeStopped)) {
2260#ifdef DEBUG_PLAN_MOVE
2262 std::cout <<
" leaderLane=" << leaderLane->
getID() <<
" gapOffset=" << gapOffset <<
" minTimeToLeaveLane=" << minTimeToLeaveLane
2263 <<
" cands=" << cands.
toString() <<
" oppositeLeaders=" << oppositeLeaders.
toString() <<
"\n";
2271 const bool outsideLeft = leftOL > lane->
getWidth();
2272#ifdef DEBUG_PLAN_MOVE
2274 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" lane=" << lane->
getID() <<
" rightOL=" << rightOL <<
" leftOL=" << leftOL <<
"\n";
2277 if (rightOL < 0 || outsideLeft) {
2281 int sublaneOffset = 0;
2288#ifdef DEBUG_PLAN_MOVE
2290 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" lane=" << lane->
getID() <<
" sublaneOffset=" << sublaneOffset <<
" outsideLeft=" << outsideLeft <<
"\n";
2293 int addedOutsideCands = 0;
2296 && ((!outsideLeft && cand->getLeftSideOnEdge() < 0)
2297 || (outsideLeft && cand->getLeftSideOnEdge() > lane->
getEdge().
getWidth()))) {
2299 addedOutsideCands++;
2300#ifdef DEBUG_PLAN_MOVE
2302 std::cout <<
" outsideLeader=" << cand->getID() <<
" ahead=" << outsideLeaders.
toString() <<
"\n";
2309 adaptToLeaders(outsideLeaders, lateralShift, seen, lastLink, leaderLane, v, vLinkPass);
2313 adaptToLeaders(ahead, lateralShift, seen, lastLink, leaderLane, v, vLinkPass);
2315 if (lastLink !=
nullptr) {
2318#ifdef DEBUG_PLAN_MOVE
2320 std::cout <<
"\nv = " << v <<
"\n";
2328 if (shadowLane !=
nullptr
2342#ifdef DEBUG_PLAN_MOVE
2344 std::cout <<
SIMTIME <<
" opposite veh=" <<
getID() <<
" shadowLane=" << shadowLane->
getID() <<
" latOffset=" << latOffset <<
" shadowLeaders=" << shadowLeaders.
toString() <<
"\n";
2352 adaptToLeaders(shadowLeaders, latOffset, seen - turningDifference, lastLink, shadowLane, v, vLinkPass);
2357 const double latOffset = 0;
2358#ifdef DEBUG_PLAN_MOVE
2360 std::cout <<
SIMTIME <<
" opposite shadows veh=" <<
getID() <<
" shadowLane=" << shadowLane->
getID()
2361 <<
" latOffset=" << latOffset <<
" shadowLeaders=" << shadowLeaders.
toString() <<
"\n";
2365#ifdef DEBUG_PLAN_MOVE
2367 std::cout <<
" shadowLeadersFixed=" << shadowLeaders.
toString() <<
"\n";
2376 const double relativePos = lane->
getLength() - seen;
2377#ifdef DEBUG_PLAN_MOVE
2379 std::cout <<
SIMTIME <<
" adapt to pedestrians on lane=" << lane->
getID() <<
" relPos=" << relativePos <<
"\n";
2385 if (leader.first != 0) {
2387 v =
MIN2(v, stopSpeed);
2388#ifdef DEBUG_PLAN_MOVE
2390 std::cout <<
SIMTIME <<
" pedLeader=" << leader.first->getID() <<
" dist=" << leader.second <<
" v=" << v <<
"\n";
2399 const double relativePos = seen;
2400#ifdef DEBUG_PLAN_MOVE
2402 std::cout <<
SIMTIME <<
" adapt to pedestrians on lane=" << lane->
getID() <<
" relPos=" << relativePos <<
"\n";
2409 if (leader.first != 0) {
2411 v =
MIN2(v, stopSpeed);
2412#ifdef DEBUG_PLAN_MOVE
2414 std::cout <<
SIMTIME <<
" pedLeader=" << leader.first->getID() <<
" dist=" << leader.second <<
" v=" << v <<
"\n";
2424 || (
myStops.begin()->isOpposite &&
myStops.begin()->lane->getEdge().getOppositeEdge() == &lane->
getEdge()))
2430 bool isWaypoint = stop.
getSpeed() > 0;
2431 double endPos = stop.
getEndPos(*
this) + NUMERICAL_EPS;
2436 }
else if (isWaypoint && !stop.
reached) {
2439 newStopDist = seen + endPos - lane->
getLength();
2442 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" newStopDist=" << newStopDist <<
" stopLane=" << stop.
lane->
getID() <<
" stopEndPos=" << endPos <<
"\n";
2446 double stopSpeed = laneMaxV;
2448 bool waypointWithStop =
false;
2461 if (stop.
getUntil() > t + time2end) {
2463 double distToEnd = newStopDist;
2468 waypointWithStop =
true;
2474 newStopDist = std::numeric_limits<double>::max();
2481 if (lastLink !=
nullptr) {
2487 if (lastLink !=
nullptr) {
2491 v =
MIN2(v, stopSpeed);
2493 std::vector<MSLink*>::const_iterator exitLink =
MSLane::succLinkSec(*
this, view + 1, *lane, bestLaneConts);
2495 bool dummySetRequest;
2496 double dummyVLinkWait;
2500#ifdef DEBUG_PLAN_MOVE
2502 std::cout <<
"\n" <<
SIMTIME <<
" next stop: distance = " << newStopDist <<
" requires stopSpeed = " << stopSpeed <<
"\n";
2509 lfLinks.emplace_back(v, newStopDist);
2516 std::vector<MSLink*>::const_iterator link =
MSLane::succLinkSec(*
this, view + 1, *lane, bestLaneConts);
2519 if (!encounteredTurn) {
2527 nextTurn.first = seen;
2528 nextTurn.second = *link;
2529 encounteredTurn =
true;
2530#ifdef DEBUG_NEXT_TURN
2533 <<
" at " << nextTurn.first <<
"m." << std::endl;
2548 const double va =
MAX2(NUMERICAL_EPS, cfModel.
freeSpeed(
this,
getSpeed(), distToArrival, arrivalSpeed));
2550 if (lastLink !=
nullptr) {
2559 || (opposite && (*link)->getViaLaneOrLane()->getParallelOpposite() ==
nullptr
2562 if (lastLink !=
nullptr) {
2570#ifdef DEBUG_PLAN_MOVE
2572 std::cout <<
" braking for link end lane=" << lane->
getID() <<
" seen=" << seen
2578 lfLinks.emplace_back(v, seen);
2582 lateralShift += (*link)->getLateralShift();
2583 const bool yellowOrRed = (*link)->haveRed() || (*link)->haveYellow();
2594 double laneStopOffset;
2600 const bool canBrakeBeforeLaneEnd = seen >= brakeDist;
2604 laneStopOffset = majorStopOffset;
2605 }
else if ((*link)->havePriority()) {
2607 laneStopOffset =
MIN2((*link)->getFoeVisibilityDistance() - POSITION_EPS, majorStopOffset);
2610 laneStopOffset =
MIN2((*link)->getFoeVisibilityDistance() - POSITION_EPS, minorStopOffset);
2612 if (canBrakeBeforeLaneEnd) {
2614 laneStopOffset =
MIN2(laneStopOffset, seen - brakeDist);
2616 laneStopOffset =
MAX2(POSITION_EPS, laneStopOffset);
2617 double stopDist =
MAX2(0., seen - laneStopOffset);
2618 if (newStopDist != std::numeric_limits<double>::max()) {
2619 stopDist =
MAX2(stopDist, newStopDist);
2621#ifdef DEBUG_PLAN_MOVE
2623 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" effective stopOffset on lane '" << lane->
getID()
2624 <<
"' is " << laneStopOffset <<
" (-> stopDist=" << stopDist <<
")" << std::endl;
2634 mustSeeBeforeReversal = 2 * seen +
getLength();
2636 v =
MIN2(v, vMustReverse);
2639 foundRailSignal |= ((*link)->getTLLogic() !=
nullptr
2644 bool canReverseEventually =
false;
2645 const double vReverse =
checkReversal(canReverseEventually, laneMaxV, seen);
2646 v =
MIN2(v, vReverse);
2647#ifdef DEBUG_PLAN_MOVE
2649 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" canReverseEventually=" << canReverseEventually <<
" v=" << v <<
"\n";
2662 assert(timeRemaining != 0);
2665 (seen - POSITION_EPS) / timeRemaining);
2666#ifdef DEBUG_PLAN_MOVE
2668 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" slowing down to finish continuous change before"
2669 <<
" link=" << (*link)->getViaLaneOrLane()->getID()
2670 <<
" timeRemaining=" << timeRemaining
2683 const bool abortRequestAfterMinor = slowedDownForMinor && (*link)->getInternalLaneBefore() ==
nullptr;
2685 bool setRequest = (v >
NUMERICAL_EPS_SPEED && !abortRequestAfterMinor) || (leavingCurrentIntersection);
2687 double stopSpeed = cfModel.
stopSpeed(
this,
getSpeed(), stopDist, stopDecel, MSCFModel::CalcReason::CURRENT_WAIT);
2688 double vLinkWait =
MIN2(v, stopSpeed);
2689#ifdef DEBUG_PLAN_MOVE
2692 <<
" stopDist=" << stopDist
2693 <<
" stopDecel=" << stopDecel
2694 <<
" vLinkWait=" << vLinkWait
2695 <<
" brakeDist=" << brakeDist
2697 <<
" leaveIntersection=" << leavingCurrentIntersection
2698 <<
" setRequest=" << setRequest
2707 if (yellowOrRed && canBrakeBeforeStopLine && !
ignoreRed(*link, canBrakeBeforeStopLine) && seen >= mustSeeBeforeReversal) {
2714 lfLinks.push_back(
DriveProcessItem(*link, v, vLinkWait,
false, arrivalTime, vLinkWait, 0, seen, -1));
2725#ifdef DEBUG_PLAN_MOVE
2727 <<
" ignoreRed spent=" <<
STEPS2TIME(t - (*link)->getLastStateChange())
2728 <<
" redSpeed=" << redSpeed
2737 if (lastLink !=
nullptr) {
2740 double arrivalSpeed = vLinkPass;
2746 const double visibilityDistance = (*link)->getFoeVisibilityDistance();
2747 const double determinedFoePresence = seen <= visibilityDistance;
2752#ifdef DEBUG_PLAN_MOVE
2754 std::cout <<
" approaching link=" << (*link)->getViaLaneOrLane()->getID() <<
" prio=" << (*link)->havePriority() <<
" seen=" << seen <<
" visibilityDistance=" << visibilityDistance <<
" brakeDist=" << brakeDist <<
"\n";
2758 const bool couldBrakeForMinor = !(*link)->havePriority() && brakeDist < seen && !(*link)->lastWasContMajor();
2759 if (couldBrakeForMinor && !determinedFoePresence) {
2764 arrivalSpeed =
MIN2(vLinkPass, maxArrivalSpeed);
2765 slowedDownForMinor =
true;
2766#ifdef DEBUG_PLAN_MOVE
2768 std::cout <<
" slowedDownForMinor maxSpeedAtVisDist=" << maxSpeedAtVisibilityDist <<
" maxArrivalSpeed=" << maxArrivalSpeed <<
" arrivalSpeed=" << arrivalSpeed <<
"\n";
2774 std::pair<const SUMOVehicle*, const MSLink*> blocker = (*link)->getFirstApproachingFoe(*link);
2777 while (blocker.second !=
nullptr && blocker.second != *link && n > 0) {
2778 blocker = blocker.second->getFirstApproachingFoe(*link);
2786 if (blocker.second == *link) {
2794 if (couldBrakeForMinor && (*link)->getLane()->getEdge().isRoundabout()) {
2795 slowedDownForMinor =
true;
2796#ifdef DEBUG_PLAN_MOVE
2798 std::cout <<
" slowedDownForMinor at roundabout\n";
2807 double arrivalSpeedBraking = 0;
2808 const double bGap = cfModel.
brakeGap(v);
2814 arrivalSpeedBraking =
MIN2(arrivalSpeedBraking, arrivalSpeed);
2823 const double estimatedLeaveSpeed =
MIN2((*link)->getViaLaneOrLane()->getVehicleMaxSpeed(
this),
2826 arrivalTime, arrivalSpeed,
2827 arrivalSpeedBraking,
2828 seen, estimatedLeaveSpeed));
2829 if ((*link)->getViaLane() ==
nullptr) {
2830 hadNonInternal =
true;
2833#ifdef DEBUG_PLAN_MOVE
2835 std::cout <<
" checkAbort setRequest=" << setRequest <<
" v=" << v <<
" seen=" << seen <<
" dist=" << dist
2836 <<
" seenNonInternal=" << seenNonInternal
2837 <<
" seenInternal=" << seenInternal <<
" length=" << vehicleLength <<
"\n";
2841 if ((!setRequest || v <= 0 || seen > dist) && hadNonInternal && seenNonInternal >
MAX2(vehicleLength *
CRLL_LOOK_AHEAD, vehicleLength + seenInternal) && foundRailSignal) {
2845 lane = (*link)->getViaLaneOrLane();
2848 laneMaxV = std::numeric_limits<double>::max();
2856#ifdef DEBUG_PLAN_MOVE
2858 std::cout <<
" laneMaxV=" << laneMaxV <<
" freeSpeed=" << va <<
" v=" << v <<
"\n";
2868 if (leaderLane ==
nullptr) {
2875 lastLink = &lfLinks.back();
2884#ifdef PARALLEL_STOPWATCH
2904 const double s = timeDist.second;
2911 const double radicand = 4 * t * t * b * b - 8 * s * b;
2912 const double x = radicand >= 0 ? t * b - sqrt(radicand) * 0.5 : vSlowDownMin;
2913 double vSlowDown = x < vSlowDownMin ? vSlowDownMin : x;
2914#ifdef DEBUG_PLAN_MOVE
2916 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" ad=" << arrivalDelay <<
" t=" << t <<
" vsm=" << vSlowDownMin
2917 <<
" r=" << radicand <<
" vs=" << vSlowDown <<
"\n";
2951 const MSLane*
const lane,
double& v,
double& vLinkPass)
const {
2954 ahead.
getSubLanes(
this, latOffset, rightmost, leftmost);
2955#ifdef DEBUG_PLAN_MOVE
2957 <<
"\nADAPT_TO_LEADERS\nveh=" <<
getID()
2958 <<
" lane=" << lane->
getID()
2959 <<
" latOffset=" << latOffset
2960 <<
" rm=" << rightmost
2961 <<
" lm=" << leftmost
2976 for (
int sublane = rightmost; sublane <= leftmost; ++sublane) {
2978 if (pred !=
nullptr && pred !=
this) {
2981 double gap = (lastLink ==
nullptr
2987 gap = (lastLink ==
nullptr
2992 gap = (lastLink ==
nullptr
3001#ifdef DEBUG_PLAN_MOVE
3003 std::cout <<
" fixedGap=" << gap <<
" predMaxDist=" << predMaxDist <<
"\n";
3015 gap =
MAX2(0.0, gap);
3017#ifdef DEBUG_PLAN_MOVE
3019 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()) <<
"\n";
3022 adaptToLeader(std::make_pair(pred, gap), seen, lastLink, v, vLinkPass);
3031 double& v,
double& vLinkPass)
const {
3034 ahead.
getSubLanes(
this, latOffset, rightmost, leftmost);
3035#ifdef DEBUG_PLAN_MOVE
3037 <<
"\nADAPT_TO_LEADERS_DISTANCE\nveh=" <<
getID()
3038 <<
" latOffset=" << latOffset
3039 <<
" rm=" << rightmost
3040 <<
" lm=" << leftmost
3044 for (
int sublane = rightmost; sublane <= leftmost; ++sublane) {
3047 if (pred !=
nullptr && pred !=
this) {
3048#ifdef DEBUG_PLAN_MOVE
3050 std::cout <<
" pred=" << pred->
getID() <<
" predLane=" << pred->
getLane()->
getID() <<
" predPos=" << pred->
getPositionOnLane() <<
" gap=" << predDist.second <<
"\n";
3063 double& v,
double& vLinkPass)
const {
3064 if (leaderInfo.first != 0) {
3065 assert(leaderInfo.first != 0);
3067 double vsafeLeader = 0;
3069 vsafeLeader = -std::numeric_limits<double>::max();
3071 bool backOnRoute =
true;
3072 if (leaderInfo.second < 0 && lastLink !=
nullptr && lastLink->
myLink !=
nullptr) {
3073 backOnRoute =
false;
3078 if (leaderInfo.first->getBackLane() == current) {
3082 if (lane == current) {
3085 if (leaderInfo.first->getBackLane() == lane) {
3090#ifdef DEBUG_PLAN_MOVE
3092 std::cout <<
SIMTIME <<
" current=" << current->
getID() <<
" leaderBackLane=" << leaderInfo.first->getBackLane()->getID() <<
" backOnRoute=" << backOnRoute <<
"\n";
3096 double stopDist = seen - current->
getLength() - POSITION_EPS;
3105 vsafeLeader = cfModel.
followSpeed(
this,
getSpeed(), leaderInfo.second, leaderInfo.first->getSpeed(), leaderInfo.first->getCurrentApparentDecel(), leaderInfo.first);
3107 if (lastLink !=
nullptr) {
3108 const double futureVSafe = cfModel.
followSpeed(
this, lastLink->
accelV, leaderInfo.second, leaderInfo.first->getSpeed(), leaderInfo.first->getCurrentApparentDecel(), leaderInfo.first, MSCFModel::CalcReason::FUTURE);
3110#ifdef DEBUG_PLAN_MOVE
3112 std::cout <<
" vlinkpass=" << lastLink->
myVLinkPass <<
" futureVSafe=" << futureVSafe <<
"\n";
3116 v =
MIN2(v, vsafeLeader);
3117 vLinkPass =
MIN2(vLinkPass, vsafeLeader);
3118#ifdef DEBUG_PLAN_MOVE
3122 <<
" veh=" <<
getID()
3123 <<
" lead=" << leaderInfo.first->getID()
3124 <<
" leadSpeed=" << leaderInfo.first->getSpeed()
3125 <<
" gap=" << leaderInfo.second
3126 <<
" leadLane=" << leaderInfo.first->getLane()->getID()
3127 <<
" predPos=" << leaderInfo.first->getPositionOnLane()
3130 <<
" vSafeLeader=" << vsafeLeader
3131 <<
" vLinkPass=" << vLinkPass
3141 const MSLane*
const lane,
double& v,
double& vLinkPass,
3142 double distToCrossing)
const {
3143 if (leaderInfo.first != 0) {
3145 double vsafeLeader = 0;
3147 vsafeLeader = -std::numeric_limits<double>::max();
3149 if (leaderInfo.second >= 0) {
3150 vsafeLeader = cfModel.
followSpeed(
this,
getSpeed(), leaderInfo.second, leaderInfo.first->getSpeed(), leaderInfo.first->getCurrentApparentDecel(), leaderInfo.first);
3151 }
else if (leaderInfo.first !=
this) {
3155#ifdef DEBUG_PLAN_MOVE_LEADERINFO
3157 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" stopping before junction: lane=" << lane->
getID() <<
" seen=" << seen
3159 <<
" stopDist=" << seen - lane->
getLength() - POSITION_EPS
3160 <<
" vsafeLeader=" << vsafeLeader
3161 <<
" distToCrossing=" << distToCrossing
3166 if (distToCrossing >= 0) {
3169 if (leaderInfo.first ==
this) {
3171 const double vStopCrossing = cfModel.
stopSpeed(
this,
getSpeed(), distToCrossing);
3172 vsafeLeader = vStopCrossing;
3173#ifdef DEBUG_PLAN_MOVE_LEADERINFO
3175 std::cout <<
" breaking for pedestrian distToCrossing=" << distToCrossing <<
" vStop=" << vStop <<
"\n";
3178 }
else if (leaderInfo.second == -std::numeric_limits<double>::max()) {
3180#ifdef DEBUG_PLAN_MOVE_LEADERINFO
3182 std::cout <<
" stop at crossing point for critical leader\n";
3185 vsafeLeader =
MAX2(vsafeLeader, vStop);
3187 const double leaderDistToCrossing = distToCrossing - leaderInfo.second;
3195 vsafeLeader =
MAX2(vsafeLeader,
MIN2(v2, vStop));
3196#ifdef DEBUG_PLAN_MOVE_LEADERINFO
3198 std::cout <<
" driving up to the crossing point (distToCrossing=" << distToCrossing <<
")"
3199 <<
" leaderPastCPTime=" << leaderPastCPTime
3200 <<
" vFinal=" << vFinal
3202 <<
" vStop=" << vStop
3203 <<
" vsafeLeader=" << vsafeLeader <<
"\n";
3208 if (lastLink !=
nullptr) {
3211 v =
MIN2(v, vsafeLeader);
3212 vLinkPass =
MIN2(vLinkPass, vsafeLeader);
3213#ifdef DEBUG_PLAN_MOVE
3217 <<
" veh=" <<
getID()
3218 <<
" lead=" << leaderInfo.first->getID()
3219 <<
" leadSpeed=" << leaderInfo.first->getSpeed()
3220 <<
" gap=" << leaderInfo.second
3221 <<
" leadLane=" << leaderInfo.first->getLane()->getID()
3222 <<
" predPos=" << leaderInfo.first->getPositionOnLane()
3224 <<
" lane=" << lane->
getID()
3226 <<
" dTC=" << distToCrossing
3228 <<
" vSafeLeader=" << vsafeLeader
3229 <<
" vLinkPass=" << vLinkPass
3238 DriveProcessItem*
const lastLink,
double& v,
double& vLinkPass,
double& vLinkWait,
bool& setRequest)
const {
3241 checkLinkLeader(link, lane, seen, lastLink, v, vLinkPass, vLinkWait, setRequest);
3244 if (parallelLink !=
nullptr) {
3245 checkLinkLeader(parallelLink, lane, seen, lastLink, v, vLinkPass, vLinkWait, setRequest,
true);
3254 DriveProcessItem*
const lastLink,
double& v,
double& vLinkPass,
double& vLinkWait,
bool& setRequest,
3255 bool isShadowLink)
const {
3256#ifdef DEBUG_PLAN_MOVE_LEADERINFO
3262#ifdef DEBUG_PLAN_MOVE_LEADERINFO
3267 for (MSLink::LinkLeaders::const_iterator it = linkLeaders.begin(); it != linkLeaders.end(); ++it) {
3269 const MSVehicle* leader = (*it).vehAndGap.first;
3270 if (leader ==
nullptr) {
3272#ifdef DEBUG_PLAN_MOVE_LEADERINFO
3274 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" is blocked on link to " << link->
getViaLaneOrLane()->
getID() <<
" by pedestrian. dist=" << it->distToCrossing <<
"\n";
3279#ifdef DEBUG_PLAN_MOVE
3281 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" is ignoring pedestrian (jmIgnoreJunctionFoeProb)\n";
3286 adaptToJunctionLeader(std::make_pair(
this, -1), seen, lastLink, lane, v, vLinkPass, it->distToCrossing);
3287 }
else if (
isLeader(link, leader, (*it).vehAndGap.second) || (*it).inTheWay()) {
3290#ifdef DEBUG_PLAN_MOVE
3292 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" is ignoring linkLeader=" << leader->
getID() <<
" (jmIgnoreJunctionFoeProb)\n";
3303 linkLeadersAhead.
addLeader(leader,
false, 0);
3307#ifdef DEBUG_PLAN_MOVE
3311 <<
" isShadowLink=" << isShadowLink
3312 <<
" lane=" << lane->
getID()
3313 <<
" foe=" << leader->
getID()
3315 <<
" latOffset=" << latOffset
3317 <<
" linkLeadersAhead=" << linkLeadersAhead.
toString()
3322#ifdef DEBUG_PLAN_MOVE
3324 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" linkLeader=" << leader->
getID() <<
" gap=" << it->vehAndGap.second
3333 if (lastLink !=
nullptr) {
3347#ifdef DEBUG_PLAN_MOVE_LEADERINFO
3349 std::cout <<
" aborting request\n";
3356#ifdef DEBUG_PLAN_MOVE_LEADERINFO
3358 std::cout <<
" aborting previous request\n";
3364#ifdef DEBUG_PLAN_MOVE_LEADERINFO
3367 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" ignoring leader " << leader->
getID() <<
" gap=" << (*it).vehAndGap.second <<
" dtC=" << (*it).distToCrossing
3377 vLinkWait =
MIN2(vLinkWait, v);
3407 double vSafeZipper = std::numeric_limits<double>::max();
3410 bool canBrakeVSafeMin =
false;
3415 MSLink*
const link = dpi.myLink;
3417#ifdef DEBUG_EXEC_MOVE
3421 <<
" veh=" <<
getID()
3423 <<
" req=" << dpi.mySetRequest
3424 <<
" vP=" << dpi.myVLinkPass
3425 <<
" vW=" << dpi.myVLinkWait
3426 <<
" d=" << dpi.myDistance
3433 if (link !=
nullptr && dpi.mySetRequest) {
3442 const bool ignoreRedLink =
ignoreRed(link, canBrake) || beyondStopLine;
3443 if (yellow && canBrake && !ignoreRedLink) {
3444 vSafe = dpi.myVLinkWait;
3446#ifdef DEBUG_CHECKREWINDLINKLANES
3448 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (yellow)\n";
3455 bool opened = (yellow || influencerPrio
3456 || link->
opened(dpi.myArrivalTime, dpi.myArrivalSpeed, dpi.getLeaveSpeed(),
3462 ignoreRedLink,
this));
3465 if (parallelLink !=
nullptr) {
3468 opened = yellow || influencerPrio || (opened && parallelLink->
opened(dpi.myArrivalTime, dpi.myArrivalSpeed, dpi.getLeaveSpeed(),
3472 ignoreRedLink,
this));
3473#ifdef DEBUG_EXEC_MOVE
3476 <<
" veh=" <<
getID()
3480 <<
" opened=" << opened
3487#ifdef DEBUG_EXEC_MOVE
3490 <<
" opened=" << opened
3491 <<
" influencerPrio=" << influencerPrio
3494 <<
" isCont=" << link->
isCont()
3495 <<
" ignoreRed=" << ignoreRedLink
3501 double determinedFoePresence = dpi.myDistance <= visibilityDistance;
3502 if (!determinedFoePresence && (canBrake || !yellow)) {
3503 vSafe = dpi.myVLinkWait;
3505#ifdef DEBUG_CHECKREWINDLINKLANES
3507 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (minor)\n";
3523 vSafeMinDist = dpi.myDistance;
3529 canBrakeVSafeMin = canBrake;
3530#ifdef DEBUG_EXEC_MOVE
3532 std::cout <<
" vSafeMin=" << vSafeMin <<
" vSafeMinDist=" << vSafeMinDist <<
" canBrake=" << canBrake <<
"\n";
3539 vSafe = dpi.myVLinkPass;
3543#ifdef DEBUG_CHECKREWINDLINKLANES
3545 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (very slow)\n";
3550 vSafeZipper =
MIN2(vSafeZipper,
3551 link->
getZipperSpeed(
this, dpi.myDistance, dpi.myVLinkPass, dpi.myArrivalTime, &collectFoes));
3552 }
else if (!canBrake
3557#ifdef DEBUG_EXEC_MOVE
3559 std::cout <<
SIMTIME <<
" too fast to brake for closed link\n";
3562 vSafe = dpi.myVLinkPass;
3564 vSafe = dpi.myVLinkWait;
3566#ifdef DEBUG_CHECKREWINDLINKLANES
3568 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (closed)\n";
3571#ifdef DEBUG_EXEC_MOVE
3582#ifdef DEBUG_EXEC_MOVE
3584 std::cout <<
SIMTIME <<
" resetting junctionEntryTime at junction '" << link->
getJunction()->
getID() <<
"' beause of non-request exitLink\n";
3591 vSafe = dpi.myVLinkWait;
3594#ifdef DEBUG_CHECKREWINDLINKLANES
3596 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (no request, braking) vSafe=" << vSafe <<
"\n";
3601#ifdef DEBUG_CHECKREWINDLINKLANES
3603 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (no request, stopping)\n";
3638#ifdef DEBUG_EXEC_MOVE
3640 std::cout <<
"vSafeMin Problem? vSafe=" << vSafe <<
" vSafeMin=" << vSafeMin <<
" vSafeMinDist=" << vSafeMinDist << std::endl;
3643 if (canBrakeVSafeMin && vSafe <
getSpeed()) {
3649#ifdef DEBUG_CHECKREWINDLINKLANES
3651 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (vSafe=" << vSafe <<
" < vSafeMin=" << vSafeMin <<
")\n";
3669 vSafe =
MIN2(vSafe, vSafeZipper);
3679 std::cout <<
SIMTIME <<
" MSVehicle::processTraCISpeedControl() for vehicle '" <<
getID() <<
"'"
3680 <<
" vSafe=" << vSafe <<
" (init)vNext=" << vNext;
3689 vMin =
MAX2(0., vMin);
3694 std::cout <<
" (processed)vNext=" << vNext << std::endl;
3704#ifdef DEBUG_ACTIONSTEPS
3706 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" removePassedDriveItems()\n"
3707 <<
" Current items: ";
3709 if (j.myLink == 0) {
3710 std::cout <<
"\n Stop at distance " << j.myDistance;
3712 const MSLane* to = j.myLink->getViaLaneOrLane();
3713 const MSLane* from = j.myLink->getLaneBefore();
3714 std::cout <<
"\n Link at distance " << j.myDistance <<
": '"
3715 << (from == 0 ?
"NONE" : from->
getID()) <<
"' -> '" << (to == 0 ?
"NONE" : to->
getID()) <<
"'";
3718 std::cout <<
"\n myNextDriveItem: ";
3725 std::cout <<
"\n Link at distance " <<
myNextDriveItem->myDistance <<
": '"
3726 << (from == 0 ?
"NONE" : from->
getID()) <<
"' -> '" << (to == 0 ?
"NONE" : to->
getID()) <<
"'";
3729 std::cout << std::endl;
3733#ifdef DEBUG_ACTIONSTEPS
3735 std::cout <<
" Removing item: ";
3736 if (j->myLink == 0) {
3737 std::cout <<
"Stop at distance " << j->myDistance;
3739 const MSLane* to = j->myLink->getViaLaneOrLane();
3740 const MSLane* from = j->myLink->getLaneBefore();
3741 std::cout <<
"Link at distance " << j->myDistance <<
": '"
3742 << (from == 0 ?
"NONE" : from->
getID()) <<
"' -> '" << (to == 0 ?
"NONE" : to->
getID()) <<
"'";
3744 std::cout << std::endl;
3747 if (j->myLink !=
nullptr) {
3748 j->myLink->removeApproaching(
this);
3758#ifdef DEBUG_ACTIONSTEPS
3760 std::cout <<
SIMTIME <<
" updateDriveItems(), veh='" <<
getID() <<
"' (lane: '" <<
getLane()->
getID() <<
"')\nCurrent drive items:" << std::endl;
3763 <<
" vPass=" << dpi.myVLinkPass
3764 <<
" vWait=" << dpi.myVLinkWait
3765 <<
" linkLane=" << (dpi.myLink == 0 ?
"NULL" : dpi.myLink->getViaLaneOrLane()->getID())
3766 <<
" request=" << dpi.mySetRequest
3769 std::cout <<
" myNextDriveItem's linked lane: " << (
myNextDriveItem->myLink == 0 ?
"NULL" :
myNextDriveItem->myLink->getViaLaneOrLane()->getID()) << std::endl;
3776 const MSLink* nextPlannedLink =
nullptr;
3779 while (i !=
myLFLinkLanes.end() && nextPlannedLink ==
nullptr) {
3780 nextPlannedLink = i->myLink;
3784 if (nextPlannedLink ==
nullptr) {
3786#ifdef DEBUG_ACTIONSTEPS
3788 std::cout <<
"Found no link-related drive item." << std::endl;
3796#ifdef DEBUG_ACTIONSTEPS
3798 std::cout <<
"Continuing on planned lane sequence, no update required." << std::endl;
3820#ifdef DEBUG_ACTIONSTEPS
3822 std::cout <<
"Changed lane. Drive items will be updated along the current lane continuation." << std::endl;
3834 MSLink* newLink =
nullptr;
3836 if (driveItemIt->myLink ==
nullptr) {
3846#ifdef DEBUG_ACTIONSTEPS
3848 std::cout <<
"Reached end of the new continuation sequence. Erasing leftover link-items." << std::endl;
3852 if (driveItemIt->myLink ==
nullptr) {
3863 const MSLane*
const target = *bestLaneIt;
3867 if (link->getLane() == target) {
3873 if (newLink == driveItemIt->myLink) {
3875#ifdef DEBUG_ACTIONSTEPS
3877 std::cout <<
"Old and new continuation sequences merge at link\n"
3879 <<
"\nNo update beyond merge required." << std::endl;
3885#ifdef DEBUG_ACTIONSTEPS
3887 std::cout <<
"lane=" << lane->
getID() <<
"\nUpdating link\n '" << driveItemIt->myLink->getLaneBefore()->getID() <<
"'->'" << driveItemIt->myLink->getViaLaneOrLane()->getID() <<
"'"
3891 newLink->
setApproaching(
this, driveItemIt->myLink->getApproaching(
this));
3892 driveItemIt->myLink->removeApproaching(
this);
3893 driveItemIt->myLink = newLink;
3900#ifdef DEBUG_ACTIONSTEPS
3902 std::cout <<
"Updated drive items:" << std::endl;
3905 <<
" vPass=" << dpi.myVLinkPass
3906 <<
" vWait=" << dpi.myVLinkWait
3907 <<
" linkLane=" << (dpi.myLink == 0 ?
"NULL" : dpi.myLink->getViaLaneOrLane()->getID())
3908 <<
" request=" << dpi.mySetRequest
3925 brakelightsOn =
true;
3963#ifdef DEBUG_REVERSE_BIDI
3967 <<
" speedThreshold=" << speedThreshold
3975 <<
" stopOk=" << stopOk
3994 if (remainingRoute < neededFutureRoute) {
3995#ifdef DEBUG_REVERSE_BIDI
4007#ifdef DEBUG_REVERSE_BIDI
4018 const double stopPos =
myStops.front().getEndPos(*
this);
4021 if (newPos > stopPos) {
4022#ifdef DEBUG_REVERSE_BIDI
4027 if (seen >
MAX2(brakeDist, 1.0)) {
4030#ifdef DEBUG_REVERSE_BIDI
4032 std::cout <<
" train is too long, skipping stop at " << stopPos <<
" cannot be avoided\n";
4046 if (!further->getEdge().isInternal()) {
4047 if (further->getEdge().getBidiEdge() != *(
myCurrEdge + view)) {
4048#ifdef DEBUG_REVERSE_BIDI
4050 std::cout <<
" noBidi view=" << view <<
" further=" << further->
getID() <<
" furtherBidi=" <<
Named::getIDSecure(further->getEdge().getBidiEdge()) <<
" future=" << (*(
myCurrEdge + view))->getID() <<
"\n";
4057 if (toNext ==
nullptr) {
4062#ifdef DEBUG_REVERSE_BIDI
4064 std::cout <<
" do not reverse on a red signal\n";
4072 const double stopPos =
myStops.front().getEndPos(*
this);
4074 if (newPos > stopPos) {
4075#ifdef DEBUG_REVERSE_BIDI
4077 std::cout <<
" reversal would go past stop on further-opposite lane " << further->getBidiLane()->getID() <<
"\n";
4080 if (seen >
MAX2(brakeDist, 1.0)) {
4084#ifdef DEBUG_REVERSE_BIDI
4086 std::cout <<
" train is too long, skipping stop at " << stopPos <<
" cannot be avoided\n";
4097#ifdef DEBUG_REVERSE_BIDI
4099 std::cout <<
SIMTIME <<
" seen=" << seen <<
" vReverseOK=" << vMinComfortable <<
"\n";
4103 return vMinComfortable;
4112 passedLanes.push_back(*i);
4114 if (passedLanes.size() == 0 || passedLanes.back() !=
myLane) {
4115 passedLanes.push_back(
myLane);
4118 bool reverseTrain =
false;
4126#ifdef DEBUG_REVERSE_BIDI
4151 if (link !=
nullptr) {
4157 emergencyReason =
" because it must reverse direction";
4158 approachedLane =
nullptr;
4174 if (link->
haveRed() && !
ignoreRed(link,
false) && !beyondStopLine && !reverseTrain) {
4175 emergencyReason =
" because of a red traffic light";
4179 if (reverseTrain && approachedLane->
isInternal()) {
4187 }
else if (reverseTrain) {
4188 approachedLane = (*(
myCurrEdge + 1))->getLanes()[0];
4196 emergencyReason =
" because there is no connection to the next edge";
4197 approachedLane =
nullptr;
4200 if (approachedLane !=
myLane && approachedLane !=
nullptr) {
4220#ifdef DEBUG_PLAN_MOVE_LEADERINFO
4236 WRITE_WARNING(
"Vehicle '" +
getID() +
"' could not finish continuous lane change (turn lane) time=" +
4245 passedLanes.push_back(approachedLane);
4250#ifdef DEBUG_ACTIONSTEPS
4252 std::cout <<
"Updated drive items:" << std::endl;
4255 <<
" vPass=" << (*i).myVLinkPass
4256 <<
" vWait=" << (*i).myVLinkWait
4257 <<
" linkLane=" << ((*i).myLink == 0 ?
"NULL" : (*i).myLink->getViaLaneOrLane()->getID())
4258 <<
" request=" << (*i).mySetRequest
4275#ifdef DEBUG_EXEC_MOVE
4277 std::cout <<
"\nEXECUTE_MOVE\n"
4279 <<
" veh=" <<
getID()
4287 double vSafe = std::numeric_limits<double>::max();
4289 double vSafeMin = -std::numeric_limits<double>::max();
4292 double vSafeMinDist = 0;
4297#ifdef DEBUG_ACTIONSTEPS
4299 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"'\n"
4300 " vsafe from processLinkApproaches(): vsafe " << vSafe << std::endl;
4306#ifdef DEBUG_ACTIONSTEPS
4308 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' skips processLinkApproaches()\n"
4310 <<
"speed: " <<
getSpeed() <<
" -> " << vSafe << std::endl;
4324 double vNext = vSafe;
4343 vNext =
MAX2(vNext, vSafeMin);
4352#ifdef DEBUG_EXEC_MOVE
4354 std::cout <<
SIMTIME <<
" finalizeSpeed vSafe=" << vSafe <<
" vSafeMin=" << (vSafeMin == -std::numeric_limits<double>::max() ?
"-Inf" :
toString(vSafeMin))
4355 <<
" vNext=" << vNext <<
" (i.e. accel=" <<
SPEED2ACCEL(vNext -
getSpeed()) <<
")" << std::endl;
4372 vNext =
MAX2(vNext, 0.);
4382 if (elecHybridOfVehicle !=
nullptr) {
4384 elecHybridOfVehicle->
setConsum(elecHybridOfVehicle->
consumption(*
this, (vNext - this->getSpeed()) /
TS, vNext));
4388 if (elecHybridOfVehicle->
getConsum() /
TS > maxPower) {
4393 vNext =
MAX2(vNext, 0.);
4395 elecHybridOfVehicle->
setConsum(elecHybridOfVehicle->
consumption(*
this, (vNext - this->getSpeed()) /
TS, vNext));
4413 std::vector<MSLane*> passedLanes;
4417 std::string emergencyReason =
TL(
" for unknown reasons");
4425 WRITE_WARNINGF(
TL(
"Vehicle '%' performs emergency stop at the end of lane '%'% (decel=%, offset=%), time=%."),
4436 passedLanes.clear();
4438#ifdef DEBUG_ACTIONSTEPS
4440 std::cout <<
SIMTIME <<
" veh '" <<
getID() <<
"' updates further lanes." << std::endl;
4469#ifdef DEBUG_ACTIONSTEPS
4471 std::cout <<
SIMTIME <<
" veh '" <<
getID() <<
"' skips LCM->prepareStep()." << std::endl;
4479#ifdef DEBUG_EXEC_MOVE
4487 MSLane* newOpposite =
nullptr;
4489 if (newOppositeEdge !=
nullptr) {
4491#ifdef DEBUG_EXEC_MOVE
4493 std::cout <<
SIMTIME <<
" newOppositeEdge=" << newOppositeEdge->
getID() <<
" oldLaneOffset=" << oldLaneOffset <<
" leftMost=" << newOppositeEdge->
getNumLanes() - 1 <<
" newOpposite=" <<
Named::getIDSecure(newOpposite) <<
"\n";
4497 if (newOpposite ==
nullptr) {
4500 WRITE_WARNINGF(
TL(
"Unexpected end of opposite lane for vehicle '%' at lane '%', time=%."),
4507 if (oldOpposite !=
nullptr) {
4520 oldLane = oldLaneMaybeOpposite;
4528 return myLane != oldLane;
4539 for (
int i = 0; i < (int)lanes.size(); i++) {
4541 if (i + 1 < (
int)lanes.size()) {
4542 const MSLane*
const to = lanes[i + 1];
4544 for (
MSLink*
const l : lanes[i]->getLinkCont()) {
4545 if ((internal && l->getViaLane() == to) || (!internal && l->getLane() == to)) {
4554 std::vector<MSLane*> passedLanes;
4556 std::string emergencyReason =
" for unknown reasons";
4557 if (lanes.size() > 1) {
4561#ifdef DEBUG_EXTRAPOLATE_DEPARTPOS
4563 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" executeFractionalMove dist=" << dist
4564 <<
" passedLanes=" <<
toString(passedLanes) <<
" lanes=" <<
toString(lanes)
4572 if (lanes.size() > 1) {
4576 std::cout <<
SIMTIME <<
" leaveLane \n";
4579 (*i)->resetPartialOccupation(
this);
4604#ifdef DEBUG_EXEC_MOVE
4606 std::cout <<
SIMTIME <<
" updateState() for veh '" <<
getID() <<
"': deltaPos=" << deltaPos
4611 if (decelPlus > 0) {
4615 decelPlus += 2 * NUMERICAL_EPS;
4618 WRITE_WARNINGF(
TL(
"Vehicle '%' performs emergency braking on lane '%' with decel=%, wished=%, severity=%, time=%."),
4652 dev->notifyParking();
4677 const std::vector<MSLane*>& passedLanes) {
4678#ifdef DEBUG_SETFURTHER
4680 <<
" updateFurtherLanes oldFurther=" <<
toString(furtherLanes)
4681 <<
" oldFurtherPosLat=" <<
toString(furtherLanesPosLat)
4682 <<
" passed=" <<
toString(passedLanes)
4685 for (std::vector<MSLane*>::iterator i = furtherLanes.begin(); i != furtherLanes.end(); ++i) {
4686 (*i)->resetPartialOccupation(
this);
4689 std::vector<MSLane*> newFurther;
4690 std::vector<double> newFurtherPosLat;
4693 if (passedLanes.size() > 1) {
4695 std::vector<MSLane*>::const_iterator fi = furtherLanes.begin();
4696 std::vector<double>::const_iterator fpi = furtherLanesPosLat.begin();
4697 for (
auto pi = passedLanes.rbegin() + 1; pi != passedLanes.rend() && backPosOnPreviousLane < 0; ++pi) {
4699 newFurther.push_back(*pi);
4700 backPosOnPreviousLane += (*pi)->setPartialOccupation(
this);
4701 if (fi != furtherLanes.end() && *pi == *fi) {
4703 newFurtherPosLat.push_back(*fpi);
4711 if (newFurtherPosLat.size() == 0) {
4718 newFurtherPosLat.push_back(newFurtherPosLat.back());
4721#ifdef DEBUG_SETFURTHER
4723 std::cout <<
SIMTIME <<
" updateFurtherLanes \n"
4724 <<
" further lane '" << (*pi)->getID() <<
"' backPosOnPreviousLane=" << backPosOnPreviousLane
4729 furtherLanes = newFurther;
4730 furtherLanesPosLat = newFurtherPosLat;
4732 furtherLanes.clear();
4733 furtherLanesPosLat.clear();
4735#ifdef DEBUG_SETFURTHER
4737 <<
" newFurther=" <<
toString(furtherLanes)
4738 <<
" newFurtherPosLat=" <<
toString(furtherLanesPosLat)
4739 <<
" newBackPos=" << backPosOnPreviousLane
4742 return backPosOnPreviousLane;
4751 <<
" getBackPositionOnLane veh=" <<
getID()
4753 <<
" cbgP=" << calledByGetPosition
4815 leftLength -= (*i)->getLength();
4826 leftLength -= (*i)->getLength();
4837 auto j = furtherTargetLanes.begin();
4838 while (leftLength > 0 && j != furtherTargetLanes.end()) {
4839 leftLength -= (*i)->getLength();
4870 double seenSpace = -lengthsInFront;
4871#ifdef DEBUG_CHECKREWINDLINKLANES
4873 std::cout <<
"\nCHECK_REWIND_LINKLANES\n" <<
" veh=" <<
getID() <<
" lengthsInFront=" << lengthsInFront <<
"\n";
4876 bool foundStopped =
false;
4879 for (
int i = 0; i < (int)lfLinks.size(); ++i) {
4882#ifdef DEBUG_CHECKREWINDLINKLANES
4885 <<
" foundStopped=" << foundStopped;
4887 if (item.
myLink ==
nullptr || foundStopped) {
4888 if (!foundStopped) {
4893#ifdef DEBUG_CHECKREWINDLINKLANES
4902 if (approachedLane !=
nullptr) {
4905 if (approachedLane ==
myLane) {
4912#ifdef DEBUG_CHECKREWINDLINKLANES
4914 <<
" approached=" << approachedLane->
getID()
4917 <<
" seenSpace=" << seenSpace
4919 <<
" lengthsInFront=" << lengthsInFront
4926 if (last ==
nullptr || last ==
this) {
4929 seenSpace += approachedLane->
getLength();
4932#ifdef DEBUG_CHECKREWINDLINKLANES
4938 bool foundStopped2 =
false;
4940 seenSpace += spaceTillLastStanding;
4941 if (foundStopped2) {
4942 foundStopped =
true;
4947 foundStopped =
true;
4950#ifdef DEBUG_CHECKREWINDLINKLANES
4952 <<
" approached=" << approachedLane->
getID()
4953 <<
" last=" << last->
getID()
4960 <<
" stls=" << spaceTillLastStanding
4962 <<
" seenSpace=" << seenSpace
4963 <<
" foundStopped=" << foundStopped
4964 <<
" foundStopped2=" << foundStopped2
4971 for (
int i = ((
int)lfLinks.size() - 1); i > 0; --i) {
4975 const bool opened = (item.
myLink !=
nullptr
4976 && (canLeaveJunction || (
4987#ifdef DEBUG_CHECKREWINDLINKLANES
4990 <<
" canLeave=" << canLeaveJunction
4991 <<
" opened=" << opened
4992 <<
" allowsContinuation=" << allowsContinuation
4993 <<
" foundStopped=" << foundStopped
4996 if (!opened && item.
myLink !=
nullptr) {
4997 foundStopped =
true;
5001 allowsContinuation =
true;
5005 if (allowsContinuation) {
5007#ifdef DEBUG_CHECKREWINDLINKLANES
5017 int removalBegin = -1;
5018 for (
int i = 0; foundStopped && i < (int)lfLinks.size() && removalBegin < 0; ++i) {
5021 if (item.
myLink ==
nullptr) {
5032#ifdef DEBUG_CHECKREWINDLINKLANES
5035 <<
" veh=" <<
getID()
5038 <<
" leftSpace=" << leftSpace
5041 if (leftSpace < 0/* && item.myLink->willHaveBlockedFoe()*/) {
5042 double impatienceCorrection = 0;
5049 if (leftSpace < -impatienceCorrection / 10. &&
keepClear(item.
myLink)) {
5058 while (removalBegin < (
int)(lfLinks.size())) {
5060 if (dpi.
myLink ==
nullptr) {
5064#ifdef DEBUG_CHECKREWINDLINKLANES
5069 if (dpi.
myDistance >= brakeGap + POSITION_EPS) {
5071 if (!dpi.
myLink->
isExitLink() || !lfLinks[removalBegin - 1].mySetRequest) {
5089 if (dpi.myLink !=
nullptr) {
5093 dpi.myLink->setApproaching(
this, dpi.myArrivalTime, dpi.myArrivalSpeed, dpi.getLeaveSpeed(),
5100 if (dpi.myLink !=
nullptr) {
5106 if (parallelLink !=
nullptr) {
5108 parallelLink->
setApproaching(
this, dpi.myArrivalTime, dpi.myArrivalSpeed, dpi.getLeaveSpeed(),
5109 dpi.mySetRequest, dpi.myArrivalSpeedBraking,
getWaitingTime(), dpi.myDistance,
5116#ifdef DEBUG_PLAN_MOVE
5119 <<
" veh=" <<
getID()
5120 <<
" after checkRewindLinkLanes\n";
5123 <<
" vPass=" << dpi.myVLinkPass
5124 <<
" vWait=" << dpi.myVLinkWait
5125 <<
" linkLane=" << (dpi.myLink == 0 ?
"NULL" : dpi.myLink->getViaLaneOrLane()->getID())
5126 <<
" request=" << dpi.mySetRequest
5127 <<
" atime=" << dpi.myArrivalTime
5150 if (rem->first->getLane() !=
nullptr && rem->second > 0.) {
5152 if (myTraceMoveReminders) {
5153 traceMoveReminder(
"notifyEnter_skipped", rem->first, rem->second,
true);
5158 if (rem->first->notifyEnter(*
this, reason, enteredLane)) {
5160 if (myTraceMoveReminders) {
5161 traceMoveReminder(
"notifyEnter", rem->first, rem->second,
true);
5167 if (myTraceMoveReminders) {
5168 traceMoveReminder(
"notifyEnter", rem->first, rem->second,
false);
5205 if (!onTeleporting) {
5209 assert(oldLane !=
nullptr);
5211 if (link !=
nullptr) {
5254 int deleteFurther = 0;
5255#ifdef DEBUG_SETFURTHER
5265 if (lane !=
nullptr) {
5268#ifdef DEBUG_SETFURTHER
5270 std::cout <<
" enterLaneAtLaneChange i=" << i <<
" lane=" <<
Named::getIDSecure(lane) <<
" leftLength=" << leftLength <<
"\n";
5273 if (leftLength > 0) {
5274 if (lane !=
nullptr) {
5280 leftLength -= (lane)->setPartialOccupation(
this);
5282#ifdef DEBUG_SETFURTHER
5295#ifdef DEBUG_SETFURTHER
5306 if (deleteFurther > 0) {
5307#ifdef DEBUG_SETFURTHER
5309 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" shortening myFurtherLanes by " << deleteFurther <<
"\n";
5315#ifdef DEBUG_SETFURTHER
5330 MSLane* clane = enteredLane;
5332 while (leftLength > 0) {
5336 const MSEdge* fromRouteEdge =
myRoute->getEdges()[routeIndex];
5340 if (ili.lane->getEdge().getNormalBefore() == fromRouteEdge) {
5362#ifdef DEBUG_SETFURTHER
5370#ifdef DEBUG_SETFURTHER
5372 std::cout <<
SIMTIME <<
" opposite: resetPartialOccupation " << (*i)->getID() <<
" \n";
5375 (*i)->resetPartialOccupation(
this);
5426 if (rem->first->notifyLeave(*
this,
myState.
myPos + rem->second, reason, approachedLane)) {
5428 if (myTraceMoveReminders) {
5429 traceMoveReminder(
"notifyLeave", rem->first, rem->second,
true);
5435 if (myTraceMoveReminders) {
5436 traceMoveReminder(
"notifyLeave", rem->first, rem->second,
false);
5454 std::cout <<
SIMTIME <<
" leaveLane \n";
5457 (*i)->resetPartialOccupation(
this);
5467 myStopDist = std::numeric_limits<double>::max();
5474 if (
myStops.front().getSpeed() <= 0) {
5487 if (stop.
busstop !=
nullptr) {
5503 myStopDist = std::numeric_limits<double>::max();
5527const std::vector<MSVehicle::LaneQ>&
5535#ifdef DEBUG_BESTLANES
5540 if (startLane ==
nullptr) {
5543 assert(startLane != 0);
5551 assert(startLane != 0);
5552#ifdef DEBUG_BESTLANES
5554 std::cout <<
" startLaneIsOpposite newStartLane=" << startLane->
getID() <<
"\n";
5565#ifdef DEBUG_BESTLANES
5567 std::cout <<
" only updateOccupancyAndCurrentBestLane\n";
5578#ifdef DEBUG_BESTLANES
5580 std::cout <<
" nothing to do on internal\n";
5590 std::vector<LaneQ>& lanes = *it;
5591 assert(lanes.size() > 0);
5592 if (&(lanes[0].lane->getEdge()) == nextEdge) {
5594 std::vector<LaneQ> oldLanes = lanes;
5596 const std::vector<MSLane*>& sourceLanes = startLane->
getEdge().
getLanes();
5597 for (std::vector<MSLane*>::const_iterator it_source = sourceLanes.begin(); it_source != sourceLanes.end(); ++it_source) {
5598 for (std::vector<LaneQ>::iterator it_lane = oldLanes.begin(); it_lane != oldLanes.end(); ++it_lane) {
5599 if ((*it_source)->getLinkCont()[0]->getLane() == (*it_lane).lane) {
5600 lanes.push_back(*it_lane);
5607 for (
int i = 0; i < (int)lanes.size(); ++i) {
5608 if (i + lanes[i].bestLaneOffset < 0) {
5609 lanes[i].bestLaneOffset = -i;
5611 if (i + lanes[i].bestLaneOffset >= (
int)lanes.size()) {
5612 lanes[i].bestLaneOffset = (int)lanes.size() - i - 1;
5614 assert(i + lanes[i].bestLaneOffset >= 0);
5615 assert(i + lanes[i].bestLaneOffset < (
int)lanes.size());
5616 if (lanes[i].bestContinuations[0] != 0) {
5618 lanes[i].bestContinuations.insert(lanes[i].bestContinuations.begin(), (
MSLane*)
nullptr);
5620 if (startLane->
getLinkCont()[0]->getLane() == lanes[i].lane) {
5623 assert(&(lanes[i].lane->getEdge()) == nextEdge);
5627#ifdef DEBUG_BESTLANES
5629 std::cout <<
" updated for internal\n";
5647 const MSLane* nextStopLane =
nullptr;
5648 double nextStopPos = 0;
5649 bool nextStopIsWaypoint =
false;
5652 nextStopLane = nextStop.
lane;
5657 nextStopEdge = nextStop.
edge;
5659 nextStopIsWaypoint = nextStop.
getSpeed() > 0;
5663 nextStopEdge = (
myRoute->end() - 1);
5667 if (nextStopEdge !=
myRoute->end()) {
5670 nextStopPos =
MAX2(POSITION_EPS,
MIN2((
double)nextStopPos, (
double)(nextStopLane->
getLength() - 2 * POSITION_EPS)));
5673 nextStopPos = (*nextStopEdge)->getLength();
5682 double seenLength = 0;
5683 bool progress =
true;
5687 std::vector<LaneQ> currentLanes;
5688 const std::vector<MSLane*>* allowed =
nullptr;
5689 const MSEdge* nextEdge =
nullptr;
5691 nextEdge = *(ce + 1);
5694 const std::vector<MSLane*>& lanes = (*ce)->getLanes();
5695 for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
5704 q.
allowsContinuation = allowed ==
nullptr || std::find(allowed->begin(), allowed->end(), cl) != allowed->end();
5707 currentLanes.push_back(q);
5710 if (nextStopEdge == ce
5713 if (!nextStopLane->
isInternal() && !continueAfterStop) {
5717 for (std::vector<LaneQ>::iterator q = currentLanes.begin(); q != currentLanes.end(); ++q) {
5718 if (nextStopLane !=
nullptr && normalStopLane != (*q).lane) {
5719 (*q).allowsContinuation =
false;
5720 (*q).length = nextStopPos;
5721 (*q).currentLength = (*q).length;
5728 seenLength += currentLanes[0].lane->getLength();
5730 progress &= (seen <= 4 || seenLength <
MAX2(maxBrakeDist, 3000.0));
5732 progress &= ce !=
myRoute->end();
5742 double bestLength = -1;
5744 int bestThisIndex = 0;
5745 int bestThisMaxIndex = 0;
5748 for (std::vector<LaneQ>::iterator j = last.begin(); j != last.end(); ++j, ++index) {
5749 if ((*j).length > bestLength) {
5750 bestLength = (*j).length;
5751 bestThisIndex = index;
5752 bestThisMaxIndex = index;
5753 }
else if ((*j).length == bestLength) {
5754 bestThisMaxIndex = index;
5758 bool requiredChangeRightForbidden =
false;
5759 int requireChangeToLeftForbidden = -1;
5760 for (std::vector<LaneQ>::iterator j = last.begin(); j != last.end(); ++j, ++index) {
5761 if ((*j).length < bestLength) {
5762 if (abs(bestThisIndex - index) < abs(bestThisMaxIndex - index)) {
5763 (*j).bestLaneOffset = bestThisIndex - index;
5765 (*j).bestLaneOffset = bestThisMaxIndex - index;
5767 if ((*j).bestLaneOffset < 0 && (!(*j).lane->allowsChangingRight(
getVClass())
5768 || !(*j).lane->getParallelLane(-1,
false)->allowsVehicleClass(
getVClass())
5769 || requiredChangeRightForbidden)) {
5771 requiredChangeRightForbidden =
true;
5773 }
else if ((*j).bestLaneOffset > 0 && (!(*j).lane->allowsChangingLeft(
getVClass())
5774 || !(*j).lane->getParallelLane(1,
false)->allowsVehicleClass(
getVClass()))) {
5776 requireChangeToLeftForbidden = (*j).lane->getIndex();
5780 for (
int i = requireChangeToLeftForbidden; i >= 0; i--) {
5783#ifdef DEBUG_BESTLANES
5785 std::cout <<
" last edge=" << last.front().lane->getEdge().getID() <<
" (bestIndex=" << bestThisIndex <<
" bestMaxIndex=" << bestThisMaxIndex <<
"):\n";
5787 for (std::vector<LaneQ>::iterator j = laneQs.begin(); j != laneQs.end(); ++j) {
5788 std::cout <<
" lane=" << (*j).lane->getID() <<
" length=" << (*j).length <<
" bestOffset=" << (*j).bestLaneOffset <<
"\n";
5795 for (std::vector<std::vector<LaneQ> >::reverse_iterator i =
myBestLanes.rbegin() + 1; i !=
myBestLanes.rend(); ++i) {
5796 std::vector<LaneQ>& nextLanes = (*(i - 1));
5797 std::vector<LaneQ>& clanes = (*i);
5798 MSEdge*
const cE = &clanes[0].lane->getEdge();
5800 double bestConnectedLength = -1;
5801 double bestLength = -1;
5802 for (
const LaneQ& j : nextLanes) {
5803 if (j.lane->isApproachedFrom(cE) && bestConnectedLength < j.length) {
5804 bestConnectedLength = j.length;
5806 if (bestLength < j.length) {
5807 bestLength = j.length;
5811 int bestThisIndex = 0;
5812 int bestThisMaxIndex = 0;
5813 if (bestConnectedLength > 0) {
5815 for (
LaneQ& j : clanes) {
5816 const LaneQ* bestConnectedNext =
nullptr;
5817 if (j.allowsContinuation) {
5818 for (
const LaneQ& m : nextLanes) {
5819 if ((m.lane->allowsVehicleClass(
getVClass()) || m.lane->hadPermissionChanges())
5820 && m.lane->isApproachedFrom(cE, j.lane)) {
5821 if (bestConnectedNext ==
nullptr || bestConnectedNext->
length < m.length ||
5822 (bestConnectedNext->
length == m.length && abs(bestConnectedNext->
bestLaneOffset) > abs(m.bestLaneOffset))) {
5823 bestConnectedNext = &m;
5827 if (bestConnectedNext !=
nullptr) {
5828 if (bestConnectedNext->
length == bestConnectedLength && abs(bestConnectedNext->
bestLaneOffset) < 2) {
5831 j.length += bestConnectedNext->
length;
5839 j.allowsContinuation =
false;
5841 if (clanes[bestThisIndex].length < j.length
5842 || (clanes[bestThisIndex].length == j.length && abs(clanes[bestThisIndex].bestLaneOffset) > abs(j.bestLaneOffset))
5843 || (clanes[bestThisIndex].length == j.length && abs(clanes[bestThisIndex].bestLaneOffset) == abs(j.bestLaneOffset) &&
5846 bestThisIndex = index;
5847 bestThisMaxIndex = index;
5848 }
else if (clanes[bestThisIndex].length == j.length
5849 && abs(clanes[bestThisIndex].bestLaneOffset) == abs(j.bestLaneOffset)
5851 bestThisMaxIndex = index;
5859 for (
const LaneQ& j : clanes) {
5861 if (overheadWireSegmentID !=
"") {
5862 bestThisIndex = index;
5863 bestThisMaxIndex = index;
5871 int bestNextIndex = 0;
5872 int bestDistToNeeded = (int) clanes.size();
5874 for (std::vector<LaneQ>::iterator j = clanes.begin(); j != clanes.end(); ++j, ++index) {
5875 if ((*j).allowsContinuation) {
5877 for (std::vector<LaneQ>::const_iterator m = nextLanes.begin(); m != nextLanes.end(); ++m, ++nextIndex) {
5878 if ((*m).lane->isApproachedFrom(cE, (*j).lane)) {
5879 if (bestDistToNeeded > abs((*m).bestLaneOffset)) {
5880 bestDistToNeeded = abs((*m).bestLaneOffset);
5881 bestThisIndex = index;
5882 bestThisMaxIndex = index;
5883 bestNextIndex = nextIndex;
5889 clanes[bestThisIndex].length += nextLanes[bestNextIndex].length;
5890 copy(nextLanes[bestNextIndex].bestContinuations.begin(), nextLanes[bestNextIndex].bestContinuations.end(), back_inserter(clanes[bestThisIndex].bestContinuations));
5895 bool requiredChangeRightForbidden =
false;
5896 int requireChangeToLeftForbidden = -1;
5897 for (std::vector<LaneQ>::iterator j = clanes.begin(); j != clanes.end(); ++j, ++index) {
5898 if ((*j).length < clanes[bestThisIndex].length
5899 || ((*j).length == clanes[bestThisIndex].length && abs((*j).bestLaneOffset) > abs(clanes[bestThisIndex].bestLaneOffset))
5902 if (abs(bestThisIndex - index) < abs(bestThisMaxIndex - index)) {
5903 (*j).bestLaneOffset = bestThisIndex - index;
5905 (*j).bestLaneOffset = bestThisMaxIndex - index;
5909 (*j).length = (*j).currentLength;
5911 if ((*j).bestLaneOffset < 0 && (!(*j).lane->allowsChangingRight(
getVClass())
5912 || !(*j).lane->getParallelLane(-1,
false)->allowsVehicleClass(
getVClass())
5913 || requiredChangeRightForbidden)) {
5915 requiredChangeRightForbidden =
true;
5916 if ((*j).length == (*j).currentLength) {
5919 }
else if ((*j).bestLaneOffset > 0 && (!(*j).lane->allowsChangingLeft(
getVClass())
5920 || !(*j).lane->getParallelLane(1,
false)->allowsVehicleClass(
getVClass()))) {
5922 requireChangeToLeftForbidden = (*j).lane->getIndex();
5925 (*j).bestLaneOffset = 0;
5928 for (
int idx = requireChangeToLeftForbidden; idx >= 0; idx--) {
5929 if (clanes[idx].length == clanes[idx].currentLength) {
5930 clanes[idx].length = 0;
5938 if (overheadWireID !=
"") {
5939 for (std::vector<LaneQ>::iterator j = clanes.begin(); j != clanes.end(); ++j, ++index) {
5940 (*j).bestLaneOffset = bestThisIndex - index;
5945#ifdef DEBUG_BESTLANES
5947 std::cout <<
" edge=" << cE->
getID() <<
" (bestIndex=" << bestThisIndex <<
" bestMaxIndex=" << bestThisMaxIndex <<
"):\n";
5948 std::vector<LaneQ>& laneQs = clanes;
5949 for (std::vector<LaneQ>::iterator j = laneQs.begin(); j != laneQs.end(); ++j) {
5950 std::cout <<
" lane=" << (*j).lane->getID() <<
" length=" << (*j).length <<
" bestOffset=" << (*j).bestLaneOffset <<
" allowCont=" << (*j).allowsContinuation <<
"\n";
5957#ifdef DEBUG_BESTLANES
5968 if (conts.size() < 2) {
5971 const MSLink*
const link = conts[0]->getLinkTo(conts[1]);
5972 if (link !=
nullptr) {
5984 std::vector<LaneQ>& currLanes = *
myBestLanes.begin();
5985 std::vector<LaneQ>::iterator i;
5986 for (i = currLanes.begin(); i != currLanes.end(); ++i) {
5987 double nextOccupation = 0;
5988 for (std::vector<MSLane*>::const_iterator j = (*i).bestContinuations.begin() + 1; j != (*i).bestContinuations.end(); ++j) {
5989 nextOccupation += (*j)->getBruttoVehLenSum();
5991 (*i).nextOccupation = nextOccupation;
5992#ifdef DEBUG_BESTLANES
5994 std::cout <<
" lane=" << (*i).lane->getID() <<
" nextOccupation=" << nextOccupation <<
"\n";
5997 if ((*i).lane == startLane) {
6004const std::vector<MSLane*>&
6009 return (*myCurrentLaneInBestLanes).bestContinuations;
6013const std::vector<MSLane*>&
6025 if ((*i).lane == lane) {
6026 return (*i).bestContinuations;
6032const std::vector<const MSLane*>
6034 std::vector<const MSLane*> lanes;
6036 if (distance <= 0.) {
6047 while (lane->
isInternal() && (distance > 0.)) {
6048 lanes.insert(lanes.end(), lane);
6050 lane = lane->
getLinkCont().front()->getViaLaneOrLane();
6054 if (contLanes.empty()) {
6057 auto contLanesIt = contLanes.begin();
6059 while (distance > 0.) {
6061 if (contLanesIt != contLanes.end()) {
6064 assert(l->
getEdge().
getID() == (*routeIt)->getLanes().front()->getEdge().getID());
6073 }
else if (routeIt !=
myRoute->end()) {
6075 l = (*routeIt)->getLanes().back();
6081 assert(l !=
nullptr);
6085 while ((internalLane !=
nullptr) && internalLane->
isInternal() && (distance > 0.)) {
6086 lanes.insert(lanes.end(), internalLane);
6088 internalLane = internalLane->
getLinkCont().front()->getViaLaneOrLane();
6090 if (distance <= 0.) {
6094 lanes.insert(lanes.end(), l);
6101const std::vector<const MSLane*>
6103 std::vector<const MSLane*> lanes;
6105 if (distance <= 0.) {
6117 while (lane->
isInternal() && (distance > 0.)) {
6118 lanes.insert(lanes.end(), lane);
6123 while (distance > 0.) {
6125 MSLane* l = (*routeIt)->getLanes().back();
6129 const MSLane* internalLane = internalEdge !=
nullptr ? internalEdge->
getLanes().front() :
nullptr;
6130 std::vector<const MSLane*> internalLanes;
6131 while ((internalLane !=
nullptr) && internalLane->
isInternal()) {
6132 internalLanes.insert(internalLanes.begin(), internalLane);
6133 internalLane = internalLane->
getLinkCont().front()->getViaLaneOrLane();
6135 for (
auto it = internalLanes.begin(); (it != internalLanes.end()) && (distance > 0.); ++it) {
6136 lanes.insert(lanes.end(), *it);
6137 distance -= (*it)->getLength();
6139 if (distance <= 0.) {
6143 lanes.insert(lanes.end(), l);
6148 if (routeIt !=
myRoute->begin()) {
6159const std::vector<MSLane*>
6162 std::vector<MSLane*> result;
6163 for (
const MSLane* lane : routeLanes) {
6165 if (opposite !=
nullptr) {
6166 result.push_back(opposite);
6180 return (*myCurrentLaneInBestLanes).bestLaneOffset;
6189 return (*myCurrentLaneInBestLanes).length;
6197 std::vector<MSVehicle::LaneQ>& preb =
myBestLanes.front();
6198 assert(laneIndex < (
int)preb.size());
6199 preb[laneIndex].occupation = density + preb[laneIndex].nextOccupation;
6210std::pair<const MSLane*, double>
6212 if (distance == 0) {
6217 for (
const MSLane* lane : lanes) {
6218 if (lane->getLength() > distance) {
6219 return std::make_pair(lane, distance);
6221 distance -= lane->getLength();
6223 return std::make_pair(
nullptr, -1);
6229 double distance = std::numeric_limits<double>::max();
6230 if (
isOnRoad() && destEdge !=
nullptr) {
6235 distance +=
myRoute->getDistanceBetween(0, destPos, *(
myCurrEdge + 1), destEdge);
6245std::pair<const MSVehicle* const, double>
6248 return std::make_pair(
static_cast<const MSVehicle*
>(
nullptr), -1);
6257 MSLane::VehCont::const_iterator it = std::find(vehs.begin(), vehs.end(),
this);
6258 if (it != vehs.end() && it + 1 != vehs.end()) {
6261 if (lead !=
nullptr) {
6262 std::pair<const MSVehicle* const, double> result(
6275std::pair<const MSVehicle* const, double>
6278 return std::make_pair(
static_cast<const MSVehicle*
>(
nullptr), -1);
6290 std::pair<const MSVehicle* const, double> leaderInfo =
getLeader(-1);
6291 if (leaderInfo.first ==
nullptr ||
getSpeed() == 0) {
6303 if (
myStops.front().triggered &&
myStops.front().numExpectedPerson > 0) {
6304 myStops.front().numExpectedPerson -= (int)
myStops.front().pars.awaitedPersons.count(transportable->
getID());
6307 if (
myStops.front().pars.containerTriggered &&
myStops.front().numExpectedContainer > 0) {
6308 myStops.front().numExpectedContainer -= (int)
myStops.front().pars.awaitedContainers.count(transportable->
getID());
6320 const bool blinkerManoeuvre = (((state &
LCA_SUBLANE) == 0) && (
6328 if ((state &
LCA_LEFT) != 0 && blinkerManoeuvre) {
6330 }
else if ((state &
LCA_RIGHT) != 0 && blinkerManoeuvre) {
6342 switch ((*link)->getDirection()) {
6359 && (
myStops.begin()->reached ||
6362 if (
myStops.begin()->lane->getIndex() > 0 &&
myStops.begin()->lane->getParallelLane(-1)->allowsVehicleClass(
getVClass())) {
6380 if (currentTime % 1000 == 0) {
6470 for (
int i = 0; i < (int)shadowFurther.size(); ++i) {
6472 if (shadowFurther[i] == lane) {
6512 for (
int i = 0; i < (int)shadowFurther.size(); ++i) {
6513 if (shadowFurther[i] == lane) {
6517 <<
" lane=" << lane->
getID()
6531 MSLane* targetLane = furtherTargets[i];
6532 if (targetLane == lane) {
6535#ifdef DEBUG_TARGET_LANE
6537 std::cout <<
" getLatOffset veh=" <<
getID()
6543 <<
" targetDir=" << targetDir
6544 <<
" latOffset=" << latOffset
6561 assert(offset == 0 || offset == 1 || offset == -1);
6562 assert(
myLane !=
nullptr);
6565 const double halfVehWidth = 0.5 * (
getWidth() + NUMERICAL_EPS);
6568 double leftLimit = halfCurrentLaneWidth - halfVehWidth - oppositeSign * latPos;
6569 double rightLimit = -halfCurrentLaneWidth + halfVehWidth - oppositeSign * latPos;
6570 double latLaneDist = 0;
6572 if (latPos + halfVehWidth > halfCurrentLaneWidth) {
6574 latLaneDist = halfCurrentLaneWidth - latPos - halfVehWidth;
6575 }
else if (latPos - halfVehWidth < -halfCurrentLaneWidth) {
6577 latLaneDist = -halfCurrentLaneWidth - latPos + halfVehWidth;
6579 latLaneDist *= oppositeSign;
6580 }
else if (offset == -1) {
6581 latLaneDist = rightLimit - (
getWidth() + NUMERICAL_EPS);
6582 }
else if (offset == 1) {
6583 latLaneDist = leftLimit + (
getWidth() + NUMERICAL_EPS);
6585#ifdef DEBUG_ACTIONSTEPS
6588 <<
" veh=" <<
getID()
6589 <<
" halfCurrentLaneWidth=" << halfCurrentLaneWidth
6590 <<
" halfVehWidth=" << halfVehWidth
6591 <<
" latPos=" << latPos
6592 <<
" latLaneDist=" << latLaneDist
6593 <<
" leftLimit=" << leftLimit
6594 <<
" rightLimit=" << rightLimit
6622 if (dpi.myLink !=
nullptr) {
6623 dpi.myLink->removeApproaching(
this);
6641 std::vector<MSLink*>::const_iterator link =
MSLane::succLinkSec(*
this, view, *lane, bestLaneConts);
6643 while (!lane->
isLinkEnd(link) && seen <= dist) {
6645 && (((*link)->getState() ==
LINKSTATE_ZIPPER && seen < (*link)->getFoeVisibilityDistance())
6646 || !(*link)->havePriority())) {
6650 if ((*di).myLink !=
nullptr) {
6651 const MSLane* diPredLane = (*di).myLink->getLaneBefore();
6652 if (diPredLane !=
nullptr) {
6663 const SUMOTime leaveTime = (*link)->getLeaveTime((*di).myArrivalTime, (*di).myArrivalSpeed,
6665 if ((*link)->hasApproachingFoe((*di).myArrivalTime, leaveTime, (*di).myArrivalSpeed,
getCarFollowModel().getMaxDecel())) {
6672 lane = (*link)->getViaLaneOrLane();
6696 centerLine.push_back(lane->getShape().back());
6736 result.push_back(line1[0]);
6737 result.push_back(line2[0]);
6738 result.push_back(line2[1]);
6739 result.push_back(line1[1]);
6742 result.push_back(line1[1]);
6743 result.push_back(line2[1]);
6744 result.push_back(line2[0]);
6745 result.push_back(line1[0]);
6757 if (&(*i)->getEdge() == edge) {
6774 if (destParkArea ==
nullptr) {
6776 errorMsg =
"Vehicle " +
getID() +
" is not driving to a parking area so it cannot be rerouted.";
6789 if (newParkingArea ==
nullptr) {
6790 errorMsg =
"Parking area ID " +
toString(parkingAreaID) +
" not found in the network.";
6803 if (!newDestination) {
6814 if (edgesFromPark.size() > 0) {
6815 edges.insert(edges.end(), edgesFromPark.begin() + 1, edgesFromPark.end());
6818 if (newDestination) {
6829 const bool onInit =
myLane ==
nullptr;
6842 const int numStops = (int)
myStops.size();
6887 if (stop.
busstop !=
nullptr) {
6912 rem.first->notifyStopEnded();
6923 myStopDist = std::numeric_limits<double>::max();
7022#ifdef DEBUG_IGNORE_RED
7027 if (ignoreRedTime < 0) {
7029 if (ignoreYellowTime > 0 && link->
haveYellow()) {
7033 return !canBrake || ignoreYellowTime > yellowDuration;
7043#ifdef DEBUG_IGNORE_RED
7047 <<
" ignoreRedTime=" << ignoreRedTime
7048 <<
" spentRed=" << redDuration
7049 <<
" canBrake=" << canBrake <<
"\n";
7053 return !canBrake || ignoreRedTime > redDuration;
7079 if (veh ==
nullptr) {
7106 assert(logic !=
nullptr);
7117 const double foeGap = -gap - veh->
getLength();
7118#ifdef DEBUG_PLAN_MOVE_LEADERINFO
7120 std::cout <<
" foeGap=" << foeGap <<
" foeBGap=" << veh->
getBrakeGap(
true) <<
"\n";
7133 response = foeEntry->
haveRed();
7148#ifdef DEBUG_PLAN_MOVE_LEADERINFO
7151 <<
" foeLane=" << foeLane->
getID()
7153 <<
" linkIndex=" << link->
getIndex()
7154 <<
" foeLinkIndex=" << foeLink->
getIndex()
7157 <<
" response=" << response
7158 <<
" response2=" << response2
7166 }
else if (response && response2) {
7172 if (egoET == foeET) {
7176#ifdef DEBUG_PLAN_MOVE_LEADERINFO
7178 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" equal ET " << egoET <<
" with foe " << veh->
getID()
7179 <<
" foeIsLeaderByID=" << (
getID() < veh->
getID()) <<
"\n";
7184#ifdef DEBUG_PLAN_MOVE_LEADERINFO
7186 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" equal ET " << egoET <<
" with foe " << veh->
getID()
7196#ifdef DEBUG_PLAN_MOVE_LEADERINFO
7198 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" egoET " << egoET <<
" with foe " << veh->
getID()
7199 <<
" foeET=" << foeET <<
" isLeader=" << (egoET > foeET) <<
"\n";
7202 return egoET > foeET;
7218 std::vector<std::string> internals;
7237 stop.write(out,
false);
7254 dev->saveState(out);
7262 throw ProcessError(
TL(
"Error: Invalid vehicles in state (may be a meso state)!"));
7281 while (pastStops > 0) {
7302 myStops.front().startedFromState =
true;
7311 SUMOTime arrivalTime,
double arrivalSpeed,
7312 double arrivalSpeedBraking,
7313 double dist,
double leaveSpeed) {
7316 arrivalTime, arrivalSpeed, arrivalSpeedBraking, dist, leaveSpeed));
7321std::shared_ptr<MSSimpleDriverState>
7337 if (prevAcceleration != std::numeric_limits<double>::min()) {
7393 return (myGUIIncrement);
7398 return (myManoeuvreType);
7414 myManoeuvreType = mType;
7429 if (abs(GUIAngle) < 0.1) {
7432 myManoeuvreVehicleID = veh->
getID();
7435 myManoeuvreStartTime = currentTime;
7437 myGUIIncrement = GUIAngle / (
STEPS2TIME(myManoeuvreCompleteTime - myManoeuvreStartTime) /
TS);
7441 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 <<
7442 " endTime=" << myManoeuvreCompleteTime <<
" manoeuvre time=" << myManoeuvreCompleteTime - currentTime <<
" parkArea=" << myManoeuvreStop << std::endl;
7467 if (abs(GUIAngle) < 0.1) {
7471 myManoeuvreVehicleID = veh->
getID();
7474 myManoeuvreStartTime = currentTime;
7476 myGUIIncrement = -GUIAngle / (
STEPS2TIME(myManoeuvreCompleteTime - myManoeuvreStartTime) /
TS);
7483 std::cout <<
"EXIT manoeuvre start: vehicle=" << veh->
getID() <<
" Manoeuvre Angle=" << manoeuverAngle <<
" increment=" <<
RAD2DEG(myGUIIncrement) <<
" currentTime=" << currentTime
7484 <<
" endTime=" << myManoeuvreCompleteTime <<
" manoeuvre time=" << myManoeuvreCompleteTime - currentTime <<
" parkArea=" << myManoeuvreStop << std::endl;
7501 if (configureEntryManoeuvre(veh)) {
7518 if (checkType != myManoeuvreType) {
7539std::pair<double, double>
7543 if (lane ==
nullptr) {
7554 travelTime += (*it)->getMinimumTravelTime(
this);
7555 dist += (*it)->getLength();
7560 dist += stopEdgeDist;
7567 const double d = dist;
7573 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))))
7574 + pow((a * vs), 2))))) * 0.5) + (c * b)) / (b + a));
7578 double timeLossAccel = 0;
7579 double timeLossDecel = 0;
7580 double timeLossLength = 0;
7582 double v =
MIN2(maxVD, (*it)->getVehicleMaxSpeed(
this));
7584 if (edgeLength <= len && v0Stable && v0 < v) {
7585 const double lengthDist =
MIN2(len, edgeLength);
7586 const double dTL = lengthDist / v0 - lengthDist / v;
7588 timeLossLength += dTL;
7590 if (edgeLength > len) {
7591 const double dv = v - v0;
7594 const double dTA = dv / a - dv * (v + v0) / (2 * a * v);
7596 timeLossAccel += dTA;
7598 }
else if (dv < 0) {
7600 const double dTD = -dv / b + dv * (v + v0) / (2 * b * v0);
7602 timeLossDecel += dTD;
7611 const double dv = v - v0;
7614 const double dTA = dv / a - dv * (v + v0) / (2 * a * v);
7616 timeLossAccel += dTA;
7618 }
else if (dv < 0) {
7620 const double dTD = -dv / b + dv * (v + v0) / (2 * b * v0);
7622 timeLossDecel += dTD;
7624 const double result = travelTime + timeLossAccel + timeLossDecel + timeLossLength;
7627 return {
MAX2(0.0, result), dist};
7685 return nextInternal ? nextInternal : nextNormal;
std::vector< const MSEdge * > ConstMSEdgeVector
std::vector< MSEdge * > MSEdgeVector
std::pair< const MSVehicle *, double > CLeaderDist
std::pair< const MSPerson *, double > PersonDist
ConstMSEdgeVector::const_iterator MSRouteIterator
#define NUMERICAL_EPS_SPEED
#define STOPPING_PLACE_OFFSET
#define JUNCTION_BLOCKAGE_TIME
#define DIST_TO_STOPLINE_EXPECT_PRIORITY
#define WRITE_WARNINGF(...)
#define WRITE_WARNING(msg)
std::shared_ptr< const MSRoute > ConstMSRoutePtr
std::string time2string(SUMOTime t)
convert SUMOTime to string
bool isRailway(SVCPermissions permissions)
Returns whether an edge with the given permission is a railway edge.
@ SVC_RAIL_CLASSES
classes which drive on tracks
@ SVC_EMERGENCY
public emergency vehicles
@ 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")
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
@ GIVEN
The lane is given.
@ GIVEN
The speed is given.
@ GIVEN
The arrival lane is given.
@ GIVEN
The speed is given.
const int VEHPARS_FORCE_REROUTE
@ GIVEN
The arrival position is given.
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_IGNORE_KEEPCLEAR_TIME
@ SUMO_ATTR_MAXIMUMPOWER
Maximum Power.
@ SUMO_ATTR_JM_STOPLINE_GAP
@ SUMO_ATTR_JM_DRIVE_AFTER_RED_TIME
@ SUMO_ATTR_JM_DRIVE_AFTER_YELLOW_TIME
@ SUMO_ATTR_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 getDouble(SumoXMLAttr attr) const
void setDouble(SumoXMLAttr attr, double value)
Sets a parameter.
static double naviDegree(const double angle)
static double fromNaviDegree(const double angle)
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
virtual void prepareStep()
void resetChanged()
reset the flag whether a vehicle already moved to false
MSLane * getShadowLane() const
Returns the lane the vehicle's shadow is on during continuous/sublane lane change.
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.
SUMOTime remainingTime() const
Compute the remaining time until LC completion.
void setShadowApproachingInformation(MSLink *link) const
set approach information for the shadow vehicle
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
const std::vector< MSLane * > & getShadowFurtherLanes() const
bool isChangingLanes() const
return true if the vehicle currently performs a lane change maneuver
void removeShadowApproachingInformation() const
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const int rngIndex, SUMOVehicleClass svc) const
The base class for microscopic and mesoscopic vehicles.
double getMaxSpeed() const
Returns the maximum speed (the minimum of desired and technical maximum speed)
MSVehicleDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists, nullptr otherwise.
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)
MSVehicleType * myType
This vehicle's type.
MoveReminderCont myMoveReminders
Currently relevant move reminders.
double myDepartPos
The real depart position.
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
void addReminder(MSMoveReminder *rem)
Adds a MoveReminder dynamically.
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.
MSVehicleType & getSingularType()
Replaces the current vehicle type with a new one used by this vehicle only.
virtual void replaceVehicleType(MSVehicleType *type)
Replaces the current vehicle type by the one given.
double getLength() const
Returns the vehicle's length.
bool isParking() const
Returns whether the vehicle is parking.
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
int getPersonNumber() const
Returns the number of persons.
MSRouteIterator myCurrEdge
Iterator to current route-edge.
bool hasDeparted() const
Returns whether this vehicle has already departed.
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
SUMOTime getDeparture() const
Returns this vehicle's real departure time.
double getWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s)
MSDevice_Transportable * myPersonDevice
The passengers this vehicle may have.
bool hasStops() const
Returns whether the vehicle has to stop somewhere.
@ ROUTE_START_INVALID_LANE
@ ROUTE_START_INVALID_PERMISSIONS
SUMOVehicleClass getVClass() const
Returns the vehicle's access class.
int myArrivalLane
The destination lane where the vehicle stops.
SUMOTime myDeparture
The real departure time.
bool isStoppedTriggered() const
Returns whether the vehicle is on a triggered stop.
std::vector< SUMOVehicleParameter::Stop > myPastStops
The list of stops that the vehicle has already reached.
void onDepart()
Called when the vehicle is inserted into the network.
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
static const SUMOTime NOT_YET_DEPARTED
bool myAmRegisteredAsWaiting
Whether this vehicle is registered as waiting for a person or container (for deadlock-recognition)
EnergyParams * myEnergyParams
The emission parameters this vehicle may have.
const SUMOVehicleParameter * myParameter
This vehicle's parameter.
int myRouteValidity
status of the current vehicle route
virtual 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.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
bool isStopped() const
Returns whether the vehicle is at a stop.
int myNumberReroutes
The number of reroutings.
double myArrivalPos
The position on the destination lane where the vehicle stops.
virtual void saveState(OutputDevice &out)
Saves the (common) state of a vehicle.
double myOdometer
A simple odometer to keep track of the length of the route already driven.
int getContainerNumber() const
Returns the number of containers.
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.
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 maximumSafeStopSpeed(double gap, double decel, double currentSpeed, bool onInsertion=false, double headway=-1) const
Returns the maximum next velocity for stopping within gap.
double getEmergencyDecel() const
Get the vehicle type's maximal phisically 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...
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...
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 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)
double getParameterDouble(const std::string &key) const
void setConsum(const double consumption)
double acceleration(SUMOVehicle &veh, double power, double oldSpeed)
double getConsum() const
Get consum.
A device which collects info on current friction Coefficient on the road.
double getMeasuredFriction()
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 checkCollisionForInactive(MSLane *l)
trigger collision checking for inactive lane
A road/street connecting two junctions.
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 * getBidiEdge() const
return opposite superposable/congruent edge, if it exist and 0 else
bool isNormal() const
return whether this edge is an internal edge
const std::vector< MSLane * > * allowedLanes(const MSEdge &destination, SUMOVehicleClass vclass=SVC_IGNORING) const
Get the allowed lanes to reach the destination-edge.
double getSpeedLimit() const
Returns the speed limit of the edge @caution The speed limit of the first lane is retured; should pro...
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 gLefthand
Whether lefthand-drive is being simulated.
static bool gSublane
whether sublane simulation is enabled (sublane model or continuous lanechanging)
static SUMOTime gLaneChangeDuration
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< MSVehicle *const, double > getFollower(const MSVehicle *ego, double egoPos, double dist, MinorLinkMode mLinkMode) const
Find follower vehicle for the given ego vehicle (which may be on the opposite direction lane)
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...
static std::vector< MSLink * >::const_iterator succLinkSec(const SUMOVehicle &veh, int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane * > &conts)
const MSLink * getLinkTo(const MSLane *const) const
returns the link to the given lane or nullptr, if it is not connected
void forceVehicleInsertion(MSVehicle *veh, double pos, MSMoveReminder::Notification notification, double posLat=0)
Inserts the given vehicle at the given position.
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.
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
const MSLeaderInfo getLastVehicleInformation(const MSVehicle *ego, double latOffset, double minPos=0, bool allowCached=true) const
Returns the last vehicles on the lane.
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 precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
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.
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
std::pair< MSVehicle *const, double > getLeaderOnConsecutive(double dist, double seen, double speed, const MSVehicle &veh, const std::vector< MSLane * > &bestLaneConts) const
Returns the immediate leader and the distance to him.
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
MSLeaderDistanceInfo getFollowersOnConsecutive(const MSVehicle *ego, double backOffset, bool allSublanes, double searchDist=-1, MinorLinkMode mLinkMode=FOLLOW_ALWAYS) const
return the sublane followers with the largest missing rear gap among all predecessor lanes (within di...
double getWidth() const
Returns the lane's width.
const std::vector< MSLink * > & getLinkCont() const
returns the container with all links !!!
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.
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 isConflictEntryLink() const
return whether this link enters the conflict area (not a continuation link)
int getIndex() const
Returns the respond index (for visualization)
std::vector< const SUMOVehicle * > BlockingFoes
bool havePriority() const
Returns whether this link is a major link.
double getZipperSpeed(const MSVehicle *ego, const double dist, double vSafe, SUMOTime arrivalTime, BlockingFoes *collectFoes) const
return the speed at which ego vehicle must approach the zipper link
const LinkLeaders getLeaderInfo(const MSVehicle *ego, double dist, std::vector< const MSPerson * > *collectBlockers=0, bool isShadowLink=false) const
Returns all potential link leaders (vehicles on foeLanes) Valid during the planMove() phase.
bool isEntryLink() const
return whether the toLane of this link is an internal lane and fromLane is a normal lane
const MSLane * getLaneBefore() const
return the internalLaneBefore if it exists and the laneBefore otherwise
bool isInternalJunctionLink() const
return whether the fromLane and the toLane of this link are internal lanes
bool isExitLink() const
return whether the fromLane of this link is an internal lane and toLane is a normal lane
std::vector< LinkLeader > LinkLeaders
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 lane or 0
MSLane * getViaLaneOrLane() const
return the via lane if it exists and the lane otherwise
double getLateralShift() const
return lateral shift that must be applied when passing this link
bool opened(SUMOTime arrivalTime, double arrivalSpeed, double leaveSpeed, double vehicleLength, double impatience, double decel, SUMOTime waitingTime, double posLat=0, BlockingFoes *collectFoes=nullptr, bool ignoreRed=false, const SUMOTrafficObject *ego=nullptr) const
Returns the information whether the link may be passed.
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.
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.
Interface for objects listening to vehicle state changes.
The simulated network and simulation perfomer.
void removeVehicleStateListener(VehicleStateListener *listener)
Removes a vehicle states listener.
VehicleState
Definition of a vehicle state.
@ 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.
A lane area vehicles can halt at.
void leaveFrom(SUMOVehicle *what)
Called if a vehicle leaves this stop.
int getCapacity() const
Returns the area capacity.
void enter(SUMOVehicle *veh)
Called if a vehicle enters this stop.
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
int getOccupancyIncludingBlocked() const
Returns the area occupancy.
double getLastFreePosWithReservation(SUMOTime t, const SUMOVehicle &forVehicle, double brakePos)
Returns the last free position on this stop including reservatiosn 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.
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 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 stopStarted(const SUMOVehicle *veh, int numPersons, int numContainers, SUMOTime time)
void stopEnded(const SUMOVehicle *veh, const SUMOVehicleParameter::Stop &stop, const std::string &laneOrEdgeID, bool simEnd=false)
static MSStopOut * getInstance()
double getBeginLanePosition() const
Returns the begin position of this stop.
bool fits(double pos, const SUMOVehicle &veh) const
return whether the given vehicle fits at the given position
double getEndLanePosition() const
Returns the end position of this stop.
void enter(SUMOVehicle *veh, bool parking)
Called if a vehicle enters this stop.
const MSLane & getLane() const
Returns the lane this stop is located at.
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)
load any applicable transportables Loads any person / container that is waiting on that edge for the ...
bool isPerson() const
Whether it is a person.
A static instance of this class in GapControlState deactivates gap control for vehicles whose referen...
void vehicleStateChanged(const SUMOVehicle *const vehicle, MSNet::VehicleState to, const std::string &info="")
Called if a vehicle changes its state.
Changes the wished vehicle speed / lanes.
void setLaneChangeMode(int value)
Sets lane changing behavior.
TraciLaneChangePriority myTraciLaneChangePriority
flags for determining the priority of traci lane change requests
bool getEmergencyBrakeRedLight() const
Returns whether red lights shall be a reason to brake.
SUMOTime getLaneTimeLineEnd()
void adaptLaneTimeLine(int indexShift)
Adapts lane timeline when moving to a new lane and the lane index changes.
void setRemoteControlled(Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, const ConstMSEdgeVector &route, SUMOTime t)
bool isRemoteAffected(SUMOTime t) const
int getSpeedMode() const
return the current speed mode
void deactivateGapController()
Deactivates the gap control.
void setSpeedMode(int speedMode)
Sets speed-constraining behaviors.
std::shared_ptr< GapControlState > myGapControlState
The gap control state.
bool considerSafeVelocity() const
Returns whether safe velocities shall be considered.
bool myConsiderMaxDeceleration
Whether the maximum deceleration shall be regarded.
void setLaneTimeLine(const std::vector< std::pair< SUMOTime, int > > &laneTimeLine)
Sets a new lane timeline.
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.
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
static 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 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
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 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...
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 replaceParkingArea(MSParkingArea *parkingArea, std::string &errorMsg)
replace the current parking area stop with a new stop with merge duration
void boardTransportables(MSStop &stop)
board persons and load transportables at the given stop
const std::vector< const MSLane * > getUpcomingLanesUntil(double distance) const
Returns the upcoming (best followed by default 0) sequence of lanes to continue the route starting at...
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
void adaptLaneEntering2MoveReminder(const MSLane &enteredLane)
Adapts the vehicle's entering of a new lane.
void addTransportable(MSTransportable *transportable)
Adds a person or container to this vehicle.
MSParkingArea * getNextParkingArea()
get the upcoming parking area stop or nullptr
SUMOTime myJunctionConflictEntryTime
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 with transitions
SUMOTime getWaitingTime() const
Returns the SUMOTime waited (speed was lesser than 0.1m/s)
void workOnMoveReminders(double oldPos, double newPos, double newSpeed)
Processes active move reminder.
bool isStoppedOnLane() const
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
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.
void setPreviousSpeed(double prevSpeed, double prevAcceleration)
Sets the influenced previous speed.
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.
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 wether 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 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)
void planMoveInternal(const SUMOTime t, MSLeaderInfo ahead, DriveItemVector &lfLinks, double &myStopDist, std::pair< double, const MSLink * > &myNextTurn) const
std::pair< double, const MSLink * > myNextTurn
the upcoming turn for the vehicle
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.
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
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.
MSParkingArea * getCurrentParkingArea()
get the current parking area stop or nullptr
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 resetActionOffset(const SUMOTime timeUntilNextAction=0)
Resets the action offset for the vehicle.
std::vector< DriveProcessItem > DriveItemVector
Container for used Links/visited Lanes during planMove() and executeMove.
void setBlinkerInformation()
sets the blue flashing light for emergency vehicles
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
void leaveLane(const MSMoveReminder::Notification reason, const MSLane *approachedLane=0)
Update of members if vehicle leaves a new lane in the lane change step or at arrival.
bool isIdling() const
Returns whether a sim vehicle is waiting to enter a lane (after parking has completed)
std::shared_ptr< MSSimpleDriverState > getDriverState() const
Returns the vehicle driver's state.
void removeApproachingInformation(const DriveItemVector &lfLinks) const
unregister approach from all upcoming links
void replaceVehicleType(MSVehicleType *type)
Replaces the current vehicle type by the one given.
SUMOTime myJunctionEntryTimeNeverYield
double getLatOffset(const MSLane *lane) const
Get the offset that that must be added to interpret myState.myPosLat for the given lane.
bool rerouteParkingArea(const std::string &parkingAreaID, std::string &errorMsg)
bool hasArrived() const
Returns whether this vehicle has already arived (reached the arrivalPosition on its final edge)
void switchOffSignal(int signal)
Switches the given signal off.
void updateState(double vNext)
updates the vehicles state, given a next value for its speed. This value can be negative in case of t...
double getStopArrivalDelay() const
Returns the estimated public transport stop arrival delay in seconds.
int mySignals
State of things of the vehicle that can be on or off.
bool setExitManoeuvre()
accessor function to myManoeuvre equivalent
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
std::pair< const MSVehicle *const, double > getLeader(double dist=0) const
Returns the leader of the vehicle looking for a fixed distance.
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.
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 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()
double getRightSideOnLane() const
Get the lateral position of the vehicles right side on the lane:
bool unsafeLinkAhead(const MSLane *lane) const
whether the vehicle may safely move to the given lane with regard to upcoming links
double getCurrentApparentDecel() const
get apparent deceleration based on vType parameters and current acceleration
double updateFurtherLanes(std::vector< MSLane * > &furtherLanes, std::vector< double > &furtherLanesPosLat, const std::vector< MSLane * > &passedLanes)
update a vector of further lanes and return the new backPos
DriveItemVector myLFLinkLanesPrev
planned speeds from the previous step for un-registering from junctions after the new container is fi...
std::vector< std::vector< LaneQ > > myBestLanes
void setActionStepLength(double actionStepLength, bool resetActionOffset=true)
Sets the action steplength of the vehicle.
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
double getSlope() const
Returns the slope of the road at vehicle's position in degrees.
bool myActionStep
The flag myActionStep indicates whether the current time step is an action point for the vehicle.
const Position getBackPosition() const
void loadState(const SUMOSAXAttributes &attrs, const SUMOTime offset)
Loads the state of this vehicle from the given description.
SUMOTime myTimeSinceStartup
duration of driving (speed > SUMO_const_haltingSpeed) after the last halting eposide
double getSpeed() const
Returns the vehicle's current speed.
void setApproachingForAllLinks(const SUMOTime t)
Register junction approaches for all link items in the current plan.
SUMOTime remainingStopDuration() const
Returns the remaining stop duration for a stopped vehicle or 0.
bool keepStopping(bool afterProcessing=false) const
Returns whether the vehicle is stopped and must continue to do so.
void workOnIdleReminders()
cycle through vehicle devices invoking notifyIdle
static std::vector< MSLane * > myEmptyLaneVector
Position myCachedPosition
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 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 ignore
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)
void executeFractionalMove(double dist)
move vehicle forward by the given distance during insertion
LaneChangeMode
modes for resolving conflicts between external control (traci) and vehicle control over lane changing...
virtual void drawOutsideNetwork(bool)
register vehicle for drawing while outside the network
State myState
This Vehicles driving state (pos and speed)
double getCenterOnEdge(const MSLane *lane=0) const
Get the vehicle's lateral position on the edge of the given lane (or its current edge if lane == 0)
void adaptToLeader(const std::pair< const MSVehicle *, double > leaderInfo, double seen, DriveProcessItem *const lastLink, double &v, double &vLinkPass) const
void activateReminders(const MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
"Activates" all current move reminder
double getDistanceToPosition(double destPos, const MSEdge *destEdge) const
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 SumoXMLAttr attr, const T &val)
writes a named attribute
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
A point in 2D or 3D with translation and scaling methods.
double slopeTo2D(const Position &other) const
returns the slope of the vector pointing from here to the other position
static const Position INVALID
used to indicate that a position is valid
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position
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 ammount
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)
double recomputeCosts(const std::vector< const E * > &edges, const V *const v, SUMOTime msTime, double *lengthp=nullptr) const
virtual bool compute(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E * > &into, bool silent=false)=0
Builds the route between the given edges using the minimum effort at the given time The definition of...
Encapsulated SAX-Attributes.
virtual std::string getString(int id, bool *isPresent=nullptr) const =0
Returns the string-value of the named (by its enum-value) attribute.
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.
virtual double getSpeed() const =0
Returns the object's current speed.
double speedFactorPremature
the possible speed reduction when a train is ahead of schedule
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
std::string lane
The lane to stop at.
SUMOTime extension
The maximum time extension for boarding / loading.
std::string parkingarea
(Optional) parking area if one is assigned to the stop
std::string split
the id of the vehicle (train portion) that splits of upon reaching this stop
double startPos
The stopping position start.
std::string line
the new line id of the trip within a cyclical public transport route
double posLat
the lateral offset when stopping
bool onDemand
whether the stop may be skipped
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.
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 parametersSet
Information for the router which parameter were set, TraCI may modify this (when changing color)
int departLane
(optional) The lane the vehicle shall depart from (index in edge)
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle's end speed shall be chosen.
double departSpeed
(optional) The initial speed of the vehicle
std::vector< std::string > via
List of the via-edges the vehicle must visit.
ArrivalLaneDefinition arrivalLaneProcedure
Information how the vehicle shall choose the lane to arrive on.
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
double arrivalPos
(optional) The position the vehicle shall arrive on
bool wasSet(int what) const
Returns whether the given parameter was set.
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
double arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
int arrivalEdge
(optional) The final edge within the route of the vehicle
static SUMOTime processActionStepLength(double given)
Checks and converts given value for the action step length from seconds to miliseconds assuring it be...
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) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression) 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.
double getLeaveSpeed() const
void adaptLeaveSpeed(const double v)
static std::map< const MSVehicle *, GapControlState * > refVehMap
stores reference vehicles currently in use by a gapController
static GapControlVehStateListener vehStateListener
void activate(double tauOriginal, double tauTarget, double additionalGap, double duration, double changeRate, double maxDecel, const MSVehicle *refVeh)
Start gap control with given params.
static void cleanup()
Static cleanup (removes vehicle state listener)
virtual ~GapControlState()
void deactivate()
Stop gap control.
static void init()
Static initalization (adds vehicle state listener)
A structure representing the best lanes for continuing the current route starting at 'lane'.
double length
The overall length which may be driven when using this lane without a lane change.
bool allowsContinuation
Whether this lane allows to continue the drive.
double nextOccupation
As occupation, but without the first lane.
std::vector< MSLane * > bestContinuations
MSLane * lane
The described lane.
double currentLength
The length which may be driven on this lane.
int bestLaneOffset
The (signed) number of lanes to be crossed to get to the lane which allows to continue the drive.
double occupation
The overall vehicle sum on consecutive lanes which can be passed without a lane change.