56 if (sumoVehicle == 0) {
61 throw TraCIException(
"Vehicle '" +
id +
"' is not a micro-simulation vehicle");
76 return sumoVehicle == 0 || sumoVehicle->
getLane() == 0;
79 std::vector<std::string>
81 std::vector<std::string> ids;
84 if ((*i).second->isOnRoad() || (*i).second->isParking()) {
85 ids.push_back((*i).first);
246 std::pair<std::string, double>
250 std::pair<const MSVehicle* const, double> leaderInfo = veh->
getLeader(dist);
251 return std::make_pair(
252 leaderInfo.first != 0 ? leaderInfo.first->getID() :
"",
255 return std::make_pair(
"", -1);
292 std::vector<std::string>
294 std::vector<std::string> result;
298 result.push_back((*i)->getID());
309 std::vector<TraCI_Vehicle::BestLanesData>
311 std::vector<BestLanesData> result;
314 const std::vector<MSVehicle::LaneQ>& bestLanes = veh->
getBestLanes();
315 for (std::vector<MSVehicle::LaneQ>::const_iterator i = bestLanes.begin(); i != bestLanes.end(); ++i) {
328 result.push_back(bld);
335 std::vector<TraCI_Vehicle::NextTLSData>
337 std::vector<NextTLSData> result;
347 if ((*link)->isTLSControlled()) {
349 ntd.
id = (*link)->getTLLogic()->getID();
350 ntd.
tlIndex = (*link)->getTLIndex();
352 ntd.
state = (char)(*link)->getState();
353 result.push_back(ntd);
356 lane = (*link)->getViaLaneOrLane();
373 result = (1 + (stop.
parking ? 2 : 0) +
422 veh->
getEdge(), &roadPos.first->getEdge());
460 std::vector<std::string>
472 return std::make_pair((
int)
LCA_UNKNOWN, (
int)LCA_UNKNOWN);
482 if (tok.
size() < 3) {
483 throw TraCIException(
"Invalid device parameter '" + key +
"' for vehicle '" + vehicleID +
"'");
488 throw TraCIException(
"Vehicle '" + vehicleID +
"' does not support device parameter '" + key +
"' (" + e.what() +
").");
491 const std::string attrName = key.substr(16);
495 throw TraCIException(
"Vehicle '" + vehicleID +
"' does not support laneChangeModel parameter '" + key +
"' (" + e.what() +
").");
499 if (tok.
size() != 3) {
500 throw TraCIException(
"Invalid check for device. Expected format is 'has.DEVICENAME.device'");
572 const std::string& edgeID,
581 bool parking =
false;
582 bool triggered =
false;
583 bool containerTriggered =
false;
586 parking = ((flags & 1) != 0);
587 triggered = ((flags & 2) != 0);
588 containerTriggered = ((flags & 4) != 0);
589 if ((flags & 8) != 0) {
592 if ((flags & 16) != 0) {
595 if ((flags & 32) != 0) {
598 if ((flags & 64) != 0) {
605 if (!veh->
addTraciStopAtStoppingPlace(edgeID, duration, until, parking, triggered, containerTriggered, stoppingPlaceType, error)) {
613 if (endPos < startPos) {
614 throw TraCIException(
"End position on lane must be after start position.");
621 const std::vector<MSLane*>& allLanes = road->
getLanes();
622 if ((laneIndex < 0) || laneIndex >= (
int)(allLanes.size())) {
626 if (!veh->
addTraciStop(allLanes[laneIndex], startPos, endPos, duration, until, parking, triggered, containerTriggered, error)) {
641 std::ostringstream strs;
642 strs <<
"reached: " << sto.
reached;
643 strs <<
", duration:" << sto.
duration;
644 strs <<
", edge:" << (*sto.
edge)->getID();
645 strs <<
", startPos: " << sto.
startPos;
646 std::string posStr = strs.str();
647 throw TraCIException(
"Failed to resume from stoppingfor vehicle '" + veh->
getID() +
"', " + posStr);
659 const std::string& routeID,
660 const std::string& typeID,
662 const std::string& departLane,
663 const std::string& departPos,
664 const std::string& departSpeed,
665 const std::string& arrivalLane,
666 const std::string& arrivalPos,
667 const std::string& arrivalSpeed,
668 const std::string& fromTaz,
669 const std::string& toTaz,
670 const std::string& line,
675 throw TraCIException(
"The vehicle " + vehicleID +
" to add already exists.");
684 TraCI_Vehicle::moveToXY(
const std::string& vehicleID,
const std::string& edgeID,
const int lane,
const double x,
const double y,
const double angle,
const int keepRoute) {
729 if (tok.
size() < 3) {
730 throw TraCIException(
"Invalid device parameter '" + key +
"' for vehicle '" + vehicleID +
"'");
735 throw TraCIException(
"Vehicle '" + vehicleID +
"' does not support device parameter '" + key +
"' (" + e.what() +
").");
738 const std::string attrName = key.substr(16);
742 throw TraCIException(
"Vehicle '" + vehicleID +
"' does not support laneChangeModel parameter '" + key +
"' (" + e.what() +
").");
746 if (tok.
size() != 3) {
747 throw TraCIException(
"Invalid request for device status change. Expected format is 'has.DEVICENAME.device'");
749 const std::string deviceName = tok.
get(1);
754 throw TraCIException(
"Changing device status requires a 'true' or 'false'");
757 throw TraCIException(
"Device removal is not supported for device of type '" + deviceName +
"'");
762 throw TraCIException(
"Cannot create vehicle device (" + std::string(e.what()) +
").");
virtual MSLane * getLane() const =0
Returns the lane the vehicle is on.
SumoXMLTag
Numbers representing SUMO-XML - element names.
MSEdge & getEdge() const
Returns the lane's edge.
std::vector< std::string > continuationLanes
The sequence of lanes that best allows continuing the route without lane change.
Representation of a vehicle in the micro simulation.
bool isLinkEnd(MSLinkCont::const_iterator &i) const
static MSLinkCont::const_iterator succLinkSec(const SUMOVehicle &veh, int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane * > &conts)
bool retrieveExistingTravelTime(const MSEdge *const e, const double t, double &value) const
Returns a travel time for an edge and time if stored.
static int getPersonNumber(const std::string &vehicleID)
double nextOccupation
The traffic density along length.
static bool endsWith(const std::string &str, const std::string suffix)
Checks whether a given string ends with the suffix.
static TraCIColor getColor(const std::string &vehicleID)
bool resumeFromStopping()
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...
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
static bool _2bool(const E *const data)
converts a 0-terminated char-type array into the boolean value described by it
static std::string getLaneID(const std::string &vehicleID)
int bestLaneOffset
The (signed) number of lanes to be crossed to get to the lane which allows to continue the drive...
constVehIt loadedVehBegin() const
Returns the begin of the internal vehicle map.
static void setLine(const std::string &vehicleID, const std::string &line)
static double getPMxEmission(const std::string &vehicleID)
static TraCIColor makeTraCIColor(const RGBColor &color)
double getChosenSpeedFactor() const
Returns the precomputed factor by which the driver wants to be faster than the speed limit...
static double getAllowedSpeed(const std::string &vehicleID)
static double getDistance(const std::string &vehicleID)
static MSEdge * getEdge(const std::string &edgeID)
int bestLaneOffset
The offset of this lane from the best lane.
static double getNOxEmission(const std::string &vehicleID)
static std::vector< std::string > getVia(const std::string &vehicleID)
static double getWaitingTime(const std::string &vehicleID)
double getCO2Emissions() const
Returns CO2 emission of the current state.
bool addTraciStopAtStoppingPlace(const std::string &stopId, const SUMOTime duration, const SUMOTime until, const bool parking, const bool triggered, const bool containerTriggered, const SumoXMLTag stoppingPlaceType, std::string &errorMsg)
bool reached
Information whether the stop has been reached.
double getLength() const
Returns the lane's length.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
const std::pair< int, int > & getSavedState(const int dir) const
static bool isVisible(const MSVehicle *veh)
const MSRoute & getRoute() const
Returns the current route.
static void add(const std::string &vehicleID, const std::string &routeID, const std::string &typeID="DEFAULT_VEHTYPE", std::string depart="-1", 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=0, int personNumber=0)
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
double getHCEmissions() const
Returns HC emission of the current state.
bool hasDeparted() const
Returns whether this vehicle has already departed.
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 getPositionOnLane() const
Get the vehicle's position along the lane.
Definition of vehicle stop (position and duration)
static void setParameter(const std::string &vehicleID, const std::string &key, const std::string &value)
static MSVehicle * getVehicle(const std::string &id)
double getAngle() const
Returns the vehicle's direction in radians.
std::string laneID
The id of the lane.
static int getRouteIndex(const std::string &vehicleID)
static std::pair< int, int > getLaneChangeState(const std::string &vehicleID, int direction)
const std::string & getParameter(const std::string &key, const std::string &defaultValue) const
Returns the value for a given key.
double nextOccupation
As occupation, but without the first lane.
double length
The overall length which may be driven when using this lane without a lane change.
static std::string getRouteID(const std::string &vehicleID)
static std::vector< std::string > getIDList()
bool hasValidRoute(std::string &msg, const MSRoute *route=0) const
Validates the current or given route.
bool hasStops() const
Returns whether the vehicle has to stop somewhere.
static double getCO2Emission(const std::string &vehicleID)
double dist
The distance to the tls.
bool retrieveExistingEffort(const MSEdge *const e, const double t, double &value) const
Returns an effort for an edge and time if stored.
static int getStopState(const std::string &vehicleID)
static double getSpeedWithoutTraCI(const std::string &vehicleID)
The car-following model and parameter.
bool triggered
whether an arriving person lets the vehicle continue
MSAbstractLaneChangeModel & getLaneChangeModel()
static void setColor(const std::string &vehicleID, const TraCIColor &c)
MSChargingStation * chargingStation
(Optional) charging station if one is assigned to the stop
double getSpeedWithoutTraciInfluence() const
Returns the uninfluenced velocity.
double getSlope() const
Returns the slope of the road at vehicle's position.
static std::vector< BestLanesData > getBestLanes(const std::string &vehicleID)
static std::string getLine(const std::string &vehicleID)
static TraCIPosition getPosition(const std::string &vehicleID)
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...
const std::string & getID() const
Returns the id.
A road/street connecting two junctions.
static double getAdaptedTraveltime(const std::string &vehicleID, const std::string &edgeID, int time)
double getElectricityConsumption() const
Returns electricity consumption of the current state.
static void slowDown(const std::string &vehicleID, double speed, int duration)
MSLane * lane
The described lane.
static double naviDegree(const double angle)
The action has not been determined.
static void setMaxSpeed(const std::string &vehicleID, double speed)
static double getNoiseEmission(const std::string &vehicleID)
static bool startsWith(const std::string &str, const std::string prefix)
Checks whether a given string starts with the prefix.
static void setEmissionClass(const std::string &vehicleID, const std::string &clazz)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
void createDevice(const std::string &deviceName)
create device of the given type
static double getFuelConsumption(const std::string &vehicleID)
Representation of a vehicle.
MSStoppingPlace * containerstop
(Optional) container stop if one is assigned to the stop
static double getDrivingDistance2D(const std::string &vehicleID, double x, double y)
static bool isRouteValid(const std::string &vehicleID)
int tlIndex
The tls index of the controlled link.
static double getElectricityConsumption(const std::string &vehicleID)
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the best sequence of lanes to continue the route starting at myLane.
A point in 2D or 3D with translation and scaling methods.
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 ...
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
ConstMSEdgeVector::const_iterator MSRouteIterator
static double getAngle(const std::string &vehicleID)
static int getSignalStates(const std::string &vehicleID)
bool isStopped() const
Returns whether the vehicle is at a stop.
const ConstMSEdgeVector & getEdges() const
SUMOTime duration
The stopping duration.
double getPMxEmissions() const
Returns PMx emission of the current state.
char state
The current state of the tls.
static void remove(const std::string &vehicleID, char reason=REMOVE_VAPORIZED)
A structure representing the best lanes for continuing the current route starting at 'lane'...
static void moveTo(const std::string &vehicleID, const std::string &laneID, double position)
bool allowsContinuation
Whether this lane allows continuing the route.
static void setStop(const std::string &vehicleID, const std::string &edgeID, double endPos=1., int laneIndex=0, SUMOTime duration=4294967295u, int flags=STOP_DEFAULT, double startPos=INVALID_DOUBLE_VALUE, SUMOTime until=-1)
MSParkingArea * parkingarea
(Optional) parkingArea if one is assigned to the stop
int getIndex() const
Returns the lane's index.
bool isInternal() const
return whether this edge is an internal edge
double getWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s)
bool isParking() const
Returns whether the vehicle is parking.
const std::vector< LaneQ > & getBestLanes() const
Returns the description of best lanes to use in order to continue the route.
int getRoutePosition() const
int getPersonNumber() const
Returns the number of persons.
bool allowsContinuation
Whether this lane allows to continue the drive.
double getNOxEmissions() const
Returns NOx emission of the current state.
double length
The length than can be driven from that lane without lane change.
std::string line
The vehicle's line (mainly for public transport)
#define INVALID_DOUBLE_VALUE
static double getHCEmission(const std::string &vehicleID)
static double getCOEmission(const std::string &vehicleID)
static std::pair< MSLane *, double > convertCartesianToRoadMap(Position pos)
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 std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this laneChangeModel. Throw exception for unsupported key ...
bool wasRemoteControlled(SUMOTime lookBack=DELTA_T) const
Returns the information whether the vehicle is fully controlled via TraCI within the lookBack time...
static double getSlope(const std::string &vehicleID)
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)
Influencer & getInfluencer()
Returns the velocity/lane influencer.
Structure representing possible vehicle parameter.
#define INVALID_INT_VALUE
MSRouteIterator end() const
Returns the end of the list of edges to pass.
bool containerTriggered
whether an arriving container lets the vehicle continue
static void moveToXY(const std::string &vehicleID, const std::string &edgeID, const int lane, const double x, const double y, const double angle, const int keepRoute)
static const MSVehicleType & getVehicleType(const std::string &vehicleID)
std::vector< MSLane * > bestContinuations
static void changeLane(const std::string &vehID, int laneIndex, SUMOTime duration)
std::pair< const MSVehicle *const, double > getLeader(double dist=0) const
Returns the leader of the vehicle looking for a fixed distance.
static double getSpeedFactor(const std::string &vehicleID)
std::string get(int pos) const
bool hasDevice(const std::string &deviceName) const
check whether the vehicle is equiped with a device of the given type
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
static void setVia(const std::string &vehicleID, const std::vector< std::string > &via)
MSRouteIterator edge
The edge in the route to stop at.
const std::string & getID() const
Returns the name of the vehicle type.
static std::string getRoadID(const std::string &vehicleID)
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
double getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
std::map< std::string, SUMOVehicle * >::const_iterator constVehIt
Definition of the internal vehicles map iterator.
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
double getDistanceBetween(double fromPos, double toPos, const MSEdge *fromEdge, const MSEdge *toEdge, bool includeInternal=true) const
Compute the distance between 2 given edges on this route, including the length of internal lanes...
static double getDrivingDistance(const std::string &vehicleID, const std::string &edgeID, double position, int laneIndex)
static double getLateralLanePosition(const std::string &vehicleID)
static int getSpeedMode(const std::string &vehicleID)
static TraCIPosition makeTraCIPosition(const Position &position)
int getSignals() const
Returns the signals.
double getFuelConsumption() const
Returns fuel consumption of the current state.
double getCOEmissions() const
Returns CO emission of the current state.
static std::string getTypeID(const std::string &vehicleID)
static int getLaneIndex(const std::string &vehicleID)
constVehIt loadedVehEnd() const
Returns the end of the internal vehicle map.
int getSpeedMode() const
return the current speed mode
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
The class responsible for building and deletion of vehicles.
static void resume(const std::string &vehicleID)
double getHarmonoise_NoiseEmissions() const
Returns noise emissions of the current state.
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
static double getSpeed(const std::string &vehicleID)
MSLane * getLane() const
Returns the lane the vehicle is on.
static double getLanePosition(const std::string &vehicleID)
MSStoppingPlace * busstop
(Optional) bus stop if one is assigned to the stop
Representation of a lane in the micro simulation.
const MSEdgeWeightsStorage & getWeightsStorage() const
Returns the vehicle's internal edge travel times/efforts container.
std::string id
The id of the next tls.
static std::pair< std::string, double > getLeader(const std::string &vehicleID, double dist)
static std::vector< NextTLSData > getNextTLS(const std::string &vehicleID)
static std::vector< std::string > getEdges(const std::string &vehicleID)
static bool onInit(const std::string &vehicleID)
double getDepartPos() const
Returns this vehicle's real departure position.
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
static void setSpeed(const std::string &vehicleID, double speed)
double startPos
The stopping position start.
bool parking
whether the vehicle is removed from the net while stopping
static void setShapeClass(const std::string &vehicleID, const std::string &clazz)
static double getEffort(const std::string &vehicleID, const std::string &edgeID, int time)
const std::string & getID() const
Returns the name of the vehicle.
double getSpeed() const
Returns the vehicle's current speed.