 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
106 #define DEBUG_COND (isSelected())
108 #define DEBUG_COND2(obj) (obj->isSelected())
111 #define STOPPING_PLACE_OFFSET 0.5
113 #define CRLL_LOOK_AHEAD 5
115 #define JUNCTION_BLOCKAGE_TIME 5 // s
118 #define DIST_TO_STOPLINE_EXPECT_PRIORITY 1.0
120 #define NUMERICAL_EPS_SPEED (0.1 * NUMERICAL_EPS * TS)
158 return (myPos != state.
myPos ||
168 myPos(pos), mySpeed(speed), myPosLat(posLat), myBackPos(backPos), myPreviousSpeed(speed), myLastCoveredDist(
SPEED2DIST(speed)) {}
189 myWaitingIntervals.clear();
196 assert(memorySpan <= myMemorySize);
197 if (memorySpan == -1) {
198 memorySpan = myMemorySize;
201 for (waitingIntervalList::const_iterator i = myWaitingIntervals.begin(); i != myWaitingIntervals.end(); i++) {
202 if (i->second >= memorySpan) {
203 if (i->first >= memorySpan) {
206 totalWaitingTime += memorySpan - i->first;
209 totalWaitingTime += i->second - i->first;
212 return totalWaitingTime;
217 waitingIntervalList::iterator i = myWaitingIntervals.begin();
218 waitingIntervalList::iterator end = myWaitingIntervals.end();
219 bool startNewInterval = i == end || (i->first != 0);
222 if (i->first >= myMemorySize) {
230 waitingIntervalList::iterator::difference_type d = std::distance(i, end);
232 myWaitingIntervals.pop_back();
238 }
else if (!startNewInterval) {
239 myWaitingIntervals.begin()->first = 0;
241 myWaitingIntervals.push_front(std::make_pair(0, dt));
261 const MSVehicle* msVeh = static_cast<const MSVehicle*>(vehicle);
263 if (GapControlState::refVehMap.find(msVeh) != end(GapControlState::refVehMap)) {
265 GapControlState::refVehMap[msVeh]->deactivate();
275 std::map<const MSVehicle*, MSVehicle::Influencer::GapControlState*>
282 tauOriginal(-1), tauCurrent(-1), tauTarget(-1), addGapCurrent(-1), addGapTarget(-1),
283 remainingDuration(-1), changeRate(-1), maxDecel(-1), referenceVeh(nullptr), active(false), gapAttained(false), prevLeader(nullptr),
284 lastUpdate(-1), timeHeadwayIncrement(0.0), spaceHeadwayIncrement(0.0) {}
298 WRITE_ERROR(
"MSVehicle::Influencer::GapControlState::init(): No MSNet instance found!")
315 tauOriginal = tauOrig;
316 tauCurrent = tauOrig;
319 addGapTarget = additionalGap;
320 remainingDuration = dur;
323 referenceVeh = refVeh;
326 prevLeader =
nullptr;
328 timeHeadwayIncrement = changeRate *
TS * (tauTarget - tauOriginal);
329 spaceHeadwayIncrement = changeRate *
TS * addGapTarget;
331 if (referenceVeh !=
nullptr) {
341 if (referenceVeh !=
nullptr) {
344 referenceVeh =
nullptr;
378 GapControlState::init();
383 GapControlState::cleanup();
388 mySpeedAdaptationStarted =
true;
389 mySpeedTimeLine = speedTimeLine;
394 if (myGapControlState ==
nullptr) {
395 myGapControlState = std::make_shared<GapControlState>();
397 myGapControlState->activate(originalTau, newTimeHeadway, newSpaceHeadway, duration, changeRate, maxDecel, refVeh);
402 if (myGapControlState !=
nullptr && myGapControlState->active) {
403 myGapControlState->deactivate();
409 myLaneTimeLine = laneTimeLine;
415 for (
auto& item : myLaneTimeLine) {
416 item.second += indexShift;
428 return (1 * myConsiderSafeVelocity +
429 2 * myConsiderMaxAcceleration +
430 4 * myConsiderMaxDeceleration +
431 8 * myRespectJunctionPriority +
432 16 * myEmergencyBrakeRedLight);
438 return (1 * myStrategicLC +
439 4 * myCooperativeLC +
441 64 * myRightDriveLC +
442 256 * myTraciLaneChangePriority +
449 for (std::vector<std::pair<SUMOTime, int>>::iterator i = myLaneTimeLine.begin(); i != myLaneTimeLine.end(); ++i) {
453 duration -= i->first;
461 if (!myLaneTimeLine.empty()) {
462 return myLaneTimeLine.back().first;
472 myOriginalSpeed = speed;
475 while (mySpeedTimeLine.size() == 1 || (mySpeedTimeLine.size() > 1 && currentTime > mySpeedTimeLine[1].first)) {
476 mySpeedTimeLine.erase(mySpeedTimeLine.begin());
479 if (!(mySpeedTimeLine.size() < 2 || currentTime < mySpeedTimeLine[0].first)) {
481 if (!mySpeedAdaptationStarted) {
482 mySpeedTimeLine[0].second = speed;
483 mySpeedAdaptationStarted =
true;
486 const double td =
STEPS2TIME(currentTime - mySpeedTimeLine[0].first) /
STEPS2TIME(mySpeedTimeLine[1].first +
DELTA_T - mySpeedTimeLine[0].first);
487 speed = mySpeedTimeLine[0].second - (mySpeedTimeLine[0].second - mySpeedTimeLine[1].second) * td;
488 if (myConsiderSafeVelocity) {
489 speed =
MIN2(speed, vSafe);
491 if (myConsiderMaxAcceleration) {
492 speed =
MIN2(speed, vMax);
494 if (myConsiderMaxDeceleration) {
495 speed =
MAX2(speed, vMin);
505 std::cout << currentTime <<
" Influencer::gapControlSpeed(): speed=" << speed
506 <<
", vSafe=" << vSafe
512 double gapControlSpeed = speed;
513 if (myGapControlState !=
nullptr && myGapControlState->active) {
515 const double currentSpeed = veh->
getSpeed();
516 const MSVehicle* msVeh = dynamic_cast<const MSVehicle*>(veh);
517 assert(msVeh !=
nullptr);
518 const double desiredTargetTimeSpacing = myGapControlState->tauTarget * currentSpeed;
519 std::pair<const MSVehicle*, double> leaderInfo;
520 if (myGapControlState->referenceVeh ==
nullptr) {
522 leaderInfo = msVeh->
getLeader(
MAX2(desiredTargetTimeSpacing, myGapControlState->addGapCurrent) + 20.);
525 const MSVehicle* leader = myGapControlState->referenceVeh;
533 if (dist < -100000) {
535 std::cout <<
" Ego and reference vehicle are not in CF relation..." << std::endl;
537 std::cout <<
" Reference vehicle is behind ego..." << std::endl;
544 const double fakeDist =
MAX2(0.0, leaderInfo.second - myGapControlState->addGapCurrent);
547 const double desiredCurrentSpacing = myGapControlState->tauCurrent * currentSpeed;
548 std::cout <<
" Gap control active:"
549 <<
" currentSpeed=" << currentSpeed
550 <<
", desiredTargetTimeSpacing=" << desiredTargetTimeSpacing
551 <<
", desiredCurrentSpacing=" << desiredCurrentSpacing
552 <<
", leader=" << (leaderInfo.first ==
nullptr ?
"NULL" : leaderInfo.first->getID())
553 <<
", dist=" << leaderInfo.second
554 <<
", fakeDist=" << fakeDist
555 <<
",\n tauOriginal=" << myGapControlState->tauOriginal
556 <<
", tauTarget=" << myGapControlState->tauTarget
557 <<
", tauCurrent=" << myGapControlState->tauCurrent
561 if (leaderInfo.first !=
nullptr) {
562 if (myGapControlState->prevLeader !=
nullptr && myGapControlState->prevLeader != leaderInfo.first) {
566 myGapControlState->prevLeader = leaderInfo.first;
572 gapControlSpeed =
MIN2(gapControlSpeed, cfm->
followSpeed(msVeh, currentSpeed, fakeDist, leaderInfo.first->
getSpeed(),
573 leaderInfo.first->getCurrentApparentDecel(),
nullptr));
577 std::cout <<
" -> gapControlSpeed=" << gapControlSpeed;
578 if (myGapControlState->maxDecel > 0) {
579 std::cout <<
", with maxDecel bound: " <<
MAX2(gapControlSpeed, currentSpeed -
TS * myGapControlState->maxDecel);
581 std::cout << std::endl;
584 if (myGapControlState->maxDecel > 0) {
585 gapControlSpeed =
MAX2(gapControlSpeed, currentSpeed -
TS * myGapControlState->maxDecel);
592 if (myGapControlState->lastUpdate < currentTime) {
595 std::cout <<
" Updating GapControlState." << std::endl;
598 if (myGapControlState->tauCurrent == myGapControlState->tauTarget && myGapControlState->addGapCurrent == myGapControlState->addGapTarget) {
599 if (!myGapControlState->gapAttained) {
601 myGapControlState->gapAttained = leaderInfo.first ==
nullptr || leaderInfo.second >
MAX2(desiredTargetTimeSpacing, myGapControlState->addGapTarget) -
POSITION_EPS;
604 if (myGapControlState->gapAttained) {
605 std::cout <<
" Target gap was established." << std::endl;
611 myGapControlState->remainingDuration -=
TS;
614 std::cout <<
" Gap control remaining duration: " << myGapControlState->remainingDuration << std::endl;
617 if (myGapControlState->remainingDuration <= 0) {
620 std::cout <<
" Gap control duration expired, deactivating control." << std::endl;
624 myGapControlState->deactivate();
629 myGapControlState->tauCurrent =
MIN2(myGapControlState->tauCurrent + myGapControlState->timeHeadwayIncrement, myGapControlState->tauTarget);
630 myGapControlState->addGapCurrent =
MIN2(myGapControlState->addGapCurrent + myGapControlState->spaceHeadwayIncrement, myGapControlState->addGapTarget);
633 if (myConsiderSafeVelocity) {
634 gapControlSpeed =
MIN2(gapControlSpeed, vSafe);
636 if (myConsiderMaxAcceleration) {
637 gapControlSpeed =
MIN2(gapControlSpeed, vMax);
639 if (myConsiderMaxDeceleration) {
640 gapControlSpeed =
MAX2(gapControlSpeed, vMin);
642 return MIN2(speed, gapControlSpeed);
650 return mySpeedTimeLine.empty() ? -1 : myOriginalSpeed;
657 while (myLaneTimeLine.size() == 1 || (myLaneTimeLine.size() > 1 && currentTime > myLaneTimeLine[1].first)) {
658 myLaneTimeLine.erase(myLaneTimeLine.begin());
662 if (myLaneTimeLine.size() >= 2 && currentTime >= myLaneTimeLine[0].first) {
663 const int destinationLaneIndex = myLaneTimeLine[1].second;
664 if (destinationLaneIndex < (
int)currentEdge.
getLanes().size()) {
665 if (currentLaneIndex > destinationLaneIndex) {
667 }
else if (currentLaneIndex < destinationLaneIndex) {
672 }
else if (currentEdge.
getLanes().back()->getOpposite() !=
nullptr) {
681 if ((state &
LCA_TRACI) != 0 && myLatDist != 0) {
690 mode = myStrategicLC;
692 mode = myCooperativeLC;
694 mode = mySpeedGainLC;
696 mode = myRightDriveLC;
735 switch (changeRequest) {
751 assert(myLaneTimeLine.size() >= 2);
752 assert(currentTime >= myLaneTimeLine[0].first);
753 return STEPS2TIME(myLaneTimeLine[1].first - currentTime);
759 myConsiderSafeVelocity = ((speedMode & 1) != 0);
760 myConsiderMaxAcceleration = ((speedMode & 2) != 0);
761 myConsiderMaxDeceleration = ((speedMode & 4) != 0);
762 myRespectJunctionPriority = ((speedMode & 8) != 0);
763 myEmergencyBrakeRedLight = ((speedMode & 16) != 0);
780 myRemoteXYPos = xyPos;
783 myRemotePosLat = posLat;
784 myRemoteAngle = angle;
785 myRemoteEdgeOffset = edgeOffset;
786 myRemoteRoute = route;
787 myLastRemoteAccess = t;
799 return myLastRemoteAccess >= t -
TIME2STEPS(10);
804 const bool wasOnRoad = v->
isOnRoad();
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())) {
820 myRemoteLane->forceVehicleInsertion(v, myRemotePos, notify, myRemotePosLat);
853 if (myRemoteLane !=
nullptr) {
859 if (distAlongRoute != std::numeric_limits<double>::max()) {
860 dist = distAlongRoute;
864 const double minSpeed = myConsiderMaxDeceleration ?
866 const double maxSpeed = (myRemoteLane !=
nullptr
867 ? myRemoteLane->getVehicleMaxSpeed(veh)
877 if (myRemoteLane ==
nullptr) {
897 if (myRoutingMode == 1) {
910 if (busstop !=
nullptr) {
911 return busstop->getLastFreePos(veh);
912 }
else if (containerstop !=
nullptr) {
913 return containerstop->getLastFreePos(veh);
914 }
else if (parkingarea !=
nullptr) {
915 return parkingarea->getLastFreePos(veh);
916 }
else if (chargingStation !=
nullptr) {
917 return chargingStation->getLastFreePos(veh);
925 if (parkingarea !=
nullptr) {
926 return "parkingArea:" + parkingarea->getID();
927 }
else if (containerstop !=
nullptr) {
928 return "containerStop:" + containerstop->getID();
929 }
else if (busstop !=
nullptr) {
930 return "busStop:" + busstop->getID();
931 }
else if (chargingStation !=
nullptr) {
932 return "chargingStation:" + chargingStation->getID();
934 return "lane:" + lane->getID() +
" pos:" +
toString(pars.endPos);
943 if (busstop !=
nullptr) {
946 if (containerstop !=
nullptr) {
949 if (busstop ==
nullptr && containerstop ==
nullptr) {
957 if (pars.until >= 0) {
960 if (pars.triggered) {
963 if (pars.containerTriggered) {
969 if (pars.awaitedPersons.size() > 0) {
972 if (pars.awaitedContainers.size() > 0) {
1003 myStopDist(std::numeric_limits<double>::max()),
1011 if (!(*myCurrEdge)->isTazConnector()) {
1013 if ((*myCurrEdge)->getDepartLane(*
this) ==
nullptr) {
1014 throw ProcessError(
"Invalid departlane definition for vehicle '" + pars->
id +
"'.");
1017 if ((*myCurrEdge)->allowedLanes(type->
getVehicleClass()) ==
nullptr) {
1018 throw ProcessError(
"Vehicle '" + pars->
id +
"' is not allowed to depart on any lane of its first edge.");
1023 "' is too high for the vehicle type '" + type->
getID() +
"'.");
1036 (*i)->resetPartialOccupation(
this);
1056 #ifdef DEBUG_ACTIONSTEPS
1058 std::cout <<
SIMTIME <<
" Removing vehicle '" <<
getID() <<
"' (reason: " <<
toString(reason) <<
")" << std::endl;
1091 (newCurrEdge + 1) == edges.end() || (*(newCurrEdge + 1)) != &(
myLane->
getOutgoingViaLanes().front().first->getEdge()))) {
1108 if (stopsFromScratch) {
1119 lastPos += (*myCurrEdge)->getLength();
1121 #ifdef DEBUG_REPLACE_ROUTE
1123 std::cout <<
" replaceRoute on " << (*myCurrEdge)->getID() <<
" lane=" <<
myLane->
getID() <<
"\n";
1126 for (std::list<Stop>::iterator iter =
myStops.begin(); iter !=
myStops.end();) {
1127 double endPos = iter->getEndPos(*
this);
1128 #ifdef DEBUG_REPLACE_ROUTE
1130 std::cout <<
" stopEdge=" << iter->lane->getEdge().getID() <<
" start=" << (searchStart -
myCurrEdge) <<
" endPos=" << endPos <<
" lastPos=" << lastPos <<
"\n";
1133 if (*searchStart != &iter->lane->getEdge()
1134 || endPos < lastPos) {
1135 if (searchStart != edges.end() && !iter->reached) {
1141 iter->edge = std::find(searchStart, edges.end(), &iter->lane->getEdge());
1142 #ifdef DEBUG_REPLACE_ROUTE
1144 std::cout <<
" foundIndex=" << (iter->edge -
myCurrEdge) <<
" end=" << (edges.end() -
myCurrEdge) <<
"\n";
1147 if (iter->edge == edges.end()) {
1155 searchStart = iter->edge;
1160 if (addRouteStops) {
1161 for (std::vector<SUMOVehicleParameter::Stop>::const_iterator i = newRoute->
getStops().begin(); i != newRoute->
getStops().end(); ++i) {
1173 updateBestLanes(
true, onInit ? (*myCurrEdge)->getLanes().front() : 0);
1188 const_cast<SUMOVehicleParameter*>(
myParameter)->departLaneProcedure = departLaneProcedure;
1226 if (!rem->first->notifyMove(*
this, oldPos + rem->second, newPos + rem->second,
MAX2(0., newSpeed))) {
1228 if (myTraceMoveReminders) {
1229 traceMoveReminder(
"notifyMove", rem->first, rem->second,
false);
1235 if (myTraceMoveReminders) {
1236 traceMoveReminder(
"notifyMove", rem->first, rem->second,
true);
1252 rem->second += oldLaneLength;
1256 if (myTraceMoveReminders) {
1257 traceMoveReminder(
"adaptedPos", rem->first, rem->second,
true);
1290 if (
myStops.begin()->parkingarea !=
nullptr) {
1291 return myStops.begin()->parkingarea->getVehiclePosition(*
this);
1301 if (offset == 0. && !changingLanes) {
1316 auto nextBestLane = bestLanes.begin();
1321 bool success =
true;
1323 while (offset > 0) {
1328 lane = lane->
getLinkCont()[0]->getViaLaneOrLane();
1330 if (lane ==
nullptr) {
1340 while (nextBestLane != bestLanes.end() && *nextBestLane ==
nullptr) {
1345 assert(lane == *nextBestLane);
1349 assert(nextBestLane == bestLanes.end() || *nextBestLane != 0);
1350 if (nextBestLane == bestLanes.end()) {
1377 int furtherIndex = 0;
1386 offset += lastLength;
1411 #ifdef DEBUG_FURTHER
1413 std::cout <<
SIMTIME <<
" veh '" <<
getID() <<
" setAngle(" << angle <<
") straightenFurther=" << straightenFurther << std::endl;
1421 if (further->
getLinkTo(next) !=
nullptr) {
1436 const bool newActionStepLength = actionStepLengthMillisecs != previousActionStepLength;
1437 if (newActionStepLength) {
1454 if (
myStops.begin()->parkingarea !=
nullptr) {
1455 return myStops.begin()->parkingarea->getVehicleAngle(*
this);
1480 double result = (p1 != p2 ? p2.
angleTo2D(p1) :
1485 #ifdef DEBUG_FURTHER
1503 #ifdef DEBUG_FURTHER
1510 #ifdef DEBUG_FURTHER
1529 errorMsg =
"Vehicle '" +
myParameter->
id +
"' is not allowed to stop on lane '" + stopPar.
lane +
"'.";
1541 if (stopPar.
until != -1) {
1543 const_cast<SUMOVehicleParameter::Stop&>(stop.
pars).until += untilOffset;
1549 std::string stopType =
"stop";
1550 std::string stopID =
"";
1551 if (stop.
busstop !=
nullptr) {
1552 stopType =
"busStop";
1555 stopType =
"containerStop";
1558 stopType =
"chargingStation";
1561 stopType =
"parkingArea";
1564 const std::string errorMsgStart = stopID ==
"" ? stopType : stopType +
" '" + stopID +
"'";
1567 errorMsg = errorMsgStart +
" for vehicle '" +
myParameter->
id +
"' on lane '" + stopPar.
lane +
"' has an invalid position.";
1572 errorMsg = errorMsgStart +
" on lane '" + stopPar.
lane +
"' is too short for vehicle '" +
myParameter->
id +
"'.";
1576 if (searchStart ==
nullptr) {
1581 MSEdge* prevEdge =
nullptr;
1584 std::list<Stop>::iterator iter =
myStops.begin();
1587 prevStopEdge =
myStops.back().edge;
1588 prevEdge = &
myStops.back().lane->getEdge();
1589 prevStopPos =
myStops.back().pars.endPos;
1592 if (prevStopEdge == stop.
edge
1595 stop.
edge = std::find(prevStopEdge + 1,
myRoute->
end(), stopEdge);
1600 while (iter !=
myStops.end() && (iter->edge < stop.
edge ||
1601 (iter->pars.endPos < stop.
pars.
endPos && iter->edge == stop.
edge))) {
1602 prevStopEdge = iter->edge;
1603 prevStopPos = iter->pars.endPos;
1607 int index = stopPar.
index;
1609 prevStopEdge = iter->edge;
1610 prevStopPos = iter->pars.endPos;
1617 const bool sameEdgeAsLastStop = prevStopEdge == stop.
edge && prevEdge == &stop.
lane->
getEdge();
1619 (sameEdgeAsLastStop && prevStopPos > stop.
pars.
endPos && !collision)
1624 return addStop(stopPar, errorMsg, untilOffset, collision, &next);
1626 errorMsg = errorMsgStart +
" for vehicle '" +
myParameter->
id +
"' on lane '" + stopPar.
lane +
"' is not downstream the current route.";
1649 errorMsg = errorMsgStart +
" for vehicle '" +
myParameter->
id +
"' on lane '" + stopPar.
lane +
"' is too close to break.";
1658 pos += (*myCurrEdge)->getLength();
1668 return addStop(stopPar, errorMsg, untilOffset, collision, &next);
1670 errorMsg = errorMsgStart +
" for vehicle '" +
myParameter->
id +
"' on lane '" + stopPar.
lane +
"' is before departPos.";
1674 if (iter !=
myStops.begin()) {
1675 std::list<Stop>::iterator iter2 = iter;
1678 errorMsg = errorMsgStart +
" for vehicle '" +
myParameter->
id +
"' on lane '" + stopPar.
lane +
"' ends earlier than previous stop.";
1692 if (parkingArea == 0) {
1693 errorMsg =
"new parkingArea is NULL";
1697 errorMsg =
"vehicle has no stops";
1700 if (
myStops.front().parkingarea == 0) {
1701 errorMsg =
"first stop is not at parkingArea";
1707 for (std::list<Stop>::iterator iter = ++
myStops.begin(); iter !=
myStops.end();) {
1708 if (iter->parkingarea == parkingArea) {
1709 stopPar.
duration += iter->duration;
1736 return nextParkingArea;
1744 currentParkingArea =
myStops.begin()->parkingarea;
1746 return currentParkingArea;
1780 return myStops.front().duration;
1795 myStops.begin()->parkingarea ==
nullptr || !
myStops.begin()->parkingarea->parkOnRoad());
1822 return currentVelocity;
1827 std::cout <<
"\nPROCESS_NEXT_STOP\n" <<
SIMTIME <<
" vehicle '" <<
getID() <<
"'" << std::endl;
1837 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' reached stop.\n"
1850 if (stop.
busstop !=
nullptr) {
1852 for (std::vector<MSTransportable*>::const_iterator i = persons.begin(); i != persons.end(); ++i) {
1863 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' unregisters as waiting for person." << std::endl;
1871 for (std::vector<MSTransportable*>::const_iterator i = containers.begin(); i != containers.end(); ++i) {
1882 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' unregisters as waiting for container." << std::endl;
1890 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' resumes from stopping." << std::endl;
1897 WRITE_WARNING(
"Vehicle '" +
getID() +
"' ignores triggered stop on lane '" + stop.
lane->
getID() +
"' due to capacity constraints.");
1905 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' registers as waiting for person." << std::endl;
1911 WRITE_WARNING(
"Vehicle '" +
getID() +
"' ignores container triggered stop on lane '" + stop.
lane->
getID() +
"' due to capacity constraints.");
1919 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' registers as waiting for container." << std::endl;
1938 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' hasn't reached next stop." << std::endl;
1946 bool fitsOnStoppingPlace =
true;
1947 if (stop.
busstop !=
nullptr) {
1957 fitsOnStoppingPlace =
false;
1964 if (
myStops.empty() ||
myStops.front().parkingarea != oldParkingArea) {
1966 return currentVelocity;
1969 fitsOnStoppingPlace =
false;
1978 std::cout <<
" pos=" <<
myState.
pos() <<
" speed=" << currentVelocity <<
" targetPos=" << targetPos <<
" fits=" << fitsOnStoppingPlace <<
" reachedThresh=" << reachedThreshold <<
"\n";
1986 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' reached next stop." << std::endl;
2002 if (stop.
busstop !=
nullptr) {
2024 return currentVelocity;
2032 const Stop* prev =
nullptr;
2037 const double stopPos = stop.
getEndPos(*
this);
2039 || prev->
edge != stop.edge
2041 result.push_back(*stop.edge);
2054 std::vector<std::pair<int, double> >
2056 std::vector<std::pair<int, double> > result;
2057 for (std::list<Stop>::const_iterator iter =
myStops.begin(); iter !=
myStops.end(); ++iter) {
2058 result.push_back(std::make_pair(
2060 iter->getEndPos(*
this)));
2067 if (stop ==
nullptr) {
2071 if (s.busstop == stop
2072 || s.containerstop == stop
2073 || s.parkingarea == stop
2074 || s.chargingStation == stop) {
2092 && (&
myStops.front().lane->getEdge()) == *
myStops.front().edge) {
2119 if (timeSinceLastAction == 0) {
2121 timeSinceLastAction = oldActionStepLength;
2123 if (timeSinceLastAction >= newActionStepLength) {
2127 SUMOTime timeUntilNextAction = newActionStepLength - timeSinceLastAction;
2136 #ifdef DEBUG_PLAN_MOVE
2142 <<
" veh=" <<
getID()
2157 #ifdef DEBUG_ACTIONSTEPS
2159 std::cout <<
STEPS2TIME(t) <<
" vehicle '" <<
getID() <<
"' skips action." << std::endl;
2167 #ifdef DEBUG_ACTIONSTEPS
2169 std::cout <<
STEPS2TIME(t) <<
" vehicle = '" <<
getID() <<
"' takes action." << std::endl;
2175 #ifdef DEBUG_PLAN_MOVE
2177 DriveItemVector::iterator i;
2180 <<
" vPass=" << (*i).myVLinkPass
2181 <<
" vWait=" << (*i).myVLinkWait
2182 <<
" linkLane=" << ((*i).myLink == 0 ?
"NULL" : (*i).myLink->getViaLaneOrLane()->getID())
2183 <<
" request=" << (*i).mySetRequest
2197 myStopDist = std::numeric_limits<double>::max();
2205 double lateralShift = 0;
2209 laneMaxV =
MIN2(laneMaxV, l->getVehicleMaxSpeed(
this));
2213 laneMaxV =
MAX2(laneMaxV, vMinComfortable);
2215 laneMaxV = std::numeric_limits<double>::max();
2218 double v =
MIN2(maxV, laneMaxV);
2228 #ifdef DEBUG_PLAN_MOVE
2230 std::cout <<
" dist=" << dist <<
" bestLaneConts=" <<
toString(bestLaneConts) <<
"\n";
2233 assert(bestLaneConts.size() > 0);
2234 bool hadNonInternal =
false;
2240 double seenNonInternal = 0;
2245 bool slowedDownForMinor =
false;
2251 #pragma warning(push)
2252 #pragma warning(disable: 4127) // do not warn about constant conditional expression
2256 #pragma warning(pop)
2267 if (leader.first != 0 && leader.first->getLane() == leaderLane && leader.first->getLaneChangeModel().isOpposite()) {
2271 adaptToLeaders(ahead, lateralShift, seen, lastLink, leaderLane, v, vLinkPass);
2272 if (lastLink !=
nullptr) {
2275 #ifdef DEBUG_PLAN_MOVE
2277 std::cout <<
"\nv = " << v <<
"\n";
2285 if (shadowLane !=
nullptr) {
2289 seen, lastLink, shadowLane, v, vLinkPass);
2294 const double relativePos = lane->
getLength() - seen;
2295 #ifdef DEBUG_PLAN_MOVE
2297 std::cout <<
SIMTIME <<
" adapt to pedestrians on lane=" << lane->
getID() <<
" relPos=" << relativePos <<
"\n";
2302 if (leader.first != 0) {
2304 v =
MIN2(v, stopSpeed);
2305 #ifdef DEBUG_PLAN_MOVE
2307 std::cout <<
SIMTIME <<
" pedLeader=" << leader.first->getID() <<
" dist=" << leader.second <<
" v=" << v <<
"\n";
2327 if (lastLink !=
nullptr) {
2330 v =
MIN2(v, stopSpeed);
2332 MSLinkCont::const_iterator exitLink =
MSLane::succLinkSec(*
this, view + 1, *lane, bestLaneConts);
2334 bool dummySetRequest;
2335 double dummyVLinkWait;
2340 #ifdef DEBUG_PLAN_MOVE
2342 std::cout <<
"\n" <<
SIMTIME <<
" next stop: distance = " <<
myStopDist <<
" requires stopSpeed = " << stopSpeed <<
"\n";
2352 MSLinkCont::const_iterator link =
MSLane::succLinkSec(*
this, view + 1, *lane, bestLaneConts);
2355 if (!encounteredTurn) {
2365 encounteredTurn =
true;
2366 #ifdef DEBUG_NEXT_TURN
2369 <<
" at " <<
myNextTurn.first <<
"m." << std::endl;
2385 if (lastLink !=
nullptr) {
2393 ((*link)->getViaLane() ==
nullptr
2407 if (lastLink !=
nullptr) {
2415 #ifdef DEBUG_PLAN_MOVE
2417 std::cout <<
" braking for link end lane=" << lane->
getID() <<
" seen=" << seen
2427 lateralShift += (*link)->getLateralShift();
2428 const bool yellowOrRed = (*link)->haveRed() || (*link)->haveYellow();
2439 double laneStopOffset;
2443 const bool canBrakeBeforeLaneEnd = seen >= brakeDist;
2444 const bool canBrakeBeforeStopLine = seen - lane->
getStopOffset(
this) >= brakeDist;
2447 laneStopOffset = majorStopOffset;
2448 }
else if ((*link)->havePriority()) {
2450 laneStopOffset =
MIN2((*link)->getFoeVisibilityDistance() -
POSITION_EPS, majorStopOffset);
2453 laneStopOffset =
MIN2((*link)->getFoeVisibilityDistance() -
POSITION_EPS, minorStopOffset);
2455 if (canBrakeBeforeLaneEnd) {
2457 laneStopOffset =
MIN2(laneStopOffset, seen - brakeDist);
2460 const double stopDist =
MAX2(0., seen - laneStopOffset);
2462 #ifdef DEBUG_PLAN_MOVE
2464 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" effective stopOffset on lane '" << lane->
getID()
2465 <<
"' is " << laneStopOffset <<
" (-> stopDist=" << stopDist <<
")" << std::endl;
2469 if (canBrakeBeforeLaneEnd &&
canReverse(laneMaxV)) {
2470 lfLinks.push_back(
DriveProcessItem(*link, vMinComfortable, vMinComfortable,
false, t, vMinComfortable, 0, 0, seen));
2482 assert(timeRemaining != 0);
2486 #ifdef DEBUG_PLAN_MOVE
2488 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" slowing down to finish continuous change before"
2489 <<
" link=" << (*link)->getViaLaneOrLane()->getID()
2490 <<
" timeRemaining=" << timeRemaining
2503 const bool abortRequestAfterMinor = slowedDownForMinor && (*link)->getInternalLaneBefore() ==
nullptr;
2505 bool setRequest = (v >
NUMERICAL_EPS_SPEED && !abortRequestAfterMinor) || (leavingCurrentIntersection);
2508 #ifdef DEBUG_PLAN_MOVE
2511 <<
" stopDist=" << stopDist
2512 <<
" vLinkWait=" << vLinkWait
2513 <<
" brakeDist=" << brakeDist
2515 <<
" leaveIntersection=" << leavingCurrentIntersection
2516 <<
" setRequest=" << setRequest
2527 if (yellowOrRed && canBrakeBeforeStopLine && !
ignoreRed(*link, canBrakeBeforeStopLine)) {
2537 if (
ignoreRed(*link, canBrakeBeforeStopLine) &&
STEPS2TIME(t - (*link)->getLastStateChange()) > 2) {
2542 #ifdef DEBUG_PLAN_MOVE
2544 <<
" ignoreRed spent=" <<
STEPS2TIME(t - (*link)->getLastStateChange())
2545 <<
" redSpeed=" << redSpeed
2555 if (lastLink !=
nullptr) {
2558 double arrivalSpeed = vLinkPass;
2564 double visibilityDistance = (*link)->getFoeVisibilityDistance();
2565 double determinedFoePresence = seen <= visibilityDistance;
2570 #ifdef DEBUG_PLAN_MOVE
2572 std::cout <<
" approaching link=" << (*link)->getViaLaneOrLane()->getID() <<
" prio=" << (*link)->havePriority() <<
" seen=" << seen <<
" visibilityDistance=" << visibilityDistance <<
" brakeDist=" << brakeDist <<
"\n";
2576 if (!(*link)->havePriority() && !determinedFoePresence && brakeDist < seen && !(*link)->lastWasContMajor()) {
2581 arrivalSpeed =
MIN2(vLinkPass, maxArrivalSpeed);
2582 slowedDownForMinor =
true;
2583 #ifdef DEBUG_PLAN_MOVE
2585 std::cout <<
" slowedDownForMinor maxSpeedAtVisDist=" << maxSpeedAtVisibilityDist <<
" maxArrivalSpeed=" << maxArrivalSpeed <<
" arrivalSpeed=" << arrivalSpeed <<
"\n";
2602 double arrivalSpeedBraking = 0;
2609 arrivalSpeedBraking =
MIN2(arrivalSpeedBraking, arrivalSpeed);
2613 if (v + arrivalSpeedBraking <= 0.) {
2614 arrivalTimeBraking = std::numeric_limits<long long int>::max();
2616 arrivalTimeBraking =
MAX2(arrivalTime, t +
TIME2STEPS(seen / ((v + arrivalSpeedBraking) * 0.5)));
2620 arrivalTime, arrivalSpeed,
2621 arrivalTimeBraking, arrivalSpeedBraking,
2624 if ((*link)->getViaLane() ==
nullptr) {
2625 hadNonInternal =
true;
2628 #ifdef DEBUG_PLAN_MOVE
2630 std::cout <<
" checkAbort setRequest=" << setRequest <<
" v=" << v <<
" seen=" << seen <<
" dist=" << dist
2631 <<
" seenNonInternal=" << seenNonInternal
2632 <<
" seenInternal=" << seenInternal <<
" length=" << vehicleLength <<
"\n";
2636 if ((!setRequest || v <= 0 || seen > dist) && hadNonInternal && seenNonInternal >
MAX2(vehicleLength *
CRLL_LOOK_AHEAD, vehicleLength + seenInternal)) {
2640 lane = (*link)->getViaLaneOrLane();
2643 laneMaxV = std::numeric_limits<double>::max();
2657 leaderLane = opposite ? lane->
getOpposite() : lane;
2658 if (leaderLane ==
nullptr) {
2664 lastLink = &lfLinks.back();
2679 const MSLane*
const lane,
double& v,
double& vLinkPass)
const {
2682 ahead.
getSubLanes(
this, latOffset, rightmost, leftmost);
2683 #ifdef DEBUG_PLAN_MOVE
2685 <<
"\nADAPT_TO_LEADERS\nveh=" <<
getID()
2686 <<
" lane=" << lane->
getID()
2687 <<
" latOffset=" << latOffset
2688 <<
" rm=" << rightmost
2689 <<
" lm=" << leftmost
2703 for (
int sublane = rightmost; sublane <= leftmost; ++sublane) {
2705 if (pred !=
nullptr && pred !=
this) {
2708 double gap = (lastLink ==
nullptr
2714 #ifdef DEBUG_PLAN_MOVE
2716 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";
2719 adaptToLeader(std::make_pair(pred, gap), seen, lastLink, lane, v, vLinkPass);
2728 const MSLane*
const lane,
double& v,
double& vLinkPass,
2729 double distToCrossing)
const {
2730 if (leaderInfo.first != 0) {
2731 const double vsafeLeader =
getSafeFollowSpeed(leaderInfo, seen, lane, distToCrossing);
2732 if (lastLink !=
nullptr) {
2735 v =
MIN2(v, vsafeLeader);
2736 vLinkPass =
MIN2(vLinkPass, vsafeLeader);
2738 #ifdef DEBUG_PLAN_MOVE
2742 <<
" veh=" <<
getID()
2743 <<
" lead=" << leaderInfo.first->getID()
2744 <<
" leadSpeed=" << leaderInfo.first->getSpeed()
2745 <<
" gap=" << leaderInfo.second
2746 <<
" leadLane=" << leaderInfo.first->getLane()->getID()
2747 <<
" predPos=" << leaderInfo.first->getPositionOnLane()
2749 <<
" lane=" << lane->
getID()
2751 <<
" dTC=" << distToCrossing
2753 <<
" vSafeLeader=" << vsafeLeader
2754 <<
" vLinkPass=" << vLinkPass
2763 DriveProcessItem*
const lastLink,
double& v,
double& vLinkPass,
double& vLinkWait,
bool& setRequest)
const {
2766 checkLinkLeader(link, lane, seen, lastLink, v, vLinkPass, vLinkWait, setRequest);
2769 if (parallelLink !=
nullptr) {
2770 checkLinkLeader(parallelLink, lane, seen, lastLink, v, vLinkPass, vLinkWait, setRequest,
true);
2779 DriveProcessItem*
const lastLink,
double& v,
double& vLinkPass,
double& vLinkWait,
bool& setRequest,
2780 bool isShadowLink)
const {
2781 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
2787 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
2792 for (MSLink::LinkLeaders::const_iterator it = linkLeaders.begin(); it != linkLeaders.end(); ++it) {
2794 const MSVehicle* leader = (*it).vehAndGap.first;
2795 if (leader ==
nullptr) {
2797 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
2799 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" is blocked on link to " << link->
getViaLaneOrLane()->
getID() <<
" by pedestrian. dist=" << it->distToCrossing <<
"\n";
2802 adaptToLeader(std::make_pair(
this, -1), seen, lastLink, lane, v, vLinkPass, it->distToCrossing);
2803 }
else if (
isLeader(link, leader)) {
2810 linkLeadersAhead.
addLeader(leader,
false, 0);
2814 #ifdef DEBUG_PLAN_MOVE
2818 <<
" isShadowLink=" << isShadowLink
2819 <<
" lane=" << lane->
getID()
2820 <<
" foe=" << leader->
getID()
2822 <<
" latOffset=" << latOffset
2824 <<
" linkLeadersAhead=" << linkLeadersAhead.
toString()
2829 #ifdef DEBUG_PLAN_MOVE
2838 adaptToLeader(it->vehAndGap, seen, lastLink, lane, v, vLinkPass, it->distToCrossing);
2840 if (lastLink !=
nullptr) {
2854 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
2856 std::cout <<
" aborting request\n";
2863 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
2865 std::cout <<
" aborting previous request\n";
2871 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
2874 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" ignoring leader " << leader->
getID()
2884 vLinkWait =
MIN2(vLinkWait, v);
2890 const double seen,
const MSLane*
const lane,
double distToCrossing)
const {
2891 assert(leaderInfo.first != 0);
2893 double vsafeLeader = 0;
2895 vsafeLeader = -std::numeric_limits<double>::max();
2897 if (leaderInfo.second >= 0) {
2898 vsafeLeader = cfModel.
followSpeed(
this,
getSpeed(), leaderInfo.second, leaderInfo.first->getSpeed(), leaderInfo.first->getCurrentApparentDecel(), leaderInfo.first);
2903 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
2905 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" stopping before junction: lane=" << lane->
getID() <<
" seen=" << seen
2908 <<
" vsafeLeader=" << vsafeLeader
2913 if (distToCrossing >= 0) {
2946 double vSafeZipper = std::numeric_limits<double>::max();
2949 bool canBrakeVSafeMin =
false;
2954 MSLink*
const link = dpi.myLink;
2956 #ifdef DEBUG_EXEC_MOVE
2960 <<
" veh=" <<
getID()
2962 <<
" req=" << dpi.mySetRequest
2963 <<
" vP=" << dpi.myVLinkPass
2964 <<
" vW=" << dpi.myVLinkWait
2965 <<
" d=" << dpi.myDistance
2972 if (link !=
nullptr && dpi.mySetRequest) {
2981 const bool ignoreRedLink =
ignoreRed(link, canBrake) || beyondStopLine;
2982 if (yellow && canBrake && !ignoreRedLink) {
2983 vSafe = dpi.myVLinkWait;
2985 #ifdef DEBUG_CHECKREWINDLINKLANES
2987 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (yellow)\n";
2994 std::vector<const SUMOVehicle*> collectFoes;
2995 bool opened = (yellow || influencerPrio
2996 || link->
opened(dpi.myArrivalTime, dpi.myArrivalSpeed, dpi.getLeaveSpeed(),
3002 ignoreRedLink,
this));
3005 if (parallelLink !=
nullptr) {
3008 opened = yellow || influencerPrio || (opened && parallelLink->
opened(dpi.myArrivalTime, dpi.myArrivalSpeed, dpi.getLeaveSpeed(),
3012 ignoreRedLink,
this));
3013 #ifdef DEBUG_EXEC_MOVE
3016 <<
" veh=" <<
getID()
3020 <<
" opened=" << opened
3027 #ifdef DEBUG_EXEC_MOVE
3030 <<
" opened=" << opened
3031 <<
" influencerPrio=" << influencerPrio
3034 <<
" isCont=" << link->
isCont()
3035 <<
" ignoreRed=" << ignoreRedLink
3041 double determinedFoePresence = dpi.myDistance <= visibilityDistance;
3042 if (!determinedFoePresence && (canBrake || !yellow)) {
3043 vSafe = dpi.myVLinkWait;
3045 #ifdef DEBUG_CHECKREWINDLINKLANES
3047 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (minor)\n";
3066 vSafeMinDist = dpi.myDistance;
3072 canBrakeVSafeMin = canBrake;
3073 #ifdef DEBUG_EXEC_MOVE
3075 std::cout <<
" vSafeMin=" << vSafeMin <<
" vSafeMinDist=" << vSafeMinDist <<
" canBrake=" << canBrake <<
"\n";
3082 vSafe = dpi.myVLinkPass;
3086 #ifdef DEBUG_CHECKREWINDLINKLANES
3088 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (very slow)\n";
3093 vSafeZipper =
MIN2(vSafeZipper,
3094 link->
getZipperSpeed(
this, dpi.myDistance, dpi.myVLinkPass, dpi.myArrivalTime, &collectFoes));
3096 vSafe = dpi.myVLinkWait;
3098 #ifdef DEBUG_CHECKREWINDLINKLANES
3100 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (closed)\n";
3106 #ifdef DEBUG_EXEC_MOVE
3117 #ifdef DEBUG_EXEC_MOVE
3119 std::cout <<
SIMTIME <<
" reseting junctionEntryTime at junction '" << link->
getJunction()->
getID() <<
"' beause of non-request exitLink\n";
3126 vSafe = dpi.myVLinkWait;
3129 #ifdef DEBUG_CHECKREWINDLINKLANES
3131 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (no request, braking)\n";
3136 #ifdef DEBUG_CHECKREWINDLINKLANES
3138 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (no request, stopping)\n";
3164 #ifdef DEBUG_EXEC_MOVE
3166 std::cout <<
"vSafeMin Problem? vSafe=" << vSafe <<
" vSafeMin=" << vSafeMin <<
" vSafeMinDist=" << vSafeMinDist << std::endl;
3169 if (canBrakeVSafeMin && vSafe <
getSpeed()) {
3174 #ifdef DEBUG_CHECKREWINDLINKLANES
3176 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" haveToWait (vSafe=" << vSafe <<
" < vSafeMin=" << vSafeMin <<
")\n";
3194 vSafe =
MIN2(vSafe, vSafeZipper);
3203 std::cout <<
SIMTIME <<
" MSVehicle::processTraCISpeedControl() for vehicle '" <<
getID() <<
"'"
3204 <<
" vSafe=" << vSafe <<
" (init)vNext=" << vNext;
3213 vMin =
MAX2(0., vMin);
3218 std::cout <<
" (processed)vNext=" << vNext << std::endl;
3228 #ifdef DEBUG_ACTIONSTEPS
3230 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" removePassedDriveItems()\n"
3231 <<
" Current items: ";
3233 if (j.myLink == 0) {
3234 std::cout <<
"\n Stop at distance " << j.myDistance;
3236 const MSLane* to = j.myLink->getViaLaneOrLane();
3237 const MSLane* from = j.myLink->getLaneBefore();
3238 std::cout <<
"\n Link at distance " << j.myDistance <<
": '"
3239 << (from == 0 ?
"NONE" : from->
getID()) <<
"' -> '" << (to == 0 ?
"NONE" : to->
getID()) <<
"'";
3242 std::cout <<
"\n myNextDriveItem: ";
3249 std::cout <<
"\n Link at distance " <<
myNextDriveItem->myDistance <<
": '"
3250 << (from == 0 ?
"NONE" : from->
getID()) <<
"' -> '" << (to == 0 ?
"NONE" : to->
getID()) <<
"'";
3253 std::cout << std::endl;
3257 #ifdef DEBUG_ACTIONSTEPS
3259 std::cout <<
" Removing item: ";
3260 if (j->myLink == 0) {
3261 std::cout <<
"Stop at distance " << j->myDistance;
3263 const MSLane* to = j->myLink->getViaLaneOrLane();
3264 const MSLane* from = j->myLink->getLaneBefore();
3265 std::cout <<
"Link at distance " << j->myDistance <<
": '"
3266 << (from == 0 ?
"NONE" : from->
getID()) <<
"' -> '" << (to == 0 ?
"NONE" : to->
getID()) <<
"'";
3268 std::cout << std::endl;
3271 if (j->myLink !=
nullptr) {
3272 j->myLink->removeApproaching(
this);
3282 #ifdef DEBUG_ACTIONSTEPS
3284 std::cout <<
SIMTIME <<
" updateDriveItems(), veh='" <<
getID() <<
"' (lane: '" <<
getLane()->
getID() <<
"')\nCurrent drive items:" << std::endl;
3285 DriveItemVector::iterator i;
3288 <<
" vPass=" << dpi.myVLinkPass
3289 <<
" vWait=" << dpi.myVLinkWait
3290 <<
" linkLane=" << (dpi.myLink == 0 ?
"NULL" : dpi.myLink->getViaLaneOrLane()->getID())
3291 <<
" request=" << dpi.mySetRequest
3294 std::cout <<
" myNextDriveItem's linked lane: " << (
myNextDriveItem->myLink == 0 ?
"NULL" :
myNextDriveItem->myLink->getViaLaneOrLane()->getID()) << std::endl;
3301 const MSLink* nextPlannedLink =
nullptr;
3304 while (i !=
myLFLinkLanes.end() && nextPlannedLink ==
nullptr) {
3305 nextPlannedLink = i->myLink;
3309 if (nextPlannedLink ==
nullptr) {
3311 #ifdef DEBUG_ACTIONSTEPS
3313 std::cout <<
"Found no link-related drive item." << std::endl;
3321 #ifdef DEBUG_ACTIONSTEPS
3323 std::cout <<
"Continuing on planned lane sequence, no update required." << std::endl;
3345 #ifdef DEBUG_ACTIONSTEPS
3347 std::cout <<
"Changed lane. Drive items will be updated along the current lane continuation." << std::endl;
3359 MSLink* newLink =
nullptr;
3361 if (driveItemIt->myLink ==
nullptr) {
3371 #ifdef DEBUG_ACTIONSTEPS
3373 std::cout <<
"Reached end of the new continuation sequence. Erasing leftover link-items." << std::endl;
3377 if (driveItemIt->myLink ==
nullptr) {
3390 if (newLink == driveItemIt->myLink) {
3392 #ifdef DEBUG_ACTIONSTEPS
3394 std::cout <<
"Old and new continuation sequences merge at link\n"
3396 <<
"\nNo update beyond merge required." << std::endl;
3402 #ifdef DEBUG_ACTIONSTEPS
3404 std::cout <<
"lane=" << lane->
getID() <<
"\nUpdating link\n '" << driveItemIt->myLink->getLaneBefore()->getID() <<
"'->'" << driveItemIt->myLink->getViaLaneOrLane()->getID() <<
"'"
3408 newLink->
setApproaching(
this, driveItemIt->myLink->getApproaching(
this));
3409 driveItemIt->myLink->removeApproaching(
this);
3410 driveItemIt->myLink = newLink;
3417 #ifdef DEBUG_ACTIONSTEPS
3419 std::cout <<
"Updated drive items:" << std::endl;
3420 DriveItemVector::iterator i;
3423 <<
" vPass=" << dpi.myVLinkPass
3424 <<
" vWait=" << dpi.myVLinkWait
3425 <<
" linkLane=" << (dpi.myLink == 0 ?
"NULL" : dpi.myLink->getViaLaneOrLane()->getID())
3426 <<
" request=" << dpi.mySetRequest
3443 brakelightsOn =
true;
3479 #ifdef DEBUG_REVERSE_BIDI
3516 if (!further->getEdge().isInternal()) {
3517 if (further->getEdge().getBidiEdge() != *(
myCurrEdge + view)
3533 passedLanes.push_back(*i);
3535 if (passedLanes.size() == 0 || passedLanes.back() !=
myLane) {
3536 passedLanes.push_back(
myLane);
3563 if (link !=
nullptr) {
3568 emergencyReason =
" because of a red traffic light";
3576 }
else if (reverseTrain) {
3577 approachedLane = (*(
myCurrEdge + 1))->getLanes()[0];
3587 emergencyReason =
" because there is no connection to the next edge";
3588 approachedLane =
nullptr;
3591 if (approachedLane !=
myLane && approachedLane !=
nullptr) {
3609 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
3625 WRITE_WARNING(
"Vehicle '" +
getID() +
"' could not finish continuous lane change (turn lane) time=" +
3635 passedLanes.push_back(approachedLane);
3640 #ifdef DEBUG_ACTIONSTEPS
3642 std::cout <<
"Updated drive items:" << std::endl;
3645 <<
" vPass=" << (*i).myVLinkPass
3646 <<
" vWait=" << (*i).myVLinkWait
3647 <<
" linkLane=" << ((*i).myLink == 0 ?
"NULL" : (*i).myLink->getViaLaneOrLane()->getID())
3648 <<
" request=" << (*i).mySetRequest
3665 #ifdef DEBUG_EXEC_MOVE
3667 std::cout <<
"\nEXECUTE_MOVE\n"
3669 <<
" veh=" <<
getID()
3677 double vSafe = std::numeric_limits<double>::max();
3679 double vSafeMin = -std::numeric_limits<double>::max();
3682 double vSafeMinDist = 0;
3687 #ifdef DEBUG_ACTIONSTEPS
3689 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"'\n"
3690 " vsafe from processLinkApproaches(): vsafe " << vSafe << std::endl;
3696 #ifdef DEBUG_ACTIONSTEPS
3698 std::cout <<
SIMTIME <<
" vehicle '" <<
getID() <<
"' skips processLinkApproaches()\n"
3700 <<
"speed: " <<
getSpeed() <<
" -> " << vSafe << std::endl;
3714 double vNext = vSafe;
3718 vNext =
MAX2(vNext, vSafeMin);
3726 #ifdef DEBUG_EXEC_MOVE
3728 std::cout <<
SIMTIME <<
" finalizeSpeed vSafe=" << vSafe <<
" vSafeMin=" << (vSafeMin == -std::numeric_limits<double>::max() ?
"-Inf" :
toString(vSafeMin))
3729 <<
" vNext=" << vNext <<
" (i.e. accel=" <<
SPEED2ACCEL(vNext -
getSpeed()) <<
")" << std::endl;
3746 vNext =
MAX2(vNext, 0.);
3761 std::vector<MSLane*> passedLanes;
3765 std::string emergencyReason =
" for unknown reasons";
3774 +
"'" + emergencyReason
3786 passedLanes.clear();
3788 #ifdef DEBUG_ACTIONSTEPS
3790 std::cout <<
SIMTIME <<
" veh '" <<
getID() <<
"' updates further lanes." << std::endl;
3817 #ifdef DEBUG_ACTIONSTEPS
3819 std::cout <<
SIMTIME <<
" veh '" <<
getID() <<
"' skips LCM->prepareStep()." << std::endl;
3826 #ifdef DEBUG_EXEC_MOVE
3865 #ifdef DEBUG_EXEC_MOVE
3867 std::cout <<
SIMTIME <<
" updateState() for veh '" <<
getID() <<
"': deltaPos=" << deltaPos
3872 if (decelPlus > 0) {
3882 +
" severity=" +
toString(emergencyFraction)
3923 const std::vector<MSLane*>& passedLanes) {
3924 #ifdef DEBUG_SETFURTHER
3926 <<
" updateFurtherLanes oldFurther=" <<
toString(furtherLanes)
3927 <<
" oldFurtherPosLat=" <<
toString(furtherLanesPosLat)
3928 <<
" passed=" <<
toString(passedLanes)
3931 for (std::vector<MSLane*>::iterator i = furtherLanes.begin(); i != furtherLanes.end(); ++i) {
3932 (*i)->resetPartialOccupation(
this);
3935 std::vector<MSLane*> newFurther;
3936 std::vector<double> newFurtherPosLat;
3939 if (passedLanes.size() > 1) {
3941 std::vector<MSLane*>::const_iterator fi = furtherLanes.begin();
3942 std::vector<double>::const_iterator fpi = furtherLanesPosLat.begin();
3943 for (
auto pi = passedLanes.rbegin() + 1; pi != passedLanes.rend() && backPosOnPreviousLane < 0; ++pi) {
3945 newFurther.push_back(*pi);
3946 backPosOnPreviousLane += (*pi)->setPartialOccupation(
this);
3947 if (fi != furtherLanes.end() && *pi == *fi) {
3949 newFurtherPosLat.push_back(*fpi);
3957 if (newFurtherPosLat.size() == 0) {
3964 newFurtherPosLat.push_back(newFurtherPosLat.back());
3967 #ifdef DEBUG_SETFURTHER
3969 std::cout <<
SIMTIME <<
" updateFurtherLanes \n"
3970 <<
" further lane '" << (*pi)->getID() <<
"' backPosOnPreviousLane=" << backPosOnPreviousLane
3975 furtherLanes = newFurther;
3976 furtherLanesPosLat = newFurtherPosLat;
3978 furtherLanes.clear();
3979 furtherLanesPosLat.clear();
3981 #ifdef DEBUG_SETFURTHER
3983 <<
" newFurther=" <<
toString(furtherLanes)
3984 <<
" newFurtherPosLat=" <<
toString(furtherLanesPosLat)
3985 <<
" newBackPos=" << backPosOnPreviousLane
3988 return backPosOnPreviousLane;
3994 #ifdef DEBUG_FURTHER
3997 <<
" getBackPositionOnLane veh=" <<
getID()
4028 leftLength -= (*i)->getLength();
4039 leftLength -= (*i)->getLength();
4050 auto j = furtherTargetLanes.begin();
4051 while (leftLength > 0 && j != furtherTargetLanes.end()) {
4052 leftLength -= (*i)->getLength();
4063 #pragma warning(push)
4064 #pragma warning(disable: 4127) // do not warn about constant conditional expression
4068 #pragma warning(pop)
4091 for (MSLane::VehCont::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
4097 foundStopped =
true;
4103 lengths += (*i)->getVehicleType().getLengthWithGap();
4113 double seenSpace = -lengthsInFront;
4114 #ifdef DEBUG_CHECKREWINDLINKLANES
4116 std::cout <<
"\nCHECK_REWIND_LINKLANES\n" <<
" veh=" <<
getID() <<
" lengthsInFront=" << lengthsInFront <<
"\n";
4119 bool foundStopped =
false;
4122 for (
int i = 0; i < (int)lfLinks.size(); ++i) {
4125 #ifdef DEBUG_CHECKREWINDLINKLANES
4128 <<
" foundStopped=" << foundStopped;
4130 if (item.
myLink ==
nullptr || foundStopped) {
4131 if (!foundStopped) {
4136 #ifdef DEBUG_CHECKREWINDLINKLANES
4145 if (approachedLane !=
nullptr) {
4148 if (approachedLane ==
myLane) {
4155 #ifdef DEBUG_CHECKREWINDLINKLANES
4157 <<
" approached=" << approachedLane->
getID()
4160 <<
" seenSpace=" << seenSpace
4162 <<
" lengthsInFront=" << lengthsInFront
4169 if (last ==
nullptr || last ==
this) {
4172 seenSpace += approachedLane->
getLength();
4175 #ifdef DEBUG_CHECKREWINDLINKLANES
4181 bool foundStopped2 =
false;
4183 seenSpace += spaceTillLastStanding;
4184 if (foundStopped2) {
4185 foundStopped =
true;
4190 foundStopped =
true;
4193 #ifdef DEBUG_CHECKREWINDLINKLANES
4195 <<
" approached=" << approachedLane->
getID()
4196 <<
" last=" << last->
getID()
4203 <<
" stls=" << spaceTillLastStanding
4205 <<
" seenSpace=" << seenSpace
4206 <<
" foundStopped=" << foundStopped
4207 <<
" foundStopped2=" << foundStopped2
4214 for (
int i = ((
int)lfLinks.size() - 1); i > 0; --i) {
4218 const bool opened = item.
myLink !=
nullptr && canLeaveJunction && (
4226 #ifdef DEBUG_CHECKREWINDLINKLANES
4229 <<
" canLeave=" << canLeaveJunction
4230 <<
" opened=" << opened
4231 <<
" allowsContinuation=" << allowsContinuation
4232 <<
" foundStopped=" << foundStopped
4235 if (!opened && item.
myLink !=
nullptr) {
4236 foundStopped =
true;
4240 allowsContinuation =
true;
4244 if (allowsContinuation) {
4246 #ifdef DEBUG_CHECKREWINDLINKLANES
4256 int removalBegin = -1;
4257 for (
int i = 0; foundStopped && i < (int)lfLinks.size() && removalBegin < 0; ++i) {
4260 if (item.
myLink ==
nullptr) {
4271 #ifdef DEBUG_CHECKREWINDLINKLANES
4274 <<
" veh=" <<
getID()
4277 <<
" leftSpace=" << leftSpace
4280 if (leftSpace < 0/* && item.myLink->willHaveBlockedFoe()*/) {
4281 double impatienceCorrection = 0;
4288 if (leftSpace < -impatienceCorrection / 10. &&
keepClear(item.
myLink)) {
4296 while (removalBegin < (
int)(lfLinks.size())) {
4298 lfLinks[removalBegin].myVLinkPass = lfLinks[removalBegin].myVLinkWait;
4299 #ifdef DEBUG_CHECKREWINDLINKLANES
4301 std::cout <<
" removalBegin=" << removalBegin <<
" brakeGap=" << brakeGap <<
" dist=" << lfLinks[removalBegin].myDistance <<
" speed=" <<
myState.
mySpeed <<
" a2s=" <<
ACCEL2SPEED(
getCarFollowModel().getMaxDecel()) <<
"\n";
4305 lfLinks[removalBegin].mySetRequest =
false;
4321 if (dpi.myLink !=
nullptr) {
4325 dpi.myLink->setApproaching(
this, dpi.myArrivalTime, dpi.myArrivalSpeed, dpi.getLeaveSpeed(),
4326 dpi.mySetRequest, dpi.myArrivalTimeBraking, dpi.myArrivalSpeedBraking,
getWaitingTime(), dpi.myDistance);
4332 if (dpi.myLink !=
nullptr) {
4334 if (parallelLink !=
nullptr) {
4335 parallelLink->
setApproaching(
this, dpi.myArrivalTime, dpi.myArrivalSpeed, dpi.getLeaveSpeed(),
4336 dpi.mySetRequest, dpi.myArrivalTimeBraking, dpi.myArrivalSpeedBraking,
getWaitingTime(), dpi.myDistance);
4342 #ifdef DEBUG_PLAN_MOVE
4345 <<
" veh=" <<
getID()
4346 <<
" after checkRewindLinkLanes\n";
4349 <<
" vPass=" << dpi.myVLinkPass
4350 <<
" vWait=" << dpi.myVLinkWait
4351 <<
" linkLane=" << (dpi.myLink == 0 ?
"NULL" : dpi.myLink->getViaLaneOrLane()->getID())
4352 <<
" request=" << dpi.mySetRequest
4353 <<
" atime=" << dpi.myArrivalTime
4354 <<
" atimeB=" << dpi.myArrivalTimeBraking
4365 if (rem->first->getLane() !=
nullptr && rem->second > 0.) {
4367 if (myTraceMoveReminders) {
4368 traceMoveReminder(
"notifyEnter_skipped", rem->first, rem->second,
true);
4373 if (rem->first->notifyEnter(*
this, reason, enteredLane)) {
4375 if (myTraceMoveReminders) {
4376 traceMoveReminder(
"notifyEnter", rem->first, rem->second,
true);
4382 if (myTraceMoveReminders) {
4383 traceMoveReminder(
"notifyEnter", rem->first, rem->second,
false);
4420 if (!onTeleporting) {
4424 assert(oldLane != 0);
4463 if (lane !=
nullptr) {
4466 if (lane !=
nullptr) {
4467 #ifdef DEBUG_SETFURTHER
4469 std::cout <<
SIMTIME <<
" enterLaneAtLaneChange \n";
4475 #ifdef DEBUG_SETFURTHER
4477 std::cout <<
SIMTIME <<
" enterLaneAtLaneChange \n";
4480 leftLength -= (lane)->setPartialOccupation(
this);
4488 #ifdef DEBUG_SETFURTHER
4521 MSLane* clane = enteredLane;
4522 while (leftLength > 0) {
4529 leftLength -= (clane)->setPartialOccupation(
this);
4535 #ifdef DEBUG_FURTHER
4537 std::cout <<
SIMTIME <<
" enterLaneAtInsertion \n";
4540 (*i)->resetPartialOccupation(
this);
4561 if (rem->first->notifyLeave(*
this,
myState.
myPos + rem->second, reason, approachedLane)) {
4563 if (myTraceMoveReminders) {
4564 traceMoveReminder(
"notifyLeave", rem->first, rem->second,
true);
4570 if (myTraceMoveReminders) {
4571 traceMoveReminder(
"notifyLeave", rem->first, rem->second,
false);
4581 #ifdef DEBUG_FURTHER
4583 std::cout <<
SIMTIME <<
" leaveLane \n";
4586 (*i)->resetPartialOccupation(
this);
4620 const std::vector<MSVehicle::LaneQ>&
4628 #ifdef DEBUG_BESTLANES
4633 if (startLane ==
nullptr) {
4636 assert(startLane != 0);
4641 bool startLaneIsOpposite = (startLane->
isInternal()
4644 if (startLaneIsOpposite) {
4646 assert(startLane != 0);
4651 #ifdef DEBUG_BESTLANES
4653 std::cout <<
" only updateOccupancyAndCurrentBestLane\n";
4664 #ifdef DEBUG_BESTLANES
4666 std::cout <<
" nothing to do on internal\n";
4676 std::vector<LaneQ>& lanes = *it;
4677 assert(lanes.size() > 0);
4678 if (&(lanes[0].lane->getEdge()) == nextEdge) {
4680 std::vector<LaneQ> oldLanes = lanes;
4682 const std::vector<MSLane*>& sourceLanes = startLane->
getEdge().
getLanes();
4683 for (std::vector<MSLane*>::const_iterator it_source = sourceLanes.begin(); it_source != sourceLanes.end(); ++it_source) {
4684 for (std::vector<LaneQ>::iterator it_lane = oldLanes.begin(); it_lane != oldLanes.end(); ++it_lane) {
4685 if ((*it_source)->getLinkCont()[0]->getLane() == (*it_lane).lane) {
4686 lanes.push_back(*it_lane);
4693 for (
int i = 0; i < (int)lanes.size(); ++i) {
4694 if (i + lanes[i].bestLaneOffset < 0) {
4695 lanes[i].bestLaneOffset = -i;
4697 if (i + lanes[i].bestLaneOffset >= (
int)lanes.size()) {
4698 lanes[i].bestLaneOffset = (int)lanes.size() - i - 1;
4700 assert(i + lanes[i].bestLaneOffset >= 0);
4701 assert(i + lanes[i].bestLaneOffset < (
int)lanes.size());
4702 if (lanes[i].bestContinuations[0] != 0) {
4704 lanes[i].bestContinuations.insert(lanes[i].bestContinuations.begin(), (
MSLane*)
nullptr);
4706 if (startLane->
getLinkCont()[0]->getLane() == lanes[i].lane) {
4709 assert(&(lanes[i].lane->getEdge()) == nextEdge);
4713 #ifdef DEBUG_BESTLANES
4715 std::cout <<
" updated for internal\n";
4732 const MSLane* nextStopLane =
nullptr;
4733 double nextStopPos = 0;
4736 nextStopLane = nextStop.
lane;
4737 nextStopEdge = nextStop.
edge;
4751 nextStopPos = (*nextStopEdge)->getLength();
4757 double seenLength = 0;
4758 bool progress =
true;
4760 std::vector<LaneQ> currentLanes;
4761 const std::vector<MSLane*>* allowed =
nullptr;
4762 const MSEdge* nextEdge =
nullptr;
4764 nextEdge = *(ce + 1);
4767 const std::vector<MSLane*>& lanes = (*ce)->getLanes();
4768 for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
4776 q.
allowsContinuation = allowed ==
nullptr || std::find(allowed->begin(), allowed->end(), cl) != allowed->end();
4779 currentLanes.push_back(q);
4782 if (nextStopEdge == ce
4789 for (std::vector<LaneQ>::iterator q = currentLanes.begin(); q != currentLanes.end(); ++q) {
4790 if (nextStopLane !=
nullptr && normalStopLane != (*q).lane) {
4791 (*q).allowsContinuation =
false;
4792 (*q).length = nextStopPos;
4793 (*q).currentLength = (*q).length;
4800 seenLength += currentLanes[0].lane->getLength();
4802 progress &= (seen <= 4 || seenLength < 3000);
4803 progress &= (seen <= 8 || seenLength < 200);
4814 double bestLength = -1;
4815 int bestThisIndex = 0;
4818 for (std::vector<LaneQ>::iterator j = last.begin(); j != last.end(); ++j, ++index) {
4819 if ((*j).length > bestLength) {
4820 bestLength = (*j).length;
4821 bestThisIndex = index;
4825 for (std::vector<LaneQ>::iterator j = last.begin(); j != last.end(); ++j, ++index) {
4826 if ((*j).length < bestLength) {
4827 (*j).bestLaneOffset = bestThisIndex - index;
4831 #ifdef DEBUG_BESTLANES
4833 std::cout <<
" last edge:\n";
4835 for (std::vector<LaneQ>::iterator j = laneQs.begin(); j != laneQs.end(); ++j) {
4836 std::cout <<
" lane=" << (*j).lane->getID() <<
" length=" << (*j).length <<
" bestOffset=" << (*j).bestLaneOffset <<
"\n";
4842 for (std::vector<std::vector<LaneQ> >::reverse_iterator i =
myBestLanes.rbegin() + 1; i !=
myBestLanes.rend(); ++i) {
4843 std::vector<LaneQ>& nextLanes = (*(i - 1));
4844 std::vector<LaneQ>& clanes = (*i);
4845 MSEdge& cE = clanes[0].lane->getEdge();
4847 double bestConnectedLength = -1;
4848 double bestLength = -1;
4849 for (std::vector<LaneQ>::iterator j = nextLanes.begin(); j != nextLanes.end(); ++j, ++index) {
4850 if ((*j).lane->isApproachedFrom(&cE) && bestConnectedLength < (*j).length) {
4851 bestConnectedLength = (*j).length;
4853 if (bestLength < (*j).length) {
4854 bestLength = (*j).length;
4858 int bestThisIndex = 0;
4859 if (bestConnectedLength > 0) {
4861 for (std::vector<LaneQ>::iterator j = clanes.begin(); j != clanes.end(); ++j, ++index) {
4862 LaneQ bestConnectedNext;
4863 bestConnectedNext.
length = -1;
4864 if ((*j).allowsContinuation) {
4865 for (std::vector<LaneQ>::const_iterator m = nextLanes.begin(); m != nextLanes.end(); ++m) {
4866 if ((*m).lane->isApproachedFrom(&cE, (*j).lane)) {
4867 if (bestConnectedNext.
length < (*m).length || (bestConnectedNext.
length == (*m).length && abs(bestConnectedNext.
bestLaneOffset) > abs((*m).bestLaneOffset))) {
4868 bestConnectedNext = *m;
4872 if (bestConnectedNext.
length == bestConnectedLength && abs(bestConnectedNext.
bestLaneOffset) < 2) {
4873 (*j).
length += bestLength;
4875 (*j).length += bestConnectedNext.
length;
4880 if (clanes[bestThisIndex].length < (*j).length
4881 || (clanes[bestThisIndex].length == (*j).length && abs(clanes[bestThisIndex].bestLaneOffset) > abs((*j).bestLaneOffset))
4882 || (clanes[bestThisIndex].length == (*j).length && abs(clanes[bestThisIndex].bestLaneOffset) == abs((*j).bestLaneOffset) &&
4885 bestThisIndex = index;
4888 #ifdef DEBUG_BESTLANES
4890 std::cout <<
" edge=" << cE.
getID() <<
"\n";
4891 std::vector<LaneQ>& laneQs = clanes;
4892 for (std::vector<LaneQ>::iterator j = laneQs.begin(); j != laneQs.end(); ++j) {
4893 std::cout <<
" lane=" << (*j).lane->getID() <<
" length=" << (*j).length <<
" bestOffset=" << (*j).bestLaneOffset <<
"\n";
4900 int bestNextIndex = 0;
4901 int bestDistToNeeded = (int) clanes.size();
4903 for (std::vector<LaneQ>::iterator j = clanes.begin(); j != clanes.end(); ++j, ++index) {
4904 if ((*j).allowsContinuation) {
4906 for (std::vector<LaneQ>::const_iterator m = nextLanes.begin(); m != nextLanes.end(); ++m, ++nextIndex) {
4907 if ((*m).lane->isApproachedFrom(&cE, (*j).lane)) {
4908 if (bestDistToNeeded > abs((*m).bestLaneOffset)) {
4909 bestDistToNeeded = abs((*m).bestLaneOffset);
4910 bestThisIndex = index;
4911 bestNextIndex = nextIndex;
4917 clanes[bestThisIndex].length += nextLanes[bestNextIndex].length;
4918 copy(nextLanes[bestNextIndex].bestContinuations.begin(), nextLanes[bestNextIndex].bestContinuations.end(), back_inserter(clanes[bestThisIndex].bestContinuations));
4923 for (std::vector<LaneQ>::iterator j = clanes.begin(); j != clanes.end(); ++j, ++index) {
4924 if ((*j).length < clanes[bestThisIndex].length
4925 || ((*j).length == clanes[bestThisIndex].length && abs((*j).bestLaneOffset) > abs(clanes[bestThisIndex].bestLaneOffset))
4928 (*j).bestLaneOffset = bestThisIndex - index;
4931 (*j).length = (*j).currentLength;
4934 (*j).bestLaneOffset = 0;
4939 #ifdef DEBUG_BESTLANES
4950 if (conts.size() < 2) {
4954 if (link !=
nullptr) {
4966 std::vector<LaneQ>& currLanes = *
myBestLanes.begin();
4967 std::vector<LaneQ>::iterator i;
4968 for (i = currLanes.begin(); i != currLanes.end(); ++i) {
4969 double nextOccupation = 0;
4970 for (std::vector<MSLane*>::const_iterator j = (*i).bestContinuations.begin() + 1; j != (*i).bestContinuations.end(); ++j) {
4971 nextOccupation += (*j)->getBruttoVehLenSum();
4973 (*i).nextOccupation = nextOccupation;
4974 #ifdef DEBUG_BESTLANES
4976 std::cout <<
" lane=" << (*i).lane->getID() <<
" nextOccupation=" << nextOccupation <<
"\n";
4979 if ((*i).lane == startLane) {
4986 const std::vector<MSLane*>&
4991 return (*myCurrentLaneInBestLanes).bestContinuations;
4995 const std::vector<MSLane*>&
5007 if ((*i).lane == lane) {
5008 return (*i).bestContinuations;
5020 return (*myCurrentLaneInBestLanes).bestLaneOffset;
5027 std::vector<MSVehicle::LaneQ>& preb =
myBestLanes.front();
5028 assert(laneIndex < (
int)preb.size());
5029 preb[laneIndex].occupation = density + preb[laneIndex].nextOccupation;
5043 double distance = std::numeric_limits<double>::max();
5044 if (
isOnRoad() && destEdge !=
nullptr) {
5058 std::pair<const MSVehicle* const, double>
5061 return std::make_pair(static_cast<const MSVehicle*>(
nullptr), -1);
5070 MSLane::VehCont::const_iterator it = std::find(vehs.begin(), vehs.end(),
this);
5071 if (it != vehs.end() && it + 1 != vehs.end()) {
5074 if (lead !=
nullptr) {
5075 std::pair<const MSVehicle* const, double> result(
5091 std::pair<const MSVehicle* const, double> leaderInfo =
getLeader(-1);
5092 if (leaderInfo.first ==
nullptr ||
getSpeed() == 0) {
5151 myStops.front().numExpectedPerson -= (int)
myStops.front().pars.awaitedPersons.count(person->
getID());
5158 if (
myStops.size() > 0 &&
myStops.front().reached &&
myStops.front().pars.containerTriggered &&
myStops.front().numExpectedContainer > 0) {
5159 myStops.front().numExpectedContainer -= (int)
myStops.front().pars.awaitedContainers.count(container->
getID());
5169 const bool blinkerManoeuvre = (((state &
LCA_SUBLANE) == 0) && (
5175 std::swap(left, right);
5177 if ((state &
LCA_LEFT) != 0 && blinkerManoeuvre) {
5179 }
else if ((state &
LCA_RIGHT) != 0 && blinkerManoeuvre) {
5191 switch ((*link)->getDirection()) {
5208 &&
myStops.begin()->pars.parking
5222 if (currentTime % 1000 == 0) {
5269 #ifdef DEBUG_FURTHER
5279 for (
int i = 0; i < (int)shadowFurther.size(); ++i) {
5281 if (shadowFurther[i] == lane) {
5304 #ifdef DEBUG_FURTHER
5312 #ifdef DEBUG_FURTHER
5319 for (
int i = 0; i < (int)shadowFurther.size(); ++i) {
5320 if (shadowFurther[i] == lane) {
5321 #ifdef DEBUG_FURTHER
5324 <<
" lane=" << lane->
getID()
5339 MSLane* targetLane = furtherTargets[i];
5340 if (targetLane == lane) {
5343 #ifdef DEBUG_TARGET_LANE
5345 std::cout <<
" getLatOffset veh=" <<
getID()
5351 <<
" targetDir=" << targetDir
5352 <<
" latOffset=" << latOffset
5369 assert(offset == 0 || offset == 1 || offset == -1);
5370 assert(
myLane !=
nullptr);
5375 double leftLimit = halfCurrentLaneWidth - halfVehWidth - latPos;
5376 double rightLimit = -halfCurrentLaneWidth + halfVehWidth - latPos;
5377 double latLaneDist = 0;
5379 if (latPos + halfVehWidth > halfCurrentLaneWidth) {
5381 latLaneDist = halfCurrentLaneWidth - latPos - halfVehWidth;
5382 }
else if (latPos - halfVehWidth < - halfCurrentLaneWidth) {
5384 latLaneDist = halfCurrentLaneWidth - latPos + halfVehWidth;
5386 }
else if (offset == -1) {
5388 }
else if (offset == 1) {
5391 #ifdef DEBUG_ACTIONSTEPS
5394 <<
" veh=" <<
getID()
5395 <<
" halfCurrentLaneWidth=" << halfCurrentLaneWidth
5396 <<
" halfVehWidth=" << halfVehWidth
5397 <<
" latPos=" << latPos
5398 <<
" latLaneDist=" << latLaneDist
5399 <<
" leftLimit=" << leftLimit
5400 <<
" rightLimit=" << rightLimit
5424 if (dpi.myLink !=
nullptr) {
5425 dpi.myLink->removeApproaching(
this);
5445 while (!lane->
isLinkEnd(link) && seen <= dist) {
5448 || !(*link)->havePriority())) {
5452 if ((*di).myLink !=
nullptr) {
5453 const MSLane* diPredLane = (*di).myLink->getLaneBefore();
5454 if (diPredLane !=
nullptr) {
5465 const SUMOTime leaveTime = (*link)->getLeaveTime((*di).myArrivalTime, (*di).myArrivalSpeed,
5467 if ((*link)->hasApproachingFoe((*di).myArrivalTime, leaveTime, (*di).myArrivalSpeed,
getCarFollowModel().getMaxDecel())) {
5474 lane = (*link)->getViaLaneOrLane();
5491 centerLine.push_back(lane->getShape().back());
5520 result.push_back(line1[0]);
5521 result.push_back(line2[0]);
5522 result.push_back(line2[1]);
5523 result.push_back(line1[1]);
5526 result.push_back(line1[1]);
5527 result.push_back(line2[1]);
5528 result.push_back(line2[0]);
5529 result.push_back(line1[0]);
5541 if (&(*i)->getEdge() == edge) {
5558 if (destParkArea ==
nullptr) {
5560 errorMsg =
"Vehicle " +
getID() +
" is not driving to a parking area so it cannot be rerouted.";
5573 if (newParkingArea ==
nullptr) {
5574 errorMsg =
"Parking area ID " +
toString(parkingAreaID) +
" not found in the network.";
5587 if (!newDestination) {
5598 if (edgesFromPark.size() > 0) {
5599 edges.insert(edges.end(), edgesFromPark.begin() + 1, edgesFromPark.end());
5602 if (newDestination) {
5624 const bool parking,
const bool triggered,
const bool containerTriggered, std::string& errorMsg) {
5626 for (std::list<Stop>::iterator iter =
myStops.begin(); iter !=
myStops.end(); iter++) {
5627 if (iter->lane == lane && fabs(iter->pars.endPos - endPos) <
POSITION_EPS) {
5629 if (duration == 0 && until < 0 && !iter->reached) {
5634 iter->duration = duration;
5635 iter->triggered = triggered;
5636 iter->containerTriggered = containerTriggered;
5637 const_cast<SUMOVehicleParameter::Stop&>(iter->pars).until = until;
5638 const_cast<SUMOVehicleParameter::Stop&>(iter->pars).parking = parking;
5648 newStop.
until = until;
5657 if (containerTriggered) {
5663 const bool result =
addStop(newStop, errorMsg);
5677 const bool triggered,
const bool containerTriggered,
const SumoXMLTag stoppingPlaceType, std::string& errorMsg) {
5679 for (std::list<Stop>::iterator iter =
myStops.begin(); iter !=
myStops.end(); iter++) {
5680 Named* stop =
nullptr;
5681 switch (stoppingPlaceType) {
5683 stop = iter->busstop;
5686 stop = iter->containerstop;
5689 stop = iter->chargingStation;
5692 stop = iter->parkingarea;
5697 if (stop !=
nullptr && stop->
getID() == stopId) {
5698 if (duration == 0 && !iter->reached) {
5702 iter->duration = duration;
5709 switch (stoppingPlaceType) {
5726 if (bs ==
nullptr) {
5727 errorMsg =
"The " +
toString(stoppingPlaceType) +
" '" + stopId +
"' is not known for vehicle '" +
getID() +
"'";
5731 newStop.
until = until;
5742 if (containerTriggered) {
5748 const bool result =
addStop(newStop, errorMsg);
5767 if (
myStops.front().busstop !=
nullptr) {
5769 myStops.front().busstop->leaveFrom(
this);
5772 if (
myStops.front().containerstop !=
nullptr) {
5774 myStops.front().containerstop->leaveFrom(
this);
5776 if (
myStops.front().parkingarea !=
nullptr) {
5778 myStops.front().parkingarea->leaveFrom(
this);
5783 if (vehroutes !=
nullptr) {
5811 std::list<MSVehicle::Stop>
5889 #ifdef DEBUG_IGNORE_RED
5894 if (ignoreRedTime < 0) {
5896 if (ignoreYellowTime > 0 && link->
haveYellow()) {
5900 return !canBrake || ignoreYellowTime > yellowDuration;
5910 #ifdef DEBUG_IGNORE_RED
5914 <<
" ignoreRedTime=" << ignoreRedTime
5915 <<
" spentRed=" << redDuration
5916 <<
" canBrake=" << canBrake <<
"\n";
5920 return !canBrake || ignoreRedTime > redDuration;
5946 if (veh ==
nullptr) {
5966 assert(logic !=
nullptr);
5969 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
5972 <<
" foeLane=" << foeLane->
getID()
5974 <<
" linkIndex=" << link->
getIndex()
5975 <<
" foeLinkIndex=" << foeLink->
getIndex()
5976 <<
" response=" << response
5977 <<
" response2=" << response2
5985 }
else if (response && response2) {
5991 if (egoET == foeET) {
5995 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
5997 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" equal ET " << egoET <<
" with foe " << veh->
getID()
5998 <<
" foeIsLeaderByID=" << (
getID() < veh->
getID()) <<
"\n";
6003 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
6005 std::cout <<
SIMTIME <<
" veh=" <<
getID() <<
" equal ET " << egoET <<
" with foe " << veh->
getID()
6015 #ifdef DEBUG_PLAN_MOVE_LEADERINFO
6017 std::cout <<
" egoET=" << egoET <<
" foeET=" << foeET <<
" isLeader=" << (egoET > foeET) <<
"\n";
6020 return egoET > foeET;
6036 std::vector<std::string> internals;
6047 for (std::list<Stop>::const_iterator it =
myStops.begin(); it !=
myStops.end(); ++it) {
6052 dev->saveState(out);
6060 throw ProcessError(
"Error: Invalid vehicles in state (may be a meso state)!");
6091 lastPos += (*myCurrEdge)->getLength();
6094 const double endPos = stop.getEndPos(*
this);
6095 const MSEdge*
const stopEdge = &stop.lane->getEdge();
6097 const std::string prefix =
"Stop " +
toString(i) +
" on edge '" + stopEdge->
getID() +
"' ";
6104 if (it2 == stop.edge) {
6109 WRITE_ERROR(prefix +
"used invalid route index " + err);
6111 }
else if (it2 < start) {
6115 if (it != stop.edge && endPos >= lastPos) {
6128 std::shared_ptr<MSSimpleDriverState>
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.
static SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const MSEdgeVector &prohibited=MSEdgeVector())
return the router instance
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
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].
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
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const MSEdgeVector &prohibited=MSEdgeVector()) 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
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
void removeWaiting(const MSEdge *const edge, const SUMOVehicle *vehicle)
Removes a vehicle from the list of waiting vehicles for the given edge.
const MSLeaderInfo getLastVehicleInformation(const MSVehicle *ego, double latOffset, double minPos=0, bool allowCached=true) const
Returns the last vehicles on the lane.
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
The link is a partial right direction.
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::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
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.
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)....
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.
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.
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].
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
double getZipperSpeed(const MSVehicle *ego, const double dist, double vSafe, SUMOTime arrivalTime, std::vector< const SUMOVehicle * > *collectFoes) const
return the speed at which ego vehicle must approach the zipper link
MSLane * updateTargetLane()
bool getEmergencyBrakeRedLight() const
Returns whether red lights shall be a reason to brake.
void addWaiting(const MSEdge *const edge, SUMOVehicle *vehicle)
Adds a vehicle to the list of waiting vehicles for the given edge.
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
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.
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....
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT() const
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)
bool opened(SUMOTime arrivalTime, double arrivalSpeed, double leaveSpeed, double vehicleLength, double impatience, double decel, SUMOTime waitingTime, double posLat=0, std::vector< const SUMOVehicle * > *collectFoes=0, bool ignoreRed=false, const SUMOVehicle *ego=0) const
Returns the information whether the link may be passed.
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,...
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
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.
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.
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.
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
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
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.
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.
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.
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.
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.
DepartLaneDefinition
Possible ways to choose a lane on depart.
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.
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.
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
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.
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
void resetRoutePosition(int index, DepartLaneDefinition departLaneProcedure)
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)
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.
static double fromNaviDegree(const double angle)
int getRoutePosition() const
void checkLinkLeader(const MSLink *link, const MSLane *lane, double seen, DriveProcessItem *const lastLink, double &v, double &vLinkPass, double &vLinkWait, bool &setRequest, bool isShadowLink=false) const
checks for link leaders on the given link
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.
render as a passenger vehicle
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.
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
virtual void prepareStep()
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
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
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
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.
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
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.
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.
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)
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.
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.