57#define CALL_MICRO_FUN(veh, fun, mesoResult) ((dynamic_cast<MSVehicle*>(veh) == nullptr ? (mesoResult) : dynamic_cast<MSVehicle*>(veh)->fun))
58#define CALL_MESO_FUN(veh, fun, microResult) ((dynamic_cast<MEVehicle*>(veh) == nullptr ? (microResult) : dynamic_cast<MEVehicle*>(veh)->fun))
66#define DEBUG_COND (veh->isSelected())
88Vehicle::isOnInit(
const std::string& vehID) {
90 return sumoVehicle ==
nullptr || sumoVehicle->
getLane() ==
nullptr;
94std::vector<std::string>
96 std::vector<std::string> ids;
99 if (isVisible((*i).second)) {
100 ids.push_back((*i).first);
107Vehicle::getIDCount() {
108 return (
int)getIDList().size();
113Vehicle::getSpeed(
const std::string& vehID) {
119Vehicle::getLateralSpeed(
const std::string& vehID) {
126Vehicle::getAcceleration(
const std::string& vehID) {
133Vehicle::getSpeedWithoutTraCI(
const std::string& vehID) {
140Vehicle::getPosition(
const std::string& vehID,
const bool includeZ) {
142 if (isVisible(veh)) {
145 return TraCIPosition();
150Vehicle::getPosition3D(
const std::string& vehID) {
151 return getPosition(vehID,
true);
156Vehicle::getAngle(
const std::string& vehID) {
163Vehicle::getSlope(
const std::string& vehID) {
170Vehicle::getRoadID(
const std::string& vehID) {
177Vehicle::getLaneID(
const std::string& vehID) {
184Vehicle::getShadowLaneID(
const std::string& vehID) {
192Vehicle::getLaneIndex(
const std::string& vehID) {
196 if (microVeh !=
nullptr) {
208Vehicle::getSegmentID(
const std::string& vehID) {
214Vehicle::getSegmentIndex(
const std::string& vehID) {
220Vehicle::getTypeID(
const std::string& vehID) {
226Vehicle::getRouteID(
const std::string& vehID) {
232Vehicle::getDeparture(
const std::string& vehID) {
239Vehicle::getDepartDelay(
const std::string& vehID) {
245Vehicle::getRouteIndex(
const std::string& vehID) {
252Vehicle::getColor(
const std::string& vehID) {
257Vehicle::getLanePosition(
const std::string& vehID) {
263Vehicle::getArrivalPos(
const std::string& vehID) {
268Vehicle::getLateralLanePosition(
const std::string& vehID) {
274Vehicle::getCO2Emission(
const std::string& vehID) {
280Vehicle::getCOEmission(
const std::string& vehID) {
286Vehicle::getHCEmission(
const std::string& vehID) {
292Vehicle::getPMxEmission(
const std::string& vehID) {
298Vehicle::getNOxEmission(
const std::string& vehID) {
304Vehicle::getFuelConsumption(
const std::string& vehID) {
310Vehicle::getNoiseEmission(
const std::string& vehID) {
316Vehicle::getElectricityConsumption(
const std::string& vehID) {
322Vehicle::getPersonNumber(
const std::string& vehID) {
327Vehicle::getPersonCapacity(
const std::string& vehID) {
333Vehicle::getBoardingDuration(
const std::string& vehID) {
338std::vector<std::string>
339Vehicle::getPersonIDList(
const std::string& vehID) {
343std::pair<std::string, double>
344Vehicle::getLeader(
const std::string& vehID,
double dist) {
347 std::pair<const MSVehicle* const, double> leaderInfo = veh->
getLeader(dist,
false);
348 const std::string leaderID = leaderInfo.first !=
nullptr ? leaderInfo.first->getID() :
"";
349 double gap = leaderInfo.second;
350 if (leaderInfo.first !=
nullptr
351 && leaderInfo.first->getLane() !=
nullptr
352 && leaderInfo.first->getLane()->isInternal()
355 || (veh->
getLane()->
getLinkCont().front()->getIndex() != leaderInfo.first->getLane()->getLinkCont().front()->getIndex()))) {
358 gap =
MAX2(0.0, gap);
360 return std::make_pair(leaderID, gap);
362 return std::make_pair(
"", -1);
367std::pair<std::string, double>
368Vehicle::getFollower(
const std::string& vehID,
double dist) {
371 std::pair<const MSVehicle* const, double> leaderInfo = veh->
getFollower(dist);
372 return std::make_pair(
373 leaderInfo.first !=
nullptr ? leaderInfo.first->getID() :
"",
376 return std::make_pair(
"", -1);
381std::vector<TraCIJunctionFoe>
382Vehicle::getJunctionFoes(
const std::string& vehID,
double dist) {
383 std::vector<TraCIJunctionFoe> result;
386 if (veh ==
nullptr) {
392 const std::vector<const MSLane*> internalLanes;
396 curDist += lane->getLength();
397 if (lane->isInternal()) {
398 const MSLink* exitLink = lane->getLinkCont().front();
400 const std::vector<MSLink::ConflictInfo>& conflicts = exitLink->
getConflicts();
408 const MSLink* foeExitLink = foeLane->getLinkCont().front();
409 const double distToCrossing = curDist - distBehindCrossing;
414 jf.foeId = foe->
getID();
415 jf.egoDist = distToCrossing;
421 jf.foeDist = item.second.dist - foeDistBehindCrossing - prevFoeDist;
424 jf.egoLane = lane->getID();
425 jf.foeLane = foeLane->getID();
428 result.push_back(jf);
440Vehicle::getWaitingTime(
const std::string& vehID) {
446Vehicle::getAccumulatedWaitingTime(
const std::string& vehID) {
453Vehicle::getAdaptedTraveltime(
const std::string& vehID,
double time,
const std::string& edgeID) {
462Vehicle::getEffort(
const std::string& vehID,
double time,
const std::string& edgeID) {
471Vehicle::isRouteValid(
const std::string& vehID) {
477std::vector<std::string>
478Vehicle::getRoute(
const std::string& vehID) {
479 std::vector<std::string> result;
483 result.push_back((*i)->getID());
490Vehicle::getSignals(
const std::string& vehID) {
496std::vector<TraCIBestLanesData>
497Vehicle::getBestLanes(
const std::string& vehID) {
498 std::vector<TraCIBestLanesData> result;
500 if (veh !=
nullptr && veh->
isOnRoad()) {
502 TraCIBestLanesData bld;
503 bld.laneID = lq.lane->
getID();
504 bld.length = lq.length;
505 bld.occupation = lq.nextOccupation;
506 bld.bestLaneOffset = lq.bestLaneOffset;
507 bld.allowsContinuation = lq.allowsContinuation;
508 for (
const MSLane*
const lane : lq.bestContinuations) {
509 if (lane !=
nullptr) {
510 bld.continuationLanes.push_back(lane->getID());
513 result.emplace_back(bld);
520std::vector<TraCINextTLSData>
521Vehicle::getNextTLS(
const std::string& vehID) {
522 std::vector<TraCINextTLSData> result;
525 if (veh !=
nullptr) {
532 std::vector<MSLink*>::const_iterator linkIt =
MSLane::succLinkSec(*veh, view, *lane, bestLaneConts);
535 if ((*linkIt)->isTLSControlled()) {
536 TraCINextTLSData ntd;
537 ntd.id = (*linkIt)->getTLLogic()->getID();
538 ntd.tlIndex = (*linkIt)->getTLIndex();
540 ntd.state = (char)(*linkIt)->getState();
541 result.push_back(ntd);
544 lane = (*linkIt)->getViaLaneOrLane();
555 for (
int i = 0; i < remainingEdges; i++) {
559 if (allowed !=
nullptr && allowed->size() != 0) {
560 for (
const MSLink*
const link : allowed->front()->getLinkCont()) {
561 if (&link->getLane()->getEdge() == next) {
562 if (link->isTLSControlled()) {
563 TraCINextTLSData ntd;
564 ntd.id = link->getTLLogic()->getID();
565 ntd.tlIndex = link->getTLIndex();
567 ntd.state = (char)link->getState();
568 result.push_back(ntd);
570 seen += next->
getLength() + link->getInternalLengthsAfter();
586std::vector<TraCINextStopData>
587Vehicle::getNextStops(
const std::string& vehID) {
588 return getStops(vehID, 0);
591std::vector<libsumo::TraCIConnection>
592Vehicle::getNextLinks(
const std::string& vehID) {
593 std::vector<libsumo::TraCIConnection> result;
599 if (veh !=
nullptr) {
604 std::vector<MSLink*>::const_iterator linkIt =
MSLane::succLinkSec(*veh, view, *lane, bestLaneConts);
607 const MSLink* link = (*linkIt);
608 const std::string approachedLane = link->
getLane() !=
nullptr ? link->
getLane()->
getID() :
"";
611 const bool isOpen = link->
opened(currTime, speed, speed, veh->
getLength(),
619 result.push_back(TraCIConnection(approachedLane, hasPrio, isOpen, hasFoe, approachedInternal, state, direction, length));
621 lane = (*linkIt)->getViaLaneOrLane();
629 for (
int i = 0; i < remainingEdges; i++) {
633 if (allowed !=
nullptr && allowed->size() != 0) {
634 for (
const MSLink*
const link : allowed->front()->getLinkCont()) {
635 if (&link->getLane()->getEdge() == next) {
636 const std::string approachedLane = link->getLane() !=
nullptr ? link->getLane()->getID() :
"";
637 const bool hasPrio = link->havePriority();
638 const double speed =
MIN2(lane->
getSpeedLimit(), link->getLane()->getSpeedLimit());
639 const bool isOpen = link->opened(currTime, speed, speed, veh->
getLength(),
643 const std::string approachedInternal = link->getViaLane() !=
nullptr ? link->getViaLane()->getID() :
"";
646 const double length = link->getLength();
647 result.push_back(TraCIConnection(approachedLane, hasPrio, isOpen, hasFoe, approachedInternal, state, direction, length));
661std::vector<TraCINextStopData>
662Vehicle::getStops(
const std::string& vehID,
int limit) {
663 std::vector<TraCINextStopData> result;
668 const int n = (int)pastStops.size();
669 for (
int i =
MAX2(0, n + limit); i < n; i++) {
674 if (!stop.pars.collision) {
677 result.push_back(nsd);
678 if (limit > 0 && (
int)result.size() >= limit) {
689Vehicle::getStopState(
const std::string& vehID) {
692 if (veh ==
nullptr) {
706Vehicle::getDistance(
const std::string& vehID) {
717Vehicle::getDrivingDistance(
const std::string& vehID,
const std::string& edgeID,
double pos,
int laneIndex) {
724 if (distance == std::numeric_limits<double>::max()) {
735Vehicle::getDrivingDistance2D(
const std::string& vehID,
double x,
double y) {
737 if (veh ==
nullptr) {
746 if (distance == std::numeric_limits<double>::max()) {
757Vehicle::getReferenceDistance(
const std::string& vehID) {
774Vehicle::getAllowedSpeed(
const std::string& vehID) {
781Vehicle::getSpeedFactor(
const std::string& vehID) {
787Vehicle::getSpeedMode(
const std::string& vehID) {
794Vehicle::getLaneChangeMode(
const std::string& vehID) {
801Vehicle::getRoutingMode(
const std::string& vehID) {
807Vehicle::getLine(
const std::string& vehID) {
812std::vector<std::string>
813Vehicle::getVia(
const std::string& vehID) {
819Vehicle::getLaneChangeState(
const std::string& vehID,
int direction) {
822 return veh->
isOnRoad() ?
CALL_MICRO_FUN(veh, getLaneChangeModel().getSavedState(direction), undefined) : undefined;
827Vehicle::getParameter(
const std::string& vehID,
const std::string& key) {
832 throw TraCIException(error);
841std::vector<std::pair<std::string, double> >
842Vehicle::getNeighbors(
const std::string& vehID,
const int mode) {
843 int dir = (1 & mode) != 0 ? -1 : 1;
844 bool queryLeaders = (2 & mode) != 0;
845 bool blockersOnly = (4 & mode) != 0;
848 std::vector<std::pair<std::string, double> > result;
849 if (veh ==
nullptr) {
852#ifdef DEBUG_NEIGHBORS
854 std::cout <<
"getNeighbors() for veh '" << vehID <<
"': dir=" << dir
855 <<
", queryLeaders=" << queryLeaders
856 <<
", blockersOnly=" << blockersOnly << std::endl;
865 if (targetLane ==
nullptr) {
890 for (
int i = 0; i < neighbors.
numSublanes(); i++) {
892 if (n.first !=
nullptr) {
901 if (n.second < secureGap) {
902 blockers.
addLeader(n.first, n.second, 0, i);
906 neighbors = blockers;
910 for (
int i = 0; i < neighbors.
numSublanes(); i++) {
912 if (n.first !=
nullptr &&
914 (result.size() == 0 || result.back().first != n.first->getID())) {
915 result.push_back(std::make_pair(n.first->getID(), n.second));
924Vehicle::getFollowSpeed(
const std::string& vehID,
double speed,
double gap,
double leaderSpeed,
double leaderMaxDecel,
const std::string& leaderID) {
927 if (veh ==
nullptr) {
928 WRITE_ERROR(
"getFollowSpeed not applicable for meso");
937Vehicle::getSecureGap(
const std::string& vehID,
double speed,
double leaderSpeed,
double leaderMaxDecel,
const std::string& leaderID) {
940 if (veh ==
nullptr) {
941 WRITE_ERROR(
"getSecureGap not applicable for meso");
950Vehicle::getStopSpeed(
const std::string& vehID,
const double speed,
double gap) {
953 if (veh ==
nullptr) {
954 WRITE_ERROR(
"getStopSpeed not applicable for meso");
961Vehicle::getStopDelay(
const std::string& vehID) {
967Vehicle::getImpatience(
const std::string& vehID) {
973Vehicle::getStopArrivalDelay(
const std::string& vehID) {
983Vehicle::getTimeLoss(
const std::string& vehID) {
987std::vector<std::string>
988Vehicle::getTaxiFleet(
int taxiState) {
989 std::vector<std::string> result;
991 if (taxi->getHolder().hasDeparted()) {
993 || (taxiState == 0 && taxi->getState() == 0)
994 || (taxiState != 0 && (taxi->getState() & taxiState) == taxiState)) {
995 result.push_back(taxi->getHolder().getID());
1002std::vector<std::string>
1003Vehicle::getLoadedIDList() {
1004 std::vector<std::string> ids;
1007 ids.push_back(i->first);
1012std::vector<std::string>
1013Vehicle::getTeleportingIDList() {
1014 std::vector<std::string> ids;
1019 ids.push_back(veh->
getID());
1026Vehicle::getEmissionClass(
const std::string& vehID) {
1031Vehicle::getShapeClass(
const std::string& vehID) {
1037Vehicle::getLength(
const std::string& vehID) {
1043Vehicle::getAccel(
const std::string& vehID) {
1049Vehicle::getDecel(
const std::string& vehID) {
1054double Vehicle::getEmergencyDecel(
const std::string& vehID) {
1059double Vehicle::getApparentDecel(
const std::string& vehID) {
1064double Vehicle::getActionStepLength(
const std::string& vehID) {
1069double Vehicle::getLastActionTime(
const std::string& vehID) {
1072 if (microVeh !=
nullptr) {
1082Vehicle::getTau(
const std::string& vehID) {
1088Vehicle::getImperfection(
const std::string& vehID) {
1094Vehicle::getSpeedDeviation(
const std::string& vehID) {
1100Vehicle::getVehicleClass(
const std::string& vehID) {
1106Vehicle::getMinGap(
const std::string& vehID) {
1112Vehicle::getMinGapLat(
const std::string& vehID) {
1115 }
catch (
const TraCIException&) {
1123Vehicle::getMaxSpeed(
const std::string& vehID) {
1129Vehicle::getMaxSpeedLat(
const std::string& vehID) {
1135Vehicle::getLateralAlignment(
const std::string& vehID) {
1141Vehicle::getWidth(
const std::string& vehID) {
1147Vehicle::getHeight(
const std::string& vehID) {
1153Vehicle::getMass(
const std::string& vehID) {
1159Vehicle::setStop(
const std::string& vehID,
1160 const std::string& edgeID,
1169 pos, laneIndex, startPos, flags, duration, until);
1172 throw TraCIException(error);
1178Vehicle::replaceStop(
const std::string& vehID,
1180 const std::string& edgeID,
1193 if (teleport != 0) {
1194 if (!vehicle->
rerouteBetweenStops(nextStopIndex,
"traci:replaceStop", (teleport & 1), error)) {
1195 throw TraCIException(
"Stop replacement failed for vehicle '" + vehID +
"' (" + error +
").");
1199 if (msVeh->
getLane() !=
nullptr) {
1204 throw TraCIException(
"Stop replacement failed for vehicle '" + vehID +
"' (invalid nextStopIndex).");
1208 pos, laneIndex, startPos, flags, duration, until);
1210 if (!vehicle->
replaceStop(nextStopIndex, stopPars,
"traci:replaceStop", teleport != 0, error)) {
1211 throw TraCIException(
"Stop replacement failed for vehicle '" + vehID +
"' (" + error +
").");
1218Vehicle::insertStop(
const std::string& vehID,
1220 const std::string& edgeID,
1230 pos, laneIndex, startPos, flags, duration, until);
1233 if (!vehicle->
insertStop(nextStopIndex, stopPars,
"traci:insertStop", teleport != 0, error)) {
1234 throw TraCIException(
"Stop insertion failed for vehicle '" + vehID +
"' (" + error +
").");
1240Vehicle::getStopParameter(
const std::string& vehID,
int nextStopIndex,
const std::string& param,
bool customParam) {
1243 if (nextStopIndex >= (
int)vehicle->
getStops().size() || (nextStopIndex < 0 && -nextStopIndex > (
int)vehicle->
getPastStops().size())) {
1321 throw TraCIException(
"Could not get stop parameter for vehicle '" + vehID +
"' (" + e.what() +
")");
1328Vehicle::setStopParameter(
const std::string& vehID,
int nextStopIndex,
1329 const std::string& param,
const std::string& value,
1350 std::string edgeOrStopID = value;
1353 edgeOrStopID = pars.
edge;
1392 throw TraCIException(
"Changing stop index is not supported");
1397 if (pars.
speed > 0 && value !=
"") {
1398 throw ProcessError(
TLF(
"Waypoint (speed = %) at index % does not support triggers", pars.
speed, nextStopIndex));
1436 throw ProcessError(
TLF(
"Triggered stop at index % cannot be changed into a waypoint by setting speed to %", nextStopIndex, speed));
1459 throw TraCIException(
"Could not set stop parameter for vehicle '" + vehID +
"' (" + e.what() +
")");
1465Vehicle::rerouteParkingArea(
const std::string& vehID,
const std::string& parkingAreaID) {
1468 if (veh ==
nullptr) {
1469 WRITE_WARNING(
"rerouteParkingArea not yet implemented for meso");
1475 throw TraCIException(error);
1480Vehicle::resume(
const std::string& vehID) {
1483 if (veh ==
nullptr) {
1488 throw TraCIException(
"Failed to resume vehicle '" + veh->
getID() +
"', it has no stops.");
1492 std::ostringstream strs;
1493 strs <<
"reached: " << sto.
reached;
1494 strs <<
", duration:" << sto.
duration;
1495 strs <<
", edge:" << (*sto.
edge)->getID();
1497 std::string posStr = strs.str();
1498 throw TraCIException(
"Failed to resume from stopping for vehicle '" + veh->
getID() +
"', " + posStr);
1504Vehicle::changeTarget(
const std::string& vehID,
const std::string& edgeID) {
1507 const bool onInit = isOnInit(vehID);
1508 if (destEdge ==
nullptr) {
1509 throw TraCIException(
"Destination edge '" + edgeID +
"' is not known.");
1514 veh->
getRouterTT(), onInit,
false,
false, destEdge);
1516 throw TraCIException(
"ChangeTarget failed for vehicle '" + veh->
getID() +
"', destination edge '" + edgeID +
"' unreachable.");
1519 throw TraCIException(e.what());
1525Vehicle::changeLane(
const std::string& vehID,
int laneIndex,
double duration) {
1529 throw TraCIException(
"Duration parameter exceeds the time value range.");
1533 if (veh ==
nullptr) {
1534 WRITE_ERROR(
"changeLane not applicable for meso");
1538 std::vector<std::pair<SUMOTime, int> > laneTimeLine;
1539 laneTimeLine.push_back(std::make_pair(
MSNet::getInstance()->getCurrentTimeStep(), laneIndex));
1545Vehicle::changeLaneRelative(
const std::string& vehID,
int indexOffset,
double duration) {
1549 throw TraCIException(
"Duration parameter exceeds the time value range.");
1553 if (veh ==
nullptr) {
1554 WRITE_ERROR(
"changeLaneRelative not applicable for meso");
1558 std::vector<std::pair<SUMOTime, int> > laneTimeLine;
1560 if (laneIndex < 0 && !veh->getLaneChangeModel().isOpposite()) {
1562 WRITE_WARNINGF(
TL(
"Ignoring changeLaneRelative for vehicle '%' that isn't on the road"), vehID);
1567 laneTimeLine.push_back(std::make_pair(
MSNet::getInstance()->getCurrentTimeStep(), laneIndex));
1575Vehicle::changeSublane(
const std::string& vehID,
double latDist) {
1578 if (veh ==
nullptr) {
1579 WRITE_ERROR(
"changeSublane not applicable for meso");
1588Vehicle::add(
const std::string& vehID,
1589 const std::string& routeID,
1590 const std::string& typeID,
1591 const std::string& depart,
1592 const std::string& departLane,
1593 const std::string& departPos,
1594 const std::string& departSpeed,
1595 const std::string& arrivalLane,
1596 const std::string& arrivalPos,
1597 const std::string& arrivalSpeed,
1598 const std::string& fromTaz,
1599 const std::string& toTaz,
1600 const std::string& line,
1603 const std::string& departPosLat,
1604 const std::string& arrivalPosLat,
1606 const std::string& insertionChecks) {
1608 if (veh !=
nullptr) {
1609 throw TraCIException(
"The vehicle '" + vehID +
"' to add already exists.");
1613 vehicleParams.
id = vehID;
1616 throw TraCIException(
"Invalid type '" + typeID +
"' for vehicle '" + vehID +
"'.");
1618 if (typeID !=
"DEFAULT_VEHTYPE") {
1619 vehicleParams.
vtypeid = typeID;
1623 WRITE_WARNINGF(
TL(
"Internal routes receive an ID starting with '!' and must not be referenced in other vehicle or flow definitions. Please remove all references to route '%' in case it is internal."), routeID);
1627 if (routeID ==
"") {
1633 if (route ==
nullptr) {
1636 std::vector<std::string> edges;
1637 edges.push_back(e->getID());
1638 libsumo::Route::add(dummyRouteID, edges);
1648 throw TraCIException(
"Invalid route '" + routeID +
"' for vehicle '" + vehID +
"'.");
1652 if (route->getEdges().size() == 2) {
1653 const MSEdgeVector& succ = route->getEdges().front()->getSuccessors();
1654 if (std::find(succ.begin(), succ.end(), route->getEdges().back()) == succ.end()) {
1658 if (fromTaz !=
"" || toTaz !=
"") {
1663 throw TraCIException(error);
1667 WRITE_WARNINGF(
TL(
"Departure time for vehicle '%' is in the past; using current time instead."), vehID);
1672 throw TraCIException(error);
1675 throw TraCIException(error);
1678 throw TraCIException(error);
1681 throw TraCIException(error);
1684 throw TraCIException(error);
1687 throw TraCIException(error);
1689 if (!departPosLat.empty()) {
1691 throw TraCIException(error);
1695 if (!arrivalPosLat.empty()) {
1697 throw TraCIException(error);
1701 if (speedFactor > 0) {
1705 if (!insertionChecks.empty()) {
1710 throw TraCIException(e.what());
1714 if (departLane !=
"first") {
1717 if (departPos !=
"base") {
1720 if (departSpeed !=
"0") {
1723 if (arrivalLane !=
"current") {
1726 if (arrivalPos !=
"max") {
1729 if (arrivalSpeed !=
"current") {
1732 if (fromTaz !=
"") {
1741 if (personNumber != 0) {
1745 vehicleParams.
fromTaz = fromTaz;
1746 vehicleParams.
toTaz = toTaz;
1747 vehicleParams.
line = line;
1755 if (fromTaz ==
"" && !route->getEdges().front()->validateDepartSpeed(*vehicle)) {
1757 throw TraCIException(
"Departure speed for vehicle '" + vehID +
"' is too high for the departure edge '" + route->getEdges().front()->getID() +
"'.");
1762 throw TraCIException(
"Vehicle '" + vehID +
"' has no valid route (" + msg +
"). ");
1769 if (vehicle !=
nullptr) {
1772 throw TraCIException(e.what());
1778Vehicle::moveToXY(
const std::string& vehID,
const std::string& edgeID,
const int laneIndex,
1779 const double x,
const double y,
double angle,
const int keepRoute,
double matchThreshold) {
1782 if (veh ==
nullptr) {
1786 const bool doKeepRoute = (keepRoute & 1) != 0 && veh->
getID() !=
"VTD_EGO";
1787 const bool mayLeaveNetwork = (keepRoute & 2) != 0;
1788 const bool ignorePermissions = (keepRoute & 4) != 0;
1792 const std::string origID = edgeID +
"_" +
toString(laneIndex);
1796 const double origAngle = angle;
1801 while (angle >= 360.) {
1804 while (angle < 0.) {
1812 std::cout <<
" wantedPos=" << pos <<
" origID=" << origID <<
" laneIndex=" << laneIndex <<
" origAngle=" << origAngle <<
" angle=" << angle <<
" keepRoute=" << keepRoute << std::endl;
1818 double lanePosLat = 0;
1819 double bestDistance = std::numeric_limits<double>::max();
1820 int routeOffset = 0;
1822 double maxRouteDistance = matchThreshold;
1831 vClass, setLateralPos,
1832 bestDistance, &lane, lanePos, routeOffset);
1839 bestDistance, &lane, lanePos, routeOffset, edges);
1841 if ((found && bestDistance <= maxRouteDistance) || mayLeaveNetwork) {
1844 if (found && setLateralPos) {
1847 lanePosLat = perpDist;
1848 if (!mayLeaveNetwork) {
1860 lanePosLat = -lanePosLat;
1869 assert((found && lane != 0) || (!found && lane == 0));
1870 assert(!std::isnan(lanePos));
1872 if (lane !=
nullptr) {
1881 std::cout <<
SIMTIME <<
" veh=" << vehID +
" moveToXYResult lane='" <<
Named::getIDSecure(lane) <<
"' lanePos=" << lanePos <<
" lanePosLat=" << lanePosLat <<
"\n";
1888 if (lane ==
nullptr) {
1889 throw TraCIException(
"Could not map vehicle '" + vehID +
"', no road found within " +
toString(maxRouteDistance) +
"m.");
1891 throw TraCIException(
"Could not map vehicle '" + vehID +
"', distance to road is " +
toString(bestDistance) +
".");
1897Vehicle::slowDown(
const std::string& vehID,
double speed,
double duration) {
1901 throw TraCIException(
"Duration parameter exceeds the time value range.");
1905 if (veh ==
nullptr) {
1910 std::vector<std::pair<SUMOTime, double> > speedTimeLine;
1917Vehicle::openGap(
const std::string& vehID,
double newTimeHeadway,
double newSpaceHeadway,
double duration,
double changeRate,
double maxDecel,
const std::string& referenceVehID) {
1921 throw TraCIException(
"Duration parameter exceeds the time value range.");
1925 if (veh ==
nullptr) {
1931 if (referenceVehID !=
"") {
1935 if (newTimeHeadway == -1) {
1936 newTimeHeadway = originalTau;
1938 if (originalTau > newTimeHeadway) {
1939 WRITE_WARNING(
"Ignoring openGap(). New time headway must not be smaller than the original.");
1946Vehicle::deactivateGapControl(
const std::string& vehID) {
1949 if (veh ==
nullptr) {
1950 WRITE_ERROR(
"deactivateGapControl not applicable for meso");
1960Vehicle::requestToC(
const std::string& vehID,
double leadTime) {
1961 setParameter(vehID,
"device.toc.requestToC",
toString(leadTime));
1965Vehicle::setSpeed(
const std::string& vehID,
double speed) {
1968 if (veh ==
nullptr) {
1973 std::vector<std::pair<SUMOTime, double> > speedTimeLine;
1975 speedTimeLine.push_back(std::make_pair(
MSNet::getInstance()->getCurrentTimeStep(), speed));
1982Vehicle::setAcceleration(
const std::string& vehID,
double acceleration,
double duration) {
1986 throw TraCIException(
"Duration parameter exceeds the time value range.");
1990 if (veh ==
nullptr) {
1991 WRITE_WARNING(
"setAcceleration not yet implemented for meso");
1995 double targetSpeed = std::max(veh->
getSpeed() + acceleration * duration, 0.0);
1996 std::vector<std::pair<SUMOTime, double>> speedTimeLine;
2003Vehicle::setPreviousSpeed(
const std::string& vehID,
double prevSpeed,
double prevAcceleration) {
2006 if (veh ==
nullptr) {
2007 WRITE_WARNING(
"setPreviousSpeed not yet implemented for meso");
2011 prevAcceleration = std::numeric_limits<double>::min();
2017Vehicle::setSpeedMode(
const std::string& vehID,
int speedMode) {
2020 if (veh ==
nullptr) {
2029Vehicle::setLaneChangeMode(
const std::string& vehID,
int laneChangeMode) {
2032 if (veh ==
nullptr) {
2033 WRITE_ERROR(
"setLaneChangeMode not applicable for meso");
2041Vehicle::setRoutingMode(
const std::string& vehID,
int routingMode) {
2046Vehicle::setType(
const std::string& vehID,
const std::string& typeID) {
2048 if (vehicleType ==
nullptr) {
2049 throw TraCIException(
"Vehicle type '" + typeID +
"' is not known");
2054 if (microVeh !=
nullptr && microVeh->
isOnRoad()) {
2061Vehicle::setRouteID(
const std::string& vehID,
const std::string& routeID) {
2065 throw TraCIException(
"The route '" + routeID +
"' is not known.");
2068 WRITE_WARNINGF(
TL(
"Internal routes receive an ID starting with '!' and must not be referenced in other vehicle or flow definitions. Please remove all references to route '%' in case it is internal."), routeID);
2074 throw TraCIException(
"Route replacement failed for " + veh->
getID());
2078 std::string errorMsg;
2079 if (!veh->
replaceRoute(r,
"traci:setRouteID", veh->
getLane() ==
nullptr, 0,
true,
true, &errorMsg)) {
2080 throw TraCIException(
"Route replacement failed for vehicle '" + veh->
getID() +
"' (" + errorMsg +
").");
2085Vehicle::setRoute(
const std::string& vehID,
const std::string& edgeID) {
2086 setRoute(vehID, std::vector<std::string>({edgeID}));
2091Vehicle::setRoute(
const std::string& vehID,
const std::vector<std::string>& edgeIDs) {
2094 const bool onInit = veh->
getLane() ==
nullptr;
2097 if (edges.size() > 0 && edges.front()->isInternal()) {
2098 if (edges.size() == 1) {
2100 edges.push_back(edges.back()->getLanes()[0]->getNextNormal());
2104 edges.erase(edges.begin());
2109 throw TraCIException(
"Invalid edge list for vehicle '" + veh->
getID() +
"' (" + e.what() +
")");
2111 std::string errorMsg;
2112 if (!veh->
replaceRouteEdges(edges, -1, 0,
"traci:setRoute", onInit,
true,
true, &errorMsg)) {
2113 throw TraCIException(
"Route replacement failed for vehicle '" + veh->
getID() +
"' (" + errorMsg +
").");
2119Vehicle::setLateralLanePosition(
const std::string& vehID,
double posLat) {
2122 if (veh !=
nullptr) {
2125 WRITE_ERROR(
"setLateralLanePosition not applicable for meso");
2131Vehicle::updateBestLanes(
const std::string& vehID) {
2134 if (veh ==
nullptr) {
2135 WRITE_ERROR(
"updateBestLanes not applicable for meso");
2145Vehicle::setAdaptedTraveltime(
const std::string& vehID,
const std::string& edgeID,
2146 double time,
double begSeconds,
double endSeconds) {
2149 if (edge ==
nullptr) {
2150 throw TraCIException(
"Edge '" + edgeID +
"' is not known.");
2154 if (begSeconds == 0 && endSeconds == std::numeric_limits<double>::max()) {
2171Vehicle::setEffort(
const std::string& vehID,
const std::string& edgeID,
2172 double effort,
double begSeconds,
double endSeconds) {
2175 if (edge ==
nullptr) {
2176 throw TraCIException(
"Edge '" + edgeID +
"' is not known.");
2180 if (begSeconds == 0 && endSeconds == std::numeric_limits<double>::max()) {
2197Vehicle::rerouteTraveltime(
const std::string& vehID,
const bool currentTravelTimes) {
2212Vehicle::rerouteEffort(
const std::string& vehID) {
2220Vehicle::setSignals(
const std::string& vehID,
int signals) {
2223 if (veh ==
nullptr) {
2224 WRITE_ERROR(
"setSignals not applicable for meso");
2239Vehicle::moveTo(
const std::string& vehID,
const std::string& laneID,
double pos,
int reason) {
2242 if (veh ==
nullptr) {
2249 throw TraCIException(
"Unknown lane '" + laneID +
"'.");
2273 throw TraCIException(
"Lane '" + laneID +
"' is not on the route of vehicle '" + vehID +
"'.");
2277 if (veh->
getLane() !=
nullptr) {
2285 const int newRouteIndex = (int)(it - veh->
getRoute().
begin());
2286 if (oldRouteIndex > newRouteIndex) {
2310 throw TraCIException(
"Invalid moveTo reason '" +
toString(reason) +
"' for vehicle '" + vehID +
"'.");
2323Vehicle::setActionStepLength(
const std::string& vehID,
double actionStepLength,
bool resetActionOffset) {
2324 if (actionStepLength < 0.0) {
2325 WRITE_ERROR(
"Invalid action step length (<0). Ignoring command setActionStepLength().");
2330 if (veh ==
nullptr) {
2331 WRITE_ERROR(
"setActionStepLength not applicable for meso");
2335 if (actionStepLength == 0.) {
2344Vehicle::setBoardingDuration(
const std::string& vehID,
double boardingDuration) {
2348 throw TraCIException(
"BoardingDuration parameter exceeds the time value range.");
2355Vehicle::setImpatience(
const std::string& vehID,
double impatience) {
2363Vehicle::remove(
const std::string& vehID,
char reason) {
2387 throw TraCIException(
"Unknown removal status.");
2392 if (microVeh !=
nullptr) {
2393 if (veh->
getLane() !=
nullptr) {
2407Vehicle::setColor(
const std::string& vehID,
const TraCIColor& col) {
2409 p.
color.
set((
unsigned char)col.r, (
unsigned char)col.g, (
unsigned char)col.b, (
unsigned char)col.a);
2415Vehicle::setSpeedFactor(
const std::string& vehID,
double factor) {
2421Vehicle::setLine(
const std::string& vehID,
const std::string& line) {
2427Vehicle::setVia(
const std::string& vehID,
const std::vector<std::string>& edgeList) {
2434 throw TraCIException(e.what());
2441Vehicle::setLength(
const std::string& vehID,
double length) {
2447Vehicle::setMaxSpeed(
const std::string& vehID,
double speed) {
2453Vehicle::setVehicleClass(
const std::string& vehID,
const std::string& clazz) {
2457 if (microVeh !=
nullptr && microVeh->
isOnRoad()) {
2464Vehicle::setShapeClass(
const std::string& vehID,
const std::string& clazz) {
2470Vehicle::setEmissionClass(
const std::string& vehID,
const std::string& clazz) {
2476Vehicle::setWidth(
const std::string& vehID,
double width) {
2482Vehicle::setHeight(
const std::string& vehID,
double height) {
2488Vehicle::setMass(
const std::string& vehID,
double mass) {
2494Vehicle::setMinGap(
const std::string& vehID,
double minGap) {
2498 if (microVeh !=
nullptr && microVeh->
isOnRoad()) {
2505Vehicle::setAccel(
const std::string& vehID,
double accel) {
2511Vehicle::setDecel(
const std::string& vehID,
double decel) {
2517Vehicle::setEmergencyDecel(
const std::string& vehID,
double decel) {
2518 VehicleType::setEmergencyDecel(
Helper::getVehicle(vehID)->getSingularType().getID(), decel);
2523Vehicle::setApparentDecel(
const std::string& vehID,
double decel) {
2529Vehicle::setImperfection(
const std::string& vehID,
double imperfection) {
2535Vehicle::setTau(
const std::string& vehID,
double tau) {
2541Vehicle::setMinGapLat(
const std::string& vehID,
double minGapLat) {
2543 setParameter(vehID,
"laneChangeModel.minGapLat",
toString(minGapLat));
2544 }
catch (TraCIException&) {
2552Vehicle::setMaxSpeedLat(
const std::string& vehID,
double speed) {
2558Vehicle::setLateralAlignment(
const std::string& vehID,
const std::string& latAlignment) {
2564 throw TraCIException(
"Unknown value '" + latAlignment +
"' when setting latAlignment for vehID '" + vehID +
"';\n must be one of (\"right\", \"center\", \"arbitrary\", \"nice\", \"compact\", \"left\" or a float)");
2570Vehicle::setParameter(
const std::string& vehID,
const std::string& key,
const std::string& value) {
2575 if (tok.size() < 3) {
2576 throw TraCIException(
"Invalid device parameter '" + key +
"' for vehicle '" + vehID +
"'");
2581 throw TraCIException(
"Vehicle '" + vehID +
"' does not support device parameter '" + key +
"' (" + e.what() +
").");
2584 if (microVeh ==
nullptr) {
2585 throw TraCIException(
"Meso Vehicle '" + vehID +
"' does not support laneChangeModel parameters.");
2587 const std::string attrName =
key.substr(16);
2595 throw TraCIException(
"Vehicle '" + vehID +
"' does not support laneChangeModel parameter '" + key +
"' (" + e.what() +
").");
2599 if (microVeh ==
nullptr) {
2600 throw TraCIException(
"Meso Vehicle '" + vehID +
"' does not support carFollowModel parameters.");
2605 throw TraCIException(
"Vehicle '" + vehID +
"' does not support carFollowModel parameter '" + key +
"' (" + e.what() +
").");
2613 throw TraCIException(e.what());
2617 if (tok.size() != 3) {
2618 throw TraCIException(
"Invalid request for device status change. Expected format is 'has.DEVICENAME.device'");
2620 const std::string deviceName = tok.get(1);
2625 throw TraCIException(
"Changing device status requires a 'true' or 'false'");
2628 throw TraCIException(
"Device removal is not supported for device of type '" + deviceName +
"'");
2633 throw TraCIException(
"Cannot create vehicle device (" + std::string(e.what()) +
").");
2642Vehicle::highlight(
const std::string& vehID,
const TraCIColor& col,
double size,
const int alphaMax,
const double duration,
const int type) {
2649 const double l2 = veh->
getLength() * 0.5;
2656 const unsigned int nPoints = 34;
2660#ifdef DEBUG_DYNAMIC_SHAPES
2661 std::cout <<
SIMTIME <<
" Vehicle::highlight() for vehicle '" << vehID <<
"'\n"
2662 <<
" circle: " << circlePV << std::endl;
2668 while (Polygon::exists(polyID)) {
2677 lyr += (type + 1) / 257.;
2680 Polygon::addHighlightPolygon(vehID, type, polyID, circle, col,
true,
"highlight", (
int)lyr, lw);
2683 double maxAttack = 1.0;
2684 std::vector<double> timeSpan;
2685 if (duration > 0.) {
2686 timeSpan = {0,
MIN2(maxAttack, duration / 3.), 2.*duration / 3., duration};
2689 std::vector<double> alphaSpan;
2690 if (alphaMax > 0.) {
2691 alphaSpan = {0., (double) alphaMax, (
double)(alphaMax) / 3., 0.};
2694 Polygon::addDynamics(polyID, vehID, timeSpan, alphaSpan,
false,
true);
2698Vehicle::dispatchTaxi(
const std::string& vehID,
const std::vector<std::string>& reservations) {
2702 throw TraCIException(
"Vehicle '" + vehID +
"' has not yet departed");
2704 if (taxi ==
nullptr) {
2705 throw TraCIException(
"Vehicle '" + vehID +
"' is not a taxi");
2708 if (dispatcher ==
nullptr) {
2709 throw TraCIException(
"Cannot dispatch taxi because no reservations have been made");
2712 if (traciDispatcher ==
nullptr) {
2713 throw TraCIException(
"device.taxi.dispatch-algorithm 'traci' has not been loaded");
2715 if (reservations.size() == 0) {
2716 throw TraCIException(
"No reservations have been specified for vehicle '" + vehID +
"'");
2721 throw TraCIException(
"Could not interpret reservations for vehicle '" + vehID +
"' (" + e.what() +
").");
2729Vehicle::subscribeLeader(
const std::string& vehID,
double dist,
double begin,
double end) {
2736Vehicle::addSubscriptionFilterLanes(
const std::vector<int>& lanes,
bool noOpposite,
double downstreamDist,
double upstreamDist) {
2739 s->filterLanes = lanes;
2742 addSubscriptionFilterNoOpposite();
2745 addSubscriptionFilterDownstreamDistance(downstreamDist);
2748 addSubscriptionFilterUpstreamDistance(upstreamDist);
2754Vehicle::addSubscriptionFilterNoOpposite() {
2760Vehicle::addSubscriptionFilterDownstreamDistance(
double dist) {
2763 s->filterDownstreamDist = dist;
2769Vehicle::addSubscriptionFilterUpstreamDistance(
double dist) {
2772 s->filterUpstreamDist = dist;
2778Vehicle::addSubscriptionFilterCFManeuver(
double downstreamDist,
double upstreamDist) {
2779 addSubscriptionFilterLeadFollow(std::vector<int>({0}));
2781 addSubscriptionFilterDownstreamDistance(downstreamDist);
2784 addSubscriptionFilterUpstreamDistance(upstreamDist);
2791Vehicle::addSubscriptionFilterLCManeuver(
int direction,
bool noOpposite,
double downstreamDist,
double upstreamDist) {
2792 std::vector<int> lanes;
2795 lanes = std::vector<int>({-1, 0, 1});
2796 }
else if (direction != -1 && direction != 1) {
2797 WRITE_WARNINGF(
TL(
"Ignoring lane change subscription filter with non-neighboring lane offset direction=%."), direction);
2799 lanes = std::vector<int>({0, direction});
2801 addSubscriptionFilterLeadFollow(lanes);
2803 addSubscriptionFilterNoOpposite();
2806 addSubscriptionFilterDownstreamDistance(downstreamDist);
2809 addSubscriptionFilterUpstreamDistance(upstreamDist);
2815Vehicle::addSubscriptionFilterLeadFollow(
const std::vector<int>& lanes) {
2817 addSubscriptionFilterLanes(lanes);
2822Vehicle::addSubscriptionFilterTurn(
double downstreamDist,
double foeDistToJunction) {
2825 addSubscriptionFilterDownstreamDistance(downstreamDist);
2828 s->filterFoeDistToJunction = foeDistToJunction;
2834Vehicle::addSubscriptionFilterVClass(
const std::vector<std::string>& vClasses) {
2843Vehicle::addSubscriptionFilterVType(
const std::vector<std::string>& vTypes) {
2846 s->filterVTypes.insert(vTypes.begin(), vTypes.end());
2852Vehicle::addSubscriptionFilterFieldOfVision(
double openingAngle) {
2855 s->filterFieldOfVisionOpeningAngle = openingAngle;
2861Vehicle::addSubscriptionFilterLateralDistance(
double lateralDist,
double downstreamDist,
double upstreamDist) {
2864 s->filterLateralDist = lateralDist;
2867 addSubscriptionFilterDownstreamDistance(downstreamDist);
2870 addSubscriptionFilterUpstreamDistance(upstreamDist);
2881std::shared_ptr<VariableWrapper>
2882Vehicle::makeWrapper() {
2883 return std::make_shared<Helper::SubscriptionWrapper>(handleVariable, mySubscriptionResults, myContextSubscriptionResults);
2888Vehicle::handleVariable(
const std::string& objID,
const int variable, VariableWrapper* wrapper,
tcpip::Storage* paramData) {
2891 return wrapper->wrapStringList(objID, variable, getIDList());
2893 return wrapper->wrapInt(objID, variable, getIDCount());
2895 return wrapper->wrapPosition(objID, variable, getPosition(objID));
2897 return wrapper->wrapPosition(objID, variable, getPosition(objID,
true));
2899 return wrapper->wrapDouble(objID, variable, getAngle(objID));
2901 return wrapper->wrapDouble(objID, variable, getSpeed(objID));
2903 return wrapper->wrapDouble(objID, variable, getLateralSpeed(objID));
2905 return wrapper->wrapString(objID, variable, getRoadID(objID));
2907 return wrapper->wrapDouble(objID, variable, getSpeedWithoutTraCI(objID));
2909 return wrapper->wrapDouble(objID, variable, getSlope(objID));
2911 return wrapper->wrapString(objID, variable, getLaneID(objID));
2913 return wrapper->wrapString(objID, variable, getShadowLaneID(objID));
2915 return wrapper->wrapInt(objID, variable, getLaneIndex(objID));
2917 return wrapper->wrapString(objID, variable, getSegmentID(objID));
2919 return wrapper->wrapInt(objID, variable, getSegmentIndex(objID));
2921 return wrapper->wrapString(objID, variable, getTypeID(objID));
2923 return wrapper->wrapString(objID, variable, getRouteID(objID));
2925 return wrapper->wrapDouble(objID, variable, getDeparture(objID));
2927 return wrapper->wrapDouble(objID, variable, getDepartDelay(objID));
2929 return wrapper->wrapInt(objID, variable, getRouteIndex(objID));
2931 return wrapper->wrapColor(objID, variable, getColor(objID));
2933 return wrapper->wrapDouble(objID, variable, getLanePosition(objID));
2935 return wrapper->wrapDouble(objID, variable, getArrivalPos(objID));
2937 return wrapper->wrapDouble(objID, variable, getLateralLanePosition(objID));
2939 return wrapper->wrapDouble(objID, variable, getCO2Emission(objID));
2941 return wrapper->wrapDouble(objID, variable, getCOEmission(objID));
2943 return wrapper->wrapDouble(objID, variable, getHCEmission(objID));
2945 return wrapper->wrapDouble(objID, variable, getPMxEmission(objID));
2947 return wrapper->wrapDouble(objID, variable, getNOxEmission(objID));
2949 return wrapper->wrapDouble(objID, variable, getFuelConsumption(objID));
2951 return wrapper->wrapDouble(objID, variable, getNoiseEmission(objID));
2953 return wrapper->wrapDouble(objID, variable, getElectricityConsumption(objID));
2955 return wrapper->wrapInt(objID, variable, getPersonNumber(objID));
2957 return wrapper->wrapInt(objID, variable, getPersonCapacity(objID));
2959 return wrapper->wrapDouble(objID, variable, getBoardingDuration(objID));
2961 return wrapper->wrapStringList(objID, variable, getPersonIDList(objID));
2963 return wrapper->wrapDouble(objID, variable, getWaitingTime(objID));
2965 return wrapper->wrapDouble(objID, variable, getAccumulatedWaitingTime(objID));
2969 return wrapper->wrapDouble(objID, variable, getAdaptedTraveltime(objID, time,
StoHelp::readTypedString(*paramData)));
2977 return wrapper->wrapInt(objID, variable, isRouteValid(objID));
2979 return wrapper->wrapStringList(objID, variable, getRoute(objID));
2981 return wrapper->wrapInt(objID, variable, getSignals(objID));
2983 return wrapper->wrapBestLanesDataVector(objID, variable, getBestLanes(objID));
2985 return wrapper->wrapConnectionVector(objID, variable, getNextLinks(objID));
2987 return wrapper->wrapInt(objID, variable, getStopState(objID));
2989 return wrapper->wrapDouble(objID, variable, getDistance(objID));
2991 return wrapper->wrapDouble(objID, variable, getReferenceDistance(objID));
2993 return wrapper->wrapDouble(objID, variable, getAllowedSpeed(objID));
2995 return wrapper->wrapDouble(objID, variable, getSpeedFactor(objID));
2997 return wrapper->wrapInt(objID, variable, getSpeedMode(objID));
2999 return wrapper->wrapInt(objID, variable, getLaneChangeMode(objID));
3001 return wrapper->wrapInt(objID, variable, getRoutingMode(objID));
3003 return wrapper->wrapString(objID, variable, getLine(objID));
3005 return wrapper->wrapStringList(objID, variable, getVia(objID));
3007 return wrapper->wrapDouble(objID, variable, getAcceleration(objID));
3009 return wrapper->wrapDouble(objID, variable, getLastActionTime(objID));
3011 return wrapper->wrapDouble(objID, variable, getStopDelay(objID));
3013 return wrapper->wrapDouble(objID, variable, getImpatience(objID));
3015 return wrapper->wrapDouble(objID, variable, getStopArrivalDelay(objID));
3017 return wrapper->wrapDouble(objID, variable, getTimeLoss(objID));
3019 return wrapper->wrapDouble(objID, variable, getMinGapLat(objID));
3025 return wrapper->wrapStringList(objID, variable, getLoadedIDList());
3027 return wrapper->wrapStringList(objID, variable, getTeleportingIDList());
3034 return wrapper->wrapDouble(objID, variable, getFollowSpeed(objID, speed, gap, leaderSpeed, leaderMaxDecel,
StoHelp::readTypedString(*paramData)));
3041 return wrapper->wrapDouble(objID, variable, getSecureGap(objID, speed, leaderSpeed, leaderMaxDecel,
StoHelp::readTypedString(*paramData)));
3049 return wrapper->wrapJunctionFoeVector(objID, variable, getJunctionFoes(objID,
StoHelp::readTypedDouble(*paramData)));
3051 return wrapper->wrapStringDoublePairList(objID, variable, getNeighbors(objID,
StoHelp::readTypedByte(*paramData)));
3053 return wrapper->wrapIntPair(objID, variable, getLaneChangeState(objID,
StoHelp::readTypedInt(*paramData)));
3059 return wrapper->wrapString(objID, variable, getStopParameter(objID, nextStopIndex, param, customParam));
3062 return wrapper->wrapNextTLSDataVector(objID, variable, getNextTLS(objID));
3064 return wrapper->wrapNextStopDataVector(objID, variable, getNextStops(objID));
3066 return wrapper->wrapNextStopDataVector(objID, variable, getStops(objID,
StoHelp::readTypedInt(*paramData)));
3068 TraCIRoadPosition roadPos;
3071 return wrapper->wrapDouble(objID, variable, getDrivingDistance(objID, roadPos.edgeID, roadPos.pos, roadPos.laneIndex));
3073 return wrapper->wrapDouble(objID, variable, getDrivingDistance2D(objID, pos.
x(), pos.
y()));
3082 return VehicleType::handleVariableWithID(objID, getTypeID(objID), variable, wrapper, paramData);
std::vector< const MSEdge * > ConstMSEdgeVector
std::vector< MSEdge * > MSEdgeVector
std::pair< const MSVehicle *, double > CLeaderDist
ConstMSEdgeVector::const_iterator MSRouteIterator
#define WRITE_WARNINGF(...)
#define WRITE_WARNING(msg)
std::shared_ptr< const MSRoute > ConstMSRoutePtr
void checkTimeBounds(const double time)
check the valid SUMOTime range of double input and throw an error if out of bounds
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
constexpr SUMOTime TIME2STEPS(double x)
LatAlignmentDefinition
Possible ways to choose the lateral alignment, i.e., how vehicles align themselves within their lane.
SUMOVehicleClass getVehicleClassID(const std::string &name)
Returns the class id of the abstract class given by its name.
SUMOVehicleShape getVehicleShapeID(const std::string &name)
Returns the class id of the shape class given by its name.
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
std::string getVehicleShapeName(SUMOVehicleShape id)
Returns the class name of the shape class given by its id.
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_IGNORING
vehicles ignoring classes
const long long int VEHPARS_ARRIVALSPEED_SET
const long long int VEHPARS_DEPARTPOSLAT_SET
const long long int VEHPARS_ARRIVALPOSLAT_SET
const long long int VEHPARS_PERSON_NUMBER_SET
const long long int VEHPARS_DEPARTSPEED_SET
const int STOP_ARRIVAL_SET
const int STOP_DURATION_SET
const int STOP_POSLAT_SET
const int STOP_EXPECTED_SET
const long long int VEHPARS_FORCE_REROUTE
const int STOP_JUMP_UNTIL_SET
const int STOP_PARKING_SET
const int STOP_TRIP_ID_SET
const long long int VEHPARS_COLOR_SET
std::vector< SUMOVehicleParameter::Stop > StopParVector
const int STOP_PERMITTED_SET
const long long int VEHPARS_TO_TAZ_SET
const long long int VEHPARS_ARRIVALLANE_SET
const long long int VEHPARS_DEPARTLANE_SET
const long long int VEHPARS_DEPARTPOS_SET
const long long int VEHPARS_ARRIVALPOS_SET
const int STOP_EXTENSION_SET
const long long int VEHPARS_FROM_TAZ_SET
const long long int VEHPARS_SPEEDFACTOR_SET
const int STOP_TRIGGER_SET
const long long int VEHPARS_VTYPE_SET
const int STOP_ONDEMAND_SET
const int STOP_STARTED_SET
const int STOP_EXPECTED_CONTAINERS_SET
const long long int VEHPARS_LINE_SET
const long long int VEHPARS_INSERTION_CHECKS_SET
@ GIVEN
The time is given.
@ NOW
The vehicle is discarded if emission fails (not fully implemented yet)
@ CONTAINER_TRIGGERED
The departure is container triggered.
@ TRIGGERED
The departure is person triggered.
@ LCA_UNKNOWN
The action has not been determined.
@ SUMO_ATTR_CONTAINER_STOP
@ SUMO_ATTR_CHARGING_STATION
@ SUMO_ATTR_LCA_CONTRIGHT
@ SUMO_ATTR_EXPECTED_CONTAINERS
const double INVALID_DOUBLE
invalid double
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
#define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOM)
#define LIBSUMO_GET_PARAMETER_WITH_KEY_IMPLEMENTATION(CLASS)
double getParameter(const int index) const
Returns the nth parameter of this distribution.
static PositionVector makeRing(const double radius1, const double radius2, const Position ¢er, unsigned int nPoints)
static const double INVALID_OFFSET
a value to signify offsets outside the range of [0, Line.length()]
static double naviDegree(const double angle)
A vehicle from the mesoscopic point of view.
int getQueIndex() const
Returns the index of the que the vehicle is in.
SUMOTime getEventTime() const
Returns the (planned) time at which the vehicle leaves its current segment.
MSLane * getShadowLane() const
Returns the lane the vehicle's shadow is on during continuous/sublane lane change.
virtual double getSafetyFactor() const
return factor for modifying the safety constraints of the car-following model
void changedToOpposite()
called when a vehicle changes between lanes in opposite directions
virtual void setParameter(const std::string &key, const std::string &value)
try to set the given parameter for this laneChangeModel. Throw exception for unsupported key
void setExtraImpatience(double value)
Sets routing behavior.
The base class for microscopic and mesoscopic vehicles.
double getMaxSpeed() const
Returns the maximum speed (the minimum of desired and technical maximum speed)
double getImpatience() const
Returns this vehicles impatience.
void resetRoutePosition(int index, DepartLaneDefinition departLaneProcedure)
reset index of edge within route
bool replaceStop(int nextStopIndex, SUMOVehicleParameter::Stop stop, const std::string &info, bool teleport, std::string &errorMsg)
void setChosenSpeedFactor(const double factor)
Returns the precomputed factor by which the driver wants to be faster than the speed limit.
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 setRoutingMode(int value)
Sets routing behavior.
virtual double getStopDelay() const
Returns the estimated public transport stop (departure) delay in seconds.
bool rerouteBetweenStops(int nextStopIndex, const std::string &info, bool teleport, std::string &errorMsg)
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
double getChosenSpeedFactor() const
Returns the precomputed factor by which the driver wants to be faster than the speed limit.
virtual BaseInfluencer & getBaseInfluencer()=0
Returns the velocity/lane influencer.
virtual bool replaceRoute(ConstMSRoutePtr route, const std::string &info, bool onInit=false, int offset=0, bool addRouteStops=true, bool removeStops=true, std::string *msgReturn=nullptr)
Replaces the current route by the given one.
virtual double getTimeLossSeconds() const
Returns the time loss in seconds.
double getOdometer() const
Returns the distance that was already driven by this vehicle.
MSVehicleType & getSingularType()
Replaces the current vehicle type with a new one used by this vehicle only.
const MSRouteIterator & getCurrentRouteEdge() const
Returns an iterator pointing to the current edge in this vehicles route.
bool hasValidRoute(std::string &msg, ConstMSRoutePtr route=0) const
Validates the current or given route.
virtual void onRemovalFromNet(const MSMoveReminder::Notification)
Called when the vehicle is removed from the network.
double getLength() const
Returns the vehicle's length.
bool isParking() const
Returns whether the vehicle is parking.
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
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 parameter (not type related)
bool hasDeparted() const
Returns whether this vehicle has already departed.
const std::list< MSStop > & getStops() const
SUMOTime getDeparture() const
Returns this vehicle's real departure time.
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...
virtual std::pair< const MSVehicle *const, double > getLeader(double dist=0, bool considerCrossingFoes=true) const
Returns the leader of the vehicle looking for a fixed distance.
bool hasStops() const
Returns whether the vehicle has to stop somewhere.
void addToOdometer(double value)
Manipulate the odometer.
const MSStop & getNextStop() const
std::string getPrefixedParameter(const std::string &key, std::string &error) const
retrieve parameters of devices, models and the vehicle itself
SUMOVehicleClass getVClass() const
Returns the vehicle's access class.
virtual double getStopArrivalDelay() const
Returns the estimated public transport stop arrival delay in seconds.
MSStop & getStop(int nextStopIndex)
virtual std::pair< const MSVehicle *const, double > getFollower(double dist=0) const
Returns the follower of the vehicle looking for a fixed distance.
bool insertStop(int nextStopIndex, SUMOVehicleParameter::Stop stop, const std::string &info, bool teleport, std::string &errorMsg)
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.
virtual bool addTraciStop(SUMOVehicleParameter::Stop stop, std::string &errorMsg)
const MSRoute & getRoute() const
Returns the current route.
int getRoutingMode() const
return routing mode (configures router choice but also handling of transient permission changes)
int getRoutePosition() const
return index of edge within route
const StopParVector & getPastStops() const
double getEmissions() const
Returns emissions of the current state The value is always per 1s, so multiply by step length if nece...
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT() const
returns the router according to the current routing mode of the vehicle
virtual bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
bool reroute(SUMOTime t, const std::string &info, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, const bool onInit=false, const bool withTaz=false, const bool silent=false, const MSEdge *sink=nullptr)
Performs a rerouting using the given router.
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.
MSDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists, nullptr otherwise.
bool abortNextStop(int nextStopIndex=0)
deletes the next stop at the given index if it exists
virtual void replaceVehicleType(const MSVehicleType *type)
Replaces the current vehicle type by the one given.
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.
double getEmergencyDecel() const
Get the vehicle type's maximal physically possible deceleration [m/s^2].
@ FUTURE
the return value is used for calculating future speeds
virtual double getSecureGap(const MSVehicle *const veh, const MSVehicle *const, const double speed, const double leaderSpeed, const double leaderMaxDecel) const
Returns the minimum gap to reserve if the leader is braking at maximum (>=0)
double getApparentDecel() const
Get the vehicle type's apparent deceleration [m/s^2] (the one regarded by its followers.
double getMaxAccel() const
Get the vehicle type's maximum acceleration [m/s^2].
double brakeGap(const double speed) const
Returns the distance the vehicle needs to halt including driver's reaction time tau (i....
virtual double getImperfection() const
Get the driver's imperfection.
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
virtual double followSpeed(const MSVehicle *const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle *const pred=0, const CalcReason usage=CalcReason::CURRENT) const =0
Computes the vehicle's follow speed (no dawdling)
double stopSpeed(const MSVehicle *const veh, const double speed, double gap, const CalcReason usage=CalcReason::CURRENT) const
Computes the vehicle's safe speed for approaching a non-moving obstacle (no dawdling)
virtual double getHeadwayTime() const
Get the driver's desired headway [s].
A device which collects info on the vehicle trip (mainly on departure and arrival)
static const std::vector< MSDevice_Taxi * > & getFleet()
static MSDispatch * getDispatchAlgorithm()
A dispatch algorithm that services customers in reservation order and always sends the closest availa...
void interpretDispatch(MSDevice_Taxi *taxi, const std::vector< std::string > &reservationsIDs)
trigger taxi dispatch.
An algorithm that performs distpach for a taxi fleet.
A road/street connecting two junctions.
static const MSEdgeVector & getAllEdges()
Returns all edges with a numerical id.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
static void parseEdgesList(const std::string &desc, ConstMSEdgeVector &into, const std::string &rid)
Parses the given string assuming it contains a list of edge ids divided by spaces.
const std::vector< MSLane * > * allowedLanes(const MSEdge &destination, SUMOVehicleClass vclass=SVC_IGNORING, bool ignoreTransientPermissions=false) const
Get the allowed lanes to reach the destination-edge.
double getLength() const
return the length of the edge
double getDistanceAt(double pos) const
Returns the kilometrage/mileage at the given offset along the edge.
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....
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the maximum speed the vehicle may use on this edge.
const MSEdge * getNormalBefore() const
if this edge is an internal edge, return its first normal predecessor, otherwise the edge itself
bool retrieveExistingTravelTime(const MSEdge *const e, const double t, double &value) const
Returns a travel time for an edge and time if stored.
bool knowsTravelTime(const MSEdge *const e) const
Returns the information whether any travel time is known for the given edge.
void addTravelTime(const MSEdge *const e, double begin, double end, double value)
Adds a travel time information for an edge and a time span.
void removeEffort(const MSEdge *const e)
Removes the effort information for an edge.
bool knowsEffort(const MSEdge *const e) const
Returns the information whether any effort is known for the given edge.
void addEffort(const MSEdge *const e, double begin, double end, double value)
Adds an effort information for an edge and a time span.
bool retrieveExistingEffort(const MSEdge *const e, const double t, double &value) const
Returns an effort for an edge and time if stored.
void removeTravelTime(const MSEdge *const e)
Removes the travel time information for an edge.
static double gLateralResolution
static bool gSemiImplicitEulerUpdate
void alreadyDeparted(SUMOVehicle *veh)
stops trying to emit the given vehicle (because it already departed)
void add(SUMOVehicle *veh)
Adds a single vehicle for departure.
virtual const MSJunctionLogic * getLogic() const
virtual const MSLogicJunction::LinkBits & getResponseFor(int linkIndex) const
Returns the response for the given link.
Representation of a lane in the micro simulation.
MSLane * getParallelLane(int offset, bool includeOpposite=true) const
Returns the lane with the given offset parallel to this one or 0 if it does not exist.
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
static std::vector< MSLink * >::const_iterator succLinkSec(const SUMOVehicle &veh, int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane * > &conts)
MSLeaderDistanceInfo getFollowersOnConsecutive(const MSVehicle *ego, double backOffset, bool allSublanes, double searchDist=-1, MinorLinkMode mLinkMode=FOLLOW_ALWAYS, bool maxSearchDist=false) const
return the sublane followers with the largest missing rear gap among all predecessor lanes (within di...
void forceVehicleInsertion(MSVehicle *veh, double pos, MSMoveReminder::Notification notification, double posLat=0)
Inserts the given vehicle at the given position.
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
const MSEdge * getNextNormal() const
Returns the lane's follower if it is an internal lane, the edge of the lane otherwise.
void addLeaders(const MSVehicle *vehicle, double vehPos, MSLeaderDistanceInfo &result, bool oppositeDirection=false)
get leaders for ego on the given lane
double getLength() const
Returns the lane's length.
bool isLinkEnd(std::vector< MSLink * >::const_iterator &i) const
int getIndex() const
Returns the lane's index.
double getOppositePos(double pos) const
return the corresponding position on the opposite lane
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
virtual const PositionVector & getShape(bool) const
MSEdge & getEdge() const
Returns the lane's edge.
double getWidth() const
Returns the lane's width.
const std::vector< MSLink * > & getLinkCont() const
returns the container with all links !!!
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
saves leader/follower vehicles and their distances relative to an ego vehicle
void fixOppositeGaps(bool isFollower)
subtract vehicle length from all gaps if the leader vehicle is driving in the opposite direction
virtual int addLeader(const MSVehicle *veh, double gap, double latOffset=0, int sublane=-1)
const std::vector< const MSLane * > & getFoeLanes() const
LinkState getState() const
Returns the current state of the link.
bool hasApproachingFoe(SUMOTime arrivalTime, SUMOTime leaveTime, double speed, double decel) const
Returns the information whether a vehicle is approaching on one of the link's foe streams.
MSJunction * getJunction() const
MSLane * getLane() const
Returns the connected lane.
bool opened(SUMOTime arrivalTime, double arrivalSpeed, double leaveSpeed, double vehicleLength, double impatience, double decel, SUMOTime waitingTime, double posLat=0, BlockingFoes *collectFoes=nullptr, bool ignoreRed=false, const SUMOTrafficObject *ego=nullptr, double dist=-1) const
Returns the information whether the link may be passed.
int getIndex() const
Returns the respond index (for visualization)
bool havePriority() const
Returns whether this link is a major link.
ApproachingVehicleInformation getApproaching(const SUMOVehicle *veh) const
@ CONFLICT_NO_INTERSECTION
MSLane * getViaLane() const
Returns the following inner lane.
const std::vector< ConflictInfo > & getConflicts() const
LinkDirection getDirection() const
Returns the direction the vehicle passing this link take.
double getLength() const
Returns the length of this link.
Notification
Definition of a vehicle state.
@ NOTIFICATION_VAPORIZED_TRACI
The vehicle got removed via TraCI.
@ NOTIFICATION_ARRIVED
The vehicle arrived at its destination (is deleted)
@ NOTIFICATION_TELEPORT_ARRIVED
The vehicle was teleported out of the net.
@ NOTIFICATION_DEPARTED
The vehicle has departed (was inserted into the network)
@ NOTIFICATION_JUNCTION
The vehicle arrived at a junction.
@ NOTIFICATION_TELEPORT
The vehicle is being teleported.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
MSInsertionControl & getInsertionControl()
Returns the insertion control.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
const ConstMSEdgeVector & getEdges() const
MSRouteIterator end() const
Returns the end of the list of edges to pass.
static bool dictionary(const std::string &id, ConstMSRoutePtr route)
Adds a route to the dictionary.
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
double getDistanceBetween(double fromPos, double toPos, const MSLane *fromLane, const MSLane *toLane, int routePosition=0) const
Compute the distance between 2 given edges on this route, optionally including the length of internal...
const MSLane * lane
The lane to stop at (microsim only)
void initPars(const SUMOVehicleParameter::Stop &stopPar)
initialize attributes from the given stop parameters
int getStateFlagsOld() const
return flags as used by Vehicle::getStopState
bool reached
Information whether the stop has been reached.
MSRouteIterator edge
The edge in the route to stop at.
SUMOTime duration
The stopping duration.
const SUMOVehicleParameter::Stop pars
The stop parameter.
void setLaneChangeMode(int value)
Sets lane changing behavior.
void deactivateGapController()
Deactivates the gap control.
void setSpeedMode(int speedMode)
Sets speed-constraining behaviors.
void setLaneTimeLine(const std::vector< std::pair< SUMOTime, int > > &laneTimeLine)
Sets a new lane timeline.
void setSublaneChange(double latDist)
Sets a new sublane-change request.
void setSignals(int signals)
void setSpeedTimeLine(const std::vector< std::pair< SUMOTime, double > > &speedTimeLine)
Sets a new velocity timeline.
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,.
The class responsible for building and deletion of vehicles.
void removePending()
Removes a vehicle after it has ended.
virtual bool addVehicle(const std::string &id, SUMOVehicle *v)
Tries to insert the vehicle into the internal vehicle container.
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, SumoRNG *rng=nullptr, bool readOnly=false)
Returns the named vehicle type or a sample from the named distribution.
std::map< std::string, SUMOVehicle * >::const_iterator constVehIt
Definition of the internal vehicles map iterator.
virtual SUMOVehicle * buildVehicle(SUMOVehicleParameter *defs, ConstMSRoutePtr route, MSVehicleType *type, const bool ignoreStopErrors, const VehicleDefinitionSource source=ROUTEFILE, bool addRouteStops=true)
Builds a vehicle, increases the number of built vehicles.
void scheduleVehicleRemoval(SUMOVehicle *veh, bool checkDuplicate=false)
Removes a vehicle after it has ended.
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false, bool wasKept=false)
Deletes the vehicle.
constVehIt loadedVehBegin() const
Returns the begin of the internal vehicle map.
constVehIt loadedVehEnd() const
Returns the end of the internal vehicle map.
Representation of a vehicle in the micro simulation.
void updateBestLanes(bool forceRebuild=false, const MSLane *startLane=0)
computes the best lanes to use in order to continue the route
const std::vector< const MSLane * > getUpcomingLanesUntil(double distance) const
Returns the upcoming (best followed by default 0) sequence of lanes to continue the route starting at...
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
SUMOTime getLastActionTime() const
Returns the time of the vehicle's last action point.
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...
void setPreviousSpeed(double prevSpeed, double prevAcceleration)
Sets the influenced previous speed.
SUMOTime getWaitingTime(const bool accumulated=false) const
Returns the SUMOTime waited (speed was lesser than 0.1m/s)
MSAbstractLaneChangeModel & getLaneChangeModel()
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the best sequence of lanes to continue the route starting at myLane.
void onRemovalFromNet(const MSMoveReminder::Notification reason)
Called when the vehicle is removed from the network.
bool resumeFromStopping()
double getBackPositionOnLane(const MSLane *lane) const
Get the vehicle's position relative to the given lane.
void resetActionOffset(const SUMOTime timeUntilNextAction=0)
Resets the action offset for the vehicle.
bool rerouteParkingArea(const std::string &parkingAreaID, std::string &errorMsg)
void switchOffSignal(int signal)
Switches the given signal off.
@ VEH_SIGNAL_NONE
Everything is switched off.
const MSLane * getLane() const
Returns the lane the vehicle is on.
MSLane * getMutableLane() const
Returns the lane the vehicle is on Non const version indicates that something volatile is going on.
Influencer & getInfluencer()
void setActionStepLength(double actionStepLength, bool resetActionOffset=true)
Sets the action steplength of the vehicle.
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
double getSpeed() const
Returns the vehicle's current speed.
void updateLaneBruttoSum()
Update the lane brutto occupancy after a change in minGap.
const std::vector< LaneQ > & getBestLanes() const
Returns the description of best lanes to use in order to continue the route.
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
double getPositionOnLane() const
Get the vehicle's position along the lane.
double getAngle() const
Returns the vehicle's direction in radians.
bool hasInfluencer() const
whether the vehicle is individually influenced (via TraCI or special parameters)
void setLateralPositionOnLane(double posLat)
void switchOnSignal(int signal)
Switches the given signal on.
static MSVehicleTransfer * getInstance()
Returns the instance of this object.
void remove(MSVehicle *veh)
Remove a vehicle from this transfer object.
The car-following model and parameter.
void setHeight(const double &height)
Set a new value for this type's height.
void setMaxSpeedLat(const double &maxSpeedLat)
Set a new value for this type's maximum lateral speed.
double getMinGapLat() const
Get the minimum lateral gap that vehicles of this type maintain.
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
void setEmissionClass(SUMOEmissionClass eclass)
Set a new value for this type's emission class.
double getMaxSpeed() const
Get vehicle's (technical) maximum speed [m/s].
int getPersonCapacity() const
Get this vehicle type's person capacity.
const std::string & getID() const
Returns the name of the vehicle type.
void setMinGapLat(const double &minGapLat)
Set a new value for this type's minimum lataral gap.
double getMinGap() const
Get the free space in front of vehicles of this class.
void setApparentDecel(double apparentDecel)
Set a new value for this type's apparent deceleration.
double getHeight() const
Get the height which vehicles of this class shall have when being drawn.
void setMaxSpeed(const double &maxSpeed)
Set a new value for this type's maximum speed.
const Distribution_Parameterized & getSpeedFactor() const
Returns this type's speed factor.
void setBoardingDuration(SUMOTime duration, bool isPerson=true)
Set a new value for this type's boardingDuration.
double getActionStepLengthSecs() const
Returns this type's default action step length in seconds.
void setLength(const double &length)
Set a new value for this type's length.
double getMaxSpeedLat() const
Get vehicle's maximum lateral speed [m/s].
void setVClass(SUMOVehicleClass vclass)
Set a new value for this type's vehicle class.
void setAccel(double accel)
Set a new value for this type's acceleration.
const MSCFModel & getCarFollowModel() const
Returns the vehicle type's car following model definition (const version)
void setWidth(const double &width)
Set a new value for this type's width.
void setLcContRight(const std::string &value)
Set lcContRight (which is the only lc-attribute not used within the laneChange model)
void setImperfection(double imperfection)
Set a new value for this type's imperfection.
void setPreferredLateralAlignment(const LatAlignmentDefinition &latAlignment, double latAlignmentOffset=0.0)
Set vehicle's preferred lateral alignment.
void setTau(double tau)
Set a new value for this type's headway.
double getLength() const
Get vehicle's length [m].
void setMass(double mass)
Set a new value for this type's mass.
double getMass() const
Get this vehicle type's mass.
void setMinGap(const double &minGap)
Set a new value for this type's minimum gap.
void setShape(SUMOVehicleShape shape)
Set a new value for this type's shape.
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.
virtual const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
virtual void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
static std::string getName(const SUMOEmissionClass c)
Checks whether the string describes a known vehicle class.
static SUMOEmissionClass getClassByName(const std::string &eClass, const SUMOVehicleClass vc=SVC_IGNORING)
Checks whether the string describes a known vehicle class.
A point in 2D or 3D with translation and scaling methods.
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
void sub(double dx, double dy)
Subtracts the given position from this one.
double x() const
Returns the x-position.
void setz(double z)
set position z
double z() const
Returns the z-position.
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position (in radians bet...
double y() const
Returns the y-position.
double rotationAtOffset(double pos) const
Returns the rotation at the given length.
double distance2D(const Position &p, bool perpendicular=false) const
closest 2D-distance to point p (or -1 if perpendicular is true and the point is beyond this vector)
void move2side(double amount, double maxExtension=100)
move position vector to side using certain amount
void set(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
assigns new values
virtual double getSlope() const =0
Returns the slope of the road at object's position in degrees.
virtual const MSLane * getLane() const =0
Returns the lane the object is currently at.
virtual double getPreviousSpeed() const =0
Returns the object's previous speed.
virtual double getSpeed() const =0
Returns the object's current speed.
virtual Position getPosition(const double offset=0) const =0
Return current position (x/y, cartesian)
virtual double getPositionOnLane() const =0
Get the object's position along the lane.
static double getDefaultDecel(const SUMOVehicleClass vc=SVC_IGNORING)
Returns the default deceleration for the given vehicle class This needs to be a function because the ...
static bool parseLatAlignment(const std::string &val, double &lao, LatAlignmentDefinition &lad)
Parses and validates a given latAlignment value.
Representation of a vehicle.
virtual int getRouteValidity(bool update=true, bool silent=false, std::string *msgReturn=nullptr)=0
computes validity attributes for the current route
virtual bool wasRemoteControlled(SUMOTime lookBack=DELTA_T) const =0
Returns the information whether the vehicle is fully controlled via TraCI.
virtual bool hasDeparted() const =0
Returns whether this vehicle has departed.
virtual bool isOnRoad() const =0
Returns the information whether the vehicle is on a road (is simulated)
virtual bool isParking() const =0
Returns the information whether the vehicle is parked.
virtual double getAngle() const =0
Get the vehicle's angle.
Definition of vehicle stop (position and duration)
int getFlags() const
return flags as per Vehicle::getStops
SUMOTime started
the time at which this stop was reached
std::string edge
The edge to stop at.
ParkingType parking
whether the vehicle is removed from the net while stopping
std::string lane
The lane to stop at.
SUMOTime extension
The maximum time extension for boarding / loading.
double speed
the speed at which this stop counts as reached (waypoint mode)
std::string parkingarea
(Optional) parking area if one is assigned to the stop
std::string split
the id of the vehicle (train portion) that splits of upon reaching this stop
double startPos
The stopping position start.
std::string line
the new line id of the trip within a cyclical public transport route
double posLat
the lateral offset when stopping
bool onDemand
whether the stop may be skipped
std::string chargingStation
(Optional) charging station if one is assigned to the stop
std::vector< std::string > getTriggers() const
write trigger attribute
std::set< std::string > permitted
IDs of persons or containers that may board/load at this stop.
SUMOTime jumpUntil
earlierst jump end if there shall be a jump from this stop to the next route edge
int parametersSet
Information for the output which parameter were set.
SUMOTime jump
transfer time if there shall be a jump from this stop to the next route edge
std::string join
the id of the vehicle (train portion) to which this vehicle shall be joined
SUMOTime until
The time at which the vehicle may continue its journey.
std::string actType
act Type (only used by Persons) (used by netedit)
SUMOTime ended
the time at which this stop was ended
double endPos
The stopping position end.
std::set< std::string > awaitedPersons
IDs of persons the vehicle has to wait for until departing.
std::set< std::string > awaitedContainers
IDs of containers the vehicle has to wait for until departing.
std::string busstop
(Optional) bus stop if one is assigned to the stop
std::string tripId
id of the trip within a cyclical public transport route
std::string containerstop
(Optional) container stop if one is assigned to the stop
SUMOTime arrival
The (expected) time at which the vehicle reaches the stop.
SUMOTime duration
The stopping duration.
Structure representing possible vehicle parameter.
double departPosLat
(optional) The lateral position the vehicle shall depart from
double arrivalPosLat
(optional) The lateral position the vehicle shall arrive on
int departLane
(optional) The lane the vehicle shall depart from (index in edge)
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle's end speed shall be chosen.
double departSpeed
(optional) The initial speed of the vehicle
std::string vtypeid
The vehicle's type id.
double speedFactor
individual speedFactor (overriding distribution from vType)
std::vector< std::string > via
List of the via-edges the vehicle must visit.
static bool parseArrivalLane(const std::string &val, const std::string &element, const std::string &id, int &lane, ArrivalLaneDefinition &ald, std::string &error)
Validates a given arrivalLane value.
static bool parseArrivalPosLat(const std::string &val, const std::string &element, const std::string &id, double &pos, ArrivalPosLatDefinition &apd, std::string &error)
Validates a given arrivalPosLat value.
ArrivalLaneDefinition arrivalLaneProcedure
Information how the vehicle shall choose the lane to arrive on.
long long int parametersSet
Information for the router which parameter were set, TraCI may modify this (when changing color)
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
static bool parseDepartSpeed(const std::string &val, const std::string &element, const std::string &id, double &speed, DepartSpeedDefinition &dsd, std::string &error)
Validates a given departSpeed value.
static bool parseArrivalPos(const std::string &val, const std::string &element, const std::string &id, double &pos, ArrivalPosDefinition &apd, std::string &error)
Validates a given arrivalPos value.
int personNumber
The static number of persons in the vehicle when it departs (not including boarding persons)
static bool parseArrivalSpeed(const std::string &val, const std::string &element, const std::string &id, double &speed, ArrivalSpeedDefinition &asd, std::string &error)
Validates a given arrivalSpeed value.
DepartPosLatDefinition departPosLatProcedure
Information how the vehicle shall choose the lateral departure position.
bool wasSet(long long int what) const
Returns whether the given parameter was set.
double departPos
(optional) The position the vehicle shall depart from
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
RGBColor color
The vehicle's color, TraCI may change this.
double arrivalPos
(optional) The position the vehicle shall arrive on
static int parseInsertionChecks(const std::string &value)
parses insertion checks
static bool parseDepartLane(const std::string &val, const std::string &element, const std::string &id, int &lane, DepartLaneDefinition &dld, std::string &error)
Validates a given departLane value.
std::string id
The vehicle's id.
static bool parseDepart(const std::string &val, const std::string &element, const std::string &id, SUMOTime &depart, DepartDefinition &dd, std::string &error, const std::string &attr="departure")
Validates a given depart value.
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
static bool parseDepartPosLat(const std::string &val, const std::string &element, const std::string &id, double &pos, DepartPosLatDefinition &dpd, std::string &error)
Validates a given departPosLat value.
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.
static bool parseDepartPos(const std::string &val, const std::string &element, const std::string &id, double &pos, DepartPosDefinition &dpd, std::string &error)
Validates a given departPos value.
int insertionChecks
bitset of InsertionCheck
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)
static ParkingType parseParkingType(const std::string &value)
parses parking type value
static void parseStopTriggers(const std::vector< std::string > &triggers, bool expectTrigger, Stop &stop)
parses stop trigger values
ArrivalPosLatDefinition arrivalPosLatProcedure
Information how the vehicle shall choose the lateral arrival position.
static bool isInternalRouteID(const std::string &id)
Checks whether the route ID uses the syntax of internal routes.
static StringBijection< LinkState > LinkStates
link states
static int getIndexFromLane(const std::string laneID)
return lane index when given the lane ID
static StringBijection< LinkDirection > LinkDirections
link directions
const std::string & getString(const T key) const
get string
std::set< std::string > getSet()
return set of strings
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
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.
static int toInt(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter,...
static bool toBool(const std::string &sData)
converts a string into the bool value described by it by calling the char-type converter
C++ TraCI client API implementation.
static MSEdge * getEdge(const std::string &edgeID)
static TraCIPosition makeTraCIPosition(const Position &position, const bool includeZ=false)
static bool moveToXYMap_matchingRoutePosition(const Position &pos, const std::string &origID, const ConstMSEdgeVector ¤tRoute, int routeIndex, SUMOVehicleClass vClass, bool setLateralPos, double &bestDistance, MSLane **lane, double &lanePos, int &routeOffset)
static TraCIPositionVector makeTraCIPositionVector(const PositionVector &positionVector)
helper functions
static int readDistanceRequest(tcpip::Storage &data, TraCIRoadPosition &roadPos, Position &pos)
static MSBaseVehicle * getVehicle(const std::string &id)
static TraCIColor makeTraCIColor(const RGBColor &color)
static TraCINextStopData buildStopData(const SUMOVehicleParameter::Stop &stopPar)
static void setRemoteControlled(MSVehicle *v, Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, ConstMSEdgeVector route, SUMOTime t)
static const MSVehicleType & getVehicleType(const std::string &vehicleID)
static bool moveToXYMap(const Position &pos, double maxRouteDistance, bool mayLeaveNetwork, const std::string &origID, const double angle, double speed, const ConstMSEdgeVector ¤tRoute, const int routePosition, const MSLane *currentLane, double currentLanePos, bool onRoad, SUMOVehicleClass vClass, double currentAngle, bool setLateralPos, double &bestDistance, MSLane **lane, double &lanePos, int &routeOffset, ConstMSEdgeVector &edges)
static std::pair< MSLane *, double > convertCartesianToRoadMap(const Position &pos, const SUMOVehicleClass vClass)
static SUMOVehicleParameter::Stop buildStopParameters(const std::string &edgeOrStoppingPlaceID, double pos, int laneIndex, double startPos, int flags, double duration, double until)
static Subscription * addSubscriptionFilter(SubscriptionFilterType filter)
static const MSLane * getLaneChecking(const std::string &edgeID, int laneIndex, double pos)
static int readTypedByte(tcpip::Storage &ret, const std::string &error="")
static int readCompound(tcpip::Storage &ret, int expectedSize=-1, const std::string &error="")
static int readTypedInt(tcpip::Storage &ret, const std::string &error="")
static std::string readTypedString(tcpip::Storage &ret, const std::string &error="")
static double readTypedDouble(tcpip::Storage &ret, const std::string &error="")
#define CALL_MESO_FUN(veh, fun, microResult)
#define CALL_MICRO_FUN(veh, fun, mesoResult)
@ key
the parser read a key of a value in an object
TRACI_CONST double INVALID_DOUBLE_VALUE
TRACI_CONST int VAR_LASTACTIONTIME
TRACI_CONST int VAR_EDGES
TRACI_CONST int POSITION_ROADMAP
TRACI_CONST int VAR_NOXEMISSION
TRACI_CONST int VAR_LANECHANGE_MODE
TRACI_CONST int VAR_REFERENCE_DISTANCE
TRACI_CONST int MOVE_AUTOMATIC
TRACI_CONST int LAST_STEP_PERSON_ID_LIST
TRACI_CONST int TRACI_ID_LIST
TRACI_CONST int VAR_IMPATIENCE
TRACI_CONST int VAR_SEGMENT_ID
TRACI_CONST int VAR_DEPARTURE
TRACI_CONST int VAR_ROUTING_MODE
TRACI_CONST int VAR_SECURE_GAP
TRACI_CONST int VAR_WAITING_TIME
std::map< std::string, libsumo::SubscriptionResults > ContextSubscriptionResults
TRACI_CONST int VAR_EDGE_TRAVELTIME
TRACI_CONST int VAR_ROAD_ID
TRACI_CONST int MOVE_NORMAL
TRACI_CONST int VAR_TIMELOSS
TRACI_CONST int VAR_SPEED_FACTOR
TRACI_CONST int VAR_FOLLOW_SPEED
TRACI_CONST int VAR_STOP_ARRIVALDELAY
TRACI_CONST int VAR_SPEED_LAT
TRACI_CONST int VAR_ANGLE
TRACI_CONST int VAR_NEXT_TLS
TRACI_CONST int VAR_EDGE_EFFORT
TRACI_CONST int VAR_BEST_LANES
TRACI_CONST int VAR_ALLOWED_SPEED
TRACI_CONST int VAR_LANE_INDEX
TRACI_CONST int VAR_PMXEMISSION
TRACI_CONST int VAR_SPEED_WITHOUT_TRACI
TRACI_CONST int VAR_BOARDING_DURATION
TRACI_CONST int MOVE_TELEPORT
TRACI_CONST int VAR_PERSON_NUMBER
TRACI_CONST int VAR_COEMISSION
TRACI_CONST int VAR_COLOR
TRACI_CONST int VAR_POSITION
TRACI_CONST int VAR_PERSON_CAPACITY
TRACI_CONST int VAR_STOP_PARAMETER
TRACI_CONST int VAR_LEADER
TRACI_CONST int VAR_CO2EMISSION
TRACI_CONST int VAR_TELEPORTING_LIST
TRACI_CONST int REMOVE_TELEPORT
TRACI_CONST int VAR_TAXI_FLEET
TRACI_CONST int VAR_ROUTE_VALID
TRACI_CONST int VAR_SPEEDSETMODE
TRACI_CONST int VAR_FUELCONSUMPTION
std::map< std::string, libsumo::TraCIResults > SubscriptionResults
{object->{variable->value}}
TRACI_CONST int VAR_SLOPE
TRACI_CONST int VAR_HCEMISSION
TRACI_CONST int VAR_PARAMETER
TRACI_CONST int VAR_LANEPOSITION
TRACI_CONST int REMOVE_PARKING
TRACI_CONST int VAR_LANE_ID
TRACI_CONST int VAR_STOP_SPEED
TRACI_CONST int VAR_NOISEEMISSION
TRACI_CONST int VAR_ARRIVALPOS
TRACI_CONST int VAR_POSITION3D
TRACI_CONST int VAR_SPEED
TRACI_CONST int VAR_SIGNALS
TRACI_CONST int VAR_PARAMETER_WITH_KEY
TRACI_CONST int VAR_ACCUMULATED_WAITING_TIME
TRACI_CONST int VAR_MINGAP_LAT
TRACI_CONST int INVALID_INT_VALUE
TRACI_CONST int VAR_NEXT_LINKS
TRACI_CONST int VAR_ROUTE_INDEX
TRACI_CONST int VAR_NEXT_STOPS2
TRACI_CONST int VAR_ACCELERATION
TRACI_CONST int VAR_ROUTE_ID
TRACI_CONST int REMOVE_ARRIVED
TRACI_CONST int DISTANCE_REQUEST
@ SUBS_FILTER_LEAD_FOLLOW
@ SUBS_FILTER_UPSTREAM_DIST
@ SUBS_FILTER_DOWNSTREAM_DIST
@ SUBS_FILTER_LATERAL_DIST
@ SUBS_FILTER_FIELD_OF_VISION
TRACI_CONST int VAR_SEGMENT_INDEX
TRACI_CONST int ROUTING_MODE_DEFAULT
TRACI_CONST int VAR_LANEPOSITION_LAT
TRACI_CONST int CMD_CHANGELANE
TRACI_CONST int VAR_STOP_DELAY
TRACI_CONST int REMOVE_TELEPORT_ARRIVED
TRACI_CONST int VAR_NEIGHBORS
TRACI_CONST int REMOVE_VAPORIZED
TRACI_CONST int VAR_STOPSTATE
TRACI_CONST int VAR_FOLLOWER
TRACI_CONST int VAR_LOADED_LIST
TRACI_CONST int VAR_DEPART_DELAY
TRACI_CONST int VAR_SHADOW_LANE_ID
std::map< int, std::shared_ptr< libsumo::TraCIResult > > TraCIResults
{variable->value}
TRACI_CONST int VAR_DISTANCE
TRACI_CONST int ROUTING_MODE_AGGREGATED_CUSTOM
TRACI_CONST int VAR_ELECTRICITYCONSUMPTION
TRACI_CONST int VAR_NEXT_STOPS
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name, cert-dcl58-cpp) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression, cppcoreguidelines-noexcept-swap, performance-noexcept-swap) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
pre-computed information for conflict points
double getFoeConflictSize(const MSLink *foeExitLink) const
double conflictSize
the length of the conflict space
double getFoeLengthBehindCrossing(const MSLink *foeExitLink) const
double lengthBehindCrossing
length of internal lane after the crossing point
A structure representing the best lanes for continuing the current route starting at 'lane'.