62#define DEBUG_COND (isSelected())
70std::set<std::string> MSBaseVehicle::myShallTraceMoveReminders;
99 throw ProcessError(
"getPreviousSpeed() is not available for non-MSVehicles.");
126 , myTraceMoveReminders(myShallTraceMoveReminders.count(pars->id) > 0)
129 if ((*
myRoute->begin())->isTazConnector() ||
myRoute->getLastEdge()->isTazConnector()) {
227 if (stop ==
nullptr) {
231 if (s.busstop == stop
232 || s.containerstop == stop
233 || s.parkingarea == stop
234 || s.chargingStation == stop) {
244 if (&s.lane->getEdge() == edge) {
256 if (source ==
nullptr) {
260 if (sink ==
nullptr) {
268 double firstPos = -1;
271 if (stops.size() > 0) {
274 const bool skipFirst = stops.front() == source && (source !=
getEdge() || sourcePos +
getBrakeGap() <= firstPos);
275 const bool skipLast = stops.back() == sink &&
myArrivalPos >= lastPos && (
276 stops.size() < 2 || stops.back() != stops[stops.size() - 2]);
280 <<
" source=" << source->
getID() <<
" sourcePos=" << sourcePos <<
" firstPos=" << firstPos <<
" arrivalPos=" <<
myArrivalPos <<
" lastPos=" << lastPos
281 <<
" route=" <<
toString(
myRoute->getEdges()) <<
" stopEdges=" <<
toString(stops) <<
" skipFirst=" << skipFirst <<
" skipLast=" << skipLast <<
"\n";
284 if (stops.size() == 1 && (skipFirst || skipLast)) {
288 stops.erase(stops.begin());
291 stops.erase(stops.end() - 1);
300 if (viaEdge == source || viaEdge == sink) {
303 assert(viaEdge != 0);
307 stops.push_back(viaEdge);
312 for (
const MSEdge*
const stopEdge : stops) {
316 if (jumps.count(stopIndex) != 0) {
317 edges.push_back(source);
321 router.
computeLooped(source, stopEdge,
this, t, into, silent);
323 if (into.size() > 0) {
325 edges.insert(edges.end(), into.begin(), into.end());
326 if (stopEdge->isTazConnector()) {
327 source = into.back();
333 std::string error =
TLF(
"Vehicle '%' has no valid route from edge '%' to stop edge '%'.",
getID(), source->
getID(), stopEdge->getID());
338 edges.push_back(source);
343 if (stops.empty() && source == sink && onInit
349 if (!router.
compute(source, sink,
this, t, edges, silent)) {
355 if (edges.empty() && silent) {
358 if (!edges.empty() && edges.front()->isTazConnector()) {
359 edges.erase(edges.begin());
361 if (!edges.empty() && edges.back()->isTazConnector()) {
365 const double previousCost = onInit ? routeCost : router.
recomputeCosts(oldEdgesRemaining,
this, t);
366 const double savings = previousCost - routeCost;
394 if (msgReturn !=
nullptr) {
395 *msgReturn =
"No route found";
400 std::string
id =
getID();
404 const std::string idSuffix =
id +
"!var#";
408 id = idSuffix +
toString(++varIndex);
410 int oldSize = (int)edges.size();
413 if (origin != *
myCurrEdge && edges.front() == origin) {
415 oldSize = (int)edges.size();
430 if (msgReturn !=
nullptr) {
431 *msgReturn =
"duplicate routeID '" +
id +
"'";
440 if (msgReturn !=
nullptr) {
446 if (!
replaceRoute(constRoute, info, onInit, (
int)edges.size() - oldSize,
false, removeStops, msgReturn)) {
461 if (newCurrEdge == edges.end()) {
462 if (msgReturn !=
nullptr) {
463 *msgReturn =
TLF(
"current edge '%' not found in new route", (*myCurrEdge)->getID());
465#ifdef DEBUG_REPLACE_ROUTE
467 std::cout <<
" newCurrEdge not found\n";
474 (newCurrEdge + 1) == edges.end() || (*(newCurrEdge + 1)) != &(
getLane()->getOutgoingViaLanes().front().first->
getEdge()))) {
475 if (msgReturn !=
nullptr) {
476 *msgReturn =
TL(
"Vehicle is on junction-internal edge leading elsewhere");
478#ifdef DEBUG_REPLACE_ROUTE
480 std::cout <<
" Vehicle is on junction-internal edge leading elsewhere\n";
486 && (newCurrEdge + 1) != edges.end()
488 if (msgReturn !=
nullptr) {
489 *msgReturn =
TL(
"Vehicle is moving past junction and committed to move to another successor edge");
491#ifdef DEBUG_REPLACE_ROUTE
493 std::cout <<
" Vehicle is moving past junction and committed to move to another successor edge\n";
501 const bool stopsFromScratch = onInit &&
myRoute->getStops().empty();
511#ifdef DEBUG_REPLACE_ROUTE
513 std::cout <<
SIMTIME <<
" replaceRoute info=" << info <<
" on " << (*myCurrEdge)->getID()
515 <<
" stopsFromScratch=" << stopsFromScratch
516 <<
" newSize=" << newRoute->getEdges().size()
517 <<
" newIndex=" << (
myCurrEdge - newRoute->begin())
518 <<
" edges=" <<
toString(newRoute->getEdges())
523 if (stopsFromScratch) {
534 lastPos += (*myCurrEdge)->getLength();
536 for (std::list<MSStop>::iterator iter =
myStops.begin(); iter !=
myStops.end();) {
537 double endPos = iter->getEndPos(*
this);
538#ifdef DEBUG_REPLACE_ROUTE
540 std::cout <<
" stopEdge=" << iter->lane->getEdge().getID() <<
" start=" << (searchStart -
myCurrEdge) <<
" endPos=" << endPos <<
" lastPos=" << lastPos <<
"\n";
543 if (*searchStart != &iter->lane->getEdge()
544 || endPos + NUMERICAL_EPS < lastPos) {
545 if (searchStart != edges.end() && !iter->reached) {
551 iter->edge = std::find(searchStart, edges.end(), &iter->lane->getEdge());
552#ifdef DEBUG_REPLACE_ROUTE
554 std::cout <<
" foundIndex=" << (iter->edge -
myCurrEdge) <<
" end=" << (edges.end() -
myCurrEdge) <<
"\n";
557 if (iter->edge == edges.end()) {
564 searchStart = iter->edge;
570 for (std::vector<SUMOVehicleParameter::Stop>::const_iterator i = newRoute->getStops().begin(); i != newRoute->getStops().end(); ++i) {
640 &&
myStops.begin()->pars.permitted.count(t->
getID()) == 0) {
644 if (taxiDevice !=
nullptr) {
678 if (stop.edge == it) {
679 return stop.pars.jump >= 0;
689 if (route ==
nullptr) {
692 start = route->begin();
699 msg =
TLF(
"No connection between edge '%' and edge '%'.", (*e)->getID(), (*(e + 1))->getID());
707 if ((*e)->prohibits(
this)) {
708 msg =
TLF(
"Edge '%' prohibits.", (*e)->getID());
718 if (
myRoute->getEdges().size() > 0 && !(*myCurrEdge)->prohibits(
this)) {
722 msg =
TLF(
"Vehicle '%' is not allowed to depart on its first edge.",
getID());
739 }
else if (!silent) {
742 }
else if (msgReturn !=
nullptr) {
762 if (myTraceMoveReminders) {
763 traceMoveReminder(
"add", rem, 0,
true);
773 if (r->first == rem) {
775 if (myTraceMoveReminders) {
776 traceMoveReminder(
"remove", rem, 0,
false);
789 if (rem->first->notifyEnter(*
this, reason, enteredLane)) {
791 if (myTraceMoveReminders) {
792 traceMoveReminder(
"notifyEnter", rem->first, rem->second,
true);
798 if (myTraceMoveReminders) {
799 traceMoveReminder(
"notifyEnter", rem->first, rem->second,
false);
810 if (
myRoute->getLastEdge()->isTazConnector()) {
815 WRITE_WARNINGF(
TL(
"Vehicle '%' ignores attribute arrivalEdge=% after rerouting at time=% (routeLength=%)"),
820 arrivalEdge =
myRoute->getLastEdge();
824 const std::vector<MSLane*>& lanes = arrivalEdge->
getLanes();
825 const double lastLaneLength = lanes[0]->getLength();
854 for (
MSLane* lane : lanes) {
866 std::vector<MSLane*> usable;
867 for (
MSLane* lane : lanes) {
869 usable.push_back(lane);
872 if (usable.empty()) {
880 for (std::vector<MSLane*>::const_iterator l = lanes.begin(); l != lanes.end(); ++l) {
893 const int routeEdges = (int)
myRoute->getEdges().size();
907 const int routeEdges = (int)
myRoute->getEdges().size();
929 if (
typeid(*dev) == type) {
944 std::ostringstream os;
982 && (
myStops.begin()->parkingarea ==
nullptr || !
myStops.begin()->parkingarea->parkOnRoad())
1017 if (parkingArea == 0) {
1018 errorMsg =
"new parkingArea is NULL";
1022 errorMsg =
"vehicle has no stops";
1025 if (
myStops.front().parkingarea == 0) {
1026 errorMsg =
"first stop is not at parkingArea";
1032 for (std::list<MSStop>::iterator iter = ++
myStops.begin(); iter !=
myStops.end();) {
1033 if (iter->parkingarea == parkingArea) {
1034 stopPar.
duration += iter->duration;
1061 return nextParkingArea;
1069 currentParkingArea =
myStops.begin()->parkingarea;
1071 return currentParkingArea;
1081 && (&
myStops.front().lane->getEdge()) == *
myStops.front().edge) {
1106 if (stopPar.
lane ==
"") {
1110 if (cand->allowsVehicleClass(
getVClass())) {
1115 if (stop.
lane ==
nullptr) {
1116 errorMsg =
"Vehicle '" +
myParameter->
id +
"' is not allowed to stop on any lane of edge '" + stopPar.
edge +
"'.";
1121 if (stop.
lane ==
nullptr) {
1125 assert(stop.
lane !=
nullptr);
1128 errorMsg =
"Vehicle '" +
myParameter->
id +
"' is not allowed to stop on lane '" + stopPar.
lane +
"'.";
1135 errorMsg =
"Mesoscopic simulation does not allow stopping on internal edge '" + stopPar.
edge +
"' for vehicle '" +
myParameter->
id +
"'.";
1140 if (stopPar.
until != -1) {
1147 std::string stopType =
"stop";
1148 std::string stopID =
"";
1149 if (stop.
busstop !=
nullptr) {
1150 stopType =
"busStop";
1153 stopType =
"containerStop";
1156 stopType =
"chargingStation";
1159 stopType =
"overheadWireSegment";
1162 stopType =
"parkingArea";
1165 const std::string errorMsgStart = stopID ==
"" ? stopType : stopType +
" '" + stopID +
"'";
1168 errorMsg = errorMsgStart +
" for vehicle '" +
myParameter->
id +
"' on lane '" + stop.
lane->
getID() +
"' has an invalid position.";
1173 errorMsg = errorMsgStart +
" on lane '" + stop.
lane->
getID() +
"' is too short for vehicle '" +
myParameter->
id +
"'.";
1186 if (searchStart ==
nullptr) {
1190 searchStart = ≻
1193#ifdef DEBUG_ADD_STOP
1195 std::cout <<
"addStop desc=" << stop.
getDescription() <<
" stopEdge=" << stopEdge->
getID()
1196 <<
" searchStart=" << ((*searchStart) ==
myRoute->end() ?
"END" : (**searchStart)->getID())
1201 stop.
edge = std::find(*searchStart,
myRoute->end(), stopEdge);
1206 std::list<MSStop>::iterator iter =
myStops.begin();
1210 prevStopEdge =
myStops.back().edge;
1211 prevEdge = &
myStops.back().lane->getEdge();
1212 prevStopPos =
myStops.back().pars.endPos;
1213 stop.
edge = std::find(prevStopEdge,
myRoute->end(), stopEdge);
1214 if (prevStopEdge == stop.
edge
1217 stop.
edge = std::find(prevStopEdge + 1,
myRoute->end(), stopEdge);
1219#ifdef DEBUG_ADD_STOP
1221 std::cout <<
" (@end) prevStopEdge=" << (*prevStopEdge)->getID() <<
" index=" << (int)(prevStopEdge -
myRoute->begin())
1228 while (iter !=
myStops.end() && (iter->edge < stop.
edge ||
1229 (iter->pars.endPos < stop.
pars.
endPos && iter->edge == stop.
edge) ||
1231 prevStopEdge = iter->edge;
1232 prevStopPos = iter->pars.endPos;
1236 int index = stopPar.
index;
1238 prevStopEdge = iter->edge;
1239 prevStopPos = iter->pars.endPos;
1243#ifdef DEBUG_ADD_STOP
1245 std::cout <<
" (@fit) prevStopEdge=" << (*prevStopEdge)->getID() <<
" index=" << (int)(prevStopEdge -
myRoute->begin()) <<
"\n";
1248 stop.
edge = std::find(prevStopEdge,
myRoute->end(), stopEdge);
1251 const bool wasTooClose = errorMsg !=
"" && errorMsg.find(
"too close") != std::string::npos;
1254 errorMsg = errorMsgStart +
" for vehicle '" +
myParameter->
id +
"' on lane '" + stop.
lane->
getID() +
"' is not downstream the current route.";
1259 const bool tooClose = (prevStopEdge == stop.
edge && prevEdge == &stop.
lane->
getEdge() &&
1262 if (prevStopEdge > stop.
edge ||
1269 if (tooClose && prevStopPos <= stop.
pars.
endPos + POSITION_EPS) {
1270 errorMsg = errorMsgStart +
" for vehicle '" +
myParameter->
id +
"' on lane '" + stop.
pars.
lane +
"' is too close to brake.";
1273 return addStop(stopPar, errorMsg, untilOffset, &next);
1290 pos += (*myCurrEdge)->getLength();
1300 return addStop(stopPar, errorMsg, untilOffset, &next);
1302 errorMsg = errorMsgStart +
" for vehicle '" +
myParameter->
id +
"' on lane '" + stop.
lane->
getID() +
"' is before departPos.";
1306 if (iter !=
myStops.begin()) {
1307 std::list<MSStop>::iterator iter2 = iter;
1313 +
" earlier than previous stop at " +
time2string(iter2->getUntil()) +
".";
1318 +
" earlier than previous stop end at " +
time2string(iter2->getUntil()) +
".";
1323 +
" earlier than previous stop arrival at " +
time2string(iter2->pars.arrival) +
".";
1348 if (addRouteStops) {
1350 std::string errorMsg;
1354 if (errorMsg !=
"") {
1361 std::string errorMsg;
1362 if (!
addStop(stop, errorMsg, untilOffset, searchStart) && !ignoreStopErrors) {
1365 if (errorMsg !=
"") {
1383 lastPos += (*myCurrEdge)->getLength();
1386 const double endPos = stop.getEndPos(*
this);
1388 const std::string prefix =
"Stop " +
toString(i) +
" on edge '" + stop.lane->getEdge().getID() +
"' ";
1389 if (stop.lane->isInternal()) {
1392 it = std::find(start,
myRoute->end(), stop.lane->getEdge().getNormalBefore());
1394 it + 1 ==
myRoute->end() || *(it + 1) != stop.lane->getEdge().getNormalSuccessor())) {
1398 const MSEdge*
const stopEdge = &stop.lane->getEdge();
1399 it = std::find(start,
myRoute->end(), stopEdge);
1409 if (it2 == stop.edge) {
1415 WRITE_ERROR(prefix +
"used invalid route index " + err);
1418 }
else if (it2 < start) {
1424 if (it != stop.edge) {
1426 if (endPos >= lastPos + brakeGap) {
1447 const MSStop* prev =
nullptr;
1448 const MSEdge* internalSuccessor =
nullptr;
1451 if (stop.pars.jump >= 0) {
1452 jumps.insert((
int)result.size());
1456 const double stopPos = stop.getEndPos(*
this);
1457 if ((prev ==
nullptr
1458 || prev->
edge != stop.edge
1459 || (prev->
lane == stop.lane && prev->
getEndPos(*
this) > stopPos))
1460 && *stop.edge != internalSuccessor) {
1461 result.push_back(*stop.edge);
1462 if (stop.lane->isInternal()) {
1463 internalSuccessor = stop.lane->getNextNormal();
1464 result.push_back(internalSuccessor);
1466 internalSuccessor =
nullptr;
1474 if (stop.pars.jump >= 0) {
1475 jumps.insert((
int)result.size() - 1);
1483std::vector<std::pair<int, double> >
1485 std::vector<std::pair<int, double> > result;
1486 for (std::list<MSStop>::const_iterator iter =
myStops.begin(); iter !=
myStops.end(); ++iter) {
1487 result.push_back(std::make_pair(
1488 (
int)(iter->edge -
myRoute->begin()),
1489 iter->getEndPos(*
this)));
1504 return myStops.front().duration;
1513 if (nextStopIndex < 0 || (
int)
myStops.size() <= nextStopIndex) {
1516 auto stopIt =
myStops.begin();
1517 std::advance(stopIt, nextStopIndex);
1534 for (std::list<MSStop>::iterator iter =
myStops.begin(); iter !=
myStops.end(); iter++) {
1535 if (iter->lane->getID() == stop.
lane && fabs(iter->pars.endPos - stop.
endPos) < POSITION_EPS) {
1537 if (stop.
duration == 0 && stop.
until < 0 && !iter->reached) {
1549 const bool result =
addStop(stop, errorMsg);
1561 if (nextStopIndex == 0 &&
isStopped()) {
1564 auto stopIt =
myStops.begin();
1565 std::advance(stopIt, nextStopIndex);
1571 std::advance(stopIt2, nextStopIndex);
1583 const int n = (int)
myStops.size();
1584 if (nextStopIndex < 0 || nextStopIndex >= n) {
1585 errorMsg = (
"Invalid nextStopIndex '" +
toString(nextStopIndex) +
"' for " +
toString(n) +
" remaining stops");
1588 if (nextStopIndex == 0 &&
isStopped()) {
1589 errorMsg =
"Cannot replace reached stop";
1596 auto itStop =
myStops.begin();
1597 std::advance(itStop, nextStopIndex);
1598 MSStop& replacedStop = *itStop;
1608 errorMsg = (
"Disallowed stop lane '" + stopLane->
getID() +
"'");
1616 double startPos = nextStopIndex == 0 ?
getPositionOnLane() : stops[nextStopIndex - 1].pars.endPos;
1617 MSRouteIterator itEnd = nextStopIndex == n - 1 ? oldEdges.end() - 1 : stops[nextStopIndex + 1].edge;
1618 auto endPos = nextStopIndex == n - 1 ?
getArrivalPos() : stops[nextStopIndex + 1].pars.endPos;
1621 bool newDestination = nextStopIndex == n - 1 && stops[nextStopIndex].edge == oldEdges.end() - 1;
1625 router.
compute(*itStart, startPos, stopEdge, stop.
endPos,
this, t, toNewStop,
true);
1626 if (toNewStop.size() == 0) {
1627 errorMsg =
"No route found from edge '" + (*itStart)->getID() +
"' to stop edge '" + stopEdge->
getID() +
"'";
1633 if (!newDestination) {
1634 router.
compute(stopEdge, stop.
endPos, *itEnd, endPos,
this, t, fromNewStop,
true);
1635 if (fromNewStop.size() == 0) {
1636 errorMsg =
"No route found from stop edge '" + stopEdge->
getID() +
"' to edge '" + (*itEnd)->getID() +
"'";
1644 replacedStop.
lane = stopLane;
1648 errorMsg =
"Mesoscopic simulation does not allow stopping on internal edge '" + stop.
edge +
"' for vehicle '" +
getID() +
"'.";
1655 newEdges.insert(newEdges.end(),
myCurrEdge, itStart);
1657 newEdges.insert(newEdges.end(), toNewStop.begin(), toNewStop.end() - 1);
1659 newEdges.push_back(*itStart);
1661 if (!newDestination) {
1662 newEdges.insert(newEdges.end(), fromNewStop.begin(), fromNewStop.end() - 1);
1663 newEdges.insert(newEdges.end(), itEnd, oldEdges.end());
1665 newEdges.push_back(stopEdge);
1676 const double routeCost = router.
recomputeCosts(newEdges,
this, t);
1677 const double previousCost = router.
recomputeCosts(oldRemainingEdges,
this, t);
1678 const double savings = previousCost - routeCost;
1689 const int n = (int)
myStops.size();
1690 if (nextStopIndex < 0 || nextStopIndex > n) {
1691 errorMsg = (
"Invalid nextStopIndex '" +
toString(nextStopIndex) +
"' for " +
toString(n) +
" remaining stops");
1694 if (nextStopIndex == 0 &&
isStopped()) {
1695 errorMsg =
"Cannot reroute towards reached stop";
1704 double startPos = nextStopIndex == 0 ?
getPositionOnLane() : stops[nextStopIndex - 1].pars.endPos;
1705 MSRouteIterator itEnd = nextStopIndex == n ? oldEdges.end() - 1 : stops[nextStopIndex].edge;
1706 auto endPos = nextStopIndex == n ?
getArrivalPos() : stops[nextStopIndex].pars.endPos;
1711 router.
compute(*itStart, startPos, *itEnd, endPos,
this, t, newBetween,
true);
1712 if (newBetween.size() == 0) {
1713 errorMsg =
"No route found from edge '" + (*itStart)->getID() +
"' to stop edge '" + (*itEnd)->getID() +
"'";
1720 newEdges.insert(newEdges.end(),
myCurrEdge, itStart);
1722 newEdges.insert(newEdges.end(), newBetween.begin(), newBetween.end() - 1);
1724 newEdges.push_back(*itStart);
1726 newEdges.insert(newEdges.end(), itEnd, oldEdges.end());
1734 const double routeCost = router.
recomputeCosts(newEdges,
this, t);
1735 const double previousCost = router.
recomputeCosts(oldRemainingEdges,
this, t);
1736 const double savings = previousCost - routeCost;
1743 const int n = (int)
myStops.size();
1744 if (nextStopIndex < 0 || nextStopIndex > n) {
1745 errorMsg = (
"Invalid nextStopIndex '" +
toString(nextStopIndex) +
"' for " +
toString(n) +
" remaining stops");
1748 if (nextStopIndex == 0 &&
isStopped()) {
1749 errorMsg =
"Cannot insert stop before the currently reached stop";
1757 errorMsg = (
"Disallowed stop lane '" + stopLane->
getID() +
"'");
1765 double startPos = nextStopIndex == 0 ?
getPositionOnLane() : stops[nextStopIndex - 1].pars.endPos;
1766 MSRouteIterator itEnd = nextStopIndex == n ? oldEdges.end() - 1 : stops[nextStopIndex].edge;
1767 auto endPos = nextStopIndex == n ?
getArrivalPos() : stops[nextStopIndex].pars.endPos;
1770 bool newDestination = nextStopIndex == n && stopEdge == oldEdges.back();
1774 router.
compute(*itStart, startPos, stopEdge, stop.
endPos,
this, t, toNewStop,
true);
1775 if (toNewStop.size() == 0) {
1776 errorMsg =
"No route found from edge '" + (*itStart)->getID() +
"' to stop edge '" + stopEdge->
getID() +
"'";
1782 if (!newDestination) {
1783 router.
compute(stopEdge, stop.
endPos, *itEnd, endPos,
this, t, fromNewStop,
true);
1784 if (fromNewStop.size() == 0) {
1785 errorMsg =
"No route found from stop edge '" + stopEdge->
getID() +
"' to edge '" + (*itEnd)->getID() +
"'";
1790 auto itStop =
myStops.begin();
1791 std::advance(itStop, nextStopIndex);
1795 newStop.
lane = stopLane;
1799 errorMsg =
"Mesoscopic simulation does not allow stopping on internal edge '" + stop.
edge +
"' for vehicle '" +
getID() +
"'.";
1803 myStops.insert(itStop, newStop);
1807 newEdges.insert(newEdges.end(),
myCurrEdge, itStart);
1809 newEdges.insert(newEdges.end(), toNewStop.begin(), toNewStop.end() - 1);
1811 newEdges.push_back(*itStart);
1813 if (!newDestination) {
1814 newEdges.insert(newEdges.end(), fromNewStop.begin(), fromNewStop.end() - 1);
1815 newEdges.insert(newEdges.end(), itEnd, oldEdges.end());
1817 newEdges.push_back(stopEdge);
1828 const double routeCost = router.
recomputeCosts(newEdges,
this, t);
1829 const double previousCost = router.
recomputeCosts(oldRemainingEdges,
this, t);
1830 const double savings = previousCost - routeCost;
1905std::vector<std::string>
1907 std::vector<std::string> ret;
1908 const std::vector<MSTransportable*>& persons =
getPersons();
1909 for (std::vector<MSTransportable*>::const_iterator it_p = persons.begin(); it_p != persons.end(); ++it_p) {
1910 ret.push_back((*it_p)->getID());
1934const std::vector<MSTransportable*>&
1944const std::vector<MSTransportable*>&
1977 if (dev->deviceName() == deviceName) {
1988 if (deviceName ==
"rerouting") {
1994 assert(routingDevice != 0);
1998 throw InvalidArgument(
"Creating device of type '" + deviceName +
"' is not supported");
2007 if (dev->deviceName() == deviceName) {
2008 return dev->getParameter(key);
2011 throw InvalidArgument(
"No device of type '" + deviceName +
"' exists");
2018 if (dev->deviceName() == deviceName) {
2019 dev->setParameter(key, value);
2023 throw InvalidArgument(
"No device of type '" + deviceName +
"' exists");
2034 throw InvalidArgument(
"Vehicle '" +
getID() +
"' does not support junctionModel parameter '" + key +
"'");
2050 const std::string attrName = key.substr(15);
2077 assert(type !=
nullptr);
2102 if (lane ==
nullptr) {
2113 if (lane ==
nullptr) {
2125 if (tok.
size() < 3) {
2126 error =
"Invalid device parameter '" + key +
"' for vehicle '" +
getID() +
"'.";
2132 error =
"Vehicle '" +
getID() +
"' does not support device parameter '" + key +
"' (" + e.what() +
").";
2136 if (microVeh ==
nullptr) {
2137 error =
"Meso Vehicle '" +
getID() +
"' does not support laneChangeModel parameters.";
2140 const std::string attrName = key.substr(16);
2144 error =
"Vehicle '" +
getID() +
"' does not support laneChangeModel parameter '" + key +
"' (" + e.what() +
").";
2148 if (microVeh ==
nullptr) {
2149 error =
"Meso Vehicle '" +
getID() +
"' does not support carFollowModel parameters.";
2152 const std::string attrName = key.substr(15);
2156 error =
"Vehicle '" +
getID() +
"' does not support carFollowModel parameter '" + key +
"' (" + e.what() +
").";
2161 if (tok.
size() != 3) {
2162 error =
"Invalid check for device. Expected format is 'has.DEVICENAME.device'.";
2167 }
else if (key ==
"parking.rerouteCount") {
2170 std::vector<std::string> values;
2172 if (key ==
"parking.memory.IDList") {
2174 values.push_back(item.first->getID());
2176 }
else if (key ==
"parking.memory.score") {
2178 values.push_back(item.second.score);
2180 }
else if (key ==
"parking.memory.blockedAtTime") {
2184 }
else if (key ==
"parking.memory.blockedAtTimeLocal") {
2189 error =
"Unsupported parking parameter '" + key +
"'.";
2204 (*myParkingMemory)[pa].blockedAtTime =
SIMSTEP;
2206 (*myParkingMemory)[pa].blockedAtTimeLocal =
SIMSTEP;
2214 item.second.score =
"";
2224 (*myParkingMemory)[pa].score = score;
2237 return local ? it->second.blockedAtTimeLocal : it->second.blockedAtTime;
2243MSBaseVehicle::initMoveReminderOutput(
const OptionsCont& oc) {
2244 if (oc.
isSet(
"movereminder-output.vehicles")) {
2245 const std::vector<std::string> vehicles = oc.
getStringVector(
"movereminder-output.vehicles");
2246 myShallTraceMoveReminders.insert(vehicles.begin(), vehicles.end());
2252MSBaseVehicle::traceMoveReminder(
const std::string& type,
MSMoveReminder* rem,
double pos,
bool keep)
const {
std::vector< const MSEdge * > ConstMSEdgeVector
ConstMSEdgeVector::const_iterator MSRouteIterator
#define WRITE_WARNINGF(...)
#define WRITE_ERRORF(...)
#define WRITE_WARNING(msg)
std::shared_ptr< const MSRoute > ConstMSRoutePtr
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
const int VEHPARS_CFMODEL_PARAMS_SET
@ RANDOM
The edge is chosen randomly.
@ GIVEN
The edge index is given.
@ DEFAULT
No information given; use default.
const int VEHPARS_JUNCTIONMODEL_PARAMS_SET
DepartLaneDefinition
Possible ways to choose a lane on depart.
@ GIVEN
The speed is given.
@ GIVEN
The position is given.
@ DEFAULT
No information given; use default.
@ BASE
Back-at-zero position.
const int VEHPARS_SPEEDFACTOR_SET
@ RANDOM
The lane is chosen randomly.
@ GIVEN
The arrival lane is given.
@ FIRST_ALLOWED
The rightmost lane the vehicle may use.
const int VEHPARS_FORCE_REROUTE
@ RANDOM
The arrival position is chosen randomly.
@ GIVEN
The arrival position is given.
@ CENTER
Half the road length.
const int VEHPARS_LINE_SET
@ CONTAINER_TRIGGERED
The departure is container triggered.
@ TRIGGERED
The departure is person triggered.
@ SUMO_TAG_VEHICLE
description of a vehicle
@ SUMO_ATTR_CF_IGNORE_IDS
@ SUMO_ATTR_JM_IGNORE_IDS
@ SUMO_ATTR_JM_IGNORE_TYPES
@ SUMO_ATTR_CF_IGNORE_TYPES
@ SUMO_ATTR_TIME
trigger: the time of the step
#define UNUSED_PARAMETER(x)
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
void setSecondary(const EnergyParams *secondaryParams)
Set secondary params.
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.
MESegment * getSegmentForEdge(const MSEdge &e, double pos=0)
Get the segment for a given edge at a given position.
virtual std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this laneChangeModel. Throw exception for unsupported key
BaseInfluencer()
Constructor.
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const int rngIndex, SUMOVehicleClass svc) const
double getMaxSpeed() const
Returns the maximum speed (the minimum of desired and technical maximum speed)
MSVehicleDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists, nullptr otherwise.
bool haveValidStopEdges(bool silent=false) const
check whether all stop.edge MSRouteIterators are valid and in order
bool hasJump(const MSRouteIterator &it) const
check wether the vehicle has jump at the given part of it's route
ParkingMemory * myParkingMemory
memory for parking search
void rememberBlockedParkingArea(const MSParkingArea *pa, bool local)
std::list< MSStop > myStops
The vehicle's list of stops.
double getImpatience() const
Returns this vehicles impatience.
virtual ConstMSEdgeVector::const_iterator getRerouteOrigin() const
Returns the starting point for reroutes (usually the current edge)
const std::vector< MSTransportable * > & getPersons() const
retrieve riding persons
virtual void initDevices()
const MSEdge * succEdge(int nSuccs) const
Returns the nSuccs'th successor of edge the vehicle is currently at.
void resetRoutePosition(int index, DepartLaneDefinition departLaneProcedure)
reset index of edge within route
std::map< const MSParkingArea *, PaMemory, ComparatorIdLess > ParkingMemory
std::string getDeviceParameter(const std::string &deviceName, const std::string &key) const
try to retrieve the given parameter from any of the vehicles devices, raise InvalidArgument if no dev...
bool replaceStop(int nextStopIndex, SUMOVehicleParameter::Stop stop, const std::string &info, bool teleport, std::string &errorMsg)
MSBaseVehicle(SUMOVehicleParameter *pars, ConstMSRoutePtr route, MSVehicleType *type, const double speedFactor)
Constructor.
void calculateArrivalParams(bool onInit)
(Re-)Calculates the arrival position and lane from the vehicle parameters
virtual double getArrivalPos() const
Returns this vehicle's desired arrivalPos for its current route (may change on reroute)
void setCarFollowModelParameter(const std::string &key, const std::string &value)
set individual carFollow model parameters (not type related)
void resetParkingAreaScores()
MSVehicleType * myType
This vehicle's type.
static NumericalID myCurrentNumericalIndex
bool rerouteBetweenStops(int nextStopIndex, const std::string &info, bool teleport, std::string &errorMsg)
MoveReminderCont myMoveReminders
Currently relevant move reminders.
double myDepartPos
The real depart position.
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
void addReminder(MSMoveReminder *rem)
Adds a MoveReminder dynamically.
void replaceParameter(const SUMOVehicleParameter *newParameter)
replace the vehicle parameter (deleting the old one)
int getNumberParkingReroutes() const
std::vector< MSVehicleDevice * > myDevices
The devices this vehicle has.
double getPreviousSpeed() const
Returns the vehicle's previous speed.
virtual void addTransportable(MSTransportable *transportable)
Adds a person or container to this vehicle.
virtual BaseInfluencer & getBaseInfluencer()=0
Returns the velocity/lane influencer.
const SUMOVehicleParameter::Stop * getNextStopParameter() const
return parameters for the next stop (SUMOVehicle Interface)
double getOdometer() const
Returns the distance that was already driven by this vehicle.
virtual bool hasArrived() const
Returns whether this vehicle has already arived (by default this is true if the vehicle has reached i...
const NumericalID myNumericalID
bool isStoppedInRange(const double pos, const double tolerance, bool checkFuture=false) const
return whether the given position is within range of the current stop
bool isJumping() const
Returns whether the vehicle is perform a jump.
void checkRouteRemoval()
remove route at the end of the simulation
MSVehicleType & getSingularType()
Replaces the current vehicle type with a new one used by this vehicle only.
SUMOTime sawBlockedParkingArea(const MSParkingArea *pa, bool local) const
virtual void replaceVehicleType(MSVehicleType *type)
Replaces the current vehicle type by the one given.
const MSRouteIterator & getCurrentRouteEdge() const
Returns an iterator pointing to the current edge in this vehicles route.
bool isStoppedParking() const
Returns whether the vehicle is on a parking stop.
bool hasValidRoute(std::string &msg, ConstMSRoutePtr route=0) const
Validates the current or given route.
double getLength() const
Returns the vehicle's length.
bool isParking() const
Returns whether the vehicle is parking.
MSParkingArea * getCurrentParkingArea()
get the current parking area stop or nullptr
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
double getHarmonoise_NoiseEmissions() const
Returns noise emissions of the current state.
int getPersonNumber() const
Returns the number of persons.
void setJunctionModelParameter(const std::string &key, const std::string &value)
set individual junction model paramete (not type related)
void setDepartAndArrivalEdge()
apply departEdge and arrivalEdge attributes
void setID(const std::string &newID)
set the id (inherited from Named but forbidden for vehicles)
MSRouteIterator myCurrEdge
Iterator to current route-edge.
static MSLane * interpretOppositeStop(SUMOVehicleParameter::Stop &stop)
interpret stop lane on opposite side of the road
static std::vector< MSTransportable * > myEmptyTransportableVector
bool hasDeparted() const
Returns whether this vehicle has already departed.
ConstMSRoutePtr myRoute
This vehicle's route.
const ConstMSEdgeVector getStopEdges(double &firstPos, double &lastPos, std::set< int > &jumps) const
Returns the list of still pending stop edges also returns the first and last stop position.
MSDevice_Transportable * myContainerDevice
The containers this vehicle may have.
bool allowsBoarding(const MSTransportable *t) const
whether the given transportable is allowed to board this vehicle
double getStateOfCharge() const
Returns actual state of charge of battery (Wh) RICE_CHECK: This may be a misnomer,...
MSEdgeWeightsStorage & _getWeightsStorage() const
virtual bool handleCollisionStop(MSStop &stop, const double distToStop)
bool hasDevice(const std::string &deviceName) const
check whether the vehicle is equiped with a device of the given name
SUMOTime getDeparture() const
Returns this vehicle's real departure time.
EnergyParams * getEmissionParameters() const
retrieve parameters for the energy consumption model
double basePos(const MSEdge *edge) const
departure position where the vehicle fits fully onto the edge (if possible)
void setDeviceParameter(const std::string &deviceName, const std::string &key, const std::string &value)
try to set the given parameter from any of the vehicles devices, raise InvalidArgument if no device p...
MSDevice_Transportable * myPersonDevice
The passengers this vehicle may have.
bool hasStops() const
Returns whether the vehicle has to stop somewhere.
std::string getFlowID() const
reconstruct flow id from vehicle id
virtual void activateReminders(const MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
"Activates" all current move reminder
bool isLineStop(double position) const
returns whether the vehicle serves a public transport line that serves the given stop
double myChosenSpeedFactor
A precomputed factor by which the driver wants to be faster than the speed limit.
@ ROUTE_INVALID
route was checked and is valid
@ ROUTE_START_INVALID_PERMISSIONS
std::string getPrefixedParameter(const std::string &key, std::string &error) const
retrieve parameters of devices, models and the vehicle itself
void addStops(const bool ignoreStopErrors, MSRouteIterator *searchStart=nullptr, bool addRouteStops=true)
Adds stops to the built vehicle.
void removeTransportable(MSTransportable *t)
removes a person or container
SUMOVehicleClass getVClass() const
Returns the vehicle's access class.
MSParkingArea * getNextParkingArea()
get the upcoming parking area stop or nullptr
int myArrivalLane
The destination lane where the vehicle stops.
int getRouteValidity(bool update=true, bool silent=false, std::string *msgReturn=nullptr)
check for route validity at first insertion attempt
MSStop & getStop(int nextStopIndex)
virtual ~MSBaseVehicle()
Destructor.
bool insertStop(int nextStopIndex, SUMOVehicleParameter::Stop stop, const std::string &info, bool teleport, std::string &errorMsg)
SUMOTime myDeparture
The real departure time.
std::vector< std::string > getPersonIDList() const
Returns the list of persons.
const MSEdgeWeightsStorage & getWeightsStorage() const
Returns the vehicle's internal edge travel times/efforts container.
bool isStoppedTriggered() const
Returns whether the vehicle is on a triggered stop.
virtual bool resumeFromStopping()=0
virtual bool hasInfluencer() const =0
whether the vehicle is individually influenced (via TraCI or special parameters)
bool stopsAtEdge(const MSEdge *edge) const
Returns whether the vehicle stops at the given edge.
void rememberParkingAreaScore(const MSParkingArea *pa, const std::string &score)
score only needed when running with gui
bool addStop(const SUMOVehicleParameter::Stop &stopPar, std::string &errorMsg, SUMOTime untilOffset=0, MSRouteIterator *searchStart=nullptr)
Adds a stop.
std::vector< SUMOVehicleParameter::Stop > myPastStops
The list of stops that the vehicle has already reached.
void onDepart()
Called when the vehicle is inserted into the network.
void removeReminder(MSMoveReminder *rem)
Removes a MoveReminder dynamically.
SUMOTime getStopDuration() const
get remaining stop duration or 0 if the vehicle isn't stopped
virtual double getAcceleration() const
Returns the vehicle's acceleration.
virtual bool addTraciStop(SUMOVehicleParameter::Stop stop, std::string &errorMsg)
const MSRoute & getRoute() const
Returns the current route.
int getRoutePosition() const
return index of edge within route
bool replaceParkingArea(MSParkingArea *parkingArea, std::string &errorMsg)
replace the current parking area stop with a new stop with merge duration
static const SUMOTime NOT_YET_DEPARTED
SUMOTime getDepartDelay() const
Returns the depart delay.
double getElecHybridCurrent() const
Returns actual current (A) of ElecHybrid device RICE_CHECK: Is this the current consumed from the ove...
EnergyParams * myEnergyParams
The emission parameters this vehicle may have.
const SUMOVehicleParameter * myParameter
This vehicle's parameter.
virtual bool hasValidRouteStart(std::string &msg)
checks wether the vehicle can depart on the first edge
int myRouteValidity
status of the current vehicle route
std::vector< std::pair< int, double > > getStopIndices() const
return list of route indices for the remaining stops
SUMOTime myStopUntilOffset
The offset when adding route stops with 'until' on route replacement.
virtual bool replaceRoute(ConstMSRoutePtr route, const std::string &info, bool onInit=false, int offset=0, bool addStops=true, bool removeStops=true, std::string *msgReturn=nullptr)
Replaces the current route by the given one.
virtual bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
void reroute(SUMOTime t, const std::string &info, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, const bool onInit=false, const bool withTaz=false, const bool silent=false)
Performs a rerouting using the given router.
const std::vector< MSTransportable * > & getContainers() const
retrieve riding containers
bool stopsAt(MSStoppingPlace *stop) const
Returns whether the vehicle stops at the given stopping place.
MSEdgeWeightsStorage * myEdgeWeights
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
void createDevice(const std::string &deviceName)
create device of the given type
bool isStopped() const
Returns whether the vehicle is at a stop.
const ParkingMemory * getParkingMemory() const
bool abortNextStop(int nextStopIndex=0)
deletes the next stop at the given index if it exists
int myNumberReroutes
The number of reroutings.
double myArrivalPos
The position on the destination lane where the vehicle stops.
virtual void saveState(OutputDevice &out)
Saves the (common) state of a vehicle.
double myOdometer
A simple odometer to keep track of the length of the route already driven.
void initTransientModelParams()
init model parameters from generic params
int getContainerNumber() const
Returns the number of containers.
bool replaceRouteEdges(ConstMSEdgeVector &edges, double cost, double savings, const std::string &info, bool onInit=false, bool check=false, bool removeStops=true, std::string *msgReturn=nullptr)
Replaces the current route by the given edges.
virtual std::string getParameter(const MSVehicle *veh, const std::string &key) const
try to get the given parameter for this carFollowingModel
virtual void setParameter(MSVehicle *veh, const std::string &key, const std::string &value) const
try to set the given parameter for this carFollowingModel
Battery device for electric vehicles.
double getActualBatteryCapacity() const
Get the actual vehicle's Battery Capacity in Wh.
A device which collects info on the vehicle trip (mainly on departure and arrival)
double getCurrentFromOverheadWire() const
Get actual current in the overhead wire segment.
double getActualBatteryCapacity() const
Get the actual vehicle's Battery Capacity in kWh.
A device that performs vehicle rerouting based on current edge speeds.
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Computes a new route on vehicle insertion.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
A device which collects info on the vehicle trip (mainly on departure and arrival)
bool allowsBoarding(const MSTransportable *t) const
whether the given person is allowed to board this taxi
const std::vector< MSTransportable * > & getTransportables() const
Returns the list of transportables using this vehicle.
static MSDevice_Transportable * buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into, const bool isContainer)
Build devices for the given vehicle, if needed.
int size() const
Return the number of passengers / containers.
void addTransportable(MSTransportable *transportable)
Add a passenger.
void removeTransportable(MSTransportable *transportable)
Remove a passenger (TraCI)
Abstract in-vehicle / in-person device.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
A road/street connecting two junctions.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
const MSEdge * getOppositeEdge() const
Returns the opposite direction edge if on exists else a nullptr.
bool isNormal() const
return whether this edge is an internal edge
const std::vector< MSLane * > * allowedLanes(const MSEdge &destination, SUMOVehicleClass vclass=SVC_IGNORING) const
Get the allowed lanes to reach the destination-edge.
double getLength() const
return the length of the edge
bool isTazConnector() const
bool isInternal() const
return whether this edge is an internal edge
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn't already in the dictionary....
const MSEdge * getNormalBefore() const
if this edge is an internal edge, return its first normal predecessor, otherwise the edge itself
A storage for edge travel times and efforts.
static MELoop * gMesoNet
mesoscopic simulation infrastructure
static SUMOTime gTimeToImpatience
static bool gHaveEmissions
Whether emission output of some type is needed (files or GUI)
static bool gUseStopEnded
whether the simulation should replay previous stop times
void descheduleDeparture(const SUMOVehicle *veh)
stops trying to emit the given vehicle (and delete it)
Representation of a lane in the micro simulation.
int getRNGIndex() const
returns the associated RNG index
const MSEdge * getNextNormal() const
Returns the lane's follower if it is an internal lane, the edge of the lane otherwise.
double getLength() const
Returns the lane's length.
bool allowsVehicleClass(SUMOVehicleClass vclass) const
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
SumoRNG * getRNG() const
return the associated RNG
MSEdge & getEdge() const
Returns the lane's edge.
Something on a lane to be noticed about vehicle movement.
const std::string & getDescription() const
Notification
Definition of a vehicle state.
@ NOTIFICATION_DEPARTED
The vehicle has departed (was inserted into the network)
bool warnOnce(const std::string &typeAndID)
return whether a warning regarding the given object shall be issued
@ NEWROUTE
The vehicle got a new route.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const int rngIndex, const MSEdgeVector &prohibited=MSEdgeVector()) const
bool hasFlow(const std::string &id) const
return whether the given flow is known
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
void informVehicleStateListener(const SUMOVehicle *const vehicle, VehicleState to, const std::string &info="")
Informs all added listeners about a vehicle's state change.
MSInsertionControl & getInsertionControl()
Returns the insertion control.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
A lane area vehicles can halt at.
const ConstMSEdgeVector & getEdges() const
void setCosts(double costs)
Sets the costs of the route.
static bool hasRoute(const std::string &id)
returns whether a route with the given id exists
static bool dictionary(const std::string &id, ConstMSRoutePtr route)
Adds a route to the dictionary.
static void checkDist(const std::string &id)
Checks the distribution whether it is permanent and deletes it if not.
void setSavings(double savings)
Sets the savings of the route.
static SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const int rngIndex, SUMOVehicleClass svc, const MSEdgeVector &prohibited=MSEdgeVector())
return the router instance
const MSLane * lane
The lane to stop at (microsim only)
MSStoppingPlace * containerstop
(Optional) container stop if one is assigned to the stop
bool isOpposite
whether this an opposite-direction stop
void initPars(const SUMOVehicleParameter::Stop &stopPar)
initialize attributes from the given stop parameters
const MESegment * segment
The segment to stop at (mesosim only)
bool reached
Information whether the stop has been reached.
MSRouteIterator edge
The edge in the route to stop at.
double getEndPos(const SUMOVehicle &veh) const
return halting position for upcoming stop;
MSParkingArea * parkingarea
(Optional) parkingArea if one is assigned to the stop
MSStoppingPlace * chargingStation
(Optional) charging station if one is assigned to the stop
std::string getDescription() const
get a short description for showing in the gui
SUMOTime getUntil() const
return until / ended time
const SUMOVehicleParameter::Stop pars
The stop parameter.
MSStoppingPlace * busstop
(Optional) bus stop if one is assigned to the stop
MSStoppingPlace * overheadWireSegment
(Optional) overhead wire segment if one is assigned to the stop
A lane area vehicles can halt at.
double getBeginLanePosition() const
Returns the begin position of this stop.
double getEndLanePosition() const
Returns the end position of this stop.
const MSLane & getLane() const
Returns the lane this stop is located at.
bool isPerson() const
Whether it is a person.
bool hasVTypeDistribution(const std::string &id) const
Asks for a vehicle type distribution.
void vehicleDeparted(const SUMOVehicle &v)
Informs this control about a vehicle's departure.
void removeVType(const MSVehicleType *vehType)
Abstract in-vehicle device.
Representation of a vehicle in the micro simulation.
MSAbstractLaneChangeModel & getLaneChangeModel()
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
The car-following model and parameter.
const EnergyParams * getEmissionParameters() const
retrieve parameters for the energy consumption model
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
double getMaxSpeed() const
Get vehicle's (technical) maximum speed [m/s].
double getDesiredMaxSpeed() const
Returns the vehicles's desired maximum speed.
const std::string & getID() const
Returns the name of the vehicle type.
bool isVehicleSpecific() const
Returns whether this type belongs to a single vehicle only (was modified)
SUMOEmissionClass getEmissionClass() const
Get this vehicle type's emission class.
double getLength() const
Get vehicle's length [m].
MSVehicleType * buildSingularType(const std::string &id) const
Duplicates the microsim vehicle type giving the newly created type the given id, marking it as vehicl...
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
const std::string & getID() const
Returns the id.
A storage for options typed value containers)
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
const StringVector & getStringVector(const std::string &name) const
Returns the list of string-value of the named option (only for Option_StringVector)
static OptionsCont & getOptions()
Retrieves the options.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
int precision()
return precision set on the device
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
void setPrecision(int precision=gPrecision)
Sets the precision or resets it to default.
virtual const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
static const RGBColor DEFAULT_COLOR
The default color (for vehicle types and vehicles)
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)
bool computeLooped(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E * > &into, bool silent=false)
Builds the route between the given edges using the minimum effort at the given time if from == to,...
virtual bool compute(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E * > &into, bool silent=false)=0
Builds the route between the given edges using the minimum effort at the given time The definition of...
virtual double recomputeCosts(const std::vector< const E * > &edges, const V *const v, SUMOTime msTime, double *lengthp=nullptr) const
virtual SUMOTime getWaitingTime() const =0
virtual const MSLane * getLane() const =0
Returns the lane the object is currently at.
long long int NumericalID
virtual double getSpeed() const =0
Returns the object's current speed.
virtual double getPositionOnLane() const =0
Get the object's position along the lane.
Representation of a vehicle.
virtual bool isIdling() const =0
Returns whether the vehicle is idling (waiting to re-enter the net.
virtual double getBrakeGap(bool delayed=false) const =0
get distance for coming to a stop (used for rerouting checks)
Definition of vehicle stop (position and duration)
std::string edge
The edge to stop at (used only in netedit)
ParkingType parking
whether the vehicle is removed from the net while stopping
std::string lane
The lane to stop at.
std::string parkingarea
(Optional) parking area if one is assigned to the stop
double startPos
The stopping position start.
int index
at which position in the stops list
SUMOTime until
The time at which the vehicle may continue its journey.
bool triggered
whether an arriving person lets the vehicle continue
SUMOTime ended
the time at which this stop was ended
double endPos
The stopping position end.
bool containerTriggered
whether an arriving container lets the vehicle continue
bool collision
Whether this stop was triggered by a collision.
SUMOTime arrival
The (expected) time at which the vehicle reaches the stop.
SUMOTime duration
The stopping duration.
Structure representing possible vehicle parameter.
int parametersSet
Information for the router which parameter were set, TraCI may modify this (when changing color)
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle's end speed shall be chosen.
std::string vtypeid
The vehicle's type id.
SUMOTime repetitionOffset
The time offset between vehicle reinsertions.
std::vector< std::string > via
List of the via-edges the vehicle must visit.
int repetitionsDone
The number of times the vehicle was already inserted.
ArrivalLaneDefinition arrivalLaneProcedure
Information how the vehicle shall choose the lane to arrive on.
void write(OutputDevice &dev, const OptionsCont &oc, const SumoXMLTag altTag=SUMO_TAG_VEHICLE, const std::string &typeID="") const
Writes the parameters as a beginning element.
int personNumber
The static number of persons in the vehicle when it departs (not including boarding persons)
RouteIndexDefinition arrivalEdgeProcedure
Information how the vehicle's final edge shall be chosen.
double departPos
(optional) The position the vehicle shall depart from
double arrivalPos
(optional) The position the vehicle shall arrive on
std::string routeid
The vehicle's route id.
std::string id
The vehicle's id.
std::vector< Stop > stops
List of the stops the vehicle will make, TraCI may add entries here.
int departEdge
(optional) The initial edge within the route of the vehicle
bool wasSet(int what) const
Returns whether the given parameter was set.
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
std::string toTaz
The vehicle's destination zone (district)
double arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
int arrivalEdge
(optional) The final edge within the route of the vehicle
std::string fromTaz
The vehicle's origin zone (district)
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
std::string line
The vehicle's line (mainly for public transport)
int containerNumber
The static number of containers in the vehicle when it departs.
RouteIndexDefinition departEdgeProcedure
Information how the vehicle's initial edge shall be chosen.
static std::string getEdgeIDFromLane(const std::string laneID)
return edge id when given the lane ID
static int getIndexFromLane(const std::string laneID)
return lane index when given the lane ID
int size() const
returns the number of existing substrings
std::string get(int pos) const
returns the item at the given position
static bool startsWith(const std::string &str, const std::string prefix)
Checks whether a given string starts with the prefix.
static bool endsWith(const std::string &str, const std::string suffix)
Checks whether a given string ends with the suffix.
TRACI_CONST int ROUTING_MODE_AGGREGATED
TRACI_CONST int ROUTING_MODE_DEFAULT