 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
105 #define DEBUG_COND (isSelected())
107 #define DEBUG_COND2(obj) (obj->isSelected())
110 #define STOPPING_PLACE_OFFSET 0.5
112 #define CRLL_LOOK_AHEAD 5
114 #define JUNCTION_BLOCKAGE_TIME 5 // s
117 #define DIST_TO_STOPLINE_EXPECT_PRIORITY 1.0
119 #define NUMERICAL_EPS_SPEED (0.1 * NUMERICAL_EPS * TS)
157 return (myPos != state.
myPos ||
167 myPos(pos), mySpeed(speed), myPosLat(posLat), myBackPos(backPos), myPreviousSpeed(speed), myLastCoveredDist(
SPEED2DIST(speed)) {}
188 myWaitingIntervals.clear();
195 assert(memorySpan <= myMemorySize);
196 if (memorySpan == -1) {
197 memorySpan = myMemorySize;
200 for (waitingIntervalList::const_iterator i = myWaitingIntervals.begin(); i != myWaitingIntervals.end(); i++) {
201 if (i->second >= memorySpan) {
202 if (i->first >= memorySpan) {
205 totalWaitingTime += memorySpan - i->first;
208 totalWaitingTime += i->second - i->first;
211 return totalWaitingTime;
216 waitingIntervalList::iterator i = myWaitingIntervals.begin();
217 waitingIntervalList::iterator end = myWaitingIntervals.end();
218 bool startNewInterval = i == end || (i->first != 0);
221 if (i->first >= myMemorySize) {
229 waitingIntervalList::iterator::difference_type d = std::distance(i, end);
231 myWaitingIntervals.pop_back();
237 }
else if (!startNewInterval) {
238 myWaitingIntervals.begin()->first = 0;
240 myWaitingIntervals.push_front(std::make_pair(0, dt));
260 const MSVehicle* msVeh = static_cast<const MSVehicle*>(vehicle);
262 if (GapControlState::refVehMap.find(msVeh) != end(GapControlState::refVehMap)) {
264 GapControlState::refVehMap[msVeh]->deactivate();
274 std::map<const MSVehicle*, MSVehicle::Influencer::GapControlState*>
281 tauOriginal(-1), tauCurrent(-1), tauTarget(-1), addGapCurrent(-1), addGapTarget(-1),
282 remainingDuration(-1), changeRate(-1), maxDecel(-1), referenceVeh(nullptr), active(false), gapAttained(false), prevLeader(nullptr),
283 lastUpdate(-1), timeHeadwayIncrement(0.0), spaceHeadwayIncrement(0.0) {}
297 WRITE_ERROR(
"MSVehicle::Influencer::GapControlState::init(): No MSNet instance found!")
314 tauOriginal = tauOrig;
315 tauCurrent = tauOrig;
318 addGapTarget = additionalGap;
319 remainingDuration = dur;
322 referenceVeh = refVeh;
325 prevLeader =
nullptr;
327 timeHeadwayIncrement = changeRate *
TS * (tauTarget - tauOriginal);
328 spaceHeadwayIncrement = changeRate *
TS * addGapTarget;
330 if (referenceVeh !=
nullptr) {
340 if (referenceVeh !=
nullptr) {
343 referenceVeh =
nullptr;
377 GapControlState::init();
382 GapControlState::cleanup();
387 mySpeedAdaptationStarted =
true;
388 mySpeedTimeLine = speedTimeLine;
393 if (myGapControlState ==
nullptr) {
394 myGapControlState = std::make_shared<GapControlState>();
396 myGapControlState->activate(originalTau, newTimeHeadway, newSpaceHeadway, duration, changeRate, maxDecel, refVeh);
401 if (myGapControlState !=
nullptr && myGapControlState->active) {
402 myGapControlState->deactivate();
408 myLaneTimeLine = laneTimeLine;
414 for (
auto& item : myLaneTimeLine) {
415 item.second += indexShift;
427 return (1 * myConsiderSafeVelocity +
428 2 * myConsiderMaxAcceleration +
429 4 * myConsiderMaxDeceleration +
430 8 * myRespectJunctionPriority +
431 16 * myEmergencyBrakeRedLight);
437 return (1 * myStrategicLC +
438 4 * myCooperativeLC +
440 64 * myRightDriveLC +
441 256 * myTraciLaneChangePriority +
448 for (std::vector<std::pair<SUMOTime, int>>::iterator i = myLaneTimeLine.begin(); i != myLaneTimeLine.end(); ++i) {
452 duration -= i->first;
460 if (!myLaneTimeLine.empty()) {
461 return myLaneTimeLine.back().first;
471 myOriginalSpeed = speed;
474 while (mySpeedTimeLine.size() == 1 || (mySpeedTimeLine.size() > 1 && currentTime > mySpeedTimeLine[1].first)) {
475 mySpeedTimeLine.erase(mySpeedTimeLine.begin());
478 if (!(mySpeedTimeLine.size() < 2 || currentTime < mySpeedTimeLine[0].first)) {
480 if (!mySpeedAdaptationStarted) {
481 mySpeedTimeLine[0].second = speed;
482 mySpeedAdaptationStarted =
true;
485 const double td =
STEPS2TIME(currentTime - mySpeedTimeLine[0].first) /
STEPS2TIME(mySpeedTimeLine[1].first +
DELTA_T - mySpeedTimeLine[0].first);
486 speed = mySpeedTimeLine[0].second - (mySpeedTimeLine[0].second - mySpeedTimeLine[1].second) * td;
487 if (myConsiderSafeVelocity) {
488 speed =
MIN2(speed, vSafe);
490 if (myConsiderMaxAcceleration) {
491 speed =
MIN2(speed, vMax);
493 if (myConsiderMaxDeceleration) {
494 speed =
MAX2(speed, vMin);
504 std::cout << currentTime <<
" Influencer::gapControlSpeed(): speed=" << speed
505 <<
", vSafe=" << vSafe
511 double gapControlSpeed = speed;
512 if (myGapControlState !=
nullptr && myGapControlState->active) {
514 const double currentSpeed = veh->
getSpeed();
515 const MSVehicle* msVeh = dynamic_cast<const MSVehicle*>(veh);
516 assert(msVeh !=
nullptr);
517 const double desiredTargetTimeSpacing = myGapControlState->tauTarget * currentSpeed;
518 std::pair<const MSVehicle*, double> leaderInfo;
519 if (myGapControlState->referenceVeh ==
nullptr) {
521 leaderInfo = msVeh->
getLeader(
MAX2(desiredTargetTimeSpacing, myGapControlState->addGapCurrent) + 20.);
524 const MSVehicle* leader = myGapControlState->referenceVeh;
532 if (dist < -100000) {
534 std::cout <<
" Ego and reference vehicle are not in CF relation..." << std::endl;
536 std::cout <<
" Reference vehicle is behind ego..." << std::endl;
543 const double fakeDist =
MAX2(0.0, leaderInfo.second - myGapControlState->addGapCurrent);
546 const double desiredCurrentSpacing = myGapControlState->tauCurrent * currentSpeed;
547 std::cout <<
" Gap control active:"
548 <<
" currentSpeed=" << currentSpeed
549 <<
", desiredTargetTimeSpacing=" << desiredTargetTimeSpacing
550 <<
", desiredCurrentSpacing=" << desiredCurrentSpacing
551 <<
", leader=" << (leaderInfo.first ==
nullptr ?
"NULL" : leaderInfo.first->getID())
552 <<
", dist=" << leaderInfo.second
553 <<
", fakeDist=" << fakeDist
554 <<
",\n tauOriginal=" << myGapControlState->tauOriginal
555 <<
", tauTarget=" << myGapControlState->tauTarget
556 <<
", tauCurrent=" << myGapControlState->tauCurrent
560 if (leaderInfo.first !=
nullptr) {
561 if (myGapControlState->prevLeader !=
nullptr && myGapControlState->prevLeader != leaderInfo.first) {
565 myGapControlState->prevLeader = leaderInfo.first;
571 gapControlSpeed =
MIN2(gapControlSpeed,
572 cfm->
followSpeed(msVeh, currentSpeed, fakeDist, leaderInfo.first->
getSpeed(), leaderInfo.first->getCurrentApparentDecel(), leaderInfo.first));
576 std::cout <<
" -> gapControlSpeed=" << gapControlSpeed;
577 if (myGapControlState->maxDecel > 0) {
578 std::cout <<
", with maxDecel bound: " <<
MAX2(gapControlSpeed, currentSpeed -
TS * myGapControlState->maxDecel);
580 std::cout << std::endl;
583 if (myGapControlState->maxDecel > 0) {
584 gapControlSpeed =
MAX2(gapControlSpeed, currentSpeed -
TS * myGapControlState->maxDecel);
591 if (myGapControlState->lastUpdate < currentTime) {
594 std::cout <<
" Updating GapControlState." << std::endl;
597 if (myGapControlState->tauCurrent == myGapControlState->tauTarget && myGapControlState->addGapCurrent == myGapControlState->addGapTarget) {
598 if (!myGapControlState->gapAttained) {
600 myGapControlState->gapAttained = leaderInfo.first ==
nullptr || leaderInfo.second >
MAX2(desiredTargetTimeSpacing, myGapControlState->addGapTarget) -
POSITION_EPS;
603 if (myGapControlState->gapAttained) {
604 std::cout <<
" Target gap was established." << std::endl;
610 myGapControlState->remainingDuration -=
TS;
613 std::cout <<
" Gap control remaining duration: " << myGapControlState->remainingDuration << std::endl;
616 if (myGapControlState->remainingDuration <= 0) {
619 std::cout <<
" Gap control duration expired, deactivating control." << std::endl;
623 myGapControlState->deactivate();
628 myGapControlState->tauCurrent =
MIN2(myGapControlState->tauCurrent + myGapControlState->timeHeadwayIncrement, myGapControlState->tauTarget);
629 myGapControlState->addGapCurrent =
MIN2(myGapControlState->addGapCurrent + myGapControlState->spaceHeadwayIncrement, myGapControlState->addGapTarget);
632 if (myConsiderSafeVelocity) {
633 gapControlSpeed =
MIN2(gapControlSpeed, vSafe);
635 if (myConsiderMaxAcceleration) {
636 gapControlSpeed =
MIN2(gapControlSpeed, vMax);
638 if (myConsiderMaxDeceleration) {
639 gapControlSpeed =
MAX2(gapControlSpeed, vMin);
641 return MIN2(speed, gapControlSpeed);
649 return mySpeedTimeLine.empty() ? -1 : myOriginalSpeed;
656 while (myLaneTimeLine.size() == 1 || (myLaneTimeLine.size() > 1 && currentTime > myLaneTimeLine[1].first)) {
657 myLaneTimeLine.erase(myLaneTimeLine.begin());
661 if (myLaneTimeLine.size() >= 2 && currentTime >= myLaneTimeLine[0].first) {
662 const int destinationLaneIndex = myLaneTimeLine[1].second;
663 if (destinationLaneIndex < (
int)currentEdge.
getLanes().size()) {
664 if (currentLaneIndex > destinationLaneIndex) {
666 }
else if (currentLaneIndex < destinationLaneIndex) {
671 }
else if (currentEdge.
getLanes().back()->getOpposite() !=
nullptr) {
680 if ((state &
LCA_TRACI) != 0 && myLatDist != 0) {
689 mode = myStrategicLC;
691 mode = myCooperativeLC;
693 mode = mySpeedGainLC;
695 mode = myRightDriveLC;
734 switch (changeRequest) {
750 assert(myLaneTimeLine.size() >= 2);
751 assert(currentTime >= myLaneTimeLine[0].first);
752 return STEPS2TIME(myLaneTimeLine[1].first - currentTime);
758 myConsiderSafeVelocity = ((speedMode & 1) != 0);
759 myConsiderMaxAcceleration = ((speedMode & 2) != 0);
760 myConsiderMaxDeceleration = ((speedMode & 4) != 0);
761 myRespectJunctionPriority = ((speedMode & 8) != 0);
762 myEmergencyBrakeRedLight = ((speedMode & 16) != 0);
779 myRemoteXYPos = xyPos;
782 myRemotePosLat = posLat;
783 myRemoteAngle = angle;
784 myRemoteEdgeOffset = edgeOffset;
785 myRemoteRoute = route;
786 myLastRemoteAccess = t;
798 return myLastRemoteAccess >= t -
TIME2STEPS(10);
803 const bool wasOnRoad = v->
isOnRoad();
804 const bool keepLane = v->
getLane() == myRemoteLane;
809 if (myRemoteRoute.size() != 0) {
813 if (myRemoteLane !=
nullptr && myRemotePos > myRemoteLane->getLength()) {
814 myRemotePos = myRemoteLane->getLength();
816 if (myRemoteLane !=
nullptr && fabs(myRemotePosLat) < 0.5 * (myRemoteLane->getWidth() + v->
getVehicleType().
getWidth())) {
824 myRemoteLane->forceVehicleInsertion(v, myRemotePos, notify, myRemotePosLat);
858 if (myRemoteLane !=
nullptr) {
864 if (distAlongRoute != std::numeric_limits<double>::max()) {
865 dist = distAlongRoute;
869 const double minSpeed = myConsiderMaxDeceleration ?
871 const double maxSpeed = (myRemoteLane !=
nullptr
872 ? myRemoteLane->getVehicleMaxSpeed(veh)
882 if (myRemoteLane ==
nullptr) {
902 if (myRoutingMode == 1) {
915 if (busstop !=
nullptr) {
916 return busstop->getLastFreePos(veh);
917 }
else if (containerstop !=
nullptr) {
918 return containerstop->getLastFreePos(veh);
919 }
else if (parkingarea !=
nullptr) {
920 return parkingarea->getLastFreePos(veh);
921 }
else if (chargingStation !=
nullptr) {
922 return chargingStation->getLastFreePos(veh);
930 if (parkingarea !=
nullptr) {
931 return "parkingArea:" + parkingarea->getID();
932 }
else if (containerstop !=
nullptr) {
933 return "containerStop:" + containerstop->getID();
934 }
else if (busstop !=
nullptr) {
935 return "busStop:" + busstop->getID();
936 }
else if (chargingStation !=
nullptr) {
937 return "chargingStation:" + chargingStation->getID();
939 return "lane:" + lane->getID() +
" pos:" +
toString(pars.endPos);
948 if (busstop !=
nullptr) {
951 if (containerstop !=
nullptr) {
954 if (busstop ==
nullptr && containerstop ==
nullptr) {
962 if (pars.until >= 0) {
965 if (pars.triggered) {
968 if (pars.containerTriggered) {
974 if (pars.awaitedPersons.size() > 0) {
977 if (pars.awaitedContainers.size() > 0) {
1008 myStopDist(std::numeric_limits<double>::max()),
1016 if (!(*myCurrEdge)->isTazConnector()) {
1018 if ((*myCurrEdge)->getDepartLane(*
this) ==
nullptr) {
1019 throw ProcessError(
"Invalid departlane definition for vehicle '" + pars->
id +
"'.");
1022 if ((*myCurrEdge)->allowedLanes(type->
getVehicleClass()) ==
nullptr) {
1023 throw ProcessError(
"Vehicle '" + pars->
id +
"' is not allowed to depart on any lane of its first edge.");
1028 "' is too high for the vehicle type '" + type->
getID() +
"'.");
1041 (*i)->resetPartialOccupation(
this);
1061 #ifdef DEBUG_ACTIONSTEPS
1063 std::cout <<
SIMTIME <<
" Removing vehicle '" <<
getID() <<
"' (reason: " <<
toString(reason) <<
")" << std::endl;
1096 (newCurrEdge + 1) == edges.end() || (*(newCurrEdge + 1)) != &(
myLane->
getOutgoingViaLanes().front().first->getEdge()))) {
1113 if (stopsFromScratch) {
1124 lastPos += (*myCurrEdge)->getLength();
1126 #ifdef DEBUG_REPLACE_ROUTE
1128 std::cout <<
" replaceRoute on " << (*myCurrEdge)->getID() <<
" lane=" <<
myLane->
getID() <<
"\n";
1131 for (std::list<Stop>::iterator iter =
myStops.begin(); iter !=
myStops.end();) {
1132 double endPos = iter->getEndPos(*
this);
1133 #ifdef DEBUG_REPLACE_ROUTE
1135 std::cout <<
" stopEdge=" << iter->lane->getEdge().getID() <<
" start=" << (searchStart -
myCurrEdge) <<
" endPos=" << endPos <<
" lastPos=" << lastPos <<
"\n";
1138 if (*searchStart != &iter->lane->getEdge()
1139 || endPos < lastPos) {
1140 if (searchStart != edges.end() && !iter->reached) {
1146 iter->edge = std::find(searchStart, edges.end(), &iter->lane->getEdge());
1147 #ifdef DEBUG_REPLACE_ROUTE
1149 std::cout <<
" foundIndex=" << (iter->edge -
myCurrEdge) <<
" end=" << (edges.end() -
myCurrEdge) <<
"\n";
1152 if (iter->edge == edges.end()) {
1160 searchStart = iter->edge;
1165 if (addRouteStops) {
1166 for (std::vector<SUMOVehicleParameter::Stop>::const_iterator i = newRoute->
getStops().begin(); i != newRoute->
getStops().end(); ++i) {
1178 updateBestLanes(
true, onInit ? (*myCurrEdge)->getLanes().front() : 0);
1215 if (!rem->first->notifyMove(*
this, oldPos + rem->second, newPos + rem->second,
MAX2(0., newSpeed))) {
1217 if (myTraceMoveReminders) {
1218 traceMoveReminder(
"notifyMove", rem->first, rem->second,
false);
1224 if (myTraceMoveReminders) {
1225 traceMoveReminder(
"notifyMove", rem->first, rem->second,
true);
1241 rem->second += oldLaneLength;
1245 if (myTraceMoveReminders) {
1246 traceMoveReminder(
"adaptedPos", rem->first, rem->second,
true);
1279 if (
myStops.begin()->parkingarea !=
nullptr) {
1280 return myStops.begin()->parkingarea->getVehiclePosition(*
this);
1290 if (offset == 0. && !changingLanes) {
1305 auto nextBestLane = bestLanes.begin();
1310 bool success =
true;
1312 while (offset > 0) {
1317 lane = lane->
getLinkCont()[0]->getViaLaneOrLane();
1319 if (lane ==
nullptr) {
1329 while (nextBestLane != bestLanes.end() && *nextBestLane ==
nullptr) {
1334 assert(lane == *nextBestLane);
1338 assert(nextBestLane == bestLanes.end() || *nextBestLane != 0);
1339 if (nextBestLane == bestLanes.end()) {
1366 int furtherIndex = 0;
1375 offset += lastLength;
1400 #ifdef DEBUG_FURTHER
1402 std::cout <<
SIMTIME <<
" veh '" <<
getID() <<
" setAngle(" << angle <<
") straightenFurther=" << straightenFurther << std::endl;
1410 if (further->
getLinkTo(next) !=
nullptr) {
1425 const bool newActionStepLength = actionStepLengthMillisecs != previousActionStepLength;
1426 if (newActionStepLength) {
1443 if (
myStops.begin()->parkingarea !=
nullptr) {
1444 return myStops.begin()->parkingarea->getVehicleAngle(*
this);
1469 double result = (p1 != p2 ? p2.
angleTo2D(p1) :
1474 #ifdef DEBUG_FURTHER
1492 #ifdef DEBUG_FURTHER
1499 #ifdef DEBUG_FURTHER
1518 errorMsg =
"Vehicle '" +
myParameter->
id +
"' is not allowed to stop on lane '" + stopPar.
lane +
"'.";
1528 if (stopPar.
until != -1) {
1530 const_cast<SUMOVehicleParameter::Stop&>(stop.
pars).until += untilOffset;
1535 std::string stopType =
"stop";
1536 std::string stopID =
"";
1537 if (stop.
busstop !=
nullptr) {
1538 stopType =
"busStop";
1541 stopType =
"containerStop";
1544 stopType =
"chargingStation";
1547 stopType =
"parkingArea";
1550 const std::string errorMsgStart = stopID ==
"" ? stopType : stopType +
" '" + stopID +
"'";
1553 errorMsg = errorMsgStart +
" for vehicle '" +
myParameter->
id +
"' on lane '" + stopPar.
lane +
"' has an invalid position.";
1558 errorMsg = errorMsgStart +
" on lane '" + stopPar.
lane +
"' is too short for vehicle '" +
myParameter->
id +
"'.";
1562 if (searchStart ==
nullptr) {
1567 MSEdge* prevEdge =
nullptr;
1570 std::list<Stop>::iterator iter =
myStops.begin();
1573 prevStopEdge =
myStops.back().edge;
1574 prevEdge = &
myStops.back().lane->getEdge();
1575 prevStopPos =
myStops.back().pars.endPos;
1578 if (prevStopEdge == stop.
edge
1581 stop.
edge = std::find(prevStopEdge + 1,
myRoute->
end(), stopEdge);
1586 while (iter !=
myStops.end() && (iter->edge < stop.
edge ||
1587 (iter->pars.endPos < stop.
pars.
endPos && iter->edge == stop.
edge))) {
1588 prevStopEdge = iter->edge;
1589 prevStopPos = iter->pars.endPos;
1593 int index = stopPar.
index;
1595 prevStopEdge = iter->edge;
1596 prevStopPos = iter->pars.endPos;
1603 const bool sameEdgeAsLastStop = prevStopEdge == stop.
edge && prevEdge == &stop.
lane->
getEdge();
1605 (sameEdgeAsLastStop && prevStopPos > stop.
pars.
endPos && !collision)
1610 return addStop(stopPar, errorMsg, untilOffset, collision, &next);
1612 errorMsg = errorMsgStart +
" for vehicle '" +
myParameter->
id +
"' on lane '" + stopPar.
lane +
"' is not downstream the current route.";
1635 errorMsg = errorMsgStart +
" for vehicle '" +
myParameter->
id +
"' on lane '" + stopPar.
lane +
"' is too close to break.";
1644 pos += (*myCurrEdge)->getLength();
1654 return addStop(stopPar, errorMsg, untilOffset, collision, &next);
1656 errorMsg = errorMsgStart +
" for vehicle '" +
myParameter->
id +
"' on lane '" + stopPar.
lane +
"' is before departPos.";
1660 if (iter !=
myStops.begin()) {
1661 std::list<Stop>::iterator iter2 = iter;
1664 errorMsg = errorMsgStart +
" for vehicle '" +
myParameter->
id +
"' on lane '" + stopPar.
lane +
"' ends earlier than previous stop.";
1678 if (parkingArea == 0) {
1679 errorMsg =
"new parkingArea is NULL";
1683 errorMsg =
"vehicle has no stops";
1686 if (
myStops.front().parkingarea == 0) {
1687 errorMsg =
"first stop is not at parkingArea";
1693 for (std::list<Stop>::iterator iter = ++
myStops.begin(); iter !=
myStops.end();) {
1694 if (iter->parkingarea == parkingArea) {
1695 stopPar.
duration += iter->duration;
1722 return nextParkingArea;
1730 currentParkingArea =
myStops.begin()->parkingarea;
1732 return currentParkingArea;
1767 return myStops.front().duration;
1782 myStops.begin()->parkingarea ==
nullptr || !
myStops.begin()->parkingarea->parkOnRoad());
1809 return currentVelocity;
1814 std::cout <<
"\nPROCESS_NEXT_STOP\n" <<
SIMTIME <<
" vehicle '" <<
getID() <<
"'" << std::endl;
1824 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' reached stop.\n"
1845 if (stop.
busstop !=
nullptr) {
1847 for (std::vector<MSTransportable*>::const_iterator i = persons.begin(); i != persons.end(); ++i) {
1858 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' unregisters as waiting for person." << std::endl;
1866 for (std::vector<MSTransportable*>::const_iterator i = containers.begin(); i != containers.end(); ++i) {
1877 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' unregisters as waiting for container." << std::endl;
1885 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' resumes from stopping." << std::endl;
1892 WRITE_WARNING(
"Vehicle '" +
getID() +
"' ignores triggered stop on lane '" + stop.
lane->
getID() +
"' due to capacity constraints.");
1900 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' registers as waiting for person." << std::endl;
1906 WRITE_WARNING(
"Vehicle '" +
getID() +
"' ignores container triggered stop on lane '" + stop.
lane->
getID() +
"' due to capacity constraints.");
1914 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' registers as waiting for container." << std::endl;
1933 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' hasn't reached next stop." << std::endl;
1941 bool fitsOnStoppingPlace =
true;
1942 if (stop.
busstop !=
nullptr) {
1952 fitsOnStoppingPlace =
false;
1959 if (
myStops.empty() ||
myStops.front().parkingarea != oldParkingArea) {
1961 return currentVelocity;
1964 fitsOnStoppingPlace =
false;
1973 std::cout <<
" pos=" <<
myState.
pos() <<
" speed=" << currentVelocity <<
" targetPos=" << targetPos <<
" fits=" << fitsOnStoppingPlace <<
" reachedThresh=" << reachedThreshold <<
"\n";
1982 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' reached next stop." << std::endl;
2003 if (stop.
busstop !=
nullptr) {
2025 return currentVelocity;
2033 const Stop* prev =
nullptr;
2038 const double stopPos = stop.
getEndPos(*
this);
2040 || prev->
edge != stop.edge
2042 result.push_back(*stop.edge);
2055 std::vector<std::pair<int, double> >
2057 std::vector<std::pair<int, double> > result;
2058 for (std::list<Stop>::const_iterator iter =
myStops.begin(); iter !=
myStops.end(); ++iter) {
2059 result.push_back(std::make_pair(
2061 iter->getEndPos(*
this)));
2068 if (stop ==
nullptr) {
2072 if (s.busstop == stop
2073 || s.containerstop == stop
2074 || s.parkingarea == stop
2075 || s.chargingStation == stop) {
2085 if (&s.lane->getEdge() == edge) {
2103 && (&
myStops.front().lane->getEdge()) == *
myStops.front().edge) {
2130 if (timeSinceLastAction == 0) {
2132 timeSinceLastAction = oldActionStepLength;
2134 if (timeSinceLastAction >= newActionStepLength) {
2138 SUMOTime timeUntilNextAction = newActionStepLength - timeSinceLastAction;
2147 #ifdef DEBUG_PLAN_MOVE
2153 <<
" veh=" <<
getID()
2168 #ifdef DEBUG_ACTIONSTEPS
2170 std::cout <<
STEPS2TIME(t) <<
" vehicle '" <<
getID() <<
"' skips action." << std::endl;
2178 #ifdef DEBUG_ACTIONSTEPS
2180 std::cout <<
STEPS2TIME(t) <<
" vehicle = '" <<
getID() <<
"' takes action." << std::endl;
2186 #ifdef DEBUG_PLAN_MOVE
2188 DriveItemVector::iterator i;
2191 <<
" vPass=" << (*i).myVLinkPass
2192 <<
" vWait=" << (*i).myVLinkWait
2193 <<
" linkLane=" << ((*i).myLink == 0 ?
"NULL" : (*i).myLink->getViaLaneOrLane()->getID())
2194 <<
" request=" << (*i).mySetRequest
2215 myStopDist = std::numeric_limits<double>::max();
2223 double lateralShift = 0;
2227 laneMaxV =
MIN2(laneMaxV, l->getVehicleMaxSpeed(
this));
2231 laneMaxV =
MAX2(laneMaxV, vMinComfortable);
2233 laneMaxV = std::numeric_limits<double>::max();
2236 double v =
MIN2(maxV, laneMaxV);
2252 #ifdef DEBUG_PLAN_MOVE
2254 std::cout <<
" dist=" << dist <<
" bestLaneConts=" <<
toString(bestLaneConts) <<
"\n";
2257 assert(bestLaneConts.size() > 0);
2258 bool hadNonInternal =
false;
2264 double seenNonInternal = 0;
2269 bool slowedDownForMinor =
false;
2275 #pragma warning(push)
2276 #pragma warning(disable: 4127) // do not warn about constant conditional expression
2280 #pragma warning(pop)
2291 if (leader.first != 0 && leader.first->getLane() == leaderLane && leader.first->getLaneChangeModel().isOpposite()) {
2295 adaptToLeaders(ahead, lateralShift, seen, lastLink, leaderLane, v, vLinkPass);
2296 if (lastLink !=
nullptr) {
2299 #ifdef DEBUG_PLAN_MOVE
2301 std::cout <<
"\nv = " << v <<
"\n";
2309 if (shadowLane !=
nullptr) {
2313 seen, lastLink, shadowLane, v, vLinkPass);
2318 const double relativePos = lane->
getLength() - seen;
2319 #ifdef DEBUG_PLAN_MOVE
2321 std::cout <<
SIMTIME <<
" adapt to pedestrians on lane=" << lane->
getID() <<
" relPos=" << relativePos <<
"\n";
2326 if (leader.first != 0) {
2328 v =
MIN2(v, stopSpeed);
2329 #ifdef DEBUG_PLAN_MOVE
2331 std::cout <<
SIMTIME <<
" pedLeader=" << leader.first->getID() <<
" dist=" << leader.second <<
" v=" << v <<
"\n";
2360 myStopDist = std::numeric_limits<double>::max();
2364 if (lastLink !=
nullptr) {
2370 if (lastLink !=
nullptr) {
2374 v =
MIN2(v, stopSpeed);
2376 MSLinkCont::const_iterator exitLink =
MSLane::succLinkSec(*
this, view + 1, *lane, bestLaneConts);
2378 bool dummySetRequest;
2379 double dummyVLinkWait;
2384 #ifdef DEBUG_PLAN_MOVE
2386 std::cout <<
"\n" <<
SIMTIME <<
" next stop: distance = " <<
myStopDist <<
" requires stopSpeed = " << stopSpeed <<
"\n";
2396 MSLinkCont::const_iterator link =
MSLane::succLinkSec(*
this, view + 1, *lane, bestLaneConts);
2399 if (!encounteredTurn) {
2409 encounteredTurn =
true;
2410 #ifdef DEBUG_NEXT_TURN
2413 <<
" at " <<
myNextTurn.first <<
"m." << std::endl;
2429 if (lastLink !=
nullptr) {
2437 ((*link)->getViaLane() ==
nullptr
2451 if (lastLink !=
nullptr) {
2459 #ifdef DEBUG_PLAN_MOVE
2461 std::cout <<
" braking for link end lane=" << lane->
getID() <<
" seen=" << seen
2471 lateralShift += (*link)->getLateralShift();
2472 const bool yellowOrRed = (*link)->haveRed() || (*link)->haveYellow();
2483 double laneStopOffset;
2487 const bool canBrakeBeforeLaneEnd = seen >= brakeDist;
2488 const bool canBrakeBeforeStopLine = seen - lane->
getStopOffset(
this) >= brakeDist;
2491 laneStopOffset = majorStopOffset;
2492 }
else if ((*link)->havePriority()) {
2494 laneStopOffset =
MIN2((*link)->getFoeVisibilityDistance() -
POSITION_EPS, majorStopOffset);
2497 laneStopOffset =
MIN2((*link)->getFoeVisibilityDistance() -
POSITION_EPS, minorStopOffset);
2499 if (canBrakeBeforeLaneEnd) {
2501 laneStopOffset =
MIN2(laneStopOffset, seen - brakeDist);
2504 const double stopDist =
MAX2(0., seen - laneStopOffset);
2506 #ifdef DEBUG_PLAN_MOVE
2508 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" effective stopOffset on lane '" << lane->
getID()
2509 <<
"' is " << laneStopOffset <<
" (-> stopDist=" << stopDist <<
")" << std::endl;
2515 const double vReverse =
MIN2(
2518 #ifdef DEBUG_REVERSE_BIDI
2520 std::cout <<
SIMTIME <<
" seen=" << seen <<
" vReverse=" << vReverse <<
"\n";
2523 lfLinks.push_back(
DriveProcessItem(*link, vReverse, vReverse,
false, t, 0, t, 0, seen));
2535 assert(timeRemaining != 0);
2539 #ifdef DEBUG_PLAN_MOVE
2541 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" slowing down to finish continuous change before"
2542 <<
" link=" << (*link)->getViaLaneOrLane()->getID()
2543 <<
" timeRemaining=" << timeRemaining
2556 const bool abortRequestAfterMinor = slowedDownForMinor && (*link)->getInternalLaneBefore() ==
nullptr;
2558 bool setRequest = (v >
NUMERICAL_EPS_SPEED && !abortRequestAfterMinor) || (leavingCurrentIntersection);
2561 #ifdef DEBUG_PLAN_MOVE
2564 <<
" stopDist=" << stopDist
2565 <<
" vLinkWait=" << vLinkWait
2566 <<
" brakeDist=" << brakeDist
2568 <<
" leaveIntersection=" << leavingCurrentIntersection
2569 <<
" setRequest=" << setRequest
2580 if (yellowOrRed && canBrakeBeforeStopLine && !
ignoreRed(*link, canBrakeBeforeStopLine)) {
2590 if (
ignoreRed(*link, canBrakeBeforeStopLine) &&
STEPS2TIME(t - (*link)->getLastStateChange()) > 2) {
2595 #ifdef DEBUG_PLAN_MOVE
2597 <<
" ignoreRed spent=" <<
STEPS2TIME(t - (*link)->getLastStateChange())
2598 <<
" redSpeed=" << redSpeed
2608 if (lastLink !=
nullptr) {
2611 double arrivalSpeed = vLinkPass;
2617 double visibilityDistance = (*link)->getFoeVisibilityDistance();
2618 double determinedFoePresence = seen <= visibilityDistance;
2623 #ifdef DEBUG_PLAN_MOVE
2625 std::cout <<
" approaching link=" << (*link)->getViaLaneOrLane()->getID() <<
" prio=" << (*link)->havePriority() <<
" seen=" << seen <<
" visibilityDistance=" << visibilityDistance <<
" brakeDist=" << brakeDist <<
"\n";
2629 if (!(*link)->havePriority() && !determinedFoePresence && brakeDist < seen && !(*link)->lastWasContMajor()) {
2634 arrivalSpeed =
MIN2(vLinkPass, maxArrivalSpeed);
2635 slowedDownForMinor =
true;
2636 #ifdef DEBUG_PLAN_MOVE
2638 std::cout <<
" slowedDownForMinor maxSpeedAtVisDist=" << maxSpeedAtVisibilityDist <<
" maxArrivalSpeed=" << maxArrivalSpeed <<
" arrivalSpeed=" << arrivalSpeed <<
"\n";
2644 std::pair<const SUMOVehicle*, const MSLink*> blocker = (*link)->getFirstApproachingFoe();
2646 while (blocker.second !=
nullptr && blocker.second != *link) {
2647 blocker = blocker.second->getFirstApproachingFoe();
2651 if (blocker.second == *link) {
2652 const double threshold = (*link)->getDirection() ==
LINKDIR_STRAIGHT ? 0.25 : 0.75;
2672 double arrivalSpeedBraking = 0;
2679 arrivalSpeedBraking =
MIN2(arrivalSpeedBraking, arrivalSpeed);
2683 if (v + arrivalSpeedBraking <= 0.) {
2684 arrivalTimeBraking = std::numeric_limits<long long int>::max();
2686 arrivalTimeBraking =
MAX2(arrivalTime, t +
TIME2STEPS(seen / ((v + arrivalSpeedBraking) * 0.5)));
2690 arrivalTime, arrivalSpeed,
2691 arrivalTimeBraking, arrivalSpeedBraking,
2694 if ((*link)->getViaLane() ==
nullptr) {
2695 hadNonInternal =
true;
2698 #ifdef DEBUG_PLAN_MOVE
2700 std::cout <<
" checkAbort setRequest=" << setRequest <<
" v=" << v <<
" seen=" << seen <<
" dist=" << dist
2701 <<
" seenNonInternal=" << seenNonInternal
2702 <<
" seenInternal=" << seenInternal <<
" length=" << vehicleLength <<
"\n";
2706 if ((!setRequest || v <= 0 || seen > dist) && hadNonInternal && seenNonInternal >
MAX2(vehicleLength *
CRLL_LOOK_AHEAD, vehicleLength + seenInternal)) {
2710 lane = (*link)->getViaLaneOrLane();
2713 laneMaxV = std::numeric_limits<double>::max();
2727 leaderLane = opposite ? lane->
getOpposite() : lane;
2728 if (leaderLane ==
nullptr) {
2734 lastLink = &lfLinks.back();
2749 const MSLane*
const lane,
double& v,
double& vLinkPass)
const {
2752 ahead.
getSubLanes(
this, latOffset, rightmost, leftmost);
2753 #ifdef DEBUG_PLAN_MOVE
2755 <<
"\nADAPT_TO_LEADERS\nveh=" <<
getID()
2756 <<
" lane=" << lane->
getID()
2757 <<
" latOffset=" << latOffset
2758 <<
" rm=" << rightmost
2759 <<
" lm=" << leftmost
2773 for (
int sublane = rightmost; sublane <= leftmost; ++sublane) {
2775 if (pred !=
nullptr && pred !=
this) {
2778 double gap = (lastLink ==
nullptr
2784 #ifdef DEBUG_PLAN_MOVE
2786 std::cout <<
" pred=" << pred->
getID() <<
" predLane=" << pred->
getLane()->
getID() <<
" predPos=" << pred->
getPositionOnLane() <<
" gap=" << gap <<
" predBack=" << predBack <<
" seen=" << seen <<
" lane=" << lane->
getID() <<
" myLane=" <<
myLane->
getID() <<
"\n";
2789 adaptToLeader(std::make_pair(pred, gap), seen, lastLink, lane, v, vLinkPass);
2798 const MSLane*
const lane,
double& v,
double& vLinkPass,
2799 double distToCrossing)
const {
2800 if (leaderInfo.first != 0) {
2801 const double vsafeLeader =
getSafeFollowSpeed(leaderInfo, seen, lane, distToCrossing);
2802 if (lastLink !=
nullptr) {
2805 v =
MIN2(v, vsafeLeader);
2806 vLinkPass =
MIN2(vLinkPass, vsafeLeader);
2808 #ifdef DEBUG_PLAN_MOVE
2812 <<
" veh=" <<
getID()
2813 <<
" lead=" << leaderInfo.first->getID()
2814 <<
" leadSpeed=" << leaderInfo.first->getSpeed()
2815 <<
" gap=" << leaderInfo.second
2816 <<
" leadLane=" << leaderInfo.first->getLane()->getID()
2817 <<
" predPos=" << leaderInfo.first->getPositionOnLane()
2819 <<
" lane=" << lane->
getID()
2821 <<
" dTC=" << distToCrossing
2823 <<
" vSafeLeader=" << vsafeLeader
2824 <<
" vLinkPass=" << vLinkPass
2833 DriveProcessItem*
const lastLink,
double& v,
double& vLinkPass,
double& vLinkWait,
bool& setRequest)
const {
2836 checkLinkLeader(link, lane, seen, lastLink, v, vLinkPass, vLinkWait, setRequest);
2839 if (parallelLink !=
nullptr) {
2840 checkLinkLeader(parallelLink, lane, seen, lastLink, v, vLinkPass, vLinkWait, setRequest,
true);
2849 DriveProcessItem*
const lastLink,
double& v,
double& vLinkPass,
double& vLinkWait,
bool& setRequest,
2850 bool isShadowLink)
const {
2851 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
2857 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
2862 for (MSLink::LinkLeaders::const_iterator it = linkLeaders.begin(); it != linkLeaders.end(); ++it) {
2864 const MSVehicle* leader = (*it).vehAndGap.first;
2865 if (leader ==
nullptr) {
2867 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
2869 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" is blocked on link to " << link->
getViaLaneOrLane()->
getID() <<
" by pedestrian. dist=" << it->distToCrossing <<
"\n";
2872 adaptToLeader(std::make_pair(
this, -1), seen, lastLink, lane, v, vLinkPass, it->distToCrossing);
2873 }
else if (
isLeader(link, leader)) {
2880 linkLeadersAhead.
addLeader(leader,
false, 0);
2884 #ifdef DEBUG_PLAN_MOVE
2888 <<
" isShadowLink=" << isShadowLink
2889 <<
" lane=" << lane->
getID()
2890 <<
" foe=" << leader->
getID()
2892 <<
" latOffset=" << latOffset
2894 <<
" linkLeadersAhead=" << linkLeadersAhead.
toString()
2899 #ifdef DEBUG_PLAN_MOVE
2908 adaptToLeader(it->vehAndGap, seen, lastLink, lane, v, vLinkPass, it->distToCrossing);
2910 if (lastLink !=
nullptr) {
2924 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
2926 std::cout <<
" aborting request\n";
2933 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
2935 std::cout <<
" aborting previous request\n";
2941 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
2944 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" ignoring leader " << leader->
getID()
2954 vLinkWait =
MIN2(vLinkWait, v);
2960 const double seen,
const MSLane*
const lane,
double distToCrossing)
const {
2961 assert(leaderInfo.first != 0);
2963 double vsafeLeader = 0;
2965 vsafeLeader = -std::numeric_limits<double>::max();
2967 if (leaderInfo.second >= 0) {
2968 vsafeLeader = cfModel.
followSpeed(
this,
getSpeed(), leaderInfo.second, leaderInfo.first->getSpeed(), leaderInfo.first->getCurrentApparentDecel(), leaderInfo.first);
2973 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
2975 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" stopping before junction: lane=" << lane->
getID() <<
" seen=" << seen
2978 <<
" vsafeLeader=" << vsafeLeader
2983 if (distToCrossing >= 0) {
3016 double vSafeZipper = std::numeric_limits<double>::max();
3019 bool canBrakeVSafeMin =
false;
3024 MSLink*
const link = dpi.myLink;
3026 #ifdef DEBUG_EXEC_MOVE
3030 <<
" veh=" <<
getID()
3032 <<
" req=" << dpi.mySetRequest
3033 <<
" vP=" << dpi.myVLinkPass
3034 <<
" vW=" << dpi.myVLinkWait
3035 <<
" d=" << dpi.myDistance
3042 if (link !=
nullptr && dpi.mySetRequest) {
3051 const bool ignoreRedLink =
ignoreRed(link, canBrake) || beyondStopLine;
3052 if (yellow && canBrake && !ignoreRedLink) {
3053 vSafe = dpi.myVLinkWait;
3055 #ifdef DEBUG_CHECKREWINDLINKLANES
3057 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (yellow)\n";
3064 bool opened = (yellow || influencerPrio
3065 || link->
opened(dpi.myArrivalTime, dpi.myArrivalSpeed, dpi.getLeaveSpeed(),
3071 ignoreRedLink,
this));
3074 if (parallelLink !=
nullptr) {
3077 opened = yellow || influencerPrio || (opened && parallelLink->
opened(dpi.myArrivalTime, dpi.myArrivalSpeed, dpi.getLeaveSpeed(),
3081 ignoreRedLink,
this));
3082 #ifdef DEBUG_EXEC_MOVE
3085 <<
" veh=" <<
getID()
3089 <<
" opened=" << opened
3096 #ifdef DEBUG_EXEC_MOVE
3099 <<
" opened=" << opened
3100 <<
" influencerPrio=" << influencerPrio
3103 <<
" isCont=" << link->
isCont()
3104 <<
" ignoreRed=" << ignoreRedLink
3110 double determinedFoePresence = dpi.myDistance <= visibilityDistance;
3111 if (!determinedFoePresence && (canBrake || !yellow)) {
3112 vSafe = dpi.myVLinkWait;
3114 #ifdef DEBUG_CHECKREWINDLINKLANES
3116 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (minor)\n";
3132 vSafeMinDist = dpi.myDistance;
3138 canBrakeVSafeMin = canBrake;
3139 #ifdef DEBUG_EXEC_MOVE
3141 std::cout <<
" vSafeMin=" << vSafeMin <<
" vSafeMinDist=" << vSafeMinDist <<
" canBrake=" << canBrake <<
"\n";
3148 vSafe = dpi.myVLinkPass;
3152 #ifdef DEBUG_CHECKREWINDLINKLANES
3154 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (very slow)\n";
3159 vSafeZipper =
MIN2(vSafeZipper,
3160 link->
getZipperSpeed(
this, dpi.myDistance, dpi.myVLinkPass, dpi.myArrivalTime, &collectFoes));
3162 vSafe = dpi.myVLinkWait;
3164 #ifdef DEBUG_CHECKREWINDLINKLANES
3166 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (closed)\n";
3169 #ifdef DEBUG_EXEC_MOVE
3180 #ifdef DEBUG_EXEC_MOVE
3182 std::cout <<
SIMTIME <<
" reseting junctionEntryTime at junction '" << link->
getJunction()->
getID() <<
"' beause of non-request exitLink\n";
3189 vSafe = dpi.myVLinkWait;
3192 #ifdef DEBUG_CHECKREWINDLINKLANES
3194 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (no request, braking)\n";
3199 #ifdef DEBUG_CHECKREWINDLINKLANES
3201 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (no request, stopping)\n";
3227 #ifdef DEBUG_EXEC_MOVE
3229 std::cout <<
"vSafeMin Problem? vSafe=" << vSafe <<
" vSafeMin=" << vSafeMin <<
" vSafeMinDist=" << vSafeMinDist << std::endl;
3232 if (canBrakeVSafeMin && vSafe <
getSpeed()) {
3237 #ifdef DEBUG_CHECKREWINDLINKLANES
3239 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (vSafe=" << vSafe <<
" < vSafeMin=" << vSafeMin <<
")\n";
3257 vSafe =
MIN2(vSafe, vSafeZipper);
3266 std::cout <<
SIMTIME <<
" MSVehicle::processTraCISpeedControl() for vehicle '" <<
getID() <<
"'"
3267 <<
" vSafe=" << vSafe <<
" (init)vNext=" << vNext;
3276 vMin =
MAX2(0., vMin);
3281 std::cout <<
" (processed)vNext=" << vNext << std::endl;
3291 #ifdef DEBUG_ACTIONSTEPS
3293 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" removePassedDriveItems()\n"
3294 <<
" Current items: ";
3296 if (j.myLink == 0) {
3297 std::cout <<
"\n Stop at distance " << j.myDistance;
3299 const MSLane* to = j.myLink->getViaLaneOrLane();
3300 const MSLane* from = j.myLink->getLaneBefore();
3301 std::cout <<
"\n Link at distance " << j.myDistance <<
": '"
3302 << (from == 0 ?
"NONE" : from->
getID()) <<
"' -> '" << (to == 0 ?
"NONE" : to->
getID()) <<
"'";
3305 std::cout <<
"\n myNextDriveItem: ";
3312 std::cout <<
"\n Link at distance " <<
myNextDriveItem->myDistance <<
": '"
3313 << (from == 0 ?
"NONE" : from->
getID()) <<
"' -> '" << (to == 0 ?
"NONE" : to->
getID()) <<
"'";
3316 std::cout << std::endl;
3320 #ifdef DEBUG_ACTIONSTEPS
3322 std::cout <<
" Removing item: ";
3323 if (j->myLink == 0) {
3324 std::cout <<
"Stop at distance " << j->myDistance;
3326 const MSLane* to = j->myLink->getViaLaneOrLane();
3327 const MSLane* from = j->myLink->getLaneBefore();
3328 std::cout <<
"Link at distance " << j->myDistance <<
": '"
3329 << (from == 0 ?
"NONE" : from->
getID()) <<
"' -> '" << (to == 0 ?
"NONE" : to->
getID()) <<
"'";
3331 std::cout << std::endl;
3334 if (j->myLink !=
nullptr) {
3335 j->myLink->removeApproaching(
this);
3345 #ifdef DEBUG_ACTIONSTEPS
3347 std::cout <<
SIMTIME <<
" updateDriveItems(), veh='" <<
getID() <<
"' (lane: '" <<
getLane()->
getID() <<
"')\nCurrent drive items:" << std::endl;
3348 DriveItemVector::iterator i;
3351 <<
" vPass=" << dpi.myVLinkPass
3352 <<
" vWait=" << dpi.myVLinkWait
3353 <<
" linkLane=" << (dpi.myLink == 0 ?
"NULL" : dpi.myLink->getViaLaneOrLane()->getID())
3354 <<
" request=" << dpi.mySetRequest
3357 std::cout <<
" myNextDriveItem's linked lane: " << (
myNextDriveItem->myLink == 0 ?
"NULL" :
myNextDriveItem->myLink->getViaLaneOrLane()->getID()) << std::endl;
3364 const MSLink* nextPlannedLink =
nullptr;
3367 while (i !=
myLFLinkLanes.end() && nextPlannedLink ==
nullptr) {
3368 nextPlannedLink = i->myLink;
3372 if (nextPlannedLink ==
nullptr) {
3374 #ifdef DEBUG_ACTIONSTEPS
3376 std::cout <<
"Found no link-related drive item." << std::endl;
3384 #ifdef DEBUG_ACTIONSTEPS
3386 std::cout <<
"Continuing on planned lane sequence, no update required." << std::endl;
3408 #ifdef DEBUG_ACTIONSTEPS
3410 std::cout <<
"Changed lane. Drive items will be updated along the current lane continuation." << std::endl;
3422 MSLink* newLink =
nullptr;
3424 if (driveItemIt->myLink ==
nullptr) {
3434 #ifdef DEBUG_ACTIONSTEPS
3436 std::cout <<
"Reached end of the new continuation sequence. Erasing leftover link-items." << std::endl;
3440 if (driveItemIt->myLink ==
nullptr) {
3453 if (newLink == driveItemIt->myLink) {
3455 #ifdef DEBUG_ACTIONSTEPS
3457 std::cout <<
"Old and new continuation sequences merge at link\n"
3459 <<
"\nNo update beyond merge required." << std::endl;
3465 #ifdef DEBUG_ACTIONSTEPS
3467 std::cout <<
"lane=" << lane->
getID() <<
"\nUpdating link\n '" << driveItemIt->myLink->getLaneBefore()->getID() <<
"'->'" << driveItemIt->myLink->getViaLaneOrLane()->getID() <<
"'"
3471 newLink->
setApproaching(
this, driveItemIt->myLink->getApproaching(
this));
3472 driveItemIt->myLink->removeApproaching(
this);
3473 driveItemIt->myLink = newLink;
3480 #ifdef DEBUG_ACTIONSTEPS
3482 std::cout <<
"Updated drive items:" << std::endl;
3483 DriveItemVector::iterator i;
3486 <<
" vPass=" << dpi.myVLinkPass
3487 <<
" vWait=" << dpi.myVLinkWait
3488 <<
" linkLane=" << (dpi.myLink == 0 ?
"NULL" : dpi.myLink->getViaLaneOrLane()->getID())
3489 <<
" request=" << dpi.mySetRequest
3506 brakelightsOn =
true;
3542 #ifdef DEBUG_REVERSE_BIDI
3546 <<
" speedThreshold=" << speedThreshold
3580 if (!further->getEdge().isInternal()) {
3581 if (further->getEdge().getBidiEdge() != *(
myCurrEdge + view)
3597 passedLanes.push_back(*i);
3599 if (passedLanes.size() == 0 || passedLanes.back() !=
myLane) {
3600 passedLanes.push_back(
myLane);
3627 if (link !=
nullptr) {
3632 emergencyReason =
" because of a red traffic light";
3640 }
else if (reverseTrain) {
3641 approachedLane = (*(
myCurrEdge + 1))->getLanes()[0];
3651 emergencyReason =
" because there is no connection to the next edge";
3652 approachedLane =
nullptr;
3655 if (approachedLane !=
myLane && approachedLane !=
nullptr) {
3673 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
3689 WRITE_WARNING(
"Vehicle '" +
getID() +
"' could not finish continuous lane change (turn lane) time=" +
3699 passedLanes.push_back(approachedLane);
3704 #ifdef DEBUG_ACTIONSTEPS
3706 std::cout <<
"Updated drive items:" << std::endl;
3709 <<
" vPass=" << (*i).myVLinkPass
3710 <<
" vWait=" << (*i).myVLinkWait
3711 <<
" linkLane=" << ((*i).myLink == 0 ?
"NULL" : (*i).myLink->getViaLaneOrLane()->getID())
3712 <<
" request=" << (*i).mySetRequest
3729 #ifdef DEBUG_EXEC_MOVE
3731 std::cout <<
"\nEXECUTE_MOVE\n"
3733 <<
" veh=" <<
getID()
3741 double vSafe = std::numeric_limits<double>::max();
3743 double vSafeMin = -std::numeric_limits<double>::max();
3746 double vSafeMinDist = 0;
3751 #ifdef DEBUG_ACTIONSTEPS
3753 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"'\n"
3754 " vsafe from processLinkApproaches(): vsafe " << vSafe << std::endl;
3760 #ifdef DEBUG_ACTIONSTEPS
3762 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' skips processLinkApproaches()\n"
3764 <<
"speed: " <<
getSpeed() <<
" -> " << vSafe << std::endl;
3778 double vNext = vSafe;
3782 vNext =
MAX2(vNext, vSafeMin);
3790 #ifdef DEBUG_EXEC_MOVE
3792 std::cout <<
SIMTIME <<
" finalizeSpeed vSafe=" << vSafe <<
" vSafeMin=" << (vSafeMin == -std::numeric_limits<double>::max() ?
"-Inf" :
toString(vSafeMin))
3793 <<
" vNext=" << vNext <<
" (i.e. accel=" <<
SPEED2ACCEL(vNext -
getSpeed()) <<
")" << std::endl;
3810 vNext =
MAX2(vNext, 0.);
3825 std::vector<MSLane*> passedLanes;
3829 std::string emergencyReason =
" for unknown reasons";
3838 +
"'" + emergencyReason
3850 passedLanes.clear();
3852 #ifdef DEBUG_ACTIONSTEPS
3854 std::cout <<
SIMTIME <<
" veh '" <<
getID() <<
"' updates further lanes." << std::endl;
3881 #ifdef DEBUG_ACTIONSTEPS
3883 std::cout <<
SIMTIME <<
" veh '" <<
getID() <<
"' skips LCM->prepareStep()." << std::endl;
3890 #ifdef DEBUG_EXEC_MOVE
3929 #ifdef DEBUG_EXEC_MOVE
3931 std::cout <<
SIMTIME <<
" updateState() for veh '" <<
getID() <<
"': deltaPos=" << deltaPos
3936 if (decelPlus > 0) {
3946 +
" severity=" +
toString(emergencyFraction)
3987 const std::vector<MSLane*>& passedLanes) {
3988 #ifdef DEBUG_SETFURTHER
3990 <<
" updateFurtherLanes oldFurther=" <<
toString(furtherLanes)
3991 <<
" oldFurtherPosLat=" <<
toString(furtherLanesPosLat)
3992 <<
" passed=" <<
toString(passedLanes)
3995 for (std::vector<MSLane*>::iterator i = furtherLanes.begin(); i != furtherLanes.end(); ++i) {
3996 (*i)->resetPartialOccupation(
this);
3999 std::vector<MSLane*> newFurther;
4000 std::vector<double> newFurtherPosLat;
4003 if (passedLanes.size() > 1) {
4005 std::vector<MSLane*>::const_iterator fi = furtherLanes.begin();
4006 std::vector<double>::const_iterator fpi = furtherLanesPosLat.begin();
4007 for (
auto pi = passedLanes.rbegin() + 1; pi != passedLanes.rend() && backPosOnPreviousLane < 0; ++pi) {
4009 newFurther.push_back(*pi);
4010 backPosOnPreviousLane += (*pi)->setPartialOccupation(
this);
4011 if (fi != furtherLanes.end() && *pi == *fi) {
4013 newFurtherPosLat.push_back(*fpi);
4021 if (newFurtherPosLat.size() == 0) {
4028 newFurtherPosLat.push_back(newFurtherPosLat.back());
4031 #ifdef DEBUG_SETFURTHER
4033 std::cout <<
SIMTIME <<
" updateFurtherLanes \n"
4034 <<
" further lane '" << (*pi)->getID() <<
"' backPosOnPreviousLane=" << backPosOnPreviousLane
4039 furtherLanes = newFurther;
4040 furtherLanesPosLat = newFurtherPosLat;
4042 furtherLanes.clear();
4043 furtherLanesPosLat.clear();
4045 #ifdef DEBUG_SETFURTHER
4047 <<
" newFurther=" <<
toString(furtherLanes)
4048 <<
" newFurtherPosLat=" <<
toString(furtherLanesPosLat)
4049 <<
" newBackPos=" << backPosOnPreviousLane
4052 return backPosOnPreviousLane;
4058 #ifdef DEBUG_FURTHER
4061 <<
" getBackPositionOnLane veh=" <<
getID()
4092 leftLength -= (*i)->getLength();
4103 leftLength -= (*i)->getLength();
4114 auto j = furtherTargetLanes.begin();
4115 while (leftLength > 0 && j != furtherTargetLanes.end()) {
4116 leftLength -= (*i)->getLength();
4127 #pragma warning(push)
4128 #pragma warning(disable: 4127) // do not warn about constant conditional expression
4132 #pragma warning(pop)
4155 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
4161 foundStopped =
true;
4167 lengths += (*i)->getVehicleType().getLengthWithGap();
4177 double seenSpace = -lengthsInFront;
4178 #ifdef DEBUG_CHECKREWINDLINKLANES
4180 std::cout <<
"\nCHECK_REWIND_LINKLANES\n" <<
" veh=" <<
getID() <<
" lengthsInFront=" << lengthsInFront <<
"\n";
4183 bool foundStopped =
false;
4186 for (
int i = 0; i < (int)lfLinks.size(); ++i) {
4189 #ifdef DEBUG_CHECKREWINDLINKLANES
4192 <<
" foundStopped=" << foundStopped;
4194 if (item.
myLink ==
nullptr || foundStopped) {
4195 if (!foundStopped) {
4200 #ifdef DEBUG_CHECKREWINDLINKLANES
4209 if (approachedLane !=
nullptr) {
4212 if (approachedLane ==
myLane) {
4219 #ifdef DEBUG_CHECKREWINDLINKLANES
4221 <<
" approached=" << approachedLane->
getID()
4224 <<
" seenSpace=" << seenSpace
4226 <<
" lengthsInFront=" << lengthsInFront
4233 if (last ==
nullptr || last ==
this) {
4236 seenSpace += approachedLane->
getLength();
4239 #ifdef DEBUG_CHECKREWINDLINKLANES
4245 bool foundStopped2 =
false;
4247 seenSpace += spaceTillLastStanding;
4248 if (foundStopped2) {
4249 foundStopped =
true;
4254 foundStopped =
true;
4257 #ifdef DEBUG_CHECKREWINDLINKLANES
4259 <<
" approached=" << approachedLane->
getID()
4260 <<
" last=" << last->
getID()
4267 <<
" stls=" << spaceTillLastStanding
4269 <<
" seenSpace=" << seenSpace
4270 <<
" foundStopped=" << foundStopped
4271 <<
" foundStopped2=" << foundStopped2
4278 for (
int i = ((
int)lfLinks.size() - 1); i > 0; --i) {
4282 const bool opened = (item.
myLink !=
nullptr
4283 && (canLeaveJunction || (
4294 #ifdef DEBUG_CHECKREWINDLINKLANES
4297 <<
" canLeave=" << canLeaveJunction
4298 <<
" opened=" << opened
4299 <<
" allowsContinuation=" << allowsContinuation
4300 <<
" foundStopped=" << foundStopped
4303 if (!opened && item.
myLink !=
nullptr) {
4304 foundStopped =
true;
4308 allowsContinuation =
true;
4312 if (allowsContinuation) {
4314 #ifdef DEBUG_CHECKREWINDLINKLANES
4324 int removalBegin = -1;
4325 for (
int i = 0; foundStopped && i < (int)lfLinks.size() && removalBegin < 0; ++i) {
4328 if (item.
myLink ==
nullptr) {
4339 #ifdef DEBUG_CHECKREWINDLINKLANES
4342 <<
" veh=" <<
getID()
4345 <<
" leftSpace=" << leftSpace
4348 if (leftSpace < 0/* && item.myLink->willHaveBlockedFoe()*/) {
4349 double impatienceCorrection = 0;
4356 if (leftSpace < -impatienceCorrection / 10. &&
keepClear(item.
myLink)) {
4364 while (removalBegin < (
int)(lfLinks.size())) {
4366 lfLinks[removalBegin].myVLinkPass = lfLinks[removalBegin].myVLinkWait;
4367 #ifdef DEBUG_CHECKREWINDLINKLANES
4369 std::cout <<
" removalBegin=" << removalBegin <<
" brakeGap=" << brakeGap <<
" dist=" << lfLinks[removalBegin].myDistance <<
" speed=" <<
myState.
mySpeed <<
" a2s=" <<
ACCEL2SPEED(
getCarFollowModel().getMaxDecel()) <<
"\n";
4373 lfLinks[removalBegin].mySetRequest =
false;
4389 if (dpi.myLink !=
nullptr) {
4393 dpi.myLink->setApproaching(
this, dpi.myArrivalTime, dpi.myArrivalSpeed, dpi.getLeaveSpeed(),
4394 dpi.mySetRequest, dpi.myArrivalTimeBraking, dpi.myArrivalSpeedBraking,
getWaitingTime(), dpi.myDistance);
4400 if (dpi.myLink !=
nullptr) {
4402 if (parallelLink !=
nullptr) {
4403 parallelLink->
setApproaching(
this, dpi.myArrivalTime, dpi.myArrivalSpeed, dpi.getLeaveSpeed(),
4404 dpi.mySetRequest, dpi.myArrivalTimeBraking, dpi.myArrivalSpeedBraking,
getWaitingTime(), dpi.myDistance);
4410 #ifdef DEBUG_PLAN_MOVE
4413 <<
" veh=" <<
getID()
4414 <<
" after checkRewindLinkLanes\n";
4417 <<
" vPass=" << dpi.myVLinkPass
4418 <<
" vWait=" << dpi.myVLinkWait
4419 <<
" linkLane=" << (dpi.myLink == 0 ?
"NULL" : dpi.myLink->getViaLaneOrLane()->getID())
4420 <<
" request=" << dpi.mySetRequest
4421 <<
" atime=" << dpi.myArrivalTime
4422 <<
" atimeB=" << dpi.myArrivalTimeBraking
4433 if (rem->first->getLane() !=
nullptr && rem->second > 0.) {
4435 if (myTraceMoveReminders) {
4436 traceMoveReminder(
"notifyEnter_skipped", rem->first, rem->second,
true);
4441 if (rem->first->notifyEnter(*
this, reason, enteredLane)) {
4443 if (myTraceMoveReminders) {
4444 traceMoveReminder(
"notifyEnter", rem->first, rem->second,
true);
4450 if (myTraceMoveReminders) {
4451 traceMoveReminder(
"notifyEnter", rem->first, rem->second,
false);
4488 if (!onTeleporting) {
4492 assert(oldLane != 0);
4531 if (lane !=
nullptr) {
4534 if (lane !=
nullptr) {
4535 #ifdef DEBUG_SETFURTHER
4537 std::cout <<
SIMTIME <<
" enterLaneAtLaneChange \n";
4543 #ifdef DEBUG_SETFURTHER
4545 std::cout <<
SIMTIME <<
" enterLaneAtLaneChange \n";
4548 leftLength -= (lane)->setPartialOccupation(
this);
4556 #ifdef DEBUG_SETFURTHER
4589 MSLane* clane = enteredLane;
4590 while (leftLength > 0) {
4597 leftLength -= (clane)->setPartialOccupation(
this);
4603 #ifdef DEBUG_FURTHER
4605 std::cout <<
SIMTIME <<
" enterLaneAtInsertion \n";
4608 (*i)->resetPartialOccupation(
this);
4629 if (rem->first->notifyLeave(*
this,
myState.
myPos + rem->second, reason, approachedLane)) {
4631 if (myTraceMoveReminders) {
4632 traceMoveReminder(
"notifyLeave", rem->first, rem->second,
true);
4638 if (myTraceMoveReminders) {
4639 traceMoveReminder(
"notifyLeave", rem->first, rem->second,
false);
4652 #ifdef DEBUG_FURTHER
4654 std::cout <<
SIMTIME <<
" leaveLane \n";
4657 (*i)->resetPartialOccupation(
this);
4691 const std::vector<MSVehicle::LaneQ>&
4699 #ifdef DEBUG_BESTLANES
4704 if (startLane ==
nullptr) {
4707 assert(startLane != 0);
4712 bool startLaneIsOpposite = (startLane->
isInternal()
4715 if (startLaneIsOpposite) {
4717 assert(startLane != 0);
4722 #ifdef DEBUG_BESTLANES
4724 std::cout <<
" only updateOccupancyAndCurrentBestLane\n";
4735 #ifdef DEBUG_BESTLANES
4737 std::cout <<
" nothing to do on internal\n";
4747 std::vector<LaneQ>& lanes = *it;
4748 assert(lanes.size() > 0);
4749 if (&(lanes[0].lane->getEdge()) == nextEdge) {
4751 std::vector<LaneQ> oldLanes = lanes;
4753 const std::vector<MSLane*>& sourceLanes = startLane->
getEdge().
getLanes();
4754 for (std::vector<MSLane*>::const_iterator it_source = sourceLanes.begin(); it_source != sourceLanes.end(); ++it_source) {
4755 for (std::vector<LaneQ>::iterator it_lane = oldLanes.begin(); it_lane != oldLanes.end(); ++it_lane) {
4756 if ((*it_source)->getLinkCont()[0]->getLane() == (*it_lane).lane) {
4757 lanes.push_back(*it_lane);
4764 for (
int i = 0; i < (int)lanes.size(); ++i) {
4765 if (i + lanes[i].bestLaneOffset < 0) {
4766 lanes[i].bestLaneOffset = -i;
4768 if (i + lanes[i].bestLaneOffset >= (
int)lanes.size()) {
4769 lanes[i].bestLaneOffset = (int)lanes.size() - i - 1;
4771 assert(i + lanes[i].bestLaneOffset >= 0);
4772 assert(i + lanes[i].bestLaneOffset < (
int)lanes.size());
4773 if (lanes[i].bestContinuations[0] != 0) {
4775 lanes[i].bestContinuations.insert(lanes[i].bestContinuations.begin(), (
MSLane*)
nullptr);
4777 if (startLane->
getLinkCont()[0]->getLane() == lanes[i].lane) {
4780 assert(&(lanes[i].lane->getEdge()) == nextEdge);
4784 #ifdef DEBUG_BESTLANES
4786 std::cout <<
" updated for internal\n";
4803 const MSLane* nextStopLane =
nullptr;
4804 double nextStopPos = 0;
4807 nextStopLane = nextStop.
lane;
4808 nextStopEdge = nextStop.
edge;
4822 nextStopPos = (*nextStopEdge)->getLength();
4828 double seenLength = 0;
4829 bool progress =
true;
4831 std::vector<LaneQ> currentLanes;
4832 const std::vector<MSLane*>* allowed =
nullptr;
4833 const MSEdge* nextEdge =
nullptr;
4835 nextEdge = *(ce + 1);
4838 const std::vector<MSLane*>& lanes = (*ce)->getLanes();
4839 for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
4847 q.
allowsContinuation = allowed ==
nullptr || std::find(allowed->begin(), allowed->end(), cl) != allowed->end();
4850 currentLanes.push_back(q);
4853 if (nextStopEdge == ce
4860 for (std::vector<LaneQ>::iterator q = currentLanes.begin(); q != currentLanes.end(); ++q) {
4861 if (nextStopLane !=
nullptr && normalStopLane != (*q).lane) {
4862 (*q).allowsContinuation =
false;
4863 (*q).length = nextStopPos;
4864 (*q).currentLength = (*q).length;
4871 seenLength += currentLanes[0].lane->getLength();
4873 progress &= (seen <= 4 || seenLength < 3000);
4874 progress &= (seen <= 8 || seenLength < 200);
4885 double bestLength = -1;
4886 int bestThisIndex = 0;
4889 for (std::vector<LaneQ>::iterator j = last.begin(); j != last.end(); ++j, ++index) {
4890 if ((*j).length > bestLength) {
4891 bestLength = (*j).length;
4892 bestThisIndex = index;
4896 for (std::vector<LaneQ>::iterator j = last.begin(); j != last.end(); ++j, ++index) {
4897 if ((*j).length < bestLength) {
4898 (*j).bestLaneOffset = bestThisIndex - index;
4902 #ifdef DEBUG_BESTLANES
4904 std::cout <<
" last edge:\n";
4906 for (std::vector<LaneQ>::iterator j = laneQs.begin(); j != laneQs.end(); ++j) {
4907 std::cout <<
" lane=" << (*j).lane->getID() <<
" length=" << (*j).length <<
" bestOffset=" << (*j).bestLaneOffset <<
"\n";
4913 for (std::vector<std::vector<LaneQ> >::reverse_iterator i =
myBestLanes.rbegin() + 1; i !=
myBestLanes.rend(); ++i) {
4914 std::vector<LaneQ>& nextLanes = (*(i - 1));
4915 std::vector<LaneQ>& clanes = (*i);
4916 MSEdge& cE = clanes[0].lane->getEdge();
4918 double bestConnectedLength = -1;
4919 double bestLength = -1;
4920 for (std::vector<LaneQ>::iterator j = nextLanes.begin(); j != nextLanes.end(); ++j, ++index) {
4921 if ((*j).lane->isApproachedFrom(&cE) && bestConnectedLength < (*j).length) {
4922 bestConnectedLength = (*j).length;
4924 if (bestLength < (*j).length) {
4925 bestLength = (*j).length;
4929 int bestThisIndex = 0;
4930 if (bestConnectedLength > 0) {
4932 for (std::vector<LaneQ>::iterator j = clanes.begin(); j != clanes.end(); ++j, ++index) {
4933 LaneQ bestConnectedNext;
4934 bestConnectedNext.
length = -1;
4935 if ((*j).allowsContinuation) {
4936 for (std::vector<LaneQ>::const_iterator m = nextLanes.begin(); m != nextLanes.end(); ++m) {
4937 if ((*m).lane->isApproachedFrom(&cE, (*j).lane)) {
4938 if (bestConnectedNext.
length < (*m).length || (bestConnectedNext.
length == (*m).length && abs(bestConnectedNext.
bestLaneOffset) > abs((*m).bestLaneOffset))) {
4939 bestConnectedNext = *m;
4943 if (bestConnectedNext.
length == bestConnectedLength && abs(bestConnectedNext.
bestLaneOffset) < 2) {
4944 (*j).
length += bestLength;
4946 (*j).length += bestConnectedNext.
length;
4951 if (clanes[bestThisIndex].length < (*j).length
4952 || (clanes[bestThisIndex].length == (*j).length && abs(clanes[bestThisIndex].bestLaneOffset) > abs((*j).bestLaneOffset))
4953 || (clanes[bestThisIndex].length == (*j).length && abs(clanes[bestThisIndex].bestLaneOffset) == abs((*j).bestLaneOffset) &&
4956 bestThisIndex = index;
4959 #ifdef DEBUG_BESTLANES
4961 std::cout <<
" edge=" << cE.
getID() <<
"\n";
4962 std::vector<LaneQ>& laneQs = clanes;
4963 for (std::vector<LaneQ>::iterator j = laneQs.begin(); j != laneQs.end(); ++j) {
4964 std::cout <<
" lane=" << (*j).lane->getID() <<
" length=" << (*j).length <<
" bestOffset=" << (*j).bestLaneOffset <<
"\n";
4971 int bestNextIndex = 0;
4972 int bestDistToNeeded = (int) clanes.size();
4974 for (std::vector<LaneQ>::iterator j = clanes.begin(); j != clanes.end(); ++j, ++index) {
4975 if ((*j).allowsContinuation) {
4977 for (std::vector<LaneQ>::const_iterator m = nextLanes.begin(); m != nextLanes.end(); ++m, ++nextIndex) {
4978 if ((*m).lane->isApproachedFrom(&cE, (*j).lane)) {
4979 if (bestDistToNeeded > abs((*m).bestLaneOffset)) {
4980 bestDistToNeeded = abs((*m).bestLaneOffset);
4981 bestThisIndex = index;
4982 bestNextIndex = nextIndex;
4988 clanes[bestThisIndex].length += nextLanes[bestNextIndex].length;
4989 copy(nextLanes[bestNextIndex].bestContinuations.begin(), nextLanes[bestNextIndex].bestContinuations.end(), back_inserter(clanes[bestThisIndex].bestContinuations));
4994 for (std::vector<LaneQ>::iterator j = clanes.begin(); j != clanes.end(); ++j, ++index) {
4995 if ((*j).length < clanes[bestThisIndex].length
4996 || ((*j).length == clanes[bestThisIndex].length && abs((*j).bestLaneOffset) > abs(clanes[bestThisIndex].bestLaneOffset))
4999 (*j).bestLaneOffset = bestThisIndex - index;
5002 (*j).length = (*j).currentLength;
5005 (*j).bestLaneOffset = 0;
5010 #ifdef DEBUG_BESTLANES
5021 if (conts.size() < 2) {
5025 if (link !=
nullptr) {
5037 std::vector<LaneQ>& currLanes = *
myBestLanes.begin();
5038 std::vector<LaneQ>::iterator i;
5039 for (i = currLanes.begin(); i != currLanes.end(); ++i) {
5040 double nextOccupation = 0;
5041 for (std::vector<MSLane*>::const_iterator j = (*i).bestContinuations.begin() + 1; j != (*i).bestContinuations.end(); ++j) {
5042 nextOccupation += (*j)->getBruttoVehLenSum();
5044 (*i).nextOccupation = nextOccupation;
5045 #ifdef DEBUG_BESTLANES
5047 std::cout <<
" lane=" << (*i).lane->getID() <<
" nextOccupation=" << nextOccupation <<
"\n";
5050 if ((*i).lane == startLane) {
5057 const std::vector<MSLane*>&
5062 return (*myCurrentLaneInBestLanes).bestContinuations;
5066 const std::vector<MSLane*>&
5078 if ((*i).lane == lane) {
5079 return (*i).bestContinuations;
5091 return (*myCurrentLaneInBestLanes).bestLaneOffset;
5098 std::vector<MSVehicle::LaneQ>& preb =
myBestLanes.front();
5099 assert(laneIndex < (
int)preb.size());
5100 preb[laneIndex].occupation = density + preb[laneIndex].nextOccupation;
5114 double distance = std::numeric_limits<double>::max();
5115 if (
isOnRoad() && destEdge !=
nullptr) {
5129 std::pair<const MSVehicle* const, double>
5132 return std::make_pair(static_cast<const MSVehicle*>(
nullptr), -1);
5141 MSLane::VehCont::const_iterator it = std::find(vehs.begin(), vehs.end(),
this);
5142 if (it != vehs.end() && it + 1 != vehs.end()) {
5145 if (lead !=
nullptr) {
5146 std::pair<const MSVehicle* const, double> result(
5162 std::pair<const MSVehicle* const, double> leaderInfo =
getLeader(-1);
5163 if (leaderInfo.first ==
nullptr ||
getSpeed() == 0) {
5222 myStops.front().numExpectedPerson -= (int)
myStops.front().pars.awaitedPersons.count(person->
getID());
5229 if (
myStops.size() > 0 &&
myStops.front().reached &&
myStops.front().pars.containerTriggered &&
myStops.front().numExpectedContainer > 0) {
5230 myStops.front().numExpectedContainer -= (int)
myStops.front().pars.awaitedContainers.count(container->
getID());
5240 const bool blinkerManoeuvre = (((state &
LCA_SUBLANE) == 0) && (
5246 std::swap(left, right);
5248 if ((state &
LCA_LEFT) != 0 && blinkerManoeuvre) {
5250 }
else if ((state &
LCA_RIGHT) != 0 && blinkerManoeuvre) {
5262 switch ((*link)->getDirection()) {
5279 &&
myStops.begin()->pars.parking
5293 if (currentTime % 1000 == 0) {
5346 #ifdef DEBUG_FURTHER
5356 for (
int i = 0; i < (int)shadowFurther.size(); ++i) {
5358 if (shadowFurther[i] == lane) {
5381 #ifdef DEBUG_FURTHER
5389 #ifdef DEBUG_FURTHER
5396 for (
int i = 0; i < (int)shadowFurther.size(); ++i) {
5397 if (shadowFurther[i] == lane) {
5398 #ifdef DEBUG_FURTHER
5401 <<
" lane=" << lane->
getID()
5416 MSLane* targetLane = furtherTargets[i];
5417 if (targetLane == lane) {
5420 #ifdef DEBUG_TARGET_LANE
5422 std::cout <<
" getLatOffset veh=" <<
getID()
5428 <<
" targetDir=" << targetDir
5429 <<
" latOffset=" << latOffset
5446 assert(offset == 0 || offset == 1 || offset == -1);
5447 assert(
myLane !=
nullptr);
5452 double leftLimit = halfCurrentLaneWidth - halfVehWidth - latPos;
5453 double rightLimit = -halfCurrentLaneWidth + halfVehWidth - latPos;
5454 double latLaneDist = 0;
5456 if (latPos + halfVehWidth > halfCurrentLaneWidth) {
5458 latLaneDist = halfCurrentLaneWidth - latPos - halfVehWidth;
5459 }
else if (latPos - halfVehWidth < - halfCurrentLaneWidth) {
5461 latLaneDist = halfCurrentLaneWidth - latPos + halfVehWidth;
5463 }
else if (offset == -1) {
5465 }
else if (offset == 1) {
5468 #ifdef DEBUG_ACTIONSTEPS
5471 <<
" veh=" <<
getID()
5472 <<
" halfCurrentLaneWidth=" << halfCurrentLaneWidth
5473 <<
" halfVehWidth=" << halfVehWidth
5474 <<
" latPos=" << latPos
5475 <<
" latLaneDist=" << latLaneDist
5476 <<
" leftLimit=" << leftLimit
5477 <<
" rightLimit=" << rightLimit
5501 if (dpi.myLink !=
nullptr) {
5502 dpi.myLink->removeApproaching(
this);
5522 while (!lane->
isLinkEnd(link) && seen <= dist) {
5525 || !(*link)->havePriority())) {
5529 if ((*di).myLink !=
nullptr) {
5530 const MSLane* diPredLane = (*di).myLink->getLaneBefore();
5531 if (diPredLane !=
nullptr) {
5542 const SUMOTime leaveTime = (*link)->getLeaveTime((*di).myArrivalTime, (*di).myArrivalSpeed,
5544 if ((*link)->hasApproachingFoe((*di).myArrivalTime, leaveTime, (*di).myArrivalSpeed,
getCarFollowModel().getMaxDecel())) {
5551 lane = (*link)->getViaLaneOrLane();
5568 centerLine.push_back(lane->getShape().back());
5597 result.push_back(line1[0]);
5598 result.push_back(line2[0]);
5599 result.push_back(line2[1]);
5600 result.push_back(line1[1]);
5603 result.push_back(line1[1]);
5604 result.push_back(line2[1]);
5605 result.push_back(line2[0]);
5606 result.push_back(line1[0]);
5618 if (&(*i)->getEdge() == edge) {
5635 if (destParkArea ==
nullptr) {
5637 errorMsg =
"Vehicle " +
getID() +
" is not driving to a parking area so it cannot be rerouted.";
5650 if (newParkingArea ==
nullptr) {
5651 errorMsg =
"Parking area ID " +
toString(parkingAreaID) +
" not found in the network.";
5664 if (!newDestination) {
5675 if (edgesFromPark.size() > 0) {
5676 edges.insert(edges.end(), edgesFromPark.begin() + 1, edgesFromPark.end());
5679 if (newDestination) {
5701 const bool parking,
const bool triggered,
const bool containerTriggered, std::string& errorMsg) {
5703 for (std::list<Stop>::iterator iter =
myStops.begin(); iter !=
myStops.end(); iter++) {
5704 if (iter->lane == lane && fabs(iter->pars.endPos - endPos) <
POSITION_EPS) {
5706 if (duration == 0 && until < 0 && !iter->reached) {
5711 iter->duration = duration;
5712 iter->triggered = triggered;
5713 iter->containerTriggered = containerTriggered;
5714 const_cast<SUMOVehicleParameter::Stop&>(iter->pars).until = until;
5715 const_cast<SUMOVehicleParameter::Stop&>(iter->pars).parking = parking;
5725 newStop.
until = until;
5734 if (containerTriggered) {
5740 if (duration >= 0) {
5746 const bool result =
addStop(newStop, errorMsg);
5760 const bool triggered,
const bool containerTriggered,
const SumoXMLTag stoppingPlaceType, std::string& errorMsg) {
5762 for (std::list<Stop>::iterator iter =
myStops.begin(); iter !=
myStops.end(); iter++) {
5763 Named* stop =
nullptr;
5764 switch (stoppingPlaceType) {
5766 stop = iter->busstop;
5769 stop = iter->containerstop;
5772 stop = iter->chargingStation;
5775 stop = iter->parkingarea;
5780 if (stop !=
nullptr && stop->
getID() == stopId) {
5781 if (duration == 0 && !iter->reached) {
5785 iter->duration = duration;
5792 switch (stoppingPlaceType) {
5809 if (bs ==
nullptr) {
5810 errorMsg =
"The " +
toString(stoppingPlaceType) +
" '" + stopId +
"' is not known for vehicle '" +
getID() +
"'";
5814 newStop.
until = until;
5825 if (containerTriggered) {
5831 const bool result =
addStop(newStop, errorMsg);
5850 if (
myStops.front().busstop !=
nullptr) {
5852 myStops.front().busstop->leaveFrom(
this);
5855 if (
myStops.front().containerstop !=
nullptr) {
5857 myStops.front().containerstop->leaveFrom(
this);
5859 if (
myStops.front().parkingarea !=
nullptr) {
5861 myStops.front().parkingarea->leaveFrom(
this);
5866 if (vehroutes !=
nullptr) {
5894 std::list<MSVehicle::Stop>
5972 #ifdef DEBUG_IGNORE_RED
5977 if (ignoreRedTime < 0) {
5979 if (ignoreYellowTime > 0 && link->
haveYellow()) {
5983 return !canBrake || ignoreYellowTime > yellowDuration;
5993 #ifdef DEBUG_IGNORE_RED
5997 <<
" ignoreRedTime=" << ignoreRedTime
5998 <<
" spentRed=" << redDuration
5999 <<
" canBrake=" << canBrake <<
"\n";
6003 return !canBrake || ignoreRedTime > redDuration;
6029 if (veh ==
nullptr) {
6049 assert(logic !=
nullptr);
6052 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
6055 <<
" foeLane=" << foeLane->
getID()
6057 <<
" linkIndex=" << link->
getIndex()
6058 <<
" foeLinkIndex=" << foeLink->
getIndex()
6059 <<
" response=" << response
6060 <<
" response2=" << response2
6068 }
else if (response && response2) {
6074 if (egoET == foeET) {
6078 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
6080 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" equal ET " << egoET <<
" with foe " << veh->
getID()
6081 <<
" foeIsLeaderByID=" << (
getID() < veh->
getID()) <<
"\n";
6086 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
6088 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" equal ET " << egoET <<
" with foe " << veh->
getID()
6098 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
6100 std::cout <<
" egoET=" << egoET <<
" foeET=" << foeET <<
" isLeader=" << (egoET > foeET) <<
"\n";
6103 return egoET > foeET;
6119 std::vector<std::string> internals;
6130 for (std::list<Stop>::const_iterator it =
myStops.begin(); it !=
myStops.end(); ++it) {
6135 dev->saveState(out);
6143 throw ProcessError(
"Error: Invalid vehicles in state (may be a meso state)!");
6174 lastPos += (*myCurrEdge)->getLength();
6177 const double endPos = stop.getEndPos(*
this);
6178 const MSEdge*
const stopEdge = &stop.lane->getEdge();
6180 const std::string prefix =
"Stop " +
toString(i) +
" on edge '" + stopEdge->
getID() +
"' ";
6187 if (it2 == stop.edge) {
6192 WRITE_ERROR(prefix +
"used invalid route index " + err);
6194 }
else if (it2 < start) {
6198 if (it != stop.edge && endPos >= lastPos) {
6211 std::shared_ptr<MSSimpleDriverState>
6265 return (myManoeuvreAngle);
6270 return (myManoeuvreType);
6286 myManoeuvreType = mType;
6299 myManoeuvreVehicleID = veh->
getID();
6303 myManoeuvreStartTime = currentTime;
6307 std::cout <<
"ENTRY manoeuvre start: vehicle=" << veh->
getID() <<
" Angle=" << myManoeuvreAngle <<
" currentTime=" << currentTime <<
6308 " endTime=" << myManoeuvreCompleteTime <<
" manoeuvre time=" << myManoeuvreCompleteTime - currentTime <<
" parkArea=" << myManoeuvreStop << std::endl;
6331 myManoeuvreVehicleID = veh->
getID();
6334 myManoeuvreStartTime = currentTime;
6342 std::cout <<
"EXIT manoeuvre start: vehicle=" << veh->
getID() <<
" Angle=" << myManoeuvreAngle <<
" currentTime=" << currentTime
6343 <<
" endTime=" << myManoeuvreCompleteTime <<
" manoeuvre time=" << myManoeuvreCompleteTime - currentTime <<
" parkArea=" << myManoeuvreStop << std::endl;
6360 if (configureEntryManoeuvre(veh)) {
6379 if (checkType != myManoeuvreType) {
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
The car-following model and parameter.
double processNextStop(double currentVelocity)
Processes stops, returns the velocity needed to reach the stop.
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...
const MSLane & getLane() const
Returns the lane this stop is located at.
static void cleanup()
Static cleanup.
void updateBestLanes(bool forceRebuild=false, const MSLane *startLane=0)
computes the best lanes to use in order to continue the route
std::set< std::string > awaitedPersons
IDs of persons the vehicle has to wait for until departing.
vehicle want's to change to right lane
bool hasFoes() const
Returns whether this link belongs to a junction where more than one edge is incoming.
bool boardAnyWaiting(MSEdge *edge, SUMOVehicle *vehicle, const SUMOVehicleParameter::Stop &stop, SUMOTime &timeToBoardNextPerson, SUMOTime &stopDuration)
board any applicable persons Boards any people who wait on that edge for the given vehicle and remove...
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.
The vehicle changes lanes (micro only)
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)
SUMOEmissionClass getEmissionClass() const
Get this vehicle type's emission class.
LinkDirection getDirection() const
Returns the direction the vehicle passing this link take.
double getLateralShift()
return lateral shift that must be applied when passing this link
bool isRoundabout() const
bool isConflictEntryLink() const
return whether this link enters the conflict area (not a continuation link)
double getSpeedWithoutTraciInfluence() const
Returns the uninfluenced velocity.
const std::vector< MSTransportable * > & getTransportables() const
Returns the list of transportables using this vehicle.
SUMOTime collisionStopTime() const
Returns the remaining time a vehicle needs to stop due to a collision. A negative value indicates tha...
Left blinker lights are switched on.
int bestLaneOffset
The (signed) number of lanes to be crossed to get to the lane which allows to continue the drive.
bool havePriority() const
Returns whether this link is a major link.
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
void setApproaching(const SUMOVehicle *approaching, const SUMOTime arrivalTime, const double arrivalSpeed, const double leaveSpeed, const bool setRequest, const SUMOTime arrivalTimeBraking, const double arrivalSpeedBraking, const SUMOTime waitingTime, double dist)
Sets the information about an approaching vehicle.
MSStoppingPlace * busstop
(Optional) bus stop if one is assigned to the stop
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const int rngIndex, const MSEdgeVector &prohibited=MSEdgeVector()) const
void release() const
deletes the route if there are no further references to it
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
The arrival position is given.
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
double brakeGap(const double speed) const
Returns the distance the vehicle needs to halt including driver's reaction time tau (i....
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
const std::string & getID() const
Returns the name of the vehicle type.
int getBestLaneOffset() const
double getPreviousSpeed() const
Returns the vehicle's speed before the previous time step.
SUMOTime getLastAccessTimeStep() const
#define STOPPING_PLACE_OFFSET
void registerOneWaiting(const bool isPerson)
increases the count of vehicles waiting for a transport to allow recognition of person / container re...
bool hasDeparted() const
Returns whether this vehicle has already departed.
This is an uncontrolled, right-before-left link.
A lane area vehicles can halt at.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
double getMaxAccel() const
Get the vehicle type's maximum acceleration [m/s^2].
ManoeuvreType
flag identifying which, if any, manoeuvre is in progress
bool haveValidStopEdges() const
check whether all stop.edge MSRouteIterators are valid and in order
bool hasArrived() const
Returns whether this vehicle has already arived (reached the arrivalPosition on its final edge)
int numExpectedPerson
The number of still expected persons.
bool myAmRegisteredAsWaitingForPerson
Whether this vehicle is registered as waiting for a person (for deadlock-recognition)
MSLane * getViaLaneOrLane() const
return the via lane if it exists and the lane otherwise
const std::set< MSTransportable * > & getPersons() const
Returns this edge's persons set.
LinkState getState() const
Returns the current state of the link.
virtual double getArrivalPos() const
Returns this vehicle's desired arrivalPos for its current route (may change on reroute)
A lane area vehicles can halt at.
Changes the wished vehicle speed / lanes.
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
public emergency vehicles
std::vector< MSLane * > myFurtherLanes
The information into which lanes the vehicle laps into.
double myStopDist
distance to the next stop or doubleMax if there is none
void setNoShadowPartialOccupator(MSLane *lane)
void enter(SUMOVehicle *what, double beg, double end)
Called if a vehicle enters this stop.
double influenceSpeed(SUMOTime currentTime, double speed, double vSafe, double vMin, double vMax)
Applies stored velocity information on the speed to use.
#define WRITE_WARNING(msg)
bool hasContainers() const
Returns whether containers are simulated.
bool reached
Information whether the stop has been reached.
std::list< Stop > getMyStops()
const std::vector< LaneQ > & getBestLanes() const
Returns the description of best lanes to use in order to continue the route.
int getContainerNumber() const
Returns the number of containers.
bool enterLaneAtMove(MSLane *enteredLane, bool onTeleporting=false)
Update when the vehicle enters a new lane in the move step.
Representation of a lane in the micro simulation.
bool isStopped() const
Returns whether the vehicle is at a stop.
Base class for objects which have an id.
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle's end speed shall be chosen.
bool wasRemoteControlled(SUMOTime lookBack=DELTA_T) const
Returns the information whether the vehicle is fully controlled via TraCI within the lookBack time.
bool isLinkEnd(MSLinkCont::const_iterator &i) const
bool isVaporizing() const
Returns whether vehicles on this edge shall be vaporized.
SUMOTime myCollisionImmunity
amount of time for which the vehicle is immune from collisions
MSParkingArea * parkingarea
(Optional) parkingArea if one is assigned to the stop
bool executeMove()
Executes planned vehicle movements with regards to right-of-way.
SUMOTime getLastStateChange() const
void addWaiting(SUMOVehicle *vehicle) const
Adds a vehicle to the list of waiting vehicles.
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
bool lastWasContMajor() const
whether this is a link past an internal junction which currently has priority
std::string lane
The lane to stop at.
bool isVehicleSpecific() const
Returns whether this type belongs to a single vehicle only (was modified)
void remove(MSVehicle *veh)
Remove a vehicle from this transfer object.
DriveItemVector myLFLinkLanesPrev
planned speeds from the previous step for un-registering from junctions after the new container is fi...
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
The arrival lane is given.
bool isRemoteControlled() const
Returns the information whether the vehicle is fully controlled via TraCI.
void removeVType(const MSVehicleType *vehType)
MSVehicle * getLastAnyVehicle() const
returns the last vehicle that is fully or partially on this lane
SUMOTime duration
The stopping duration.
double getEndLanePosition() const
Returns the end position of this stop.
std::shared_ptr< MSSimpleDriverState > getDriverState() const
return internal state
Static storage of an output device and its base (abstract) implementation.
LaneChangeMode mySpeedGainLC
lane changing to travel with higher speed
virtual double maxNextSpeed(double speed, const MSVehicle *const veh) const
Returns the maximum speed given the current speed.
void removeVehicleStateListener(VehicleStateListener *listener)
Removes a vehicle states listener.
SUMOTime myDeparture
The real departure time.
int mySignals
State of things of the vehicle that can be on or off.
Right blinker lights are switched on.
int influenceChangeDecision(int state)
allow TraCI to influence a lane change decision
MSRouteIterator end() const
Returns the end of the list of edges to pass.
SUMOVehicleShape getGuiShape() const
Get this vehicle type's shape.
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 hasInfluencer() const
vehicle want's to keep the current lane
ConstMSEdgeVector::const_iterator MSRouteIterator
void passTime(SUMOTime dt, bool waiting)
void updateOccupancyAndCurrentBestLane(const MSLane *startLane)
updates LaneQ::nextOccupation and myCurrentLaneInBestLanes
static const Position INVALID
used to indicate that a position is valid
static MSStopOut * getInstance()
double departSpeed
(optional) The initial speed of the vehicle
double getLatOffset(const MSLane *lane) const
Get the offset that that must be added to interpret myState.myPosLat for the given lane.
const MSEdge * myLastBestLanesEdge
bool operator!=(const State &state)
Operator !=.
PositionVector getBoundingBox() const
get bounding rectangle
double length
The overall length which may be driven when using this lane without a lane change.
virtual MSTransportableControl & getContainerControl()
Returns the container control.
std::vector< MSVehicleDevice * > myDevices
The devices this vehicle has.
void informVehicleStateListener(const SUMOVehicle *const vehicle, VehicleState to, const std::string &info="")
Informs all added listeners about a vehicle's state change.
bool isExitLink() const
return whether the fromLane of this link is an internal lane and toLane is a normal lane
double myBackPos
the stored back position
Interface for objects listening to vehicle state changes.
double getBrakeGap() const
get distance for coming to a stop (used for rerouting checks)
bool isFringe() const
return whether this edge is at the fringe of the network
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
static const double ZIPPER_ADAPT_DIST
const MSLeaderInfo getLastVehicleInformation(const MSVehicle *ego, double latOffset, double minPos=0, bool allowCached=true) const
Returns the last vehicles on the lane.
int getManoeuvreAngle() const
Accessor for manoeuvre angle.
The simulated network and simulation perfomer.
double getApparentDecel() const
Get the vehicle type's apparent deceleration [m/s^2] (the one regarded by its followers.
const Position getBackPosition() const
bool operator!=(const Manoeuvre &manoeuvre)
Operator !=.
The link is a partial right direction.
Manoeuvre & operator=(const Manoeuvre &manoeuvre)
Assignment operator.
double getBeginLanePosition() const
Returns the begin position of this stop.
TraciLaneChangePriority myTraciLaneChangePriority
flags for determining the priority of traci lane change requests
SUMOTime getMinimalArrivalTime(double dist, double currentSpeed, double arrivalSpeed) const
Computes the minimal time needed to cover a distance given the desired speed at arrival.
#define JUNCTION_BLOCKAGE_TIME
std::vector< const SUMOVehicle * > BlockingFoes
std::string busstop
(Optional) bus stop if one is assigned to the stop
static MSLink * getConnectingLink(const MSLane &from, const MSLane &to)
Returns the link connecting both lanes Both lanes have to be non-internal; 0 may be returned if no co...
void setLaneTimeLine(const std::vector< std::pair< SUMOTime, int > > &laneTimeLine)
Sets a new lane timeline.
int parametersSet
Information for the output which parameter were set.
bool addTraciStopAtStoppingPlace(const std::string &stopId, const SUMOTime duration, const SUMOTime until, const bool parking, const bool triggered, const bool containerTriggered, const SumoXMLTag stoppingPlaceType, std::string &errorMsg)
bool isParking() const
Returns whether the vehicle is parking.
double getBackPositionOnLane() const
Get the vehicle's position relative to its current lane.
double getRightSideOnEdge() const
bool warnOnce(const std::string &typeAndID)
return whether a warning regarding the given object shall be issued
double getLength() const
Returns the vehicle's length.
No information given; use default.
static MSLinkCont::const_iterator succLinkSec(const SUMOVehicle &veh, int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane * > &conts)
const MSEdge * getLastEdge() const
returns the destination edge
SUMOTime getDeparture() const
Returns this vehicle's real departure time.
Container that holds the vehicles driving state (position+speed).
SUMOTime getActionStepLength() const
Returns the vehicle's action step length in millisecs, i.e. the interval between two action points.
bool stopsAt(MSStoppingPlace *stop) const
Returns whether the vehicle stops at the given stopping place.
void addPerson(MSTransportable *person)
Adds a passenger.
A structure representing the best lanes for continuing the current route starting at 'lane'.
vehicle want's to change to left lane
static void init()
Static initalization.
Representation of a vehicle.
std::vector< MSVehicle * > VehCont
Container for vehicles.
double getMinimalArrivalSpeed(double dist, double currentSpeed) const
Computes the minimal possible arrival speed after covering a given distance.
static double naviDegree(const double angle)
const MSRoute * myRoute
This vehicle's route.
const MSRoute & getRoute() const
Returns the current route.
bool resumeFromStopping()
void scaleRelative(double factor)
enlarges/shrinks the polygon by a factor based at the centroid
double mySpeed
the stored speed (should be >=0 at any time)
double slopeDegreeAtOffset(double pos) const
Returns the slope at the given length.
State(double pos, double speed, double posLat, double backPos)
Constructor.
std::vector< const MSEdge * > ConstMSEdgeVector
ManoeuvreType myManoeuvreType
Manoeuvre type - currently entry, exit or none.
double speed() const
Speed of this state.
bool keepStopping(bool afterProcessing=false) const
Returns whether the vehicle is stopped and must continue to do so.
void replaceParameter(const SUMOVehicleParameter *newParameter)
replace the vehicle parameter (deleting the old one)
void updateActionOffset(const SUMOTime oldActionStepLength, const SUMOTime newActionStepLength)
Process an updated action step length value (only affects the vehicle's action offset,...
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,.
static int nextLinkPriority(const std::vector< MSLane * > &conts)
get a numerical value for the priority of the upcoming link
The action is due to the wish to be faster (tactical lc)
double myOriginalSpeed
The velocity before influence.
void adaptLaneTimeLine(int indexShift)
Adapts lane timeline when moving to a new lane and the lane index changes.
int myArrivalLane
The destination lane where the vehicle stops.
WaitingTimeCollector myWaitingTimeCollector
void vehicleStateChanged(const SUMOVehicle *const vehicle, MSNet::VehicleState to, const std::string &info="")
Called if a vehicle changes its state.
double getTimeGapOnLane() const
Returns the time gap in seconds to the leader of the vehicle on the same lane.
void resetChanged()
reset the flag whether a vehicle already moved to false
std::string line
the new line id of the trip within a cyclical public transport route
bool addStop(const SUMOVehicleParameter::Stop &stopPar, std::string &errorMsg, SUMOTime untilOffset=0, bool collision=false, MSRouteIterator *searchStart=0)
Adds a stop.
The action is urgent (to be defined by lc-model)
bool isStoppedOnLane() const
std::string getDescription() const
get a short description for showing in the gui
bool hasPersons() const
Returns whether persons are simulated.
const double SUMO_const_laneWidth
void onRemovalFromNet(const MSMoveReminder::Notification reason)
Called when the vehicle is removed from the network.
void removeTransportable(MSTransportable *p)
Removes a transportable from this stop.
bool considerSafeVelocity() const
Returns whether safe velocities shall be considered.
bool collision
Whether this stop was triggered by a collision.
const ConstMSEdgeVector & getEdges() const
std::vector< DriveProcessItem > DriveItemVector
Container for used Links/visited Lanes during planMove() and executeMove.
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.
void setManoeuvreType(const MSVehicle::ManoeuvreType mType)
accessor function to myManoeuvre equivalent
LaneChangeMode myStrategicLC
lane changing which is necessary to follow the current route
std::string parkingarea
(Optional) parking area if one is assigned to the stop
bool myConsiderMaxAcceleration
Whether the maximum acceleration shall be regarded.
Structure representing possible vehicle parameter.
double myPreviousSpeed
the speed at the begin of the previous time step
bool myHaveToWaitOnNextLink
double getHarmonoise_NoiseEmissions() const
Returns noise emissions of the current state.
LinkDirection
The different directions a link between two lanes may take (or a stream between two edges)....
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
virtual double getFloat(int id) const =0
Returns the double-value of the named (by its enum-value) attribute.
bool myConsiderSafeVelocity
Whether the safe velocity shall be regarded.
Container for manouevering time associated with stopping.
MSLink * getParallelLink(int direction) const
return the link that is parallel to this lane or 0
int myRoutingMode
routing mode (see TraCIConstants.h)
DriveItemVector myLFLinkLanes
container for the planned speeds in the current step
static CollisionAction getCollisionAction()
The vehicle arrived at his destination (is deleted)
The vehicle was teleported out of the net.
static SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const int rngIndex, const MSEdgeVector &prohibited=MSEdgeVector())
return the router instance
double getLength() const
return the length of the edge
MSLane * getBidiLane() const
retrieve bidirectional lane or nullptr
virtual int addLeader(const MSVehicle *veh, bool beyond, double latOffset=0)
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 getSafeFollowSpeed(const std::pair< const MSVehicle *, double > leaderInfo, const double seen, const MSLane *const lane, double distToCrossing) const
compute safe speed for following the given leader
The link has no direction (is a dead end link)
bool triggered
whether an arriving person lets the vehicle continue
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
std::pair< double, LinkDirection > myNextTurn
the upcoming turn for the vehicle
The vehicle got a new route.
const MSLane * getBackLane() const
double getSlope() const
Returns the slope of the road at vehicle's position.
int getIndex() const
Returns the respond index (for visualization)
The ToC Device controls transition of control between automated and manual driving.
Signalling
Some boolean values which describe the state of some vehicle parts.
virtual void setHeadwayTime(double headwayTime)
Sets a new value for desired headway [s].
bool manoeuvreIsComplete(const ManoeuvreType checkType) const
Check if specific manoeuver is ongoing and whether the completion time is beyond currentTime.
LaneChangeMode myCooperativeLC
lane changing with the intent to help other vehicles
std::vector< double > myFurtherLanesPosLat
lateral positions on further lanes
SumoXMLTag
Numbers representing SUMO-XML - element names.
bool loadAnyWaiting(MSEdge *edge, SUMOVehicle *vehicle, const SUMOVehicleParameter::Stop &stop, SUMOTime &timeToLoadNextContainer, SUMOTime &stopDuration)
load any applicable containers Loads any container that is waiting on that edge for the given vehicle...
bool isEntryLink() const
return whether the toLane of this link is an internal lane and fromLane is a normal lane
MSLane * updateTargetLane()
bool getEmergencyBrakeRedLight() const
Returns whether red lights shall be a reason to brake.
A storage for edge travel times and efforts.
bool isChangingLanes() const
return true if the vehicle currently performs a lane change maneuver
void planMoveInternal(const SUMOTime t, MSLeaderInfo ahead, DriveItemVector &lfLinks, double &myStopDist, std::pair< double, LinkDirection > &myNextTurn) const
double getMaxSpeed() const
Returns the maximum speed.
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
virtual bool isSelected() const
whether this vehicle is selected in the GUI
static double gEmergencyDecelWarningThreshold
treshold for warning about strong deceleration
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
The vehicle had to brake harder than permitted.
void removeApproachingInformation(const DriveItemVector &lfLinks) const
unregister approach from all upcoming links
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
void calculateArrivalParams()
(Re-)Calculates the arrival position and lane from the vehicle parameters
static double gLateralResolution
render as a sedan passenger vehicle ("Stufenheck")
The vehicle got vaporized.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
SUMOTime timeToBoardNextPerson
The time at which the vehicle is able to board another person.
double getOriginalSpeed() const
Returns the originally longitudinal speed to use.
const SUMOVehicleParameter * myParameter
This vehicle's parameter.
double myArrivalPos
The position on the destination lane where the vehicle stops.
The vehicle needs another parking area.
static MSVehicleTransfer * getInstance()
Returns the instance of this object.
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
int getVehicleNumber() const
Returns the number of vehicles on this lane (for which this lane is responsible)
void adaptLaneEntering2MoveReminder(const MSLane &enteredLane)
Adapts the vehicle's entering of a new lane.
vehicle doesn't want to change
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
void saveState(OutputDevice &out)
Saves the states of a vehicle.
bool stopsAtEdge(const MSEdge *edge) const
Returns whether the vehicle stops at the given edge.
void removePassedDriveItems()
Erase passed drive items from myLFLinkLanes (and unregister approaching information for corresponding...
The vehicle is blocked being overlapping.
The link is a (hard) right direction.
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 isInternal() const
return whether this edge is an internal edge
LaneChangeMode
modes for resolving conflicts between external control (traci) and vehicle control over lane changing...
double getWidth() const
Returns the edges's width (sum over all lanes)
void write(OutputDevice &dev) const
Write the current stop configuration (used for state saving)
void removeShadowApproachingInformation() const
void switchOffSignal(int signal)
Switches the given signal off.
void fixPosition()
repair errors in vehicle position after changing between internal edges
void switchOnSignal(int signal)
Switches the given signal on.
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
entry for an alternative parking zone
double getBruttoVehLenSum() const
Returns the sum of lengths of vehicles, including their minGaps, which were on the lane during the la...
const waitingIntervalList & getWaitingIntervals() const
void registerEmergencyStop()
register emergency stop
The link is a 180 degree turn.
void addContainer(MSTransportable *container)
Adds a container.
int getSpeedMode() const
return the current speed mode
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
static SUMOTime processActionStepLength(double given)
Checks and converts given value for the action step length from seconds to miliseconds assuring it be...
void checkCollisionForInactive(MSLane *l)
trigger collision checking for inactive lane
const MSJunction * getFromJunction() const
void getSubLanes(const MSVehicle *veh, double latOffset, int &rightmost, int &leftmost) const
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic,...
std::string myManoeuvreStop
The name of the stop associated with the Manoeuvre - for debug output.
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.
double getPMxEmissions() const
Returns PMx emission of the current state.
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
virtual void saveState(OutputDevice &out)
Saves the (common) state of a vehicle.
virtual double freeSpeed(const MSVehicle *const veh, double speed, double seen, double maxSpeed, const bool onInsertion=false) const
Computes the vehicle's safe speed without a leader.
The link is a straight direction.
bool myAmOnNet
Whether the vehicle is on the network (not parking, teleported, vaporized, or arrived)
void setBlinkerInformation()
sets the blue flashing light for emergency vehicles
MSDevice_Transportable * myPersonDevice
The passengers this vehicle may have.
double getCurrentApparentDecel() const
get apparent deceleration based on vType parameters and current acceleration
MSLane * getLane() const
Returns the connected lane.
LaneChangeMode myRightDriveLC
changing to the rightmost lane
bool mySpeedAdaptationStarted
Whether influencing the speed has already started.
std::string tripId
id of the trip within a cyclical public transport route
double getSpaceTillLastStanding(const MSLane *l, bool &foundStopped) const
The vehicles starts to park.
double implicitSpeedRemote(const MSVehicle *veh, double oldSpeed)
return the speed that is implicit in the new remote position
std::pair< const MSPerson *, double > PersonDist
bool manoeuvreIsComplete() const
accessor function to myManoeuvre equivalent
The action is needed to follow the route (navigational lc)
static std::vector< MSLane * > myEmptyLaneVector
static double computeNoise(SUMOEmissionClass c, double v, double a)
Returns the noise produced by the a vehicle of the given type at the given speed.
double getPositionOnLane() const
Get the vehicle's position along the lane.
virtual void clear()
discard all information
std::pair< const MSVehicle *const, double > getLeader(double dist=0) const
Returns the leader of the vehicle looking for a fixed distance.
std::shared_ptr< MSSimpleDriverState > getDriverState() const
Returns the vehicle driver's state.
const MSCFModel & getCarFollowModel() const
Returns the vehicle type's car following model definition (const version)
bool keepClear(const MSLink *link) const
decide whether the given link must be kept clear
ArrivalLaneDefinition arrivalLaneProcedure
Information how the vehicle shall choose the lane to arrive on.
double getImpatience() const
Returns this vehicles impatience.
SUMOTime remainingStopDuration() const
Returns the remaining stop duration for a stopped vehicle or 0.
SUMOTime myJunctionEntryTime
time at which the current junction was entered
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
virtual std::string toString() const
print a debugging representation
classes which drive on tracks
VehicleState
Definition of a vehicle state.
int getVehicleNumberWithPartials() const
Returns the number of vehicles on this lane (including partial occupators)
TraciLaneChangePriority
modes for prioritizing traci lane change requests
const std::vector< MSMoveReminder * > & getMoveReminders() const
Return the list of this lane's move reminders.
double getStopOffset(const MSVehicle *veh) const
Returns vehicle class specific stopOffset for the vehicle.
MSLane * getShadowLane() const
Returns the lane the vehicle's shadow is on during continuous/sublane lane change.
double getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
bool lefthand() const
return whether the network was built for lefthand traffic
double processTraCISpeedControl(double vSafe, double vNext)
Check for speed advices from the traci client and adjust the speed vNext in the current (euler) / aft...
virtual void addPerson(MSTransportable *person)
Adds a person to this vehicle.
virtual void prepareStep()
double getCOEmissions() const
Returns CO emission of the current state.
SUMOTime until
The time at which the vehicle may continue its journey.
virtual const MSLogicJunction::LinkBits & getResponseFor(int linkIndex) const
Returns the response for the given link.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
static MSAbstractLaneChangeModel * build(LaneChangeModel lcm, MSVehicle &vehicle)
Factory method for instantiating new lane changing models.
void postProcessRemoteControl(MSVehicle *v)
MSJunction * getJunction() const
int getCapacity() const
Returns the area capacity.
MSEdgeWeightsStorage & _getWeightsStorage() const
double maximumSafeStopSpeed(double gap, double currentSpeed, bool onInsertion=false, double headway=-1) const
Returns the maximum next velocity for stopping within gap.
#define SOFT_ASSERT(expr)
define SOFT_ASSERT raise an assertion in debug mode everywhere except on the windows test server
static void clear()
Clears the dictionary.
bool hasDriverState() const
Whether this vehicle is equipped with a MSDriverState.
bool configureEntryManoeuvre(MSVehicle *veh)
Setup the entry manoeuvre for this vehicle (Sets completion time and manoeuvre type)
void setSpeedTimeLine(const std::vector< std::pair< SUMOTime, double > > &speedTimeLine)
Sets a new velocity timeline.
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
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 SUMOVehicle *ego=nullptr) const
Returns the information whether the link may be passed.
SUMOTime myJunctionConflictEntryTime
std::string id
The vehicle's id.
double currentLength
The length which may be driven on this lane.
double myDepartPos
The real depart position.
const MSLane * getInternalLaneBefore() const
return myInternalLaneBefore (always 0 when compiled without internal lanes)
SUMOTime myWaitingTime
The time the vehicle waits (is not faster than 0.1m/s) in seconds.
bool canReverse(double speedThreshold=SUMO_const_haltingSpeed) const
whether the vehicle is a train that can reverse its direction at the current point in its route
double interpolateLanePosToGeometryPos(double lanePos) const
This is an uncontrolled, zipper-merge link.
std::vector< LinkLeader > LinkLeaders
double getLength() const
Returns the lane's length.
PositionVector getBoundingPoly() const
get bounding polygon
MSCFModel::VehicleVariables * myCFVariables
The per vehicle variables of the car following model.
double myLatDist
The requested lateral change.
void setActionStepLength(const SUMOTime actionStepLength, bool resetActionOffset)
Set a new value for this type's action step length.
void updateDriveItems()
Check whether the drive items (myLFLinkLanes) are up to date, and update them if required.
void addVehicleStateListener(VehicleStateListener *listener)
Adds a vehicle states listener.
double getOppositePos(double pos) const
return the corresponding position on the opposite lane
double arrivalPos
(optional) The position the vehicle shall arrive on
double myPosLat
the stored lateral position
SUMOTime endBoarding
the maximum time at which persons may board this vehicle
void setSublaneChange(double latDist)
Sets a new sublane-change request.
render as a hatchback passenger vehicle ("Fliessheck")
MSAbstractLaneChangeModel & getLaneChangeModel()
void setShadowApproachingInformation(MSLink *link) const
set approach information for the shadow vehicle
std::pair< MSVehicle *const, double > getOppositeLeader(const MSVehicle *ego, double dist, bool oppositeDir) const
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 ...
bool isRailway(SVCPermissions permissions)
Returns whether an edge with the given permission is a railway edge.
The vehicle started to teleport.
bool ignoreRed(const MSLink *link, bool canBrake) const
decide whether a red (or yellow light) may be ignore
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
std::vector< std::vector< LaneQ > > myBestLanes
std::vector< LaneQ >::iterator myCurrentLaneInBestLanes
static bool gModelParkingManoeuver
whether parking simulation includes manoeuver time and any associated lane blocking
A point in 2D or 3D with translation and scaling methods.
MSLane * lane
The described lane.
static GapControlVehStateListener vehStateListener
double getEndPos(const SUMOVehicle &veh) const
return halting position for upcoming stop;
double getHCEmissions() const
Returns HC emission of the current state.
bool manoeuvreIsComplete() const
Check if any manoeuver is ongoing and whether the completion time is beyond currentTime.
MSStoppingPlace * containerstop
(Optional) container stop if one is assigned to the stop
virtual const MSJunctionLogic * getLogic() const
std::string time2string(SUMOTime t)
The vehicles starts to stop.
void append(const PositionVector &v, double sameThreshold=2.0)
const MSLane * myLastBestLanesInternalLane
std::vector< std::pair< int, double > > getStopIndices() const
return list of route indices for the remaining stops
const MSLane * lane
The lane to stop at.
const MSEdge * getBidiEdge() const
return opposite superposable/congruent edge, if it exist and 0 else
const MSEdge * getNextNormal() const
Returns the lane's follower if it is an internal lane, the edge of the lane otherwise.
double getMinGap() const
Get the free space in front of vehicles of this class.
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
std::list< Stop > myStops
The vehicle's list of stops.
A road/street connecting two junctions.
const std::vector< MSLane * > & getShadowFurtherLanes() const
void update()
update internal state
MSRouteIterator edge
The edge in the route to stop at.
LaneChangeModel getLaneChangeModel() const
used by the sublane model
double endPos
The stopping position end.
double occupation
The overall vehicle sum on consecutive lanes which can be passed without a lane change.
bool allowsContinuation
Whether this lane allows to continue the drive.
The link is a (hard) left direction.
void workOnMoveReminders(double oldPos, double newPos, double newSpeed)
Processes active move reminder.
const MSEdge * getRerouteOrigin() const
Returns the starting point for reroutes (usually the current edge)
double getNOxEmissions() const
Returns NOx emission of the current state.
const MSJunction * getToJunction() const
bool isLeader(const MSLink *link, const MSVehicle *veh) const
whether the given vehicle must be followed at the given junction
SUMOTime myLastActionTime
Action offset (actions are taken at time myActionOffset + N*getActionStepLength()) Initialized to 0,...
MSLane * myLane
The lane the vehicle is on.
bool isStoppedInRange(const double pos, const double tolerance) const
return whether the given position is within range of the current stop
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
void loadState(const SUMOSAXAttributes &attrs, const SUMOTime offset)
Loads the state of this vehicle from the given description.
MSEdgeWeightsStorage * myEdgeWeights
bool myEmergencyBrakeRedLight
Whether red lights are a reason to brake.
The vehicle has departed (was inserted into the network)
const std::vector< MSLane * > * allowedLanes(const MSEdge &destination, SUMOVehicleClass vclass=SVC_IGNORING) const
Get the allowed lanes to reach the destination-edge.
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
double getAccumulatedWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s) within the last millisecs.
double getManeuverDist() const
Returns the remaining unblocked distance for the current maneuver. (only used by sublane model)
std::shared_ptr< GapControlState > myGapControlState
The gap control state.
void removeApproaching(const SUMOVehicle *veh)
removes the vehicle from myApproachingVehicles
double pos() const
Position of this state.
Manoeuvre out of stopping place.
SUMOTime myJunctionEntryTimeNeverYield
LaneChangeMode mySublaneLC
changing to the prefered lateral alignment
static void init()
Static initalization (adds vehicle state listener)
#define NUMERICAL_EPS_SPEED
bool myConsiderMaxDeceleration
Whether the maximum deceleration shall be regarded.
void setRemoteState(Position xyPos)
sets position outside the road network
bool replaceRouteEdges(ConstMSEdgeVector &edges, double cost, double savings, const std::string &info, bool onInit=false, bool check=false, bool removeStops=true)
Replaces the current route by the given edges.
SUMOTime getEntryManoeuvreTime(const int angle) const
Accessor function for parameter equivalent returning entry time for a specific manoeuver angle.
Position myCachedPosition
bool allowsVehicleClass(SUMOVehicleClass vclass) const
bool myAmRegisteredAsWaitingForContainer
Whether this vehicle is registered as waiting for a container (for deadlock-recognition)
double basePos(const MSEdge *edge) const
departure position where the vehicle fits fully onto the edge (if possible)
void setAngle(double angle, bool straightenFurther=false)
Set a custom vehicle angle in rad, optionally updates furtherLanePosLat.
void enter(SUMOVehicle *what, double beg, double end)
Called if a vehicle enters this stop.
const SUMOVehicleParameter::Stop pars
The stop parameter.
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
MSLane * getOpposite() const
return the opposite direction lane for lane changing or 0
bool isRemoteControlled() const
static std::map< const MSVehicle *, GapControlState * > refVehMap
stores reference vehicles currently in use by a gapController
SUMOTime cumulatedWaitingTime(SUMOTime memory=-1) const
virtual PersonDist nextBlocking(const MSLane *lane, double minPos, double minRight, double maxLeft, double stopTime=0)
returns the next pedestrian beyond minPos that is laterally between minRight and maxLeft or 0
void activateReminders(const MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
"Activates" all current move reminder
double myAngle
the angle in radians (
Definition of vehicle stop (position and duration)
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
double startPos
The stopping position start.
int myNumberReroutes
The number of reroutings.
MSLane * getLane() const
Returns the lane the vehicle is on.
bool isInternalJunctionLink() const
return whether the fromLane and the toLane of this link are internal lanes
const ConstMSEdgeVector getStopEdges(double &firstPos, double &lastPos) const
Returns the list of still pending stop edges also returns the first and last stop position.
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position
MSEdge & getEdge() const
Returns the lane's edge.
A blue emergency light is on.
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
double getCenterOnEdge() const
bool haveRed() const
Returns whether this link is blocked by a red (or redyellow) traffic light.
void setBrakingSignals(double vNext)
sets the braking lights on/off
void processLaneAdvances(std::vector< MSLane * > &passedLanes, bool &moved, std::string &emergencyReason)
This method checks if the vehicle has advanced over one or several lanes along its route and triggers...
void addStops(const bool ignoreStopErrors)
Adds stops to the built vehicle.
bool willStop() const
Returns whether the vehicle will stop on the current edge.
void stopEnded(const SUMOVehicleParameter::Stop &stop)
MSStoppingPlace * chargingStation
(Optional) charging station if one is assigned to the stop
Influencer & getInfluencer()
Returns the velocity/lane influencer.
void adaptBestLanesOccupation(int laneIndex, double density)
update occupation from MSLaneChanger
double myPos
the stored position
SUMOTime getMemorySize() const
State myState
This Vehicles driving state (pos and speed)
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
double implicitDeltaPosRemote(const MSVehicle *veh)
return the change in longitudinal position that is implicit in the new remote position
bool myActionStep
The flag myActionStep indicates whether the current time step is an action point for the vehicle.
Vehicle maneuvering either entering or exiting a parking space.
int numExpectedContainer
The number of still expected containers.
double myAcceleration
The current acceleration after dawdling in m/s.
const PositionVector & getShape() const
Returns this lane's shape.
SUMOTime myManoeuvreStartTime
Time at which the Manoeuvre for this stop started.
const MSEdgeWeightsStorage & getWeightsStorage() const
Returns the vehicle's internal edge travel times/efforts container.
virtual bool hasPedestrians(const MSLane *lane)
whether the given lane has pedestrians on it
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
The vehicle starts or ends parking.
int getOccupancy() const
Returns the area occupancy.
bool containerTriggered
whether an arriving container lets the vehicle continue
virtual VehicleVariables * createVehicleVariables() const
Returns model specific values which are stored inside a vehicle and must be used with casting.
void setRemoteControlled(Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, const ConstMSEdgeVector &route, SUMOTime t)
std::vector< MSLane * > bestContinuations
SUMOTime getExitManoeuvreTime(const int angle) const
Accessor function for parameter equivalent returning exit time for a specific manoeuver angle.
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...
const std::vector< MSLane * > & getFurtherLanes() const
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Needs to stay on the current lane.
MSVehicle()
invalidated default constructor
void updateTimeLoss(double vNext)
Updates the vehicle's time loss.
int getLastFreeLotAngle() const
Return the angle of myLastFreeLot - the next parking lot only expected to be called after we have est...
double myTimeLoss
the time loss in seconds due to driving with less than maximum speed
MSRouteIterator myCurrEdge
Iterator to current route-edge.
A device which collects info on the vehicle trip (mainly on departure and arrival)
std::vector< std::string > via
List of the via-edges the vehicle must visit.
bool passingMinor() const
decide whether the vehicle is passing a minor link or has comitted to do so
bool mustCheckJunctionCollisions() const
whether this lane must check for junction collisions
virtual double getHeadwayTime() const
Get the driver's desired headway [s].
void adaptToLeaders(const MSLeaderInfo &ahead, double latOffset, const double seen, DriveProcessItem *const lastLink, const MSLane *const lane, double &v, double &vLinkPass) const
int index
at which position in the stops list
void adaptLeaveSpeed(const double v)
void updateWaitingTime(double vNext)
Updates the vehicle's waiting time counters (accumulated and consecutive)
double getLastFreePosWithReservation(SUMOTime t, const SUMOVehicle &forVehicle)
Returns the last free position on this stop including reservatiosn from the current lane and time ste...
double recomputeCosts(const std::vector< const E * > &edges, const V *const v, SUMOTime msTime, double *lengthp=nullptr) const
PositionVector reverse() const
reverse position vector
bool isActionStep(SUMOTime t) const
Returns whether the next simulation step will be an action point for the vehicle.
void checkRewindLinkLanes(const double lengthsInFront, DriveItemVector &lfLinks) const
runs heuristic for keeping the intersection clear in case of downstream jamming
double rotationAtOffset(double pos) const
Returns the rotation at the given length.
bool myRespectJunctionPriority
Whether the junction priority rules are respected.
void endLaneChangeManeuver(const MSMoveReminder::Notification reason=MSMoveReminder::NOTIFICATION_LANE_CHANGE)
MSAbstractLaneChangeModel * myLaneChangeModel
bool addTraciStop(MSLane *const lane, const double startPos, const double endPos, const SUMOTime duration, const SUMOTime until, const bool parking, const bool triggered, const bool containerTriggered, std::string &errorMsg)
double lateralDistanceToLane(const int offset) const
Get the minimal lateral distance required to move fully onto the lane at given offset.
double getLength() const
Get vehicle's length [m].
virtual double stopSpeed(const MSVehicle *const veh, const double speed, double gap) const =0
Computes the vehicle's safe speed for approaching a non-moving obstacle (no dawdling)
MSVehicle::ManoeuvreType getManoeuvreType() const
accessor function to myManoeuvre equivalent
void setLaneChangeMode(int value)
Sets lane changing behavior.
int getOccupancyIncludingBlocked() const
Returns the area occupancy.
double getElectricityConsumption() const
Returns electricity consumption of the current state.
SUMOTime extension
The maximum time extension for boarding / loading.
static double fromNaviDegree(const double angle)
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
const std::vector< MSTransportable * > & getPersons() const
retrieve riding persons
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)
void setSignals(int signals)
void stopStarted(const SUMOVehicle *veh, int numPersons, int numContainers, SUMOTime time)
void resetActionOffset(const SUMOTime timeUntilNextAction=0)
Resets the action offset for the vehicle.
bool isRemoteAffected(SUMOTime t) const
std::vector< MSEdge * > MSEdgeVector
double getRightSideOnLane() const
Get the vehicle's lateral position on the lane:
SUMOVehicleClass getVClass() const
Returns the vehicle's access class.
MSLink * getLinkTo(const MSLane *) const
returns the link to the given lane or 0, if it is not connected
MSVehicleType & getSingularType()
Replaces the current vehicle type with a new one used by this vehicle only.
int getPersonNumber() const
Returns the number of persons.
const int STOP_DURATION_SET
render as a passenger vehicle
SUMOTime myManoeuvreCompleteTime
Time at which this manoeuvre should complete.
double getLeaveSpeed() const
void activate(double tauOriginal, double tauTarget, double additionalGap, double duration, double changeRate, double maxDecel, const MSVehicle *refVeh)
Start gap control with given params.
Influencer * myInfluencer
An instance of a velocity/lane influencing instance; built in "getInfluencer".
const std::vector< SUMOVehicleParameter::Stop > & getStops() const
Returns the stops.
const std::string & getID() const
returns the id of the transportable
void processLinkApproaches(double &vSafe, double &vSafeMin, double &vSafeMinDist)
This method iterates through the driveprocess items for the vehicle and adapts the given in/out param...
const SUMOVTypeParameter & getParameter() const
virtual ~GapControlState()
The base class for microscopic and mesoscopic vehicles.
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the best sequence of lanes to continue the route starting at myLane.
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
bool triggered
whether an arriving person lets the vehicle continue
const std::string & getID() const
Returns the name of the vehicle.
WaitingTimeCollector(SUMOTime memory=MSGlobals::gWaitingTimeMemory)
Constructor.
void setApproachingForAllLinks(const SUMOTime t)
Register junction approaches for all link items in the current plan.
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.
bool signalSet(int which) const
Returns whether the given signal is on.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
void addReminder(MSMoveReminder *rem)
Adds a MoveReminder dynamically.
int getLaneChangeMode() const
return the current lane change mode
void deactivate()
Stop gap control.
double getFuelConsumption() const
Returns fuel consumption of the current state.
double getBackPositionOnLane(const MSLane *lane) const
Get the vehicle's position relative to the given lane.
void setManoeuvreType(const MSVehicle::ManoeuvreType mType)
Accessor (set) for manoeuvre type.
double getMaxSpeed() const
Get vehicle's maximum speed [m/s].
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)
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
double getWidth() const
Returns the lane's width.
double getCommittedSpeed() const
int influenceChangeDecision(const SUMOTime currentTime, const MSEdge ¤tEdge, const int currentLaneIndex, int state)
Applies stored LaneChangeMode information and laneTimeLine.
double computeAngle() const
compute the current vehicle angle
static MSPModel * getModel()
const int STOP_TRIGGER_SET
const int STOP_CONTAINER_TRIGGER_SET
The car-following model abstraction.
const MSEdge * getNormalBefore() const
if this edge is an internal edge, return its first normal predecessor, otherwise the edge itself
double getWidth() const
Returns the vehicle's width.
void setEmergencyBlueLight(SUMOTime currentTime)
sets the blue flashing light for emergency vehicles
static bool hasInstance()
Returns whether the network was already constructed.
SUMOTime getWaitingTime() const
Returns the SUMOTime waited (speed was lesser than 0.1m/s)
void onDepart()
Called when the vehicle is inserted into the network.
This is an uncontrolled, all-way stop link.
int getShadowDirection() const
return the direction in which the current shadow lane lies
static double compute(const SUMOEmissionClass c, const EmissionType e, const double v, const double a, const double slope, const std::map< int, double > *param=0)
Returns the amount of the emitted pollutant given the vehicle type and state (in mg/s or ml/s for fue...
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
Interface for lane-change models.
Position validatePosition(Position result, double offset=0) const
ensure that a vehicle-relative position is not invalid
#define DIST_TO_STOPLINE_EXPECT_PRIORITY
bool gDebugFlag1
global utility flags for debugging
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
double getSpeed() const
Returns the vehicle's current speed.
const int STOP_PARKING_SET
SUMOTime getLaneTimeLineDuration()
The action is due to the default of keeping right "Rechtsfahrgebot".
SUMOTime getLaneTimeLineEnd()
int gPrecision
the precision for floating point outputs
double gapControlSpeed(SUMOTime currentTime, const SUMOVehicle *veh, double speed, double vSafe, double vMin, double vMax)
Applies gap control logic on the speed.
static void cleanup()
Static cleanup (removes vehicle state listener)
void setActionStepLength(double actionStepLength, bool resetActionOffset=true)
Sets the action steplength of the vehicle.
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
bool replaceRoute(const MSRoute *route, const std::string &info, bool onInit=false, int offset=0, bool addStops=true, bool removeStops=true)
Replaces the current route by the given one.
double getLateralOverlap() const
return the amount by which the vehicle extends laterally outside it's primary lane
MSVehicle::ManoeuvreType getManoeuvreType() const
Accessor (get) for manoeuvre type.
render as a wagon passenger vehicle ("Combi")
bool containerTriggered
whether an arriving container lets the vehicle continue
void deactivateGapController()
Deactivates the gap control.
ChangeRequest
Requests set via TraCI.
static SUMOTime gLaneChangeDuration
bool fromInternalLane() const
return whether the fromLane of this link is an internal lane
bool isFrontOnLane(const MSLane *lane) const
Returns the information whether the front of the vehicle is on the given lane.
MSParkingArea * getNextParkingArea()
get the upcoming parking area stop or nullptr
void addReference() const
increments the reference counter for the route
const MSLane * getLaneBefore() const
return the internalLaneBefore if it exists and the laneBefore otherwise
const std::vector< std::pair< const MSLane *, const MSEdge * > > getOutgoingViaLanes() const
get the list of outgoing lanes
virtual void drawOutsideNetwork(bool)
register vehicle for drawing while outside the network
double speed
the speed at which this stop counts as reached (waypoint mode)
const MSLane * getNormalPredecessorLane() const
get normal lane leading to this internal lane, for normal lanes, the lane itself is returned
MSParkingArea * getCurrentParkingArea()
get the current parking area stop or nullptr
bool setExitManoeuvre()
accessor function to myManoeuvre equivalent
double estimateLeaveSpeed(const MSLink *const link, const double vLinkPass) const
estimate leaving speed when accelerating across a link
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
double changeRequestRemainingSeconds(const SUMOTime currentTime) const
Return the remaining number of seconds of the current laneTimeLine assuming one exists.
SUMOTime duration
The stopping duration.
bool fits(double pos, const SUMOVehicle &veh) const
return whether the given vehicle fits at the given position
void adaptToLeader(const std::pair< const MSVehicle *, double > leaderInfo, const double seen, DriveProcessItem *const lastLink, const MSLane *const lane, double &v, double &vLinkPass, double distToCrossing=-1) const
bool getRespectJunctionPriority() const
Returns whether junction priority rules shall be respected.
void removeWaiting(const SUMOVehicle *vehicle) const
Removes a vehicle from the list of waiting vehicles.
std::pair< const MSVehicle *, double > CLeaderDist
MSVehicleType * myType
This vehicle's type.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
double estimateSpeedAfterDistance(const double dist, const double v, const double accel) const
bool onFurtherEdge(const MSEdge *edge) const
whether this vehicle has its back (and no its front) on the given edge
double myOdometer
A simple odometer to keep track of the length of the route already driven.
MSEdgeControl & getEdgeControl()
Returns the edge control.
static bool gSemiImplicitEulerUpdate
bool contains(const MSEdge *const edge) const
void stopEnded(const SUMOVehicle *veh, const SUMOVehicleParameter::Stop &stop, const std::string &laneOrEdgeID)
WaitingTimeCollector & operator=(const WaitingTimeCollector &wt)
Assignment operator.
std::vector< Stop > stops
List of the stops the vehicle will make, TraCI may add entries here.
void changedToOpposite()
called when a vehicle changes between lanes in opposite directions
void setSpeedMode(int speedMode)
Sets speed-constraining behaviors.
MSVehicleDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists or 0.
static const SUMOTime NOT_YET_DEPARTED
const std::vector< double > & getShadowFurtherLanesPosLat() const
double getDistanceBetween(double fromPos, double toPos, const MSEdge *fromEdge, const MSEdge *toEdge, bool includeInternal=true, int routePosition=0) const
Compute the distance between 2 given edges on this route, including the length of internal lanes....
Encapsulated SAX-Attributes.
MSDevice_Transportable * myContainerDevice
The containers this vehicle may have.
bool configureExitManoeuvre(MSVehicle *veh)
Setup the myManoeuvre for exiting (Sets completion time and manoeuvre type)
std::set< std::string > awaitedContainers
IDs of containers the vehicle has to wait for until departing.
Stores the waiting intervals over the previous seconds (memory is to be specified in ms....
bool parking
whether the vehicle is removed from the net while stopping
The link is a partial left direction.
MoveReminderCont myMoveReminders
Currently relevant move reminders.
std::string chargingStation
(Optional) charging station if one is assigned to the stop
double nextOccupation
As occupation, but without the first lane.
void enterLaneAtLaneChange(MSLane *enteredLane)
Update when the vehicle enters a new lane in the laneChange step.
A static instance of this class in GapControlState deactivates gap control for vehicles whose referen...
const std::string & getID() const
Returns the id.
Notification
Definition of a vehicle state.
std::string containerstop
(Optional) container stop if one is assigned to the stop
double getCO2Emissions() const
Returns CO2 emission of the current state.
The vehicle arrived at a junction.
bool checkActionStep(const SUMOTime t)
Returns whether the vehicle is supposed to take action in the current simulation step Updates myActio...
virtual ~MSVehicle()
Destructor.
virtual double followSpeed(const MSVehicle *const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle *const pred=0) const =0
Computes the vehicle's follow speed (no dawdling)
The action is done to help someone else.
const double MIN_STOP_LENGTH
void updateState(double vNext)
updates the vehicles state, given a next value for its speed. This value can be negative in case of t...
The vehicle ends to stop.
int getIndex() const
Returns the lane's index.
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.
MSLane * getViaLane() const
Returns the following inner lane.
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const int rngIndex) const
bool isStoppedTriggered() const
Returns whether the vehicle is on a triggered stop.
MSDevice_DriverState * myDriverState
This vehicle's driver state.
double getFoeVisibilityDistance() const
Returns the distance on the approaching lane from which an approaching vehicle is able to see all rel...
double getMinimalArrivalSpeedEuler(double dist, double currentSpeed) const
Computes the minimal possible arrival speed after covering a given distance for Euler update.
const std::vector< MSLane * > & getFurtherTargetLanes() const
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
double getDeltaPos(const double accel) const
calculates the distance covered in the next integration step given an acceleration and assuming the c...
bool rerouteParkingArea(const std::string &parkingAreaID, std::string &errorMsg)
The vehicle is being teleported.
SUMOTime myLastRemoteAccess
double departPos
(optional) The position the vehicle shall depart from
Position getPositionAlongBestLanes(double offset) const
Return the (x,y)-position, which the vehicle would reach if it continued along its best continuation ...
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
void move2side(double amount, double maxExtension=100)
move position vector to side using certain ammount
The action is due to a TraCI request.
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.
void unregisterOneWaiting(const bool isPerson)
decreases the count of vehicles waiting for a transport to allow recognition of person / container re...
const MSTrafficLightLogic * getTLLogic() const
Returns the TLS index.
bool unsafeLinkAhead(const MSLane *lane) const
whether the vehicle may safely move to the given lane with regard to upcoming links
Definition of vehicle stop (position and duration)
virtual double getSpeed() const =0
Returns the vehicle's current speed.
blocked in all directions
Drive process items represent bounds on the safe velocity corresponding to the upcoming links.
double arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
Manoeuvre into stopping place.
bool replaceParkingArea(MSParkingArea *parkingArea, std::string &errorMsg)
replace the current parking area stop with a new stop with merge duration
State & operator=(const State &state)
Assignment operator.
SUMOTime timeToLoadNextContainer
The time at which the vehicle is able to load another container.
std::mt19937 * getRNG() const
bool hasStops() const
Returns whether the vehicle has to stop somewhere.
bool entryManoeuvreIsComplete(MSVehicle *veh)
Configure an entry manoeuvre if nothing is configured - otherwise check if complete.
Representation of a vehicle in the micro simulation.
double getDistanceToPosition(double destPos, const MSEdge *destEdge) const
DriveItemVector::iterator myNextDriveItem
iterator pointing to the next item in myLFLinkLanes
bool keepClear() const
whether the junction after this link must be kept clear
Abstract in-vehicle device.
virtual void addContainer(MSTransportable *container)
Adds a container to this vehicle.