62 if (sumoVehicle ==
nullptr) {
67 throw TraCIException(
"Vehicle '" +
id +
"' is not a micro-simulation vehicle");
82 return sumoVehicle ==
nullptr || sumoVehicle->
getLane() ==
nullptr;
85 std::vector<std::string>
87 std::vector<std::string> ids;
91 ids.push_back((*i).first);
199 Vehicle::getColor(
const std::string& vehicleID) {
268 std::vector<std::string>
273 std::pair<std::string, double>
277 std::pair<const MSVehicle* const, double> leaderInfo = veh->
getLeader(dist);
278 return std::make_pair(
279 leaderInfo.first !=
nullptr ? leaderInfo.first->getID() :
"",
282 return std::make_pair(
"", -1);
324 std::vector<std::string>
326 std::vector<std::string> result;
330 result.push_back((*i)->getID());
342 std::vector<TraCIBestLanesData>
344 std::vector<TraCIBestLanesData> result;
347 const std::vector<MSVehicle::LaneQ>& bestLanes = veh->
getBestLanes();
348 for (std::vector<MSVehicle::LaneQ>::const_iterator i = bestLanes.begin(); i != bestLanes.end(); ++i) {
357 if ((*j) !=
nullptr) {
361 result.push_back(bld);
368 std::vector<TraCINextTLSData>
370 std::vector<TraCINextTLSData> result;
380 if ((*link)->isTLSControlled()) {
382 ntd.
id = (*link)->getTLLogic()->getID();
383 ntd.
tlIndex = (*link)->getTLIndex();
385 ntd.
state = (char)(*link)->getState();
386 result.push_back(ntd);
389 lane = (*link)->getViaLaneOrLane();
401 std::vector<TraCINextStopData>
403 std::vector<TraCINextStopData> result;
405 std::list<MSVehicle::Stop> stops = veh->
getMyStops();
406 for (std::list<MSVehicle::Stop>::iterator it = stops.begin(); it != stops.end(); ++it) {
407 if (!it->reached && !it->collision) {
409 nsd.
lane = it->lane->getID();
410 nsd.
endPos = it->getEndPos(*veh);
412 if (it->busstop !=
nullptr) {
415 if (it->containerstop !=
nullptr) {
418 if (it->parkingarea !=
nullptr) {
421 if (it->chargingStation !=
nullptr) {
425 (it->pars.parking ? 2 : 0) +
426 (it->pars.triggered ? 4 : 0) +
427 (it->pars.containerTriggered ? 8 : 0) +
428 (it->busstop !=
nullptr ? 16 : 0) +
429 (it->containerstop !=
nullptr ? 32 : 0) +
430 (it->chargingStation !=
nullptr ? 64 : 0) +
431 (it->parkingarea !=
nullptr ? 128 : 0));
434 result.push_back(nsd);
450 (stop.
busstop !=
nullptr ? 16 : 0) +
474 if (distance == std::numeric_limits<double>::max()) {
491 if (distance == std::numeric_limits<double>::max()) {
508 if (distance == std::numeric_limits<double>::max()) {
531 Vehicle::getSpeedFactor(
const std::string& vehicleID) {
556 std::vector<std::string>
568 return std::make_pair((
int)
LCA_UNKNOWN, (
int)LCA_UNKNOWN);
578 if (tok.
size() < 3) {
579 throw TraCIException(
"Invalid device parameter '" + key +
"' for vehicle '" + vehicleID +
"'");
584 throw TraCIException(
"Vehicle '" + vehicleID +
"' does not support device parameter '" + key +
"' (" + e.what() +
").");
587 const std::string attrName = key.substr(16);
591 throw TraCIException(
"Vehicle '" + vehicleID +
"' does not support laneChangeModel parameter '" + key +
"' (" + e.what() +
").");
595 if (tok.
size() != 3) {
596 throw TraCIException(
"Invalid check for device. Expected format is 'has.DEVICENAME.device'");
612 Vehicle::getEmissionClass(
const std::string& vehicleID) {
617 Vehicle::getShapeClass(
const std::string& vehicleID) {
623 Vehicle::getLength(
const std::string& vehicleID) {
629 Vehicle::getAccel(
const std::string& vehicleID) {
635 Vehicle::getDecel(
const std::string& vehicleID) {
640 double Vehicle::getEmergencyDecel(
const std::string& vehicleID) {
645 double Vehicle::getApparentDecel(
const std::string& vehicleID) {
650 double Vehicle::getActionStepLength(
const std::string& vehicleID) {
661 Vehicle::getTau(
const std::string& vehicleID) {
667 Vehicle::getImperfection(
const std::string& vehicleID) {
673 Vehicle::getSpeedDeviation(
const std::string& vehicleID) {
679 Vehicle::getVehicleClass(
const std::string& vehicleID) {
685 Vehicle::getMinGap(
const std::string& vehicleID) {
691 Vehicle::getMinGapLat(
const std::string& vehicleID) {
697 Vehicle::getMaxSpeed(
const std::string& vehicleID) {
703 Vehicle::getMaxSpeedLat(
const std::string& vehicleID) {
709 Vehicle::getLateralAlignment(
const std::string& vehicleID) {
715 Vehicle::getWidth(
const std::string& vehicleID) {
721 Vehicle::getHeight(
const std::string& vehicleID) {
728 const std::string& edgeID,
737 bool parking =
false;
738 bool triggered =
false;
739 bool containerTriggered =
false;
742 parking = ((flags & 1) != 0);
743 triggered = ((flags & 2) != 0);
744 containerTriggered = ((flags & 4) != 0);
745 if ((flags & 8) != 0) {
748 if ((flags & 16) != 0) {
751 if ((flags & 32) != 0) {
754 if ((flags & 64) != 0) {
763 if (!veh->
addTraciStopAtStoppingPlace(edgeID, durationSteps, untilStep, parking, triggered, containerTriggered, stoppingPlaceType, error)) {
774 if (pos < startPos) {
775 throw TraCIException(
"End position on lane must be after start position.");
779 if (road ==
nullptr) {
782 const std::vector<MSLane*>& allLanes = road->
getLanes();
783 if ((laneIndex < 0) || laneIndex >= (
int)(allLanes.size())) {
787 if (!veh->
addTraciStop(allLanes[laneIndex], startPos, pos, durationSteps, untilStep, parking, triggered, containerTriggered, error)) {
811 std::ostringstream strs;
812 strs <<
"reached: " << sto.
reached;
813 strs <<
", duration:" << sto.
duration;
814 strs <<
", edge:" << (*sto.
edge)->getID();
816 std::string posStr = strs.str();
817 throw TraCIException(
"Failed to resume from stoppingfor vehicle '" + veh->
getID() +
"', " + posStr);
826 const bool onInit =
isOnInit(vehicleID);
827 if (destEdge ==
nullptr) {
850 std::vector<std::pair<SUMOTime, int> > laneTimeLine;
851 laneTimeLine.push_back(std::make_pair(
MSNet::getInstance()->getCurrentTimeStep(), laneIndex));
858 std::vector<std::pair<SUMOTime, int> > laneTimeLine;
861 if (laneChange > 0) {
866 laneTimeLine.push_back(std::make_pair(
MSNet::getInstance()->getCurrentTimeStep(), laneIndex));
880 const std::string& routeID,
881 const std::string& typeID,
882 const std::string& depart,
883 const std::string& departLane,
884 const std::string& departPos,
885 const std::string& departSpeed,
886 const std::string& arrivalLane,
887 const std::string& arrivalPos,
888 const std::string& arrivalSpeed,
889 const std::string& fromTaz,
890 const std::string& toTaz,
891 const std::string& line,
895 if (veh !=
nullptr) {
896 throw TraCIException(
"The vehicle " + vehicleID +
" to add already exists.");
900 vehicleParams.
id = vehicleID;
903 throw TraCIException(
"Invalid type '" + typeID +
"' for vehicle '" + vehicleID +
"'");
913 if (route ==
nullptr) {
915 if (e->getFunction() ==
EDGEFUNC_NORMAL && (e->getPermissions() & vclass) == vclass) {
916 std::vector<std::string> edges;
917 edges.push_back(e->getID());
928 throw TraCIException(
"Invalid route '" + routeID +
"' for vehicle: '" + vehicleID +
"'");
932 if (route->
getEdges().size() == 2) {
934 if (std::find(succ.begin(), succ.end(), route->
getEdges().back()) == succ.end()) {
938 if (fromTaz !=
"" || toTaz !=
"") {
947 WRITE_WARNING(
"Departure time for vehicle '" + vehicleID +
"' is in the past; using current time instead.");
969 vehicleParams.
fromTaz = fromTaz;
970 vehicleParams.
toTaz = toTaz;
971 vehicleParams.
line = line;
987 Vehicle::moveToXY(
const std::string& vehicleID,
const std::string& edgeID,
const int laneIndex,
const double x,
const double y,
double angle,
const int keepRoute) {
989 const bool doKeepRoute = (keepRoute == 1) && veh->
getID() !=
"VTD_EGO";
990 const bool mayLeaveNetwork = (keepRoute == 2);
992 const std::string origID = edgeID +
"_" +
toString(laneIndex);
996 const double origAngle = angle;
1001 while (angle >= 360.) {
1004 while (angle < 0.) {
1011 std::cout << std::endl <<
"begin vehicle " << veh->
getID() <<
" vehPos:" << vehPos <<
" lane:" <<
Named::getIDSecure(veh->
getLane()) << std::endl;
1012 std::cout <<
" want pos:" << pos <<
" origID:" << origID <<
" laneIndex:" << laneIndex <<
" origAngle:" << origAngle <<
" angle:" << angle <<
" keepRoute:" << keepRoute << std::endl;
1018 double lanePosLat = 0;
1019 double bestDistance = std::numeric_limits<double>::max();
1020 int routeOffset = 0;
1022 double maxRouteDistance = 100;
1031 bestDistance, &lane, lanePos, routeOffset);
1037 bestDistance, &lane, lanePos, routeOffset, edges);
1039 if ((found && bestDistance <= maxRouteDistance) || mayLeaveNetwork) {
1044 lanePosLat = perpDist;
1045 if (!mayLeaveNetwork) {
1053 WRITE_WARNING(
"Could not determine position on lane '" + lane->
getID() +
" at lateral position " +
toString(-lanePosLat) +
".");
1057 lanePosLat = -lanePosLat;
1065 assert((found && lane != 0) || (!found && lane == 0));
1067 if (lane !=
nullptr) {
1080 if (lane ==
nullptr) {
1081 throw TraCIException(
"Could not map vehicle '" + vehicleID +
"' no road found within " +
toString(maxRouteDistance) +
"m.");
1083 throw TraCIException(
"Could not map vehicle '" + vehicleID +
"' distance to road is " +
toString(bestDistance) +
".");
1091 std::vector<std::pair<SUMOTime, double> > speedTimeLine;
1098 Vehicle::openGap(
const std::string& vehicleID,
double newTimeHeadway,
double newSpaceHeadway,
double duration,
double changeRate,
double maxDecel) {
1101 if (newTimeHeadway == -1) {
1102 newTimeHeadway = originalTau;
1104 if (originalTau > newTimeHeadway) {
1105 WRITE_WARNING(
"Ignoring openGap(). New time headway must not be smaller than the original.");
1122 std::vector<std::pair<SUMOTime, double> > speedTimeLine;
1124 speedTimeLine.push_back(std::make_pair(
MSNet::getInstance()->getCurrentTimeStep(), speed));
1148 if (vehicleType ==
nullptr) {
1149 throw TraCIException(
"Vehicle type '" + typeID +
"' is not known");
1159 throw TraCIException(
"The route '" + routeID +
"' is not known.");
1163 WRITE_WARNING(
"Invalid route replacement for vehicle '" + veh->
getID() +
"'. " + msg);
1181 throw TraCIException(
"Invalid edge list for vehicle '" + veh->
getID() +
"' (" + e.what() +
")");
1197 double time,
double begSeconds,
double endSeconds) {
1200 if (edge ==
nullptr) {
1201 throw TraCIException(
"Referended edge '" + edgeID +
"' is not known.");
1205 if (begSeconds == 0 && endSeconds == std::numeric_limits<double>::max()) {
1223 double effort,
double begSeconds,
double endSeconds) {
1226 if (edge ==
nullptr) {
1227 throw TraCIException(
"Referended edge '" + edgeID +
"' is not known.");
1231 if (begSeconds == 0 && endSeconds == std::numeric_limits<double>::max()) {
1276 Vehicle::moveTo(
const std::string& vehicleID,
const std::string& laneID,
double position) {
1283 if (!veh->
willPass(&destinationEdge)) {
1284 throw TraCIException(
"Vehicle '" + laneID +
"' may be set onto an edge to pass only.");
1287 if (veh->
getLane() !=
nullptr) {
1292 while (veh->
getEdge() != &destinationEdge) {
1310 Vehicle::setActionStepLength(
const std::string& vehicleID,
double actionStepLength,
bool resetActionOffset) {
1311 if (actionStepLength < 0.0) {
1312 WRITE_ERROR(
"Invalid action step length (<0). Ignoring command setActionStepLength().");
1316 if (actionStepLength == 0.) {
1323 if (resetActionOffset) {
1360 if (veh->
getLane() !=
nullptr) {
1372 Vehicle::setColor(
const std::string& vehicleID,
const TraCIColor& col) {
1380 Vehicle::setSpeedFactor(
const std::string& vehicleID,
double factor) {
1406 Vehicle::setLength(
const std::string& vehicleID,
double length) {
1412 Vehicle::setMaxSpeed(
const std::string& vehicleID,
double speed) {
1418 Vehicle::setVehicleClass(
const std::string& vehicleID,
const std::string& clazz) {
1424 Vehicle::setShapeClass(
const std::string& vehicleID,
const std::string& clazz) {
1430 Vehicle::setEmissionClass(
const std::string& vehicleID,
const std::string& clazz) {
1436 Vehicle::setWidth(
const std::string& vehicleID,
double width) {
1442 Vehicle::setHeight(
const std::string& vehicleID,
double height) {
1448 Vehicle::setMinGap(
const std::string& vehicleID,
double minGap) {
1454 Vehicle::setAccel(
const std::string& vehicleID,
double accel) {
1460 Vehicle::setDecel(
const std::string& vehicleID,
double decel) {
1461 VehicleType::setDecel(
getVehicle(vehicleID)->getSingularType().getID(), decel);
1466 Vehicle::setEmergencyDecel(
const std::string& vehicleID,
double decel) {
1467 VehicleType::setEmergencyDecel(
getVehicle(vehicleID)->getSingularType().getID(), decel);
1472 Vehicle::setApparentDecel(
const std::string& vehicleID,
double decel) {
1478 Vehicle::setImperfection(
const std::string& vehicleID,
double imperfection) {
1484 Vehicle::setTau(
const std::string& vehicleID,
double tau) {
1490 Vehicle::setMinGapLat(
const std::string& vehicleID,
double minGapLat) {
1496 Vehicle::setMaxSpeedLat(
const std::string& vehicleID,
double speed) {
1502 Vehicle::setLateralAlignment(
const std::string& vehicleID,
const std::string& latAlignment) {
1512 if (tok.
size() < 3) {
1513 throw TraCIException(
"Invalid device parameter '" + key +
"' for vehicle '" + vehicleID +
"'");
1518 throw TraCIException(
"Vehicle '" + vehicleID +
"' does not support device parameter '" + key +
"' (" + e.what() +
").");
1521 const std::string attrName = key.substr(16);
1525 throw TraCIException(
"Vehicle '" + vehicleID +
"' does not support laneChangeModel parameter '" + key +
"' (" + e.what() +
").");
1529 if (tok.
size() != 3) {
1530 throw TraCIException(
"Invalid request for device status change. Expected format is 'has.DEVICENAME.device'");
1532 const std::string deviceName = tok.
get(1);
1537 throw TraCIException(
"Changing device status requires a 'true' or 'false'");
1540 throw TraCIException(
"Device removal is not supported for device of type '" + deviceName +
"'");
1545 throw TraCIException(
"Cannot create vehicle device (" + std::string(e.what()) +
").");
1562 std::shared_ptr<VariableWrapper>
1600 return wrapper->
wrapColor(objID, variable, getColor(objID));
1642 return wrapper->
wrapDouble(objID, variable, getSpeedFactor(objID));
SUMOVehicleClass getVehicleClassID(const std::string &name)
Returns the class id of the abstract class given by its name.
int getRoutePosition() const
static std::string getLaneID(const std::string &vehicleID)
double getApparentDecel() const
Get the vehicle type's apparent deceleration [m/s^2] (the one regarded by its followers.
static std::vector< TraCIBestLanesData > getBestLanes(const std::string &vehicleID)
void setMinGap(const double &minGap)
Set a new value for this type's minimum gap.
std::map< std::string, TraCIResults > SubscriptionResults
{object->{variable->value}}
static double gLateralResolution
double getFuelConsumption() const
Returns fuel consumption of the current state.
std::string id
The id of the next tls.
double getAccumulatedWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s) within the last millisecs...
double getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
SumoXMLTag
Numbers representing SUMO-XML - element names.
bool hasSavedState(const int dir) const
double getNOxEmissions() const
Returns NOx emission of the current state.
bool enterLaneAtMove(MSLane *enteredLane, bool onTeleporting=false)
Update when the vehicle enters a new lane in the move step.
static void setStop(const std::string &vehicleID, const std::string &edgeID, double pos=1., int laneIndex=0, double duration=INVALID_DOUBLE_VALUE, int flags=STOP_DEFAULT, double startPos=INVALID_DOUBLE_VALUE, double until=INVALID_DOUBLE_VALUE)
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT() const
RGBColor color
The vehicle's color, TraCI may change this.
MSEdge & getEdge() const
Returns the lane's edge.
static void setEffort(const std::string &vehicleID, const std::string &edgeID, double effort=INVALID_DOUBLE_VALUE, double begSeconds=0, double endSeconds=std::numeric_limits< double >::max())
Representation of a vehicle in the micro simulation.
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false)
Deletes the vehicle.
virtual bool wrapInt(const std::string &objID, const int variable, const int value)=0
const int VEHPARS_FORCE_REROUTE
bool hasValidRoute(std::string &msg, const MSRoute *route=0) const
Validates the current or given route.
double getElectricityConsumption() const
Returns electricity consumption of the current state.
static void setLine(const std::string &vehicleID, const std::string &line)
double dist
The distance to the tls.
double getAngle() const
Returns the vehicle's direction in radians.
bool allowsContinuation
Whether this lane allows continuing the route.
constVehIt loadedVehBegin() const
Returns the begin of the internal vehicle map.
static std::pair< MSLane *, double > convertCartesianToRoadMap(Position pos)
static void updateBestLanes(const std::string &vehicleID)
const ConstMSEdgeVector & getEdges() const
double until
The time at which the vehicle may continue its journey.
static TraCIColor makeTraCIColor(const RGBColor &color)
The vehicle is discarded if emission fails (not fully implemented yet)
double getWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s)
static double getSpeedWithoutTraCI(const std::string &vehicleID)
static std::string getRoadID(const std::string &vehicleID)
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) ...
#define VAR_ACCUMULATED_WAITING_TIME
bool parking
whether the vehicle is removed from the net while stopping
static void setRoute(const std::string &vehicleID, const std::vector< std::string > &edgeIDs)
bool hasDeparted() const
Returns whether this vehicle has already departed.
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
static int getPersonNumber(const std::string &vehicleID)
static bool endsWith(const std::string &str, const std::string suffix)
Checks whether a given string ends with the suffix.
bool resumeFromStopping()
MSLane * getLane() const
Returns the lane the vehicle is on.
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...
ArrivalLaneDefinition arrivalLaneProcedure
Information how the vehicle shall choose the lane to arrive on.
void setTau(double tau)
Set a new value for this type's headway.
bool knowsEffort(const MSEdge *const e) const
Returns the information whether any effort is known for the given edge.
int bestLaneOffset
The (signed) number of lanes to be crossed to get to the lane which allows to continue the drive...
void setShape(SUMOVehicleShape shape)
Set a new value for this type's shape.
static MSEdge * getEdge(const std::string &edgeID)
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
static double getAcceleration(const std::string &vehicleID)
std::pair< const MSVehicle *const, double > getLeader(double dist=0) const
Returns the leader of the vehicle looking for a fixed distance.
static void deactivateGapControl(const std::string &vehicleID)
const SUMOVehicleParameter::Stop pars
The stop parameter.
SUMOTime duration
The stopping duration.
static TraCIPosition makeTraCIPosition(const Position &position, const bool includeZ=false)
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
static void setParameter(const std::string &vehicleID, const std::string &key, const std::string &value)
virtual double getImperfection() const
Get the driver's imperfection.
std::list< Stop > getMyStops()
#define VAR_ALLOWED_SPEED
std::vector< double > & getParameter()
Returns the parameters of this distribution.
MSParkingArea * parkingarea
(Optional) parkingArea if one is assigned to the stop
static double getSlope(const std::string &vehicleID)
MSStoppingPlace * busstop
(Optional) bus stop if one is assigned to the stop
double getPositionOnLane() const
Get the vehicle's position along the lane.
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
static std::string getTypeID(const std::string &vehicleID)
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
int parametersSet
Information for the router which parameter were set, TraCI may modify this (whe changing color) ...
bool reached
Information whether the stop has been reached.
Notification
Definition of a vehicle state.
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
static void setRoutingMode(const std::string &vehicleID, int routingMode)
virtual bool compute(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E *> &into)=0
Builds the route between the given edges using the minimum effort at the given time The definition of...
virtual MSLane * getLane() const =0
Returns the lane the vehicle is on.
std::string get(int pos) const
bool knowsTravelTime(const MSEdge *const e) const
Returns the information whether any travel time is known for the given edge.
bool addTraciStopAtStoppingPlace(const std::string &stopId, const SUMOTime duration, const SUMOTime until, const bool parking, const bool triggered, const bool containerTriggered, const SumoXMLTag stoppingPlaceType, std::string &errorMsg)
static SUMOTime processActionStepLength(double given)
Checks and converts given value for the action step length from seconds to miliseconds assuring it be...
double occupation
The traffic density along length.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position ...
static double getCOEmission(const std::string &vehicleID)
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
bool retrieveExistingEffort(const MSEdge *const e, const double t, double &value) const
Returns an effort for an edge and time if stored.
static void add(const std::string &routeID, const std::vector< std::string > &edgeIDs)
std::string laneID
The id of the lane.
static void setSpeedMode(const std::string &vehicleID, int speedMode)
double getLength() const
Returns the lane's length.
const PositionVector & getShape() const
Returns this lane'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
bool isLinkEnd(MSLinkCont::const_iterator &i) const
static std::vector< std::string > getVia(const std::string &vehicleID)
virtual std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this laneChangeModel. Throw exception for unsupported key ...
const MSRoute & getRoute() const
Returns the current route.
double getMinGapLat() const
Get the minimum lateral gap that vehicles of this type maintain.
The vehicle got vaporized.
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...
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
static void rerouteParkingArea(const std::string &vehicleID, const std::string &parkingAreaID)
double rotationAtOffset(double pos) const
Returns the rotation at the given length.
void setApparentDecel(double apparentDecel)
Set a new value for this type's apparent deceleration.
virtual bool addVehicle(const std::string &id, SUMOVehicle *v)
Tries to insert the vehicle into the internal vehicle container.
std::map< std::string, SubscriptionResults > ContextSubscriptionResults
static TraCIPosition getPosition3D(const std::string &vehicleID)
void setLength(const double &length)
Set a new value for this type's length.
std::vector< const MSEdge * > ConstMSEdgeVector
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle's end speed shall be chosen.
int getSignals() const
Returns the signals.
static void setRouteID(const std::string &vehicleID, const std::string &routeID)
int getLaneChangeMode() const
return the current lane change mode
const std::string & getID() const
Returns the id.
virtual bool wrapString(const std::string &objID, const int variable, const std::string &value)=0
static double getAngle(const std::string &vehicleID)
int getSpeedMode() const
return the current speed mode
static std::shared_ptr< VariableWrapper > makeWrapper()
void setMaxSpeed(const double &maxSpeed)
Set a new value for this type's maximum speed.
double nextOccupation
As occupation, but without the first lane.
static ContextSubscriptionResults myContextSubscriptionResults
double length
The overall length which may be driven when using this lane without a lane change.
void setImperfection(double imperfection)
Set a new value for this type's imperfection.
static std::string getLine(const std::string &vehicleID)
bool rerouteParkingArea(const std::string &parkingAreaID, std::string &errorMsg)
virtual bool isParking() const =0
Returns the information whether the vehicle is parked.
#define VAR_NOISEEMISSION
#define VAR_FUELCONSUMPTION
double getWidth() const
Returns the lane's width.
static double getDistance(const std::string &vehicleID)
static double getNoiseEmission(const std::string &vehicleID)
#define WRITE_WARNING(msg)
The car-following model and parameter.
MSAbstractLaneChangeModel & getLaneChangeModel()
double getDepartPos() const
Returns this vehicle's real departure position.
std::string toTaz
The vehicle's destination zone (district)
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...
static std::pair< int, int > getLaneChangeState(const std::string &vehicleID, int direction)
std::string getVehicleShapeName(SUMOVehicleShape id)
Returns the class name of the shape class given by its id.
static double getNOxEmission(const std::string &vehicleID)
static bool toBool(const std::string &sData)
converts a string into the bool value described by it by calling the char-type converter ...
static void rerouteTraveltime(const std::string &vehicleID)
static double getEffort(const std::string &vehicleID, double time, const std::string &edgeID)
LIBSUMO_VEHICLE_TYPE_SETTER static LIBSUMO_SUBSCRIPTION_API void storeShape(const std::string &id, PositionVector &shape)
Saves the shape of the requested object in the given container.
bool replaceRoute(const MSRoute *route, const std::string &info, bool onInit=false, int offset=0, bool addStops=true, bool removeStops=true)
Replaces the current route by the given one.
static std::vector< std::string > getPersonIDList(const std::string &vehicleID)
static double getWaitingTime(const std::string &vehicleID)
static double getLastActionTime(const std::string &vehicleID)
double getChosenSpeedFactor() const
Returns the precomputed factor by which the driver wants to be faster than the speed limit...
double getMaxAccel() const
Get the vehicle type's maximum acceleration [m/s^2].
static SubscriptionResults mySubscriptionResults
static double getCO2Emission(const std::string &vehicleID)
void setMinGapLat(const double &minGapLat)
Set a new value for this type's minimum lataral gap.
static const MSVehicleType & getVehicleType(const std::string &vehicleID)
int bestLaneOffset
The offset of this lane from the best lane.
double departSpeed
(optional) The initial speed of the vehicle
A road/street connecting two junctions.
static void resume(const std::string &vehicleID)
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
#define INVALID_DOUBLE_VALUE
void setSpeedTimeLine(const std::vector< std::pair< SUMOTime, double > > &speedTimeLine)
Sets a new velocity timeline.
MSLane * lane
The described lane.
void setSpeedMode(int speedMode)
Sets speed-constraining behaviors.
static double naviDegree(const double angle)
#define VAR_PERSON_NUMBER
The action has not been determined.
double getCO2Emissions() const
Returns CO2 emission of the current state.
int getIndex() const
Returns the lane's index.
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
void removeEffort(const MSEdge *const e)
Removes the effort information for an edge.
static bool startsWith(const std::string &str, const std::string prefix)
Checks whether a given string starts with the prefix.
void setSublaneChange(double latDist)
Sets a new sublane-change request.
static std::vector< TraCINextTLSData > getNextTLS(const std::string &vehicleID)
const MSCFModel & getCarFollowModel() const
Returns the vehicle type's car following model definition (const version)
static int getSpeedMode(const std::string &vehicleID)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
void createDevice(const std::string &deviceName)
create device of the given type
static int getRouteIndex(const std::string &vehicleID)
void setAccel(double accel)
Set a new value for this type's acceleration.
Representation of a vehicle.
bool replaceRouteEdges(ConstMSEdgeVector &edges, double cost, double savings, const std::string &info, bool onInit=false, bool check=false, bool removeStops=true)
Replaces the current route by the given edges.
static void setLaneChangeMode(const std::string &vehicleID, int laneChangeMode)
static void setVia(const std::string &vehicleID, const std::vector< std::string > &via)
double startPos
The stopping position start.
static double getLateralLanePosition(const std::string &vehicleID)
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
#define REMOVE_TELEPORT_ARRIVED
static double getHCEmission(const std::string &vehicleID)
A point in 2D or 3D with translation and scaling methods.
SUMOTime getActionStepLength() const
Returns the vehicle's action step length in millisecs, i.e. the interval between two action points...
MSRouteIterator edge
The edge in the route to stop at.
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 set(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
assigns new values
std::string stoppingPlaceID
Id assigned to the stop.
void updateBestLanes(bool forceRebuild=false, const MSLane *startLane=0)
computes the best lanes to use in order to continue the route
int getRoutingMode() const
return the current routing mode
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the best sequence of lanes to continue the route starting at myLane.
static bool isOnInit(const std::string &vehicleID)
double getEmergencyDecel() const
Get the vehicle type's maximal phisically possible deceleration [m/s^2].
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
void setHeight(const double &height)
Set a new value for this type's height.
static void add(const std::string &vehicleID, const std::string &routeID, const std::string &typeID="DEFAULT_VEHTYPE", const std::string &depart="now", const std::string &departLane="first", const std::string &departPos="base", const std::string &departSpeed="0", const std::string &arrivalLane="current", const std::string &arrivalPos="max", const std::string &arrivalSpeed="current", const std::string &fromTaz="", const std::string &toTaz="", const std::string &line="", int personCapacity=4, int personNumber=0)
static double getFuelConsumption(const std::string &vehicleID)
bool triggered
whether an arriving person lets the vehicle continue
void addTravelTime(const MSEdge *const e, double begin, double end, double value)
Adds a travel time information for an edge and a time span.
#define VAR_LASTACTIONTIME
ConstMSEdgeVector::const_iterator MSRouteIterator
static double getLanePosition(const std::string &vehicleID)
static std::vector< std::string > getRoute(const std::string &vehicleID)
The vehicle arrived at its destination (is deleted)
int arrivalLane
(optional) The lane the vehicle shall arrive on (not used yet)
SUMOTime depart
The vehicle's departure time.
bool hasStops() const
Returns whether the vehicle has to stop somewhere.
void forceVehicleInsertion(MSVehicle *veh, double pos, MSMoveReminder::Notification notification, double posLat=0)
Inserts the given vehicle at the given position.
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
static void moveTo(const std::string &vehicleID, const std::string &laneID, double position)
double getMaxSpeed() const
Get vehicle's maximum speed [m/s].
double getHarmonoise_NoiseEmissions() const
Returns noise emissions of the current state.
void resetActionOffset(const SUMOTime timeUntilNextAction=0)
Resets the action offset for the vehicle.
std::string fromTaz
The vehicle's origin zone (district)
A structure representing the best lanes for continuing the current route starting at 'lane'...
static void changeLane(const std::string &vehicleID, int laneIndex, double duration)
virtual bool isOnRoad() const =0
Returns the information whether the vehicle is on a road (is simulated)
void onRemovalFromNet(const MSMoveReminder::Notification reason)
Called when the vehicle is removed from the network.
bool hasInfluencer() const
virtual bool wasRemoteControlled(SUMOTime lookBack=DELTA_T) const =0
Returns the information whether the vehicle is fully controlled via TraCI.
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.
void setEmissionClass(SUMOEmissionClass eclass)
Set a new value for this type's emission class.
static std::vector< std::string > getIDList()
double getMinGap() const
Get the free space in front of vehicles of this class.
static std::string getName(const SUMOEmissionClass c)
Checks whether the string describes a known vehicle class.
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
double endPos
The stopping position end.
static double getAccumulatedWaitingTime(const std::string &vehicleID)
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
#define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOMAIN)
static bool handleVariable(const std::string &objID, const int variable, VariableWrapper *wrapper)
void setChosenSpeedFactor(const double factor)
Returns the precomputed factor by which the driver wants to be faster than the speed limit...
static const double INVALID_OFFSET
a value to signify offsets outside the range of [0, Line.length()]
bool isInternal() const
return whether this edge is an internal edge
const int VEHPARS_COLOR_SET
static void setSpeed(const std::string &vehicleID, double speed)
int personNumber
The static number of persons in the vehicle when it departs (not including boarding persons) ...
static std::string getRouteID(const std::string &vehicleID)
static TraCIPosition getPosition(const std::string &vehicleID, const bool includeZ=false)
bool containerTriggered
whether an arriving container lets the vehicle continue
void move2side(double amount)
move position vector to side using certain ammount
static MSLinkCont::const_iterator succLinkSec(const SUMOVehicle &veh, int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane *> &conts)
std::vector< std::string > getPersonIDList() const
Returns the list of persons.
bool allowsContinuation
Whether this lane allows to continue the drive.
static int getLaneChangeMode(const std::string &vehicleID)
static double getAdaptedTraveltime(const std::string &vehicleID, double time, const std::string &edgeID)
int departLane
(optional) The lane the vehicle shall depart from (index in edge)
std::string line
The vehicle's line (mainly for public transport)
double arrivalPos
(optional) The position the vehicle shall arrive on
void setActionStepLength(const SUMOTime actionStepLength, bool resetActionOffset)
Set a new value for this type's action step length.
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
void setRoutingMode(int value)
Sets routing behavior.
virtual bool wrapDouble(const std::string &objID, const int variable, const double value)=0
void alreadyDeparted(SUMOVehicle *veh)
stops trying to emit the given vehicle (because it already departed)
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, std::mt19937 *rng=0)
Returns the named vehicle type or a sample from the named distribution.
double getCOEmissions() const
Returns CO emission of the current state.
std::vector< std::string > via
List of the via-edges the vehicle must visit.
static std::string getParameter(const std::string &vehicleID, const std::string &key)
virtual bool wrapPosition(const std::string &objID, const int variable, const TraCIPosition &value)=0
double getMaxSpeedLat() const
Get vehicle's maximum lateral speed [m/s].
static void setRemoteControlled(MSVehicle *v, Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, ConstMSEdgeVector route, SUMOTime t)
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
static int getLaneIndex(const std::string &vehicleID)
double getHeight() const
Get the height which vehicles of this class shall have when being drawn.
bool addTraciStop(MSLane *const lane, const double startPos, const double endPos, const SUMOTime duration, const SUMOTime until, const bool parking, const bool triggered, const bool containerTriggered, std::string &errorMsg)
static StringBijection< LateralAlignment > LateralAlignments
lateral alignments
double departPos
(optional) The position the vehicle shall depart from
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
void removeTravelTime(const MSEdge *const e)
Removes the travel time information for an edge.
static void changeTarget(const std::string &vehicleID, const std::string &edgeID)
The vehicle has departed (was inserted into the network)
Influencer & getInfluencer()
Returns the velocity/lane influencer.
int getPersonNumber() const
Returns the number of persons.
void scheduleVehicleRemoval(SUMOVehicle *veh)
Removes a vehicle after it has ended.
void activateGapController(double originalTau, double newTimeHeadway, double newSpaceHeadway, double duration, double changeRate, double maxDecel)
Activates the gap control with the given parameters,.
Structure representing possible vehicle parameter.
#define INVALID_INT_VALUE
#define VAR_LANEPOSITION_LAT
bool retrieveExistingTravelTime(const MSEdge *const e, const double t, double &value) const
Returns a travel time for an edge and time if stored.
static double getAllowedSpeed(const std::string &vehicleID)
static double getPMxEmission(const std::string &vehicleID)
static void setSignals(const std::string &vehicleID, int signals)
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
static SUMOEmissionClass getClassByName(const std::string &eClass, const SUMOVehicleClass vc=SVC_IGNORING)
Checks whether the string describes a known vehicle class.
static bool isRouteValid(const std::string &vehicleID)
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...
MSInsertionControl & getInsertionControl()
Returns the insertion control.
virtual bool wrapColor(const std::string &objID, const int variable, const TraCIColor &value)=0
virtual double getHeadwayTime() const
Get the driver's desired headway [s].
static const MSEdgeVector & getAllEdges()
Returns all edges with a numerical id.
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.
static void moveToXY(const std::string &vehicleID, const std::string &edgeID, const int laneIndex, const double x, const double y, double angle=INVALID_DOUBLE_VALUE, const int keepRoute=1)
static double getDrivingDistance2D(const std::string &vehicleID, double x, double y)
std::vector< MSLane * > bestContinuations
MSStoppingPlace * chargingStation
(Optional) charging station if one is assigned to the stop
char state
The current state of the tls.
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.
#define VAR_ELECTRICITYCONSUMPTION
double getAcceleration() const
Returns the vehicle's acceleration in m/s (this is computed as the last step's mean acceleration in c...
MSStoppingPlace * containerstop
(Optional) container stop if one is assigned to the stop
static std::pair< std::string, double > getLeader(const std::string &vehicleID, double dist=0.)
const MSEdge * getRerouteOrigin() const
Returns the starting point for reroutes (usually the current edge)
const std::string & getID() const
Returns the name of the vehicle type.
double getPMxEmissions() const
Returns PMx emission of the current state.
const std::string getParameter(const std::string &key, const std::string &defaultValue="") const
Returns the value for a given key.
void setWidth(const double &width)
Set a new value for this type's width.
double getActionStepLengthSecs() const
Returns this type's default action step length in seconds.
static int getRoutingMode(const std::string &vehicleID)
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.
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
static void slowDown(const std::string &vehicleID, double speed, double duration)
void updateActionOffset(const SUMOTime oldActionStepLength, const SUMOTime newActionStepLength)
Process an updated action step length value (only affects the vehicle's action offset, The actionStepLength is stored in the (singular) vtype)
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.
double getLength() const
Get vehicle's length [m].
std::map< std::string, SUMOVehicle * >::const_iterator constVehIt
Definition of the internal vehicles map iterator.
void setLaneChangeMode(int value)
Sets lane changing behavior.
void setVClass(SUMOVehicleClass vclass)
Set a new value for this type's vehicle class.
const MSEdge * succEdge(int nSuccs) const
Returns the nSuccs'th successor of edge the vehicle is currently at.
void setSignals(int signals)
static void setAdaptedTraveltime(const std::string &vehicleID, const std::string &edgeID, double time=INVALID_DOUBLE_VALUE, double begSeconds=0, double endSeconds=std::numeric_limits< double >::max())
const MSEdgeWeightsStorage & getWeightsStorage() const
Returns the vehicle's internal edge travel times/efforts container.
static void changeLaneRelative(const std::string &vehicleID, int laneChange, double duration)
SUMOVehicleShape getVehicleShapeID(const std::string &name)
Returns the class id of the shape class given by its name.
void switchOffSignal(int signal)
Switches the given signal off.
void switchOnSignal(int signal)
Switches the given signal on.
double getSlope() const
Returns the slope of the road at vehicle's position.
#define LAST_STEP_PERSON_ID_LIST
static void remove(const std::string &vehicleID, char reason=REMOVE_VAPORIZED)
bool hasDevice(const std::string &deviceName) const
check whether the vehicle is equiped with a device of the given type
#define VAR_SPEED_WITHOUT_TRACI
static MSVehicle * getVehicle(const std::string &id)
double length
The length than can be driven from that lane without lane change.
double arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
#define VAR_LANECHANGE_MODE
void setLaneTimeLine(const std::vector< std::pair< SUMOTime, int > > &laneTimeLine)
Sets a new lane timeline.
double getHCEmissions() const
Returns HC emission of the current state.
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
The vehicle was teleported out of the net.
bool isStopped() const
Returns whether the vehicle is at a stop.
void reroute(SUMOTime t, const std::string &info, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, const bool onInit=false, const bool withTaz=false)
Performs a rerouting using the given router.
The class responsible for building and deletion of vehicles.
bool willPass(const MSEdge *const edge) const
Returns whether the vehicle wil pass the given edge.
std::vector< MSEdge * > MSEdgeVector
static double getElectricityConsumption(const std::string &vehicleID)
virtual SUMOVehicle * buildVehicle(SUMOVehicleParameter *defs, const MSRoute *route, MSVehicleType *type, const bool ignoreStopErrors, const bool fromRouteFile=true)
Builds a vehicle, increases the number of built vehicles.
const std::vector< LaneQ > & getBestLanes() const
Returns the description of best lanes to use in order to continue the route.
static void setType(const std::string &vehicleID, const std::string &typeID)
double getSpeed() const
Returns the vehicle's current speed.
virtual bool wrapStringList(const std::string &objID, const int variable, const std::vector< std::string > &value)=0
MSVehicleType & getSingularType()
Replaces the current vehicle type with a new one used by this vehicle only.
void setMaxSpeedLat(const double &maxSpeedLat)
Set a new value for this type's maximum lateral speed.
void setPreferredLateralAlignment(LateralAlignment latAlignment)
Set vehicle's preferred lateral alignment.
const MSRouteIterator & getCurrentRouteEdge() const
Returns an iterator pointing to the current edge in this vehicles route.
static double getDrivingDistance(const std::string &vehicleID, const std::string &edgeID, double position, int laneIndex=0)
static bool moveToXYMap_matchingRoutePosition(const Position &pos, const std::string &origID, const ConstMSEdgeVector ¤tRoute, int routeIndex, double &bestDistance, MSLane **lane, double &lanePos, int &routeOffset)
static int getSignals(const std::string &vehicleID)
const std::string & getID() const
Returns the name of the vehicle.
void add(SUMOVehicle *veh)
Adds a single vehicle for departure.
static void changeSublane(const std::string &vehicleID, double latDist)
Representation of a lane in the micro simulation.
void deactivateGapController()
Deactivates the gap control.
int tlIndex
The tls index of the controlled link.
static double getSpeed(const std::string &vehicleID)
static int getStopState(const std::string &vehicleID)
void replaceVehicleType(MSVehicleType *type)
Replaces the current vehicle type by the one given.
static bool isVisible(const SUMOVehicle *veh)
const Distribution_Parameterized & getSpeedFactor() const
Returns this type's speed factor.
static std::vector< TraCINextStopData > getNextStops(const std::string &vehicleID)
MSRouteIterator end() const
Returns the end of the list of edges to pass.
static void openGap(const std::string &vehicleID, double newTimeHeadway, double newSpaceHeadway, double duration, double changeRate, double maxDecel)
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.
static bool parseDepart(const std::string &val, const std::string &element, const std::string &id, SUMOTime &depart, DepartDefinition &dd, std::string &error)
Validates a given depart value.
double duration
The stopping duration.
std::vector< std::string > continuationLanes
The sequence of lanes that best allows continuing the route without lane change.
constVehIt loadedVehEnd() const
Returns the end of the internal vehicle map.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
std::string id
The vehicle's id.
double getSpeedWithoutTraciInfluence() const
Returns the uninfluenced velocity.
The vehicle is being teleported.
static void rerouteEffort(const std::string &vehicleID)
Definition of vehicle stop (position and duration)
std::string lane
The lane to stop at.
const std::pair< int, int > & getSavedState(const int dir) const
void addEffort(const MSEdge *const e, double begin, double end, double value)
Adds an effort information for an edge and a time span.
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, MSLane *currentLane, double currentLanePos, bool onRoad, double &bestDistance, MSLane **lane, double &lanePos, int &routeOffset, ConstMSEdgeVector &edges)
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.
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.
double getDistanceBetween(double fromPos, double toPos, const MSEdge *fromEdge, const MSEdge *toEdge, bool includeInternal=true, int routePosition=0) const
Compute the distance between 2 given edges on this route, including the length of internal lanes...