TraCI/Vehicle Value Retrieval

From Sumo
Jump to: navigation, search

Command 0xa4: Get Vehicle Variable

ubyte string
Variable Vehicle ID

Asks for the value of a certain variable of the named vehicle. The value returned is the state of the asked variable/value within the last simulation step. In the case the vehicle is loaded, but outside the network - due not being yet inserted into the network or being teleported within the current time step - a default "error" value is returned.

The following variable values can be retrieved, the type of the return value is also shown in the table.

Overview Retrievable Vehicle Variables
Variable ValueType Description Python Method
id list (0x00) stringList Returns a list of ids of all vehicles currently running within the scenario (the given vehicle ID is ignored) getIDList
count (0x01) int Returns the number of vehicles currently running within the scenario (the given vehicle ID is ignored) getIDCount
speed (0x40) double Returns the speed of the named vehicle within the last step [m/s]; error value: -1001 getSpeed
position (0x42) position Returns the position(two doubles) of the named vehicle (center of the front bumper) within the last step [m,m]; error value: [-2^30, -2^30]. getPosition
position 3D (0x39) position Returns the 3D-position(three doubles) of the named vehicle (center of the front bumper) within the last step [m,m,m]; error value: [-2^30, -2^30, -2^30]. getPosition3D
angle (0x43) double Returns the angle of the named vehicle within the last step [°]; error value: -1001 getAngle
road id (0x50) string Returns the id of the edge the named vehicle was at within the last step; error value: "" getRoadID
lane id (0x51) string Returns the id of the lane the named vehicle was at within the last step; error value: "" getLaneID
lane index (0x52) int Returns the index of the lane the named vehicle was at within the last step; error value: -1001 getLaneIndex
type id (0x4f) string Returns the id of the type of the named vehicle getTypeID
route id (0x53) string Returns the id of the route of the named vehicle getRouteID
route index (0x69) int Returns the index of the current edge within the vehicles route or -1 if the vehicle has not yet departed getRouteIndex
edges (0x54) stringList Returns the ids of the edges the vehicle's route is made of getRoute
color (0x45) ubyte,ubyte,ubyte,ubyte Returns the vehicle's color (RGBA). getColor
lane position (0x56) double The position of the vehicle along the lane (the distance from the front bumper to the start of the lane in [m]); error value: -1001 getLanePosition
distance (0x84) double The distance, the vehicle has already driven [m]); error value: -1001 getDistance
signal states (0x5b) int An integer encoding the state of a vehicle's signals, see TraCI/Vehicle Signalling for more information. getSignals
CO2 emissions
(id 0x60)
double Vehicle's CO2 emissions in mg during this time step; error value: -1001 getCO2Emission
CO emissions
(id 0x61)
double Vehicle's CO emissions in mg during this time step; error value: -1001 getCOEmission
HC emissions
(id 0x62)
double Vehicle's HC emissions in mg during this time step; error value: -1001 getHCEmission
PMx emissions
(id 0x63)
double Vehicle's PMx emissions in mg during this time step; error value: -1001 getPMxEmission
NOx emissions
(id 0x64)
double Vehicle's NOx emissions in mg during this time step; error value: -1001 getNOxEmission
fuel consumption
(id 0x65)
double Vehicle's fuel consumption in ml during this time step; error value: -1001 getFuelConsumption
noise emission
(id 0x66)
double Noise generated by the vehicle in dBA; error value: -1001 getNoiseEmission
electricity consumption (id 0x71) double Vehicle's electricity consumption in kWh during this time step; error value: -1001 getElectricityConsumption
best lanes (id 0xb2) complex For each lane on the current edge, the sequences of lanes that would be followed from that lane without lane-change as well as information regarding lane-change desirability are returned (see below). getBestLanes
stop state (id 0xb5) ubyte value = 1 * stopped + 2 * parking + 4 * triggered + 8 * containerTriggered + 16 * atBusStop + 32 * atContainerStop + 64 * atChargingStation + 128 * atParkingArea getStopState
isAtBusStop
isAtContainerStop
isStopped
isStoppedParking
isStoppedTriggered
length (0x44) double Returns the length of the vehicles [m] getLength
vmax (0x41) double Returns the maximum speed of the vehicle [m/s] getMaxSpeed
accel (0x46) double Returns the maximum acceleration possibility of this vehicle [m/s^2] getAccel
decel (0x47) double Returns the maximum deceleration possibility of this vehicle [m/s^2] getDecel
tau (0x48) double Returns the driver's desired time headway for this vehicle [s] getTau
sigma (0x5d) double Returns the driver's imperfection (dawdling) [0,1] getImperfection
speedFactor (0x5e) double Returns the road speed multiplier for this vehicle [double] getSpeedFactor
speedDev (0x5f) double Returns the deviation of speedFactor for this vehicle [double] getSpeedDeviation
vClass (0x49) string Returns the permission class of this vehicle getVehicleClass
emission_class (0x4a) string Returns the emission class of this vehicle getEmissionClass
shape (0x4b) string Returns the shape class of this vehicle getShapeClass
minGap (0x4c) double Returns the offset (gap to front vehicle if halting) of this vehicle [m] getMinGap
width (0x4d) double Returns the width of this vehicle [m] getWidth
height (0xbc) double Returns the height of this vehicle [m] getHeight
waiting time (0x7a) double Returns the waiting time [s] getWaitingTime
accumulated waiting time (0x87) double Returns the accumulated waiting time [s] within the previous time interval of default length 100 s. (length is configurable per option --waiting-time-memory given to the main application) getAccumulatedWaitingTime
next TLS (0x70) complex Returns upcoming traffic lights, along with distance and state getNextTLS
speed mode (0xb3) int bitset (see below) Retrieves how the values set by speed (0x40) and slowdown (0x14) shall be treated. See the set speedmode command for details. getSpeedMode
slope (0x36) double Retrieves the slope at the current vehicle position in degrees getSlope
allowed speed (0xb7) double Returns the maximum allowed speed on the current lane regarding speed factor in m/s for this vehicle. getAllowedSpeed
line (0xbd) string Returns the line information of this vehicle. getLine
Person Number(0x67) int Returns the total number of persons which includes those defined using attribute 'personNumber' as well as <person>-objects which are riding in this vehicle. getPersonNumber
via edges(0xbe) stringList Returns the ids of via edges for this vehicle. getVia
speed without TraCI (0xb1) double Returns the speed that the vehicle would drive if not speed-influencing command such as setSpeed or slowDown was given. getSpeedWithoutTraCI
valid route (0x92) bool Returns whether the current vehicle route is connected for the vehicle class of the given vehicle. isRouteValid
lateral lane position (0xb8) double Returns the lateral position of the vehicle on its current lane measured in m. getLateralLanePosition
max lateral speed (0xba) double Returns the maximum lateral speed in m/s of this vehicle. getMaxSpeedLat
lateral gap (0xbb) double Returns the desired lateral gap of this vehicle at 50km/h in m. getMinGapLat
lateral alignment (0xb9) string Returns the preferred lateral alignment of the vehicle. getLateralAlignment
parameter (0x7e) string Returns the value for the given string parameter getParameter
action step length (0x7d) double Returns the current action step length for the vehicle in s. getActionStepLength
last action time (0x7f) double Returns the time of the last action step in s. getLastActionTime

Response 0xb4: Vehicle Variable

ubyte string ubyte <return_type>
Variable Vehicle ID Return type of the variable <VARIABLE_VALUE>

The respond to a "Command Get Vehicle Variable".

best lanes (0xb2)

byte int ...
value type compound number of following edge information edge information

Each edge information is:

byte string byte double byte double byte byte (signed) byte byte (unsigned) byte stringList
value type string lane-id value type double length value type double occupation value type byte offset to best lane value type ubyte 0: lane may not be used for continuing drive, 1: it may be used value type stringlist list of best subsequent lanes


Extended retrieval messages

Some further messages require additional parameters.

Overview Extended Variables Retrieval
Variable Request ValueType Response ValueType Description Python Method
edge travel time information (0x58) compound (time, edgeID), see below double Returns the edge travel time for the given time as stored in the vehicle's internal container. If such a value does not exist, -1 is returned. getAdaptedTraveltime
edge effort information (0x59) compound (time, edgeID), see below double Returns the edge effort for the given time as stored in the vehicle's internal container. If such a value does not exist, -1 is returned. getEffort
leader (0x68) double, see below compound (string, double) Returns the id of the leading vehicle and its distance, if the string is empty, no leader was found. Only vehicles ahead on the currently list of best lanes are considered (see above). This means, the leader is only valid until the next lane-change maneuver. The returned distance is measured from the ego vehicle front bumper + minGap to the back bumper of the leader vehicle. getLeader
distance request (0x83) double, see below compound (see Command 0x83: Distance Request) Returns the distance between the current vehicle position and the specified position (for the given distance type) getDrivingDistance

getDrivingDistance2D

change lane information (0x13) compound , see below int, int see below Return whether the vehicle could change lanes in the specified direction (right: -1, left: 1. sublane-change within current lane: 0).
Return the lane change state for the vehicle.
getLaneChangeState

couldChangeLane wantsAndCouldChangeLane


The request message contents are as following:

change lane information (0x13)

byte int
value type compound change direction (-1:right, 0:sublane-change within current lane or 1:left)

The result consists of two integer values. The first value returns the state as computed by the lane change model and the second value returns the state after requests where incorporated (see changeLane, setLaneChangeMode). Each value is a bitset with the following meaning:

  • 2^0: stay
  • 2^1: left
  • 2^2: right
  • 2^3: strategic
  • 2^4: cooperative
  • 2^5: speedGain
  • 2^6: keepRight
  • 2^7: TraCI
  • 2^8: urgent
  • 2^9: blocked by left leader
  • 2^10: blocked by left follower
  • 2^11: blocked by right leader
  • 2^12: bloecked by right follower
  • 2^13: overlapping
  • 2^14: insufficient space
  • 2^15: sublane


edge travel time information (0x58)

byte int byte int byte string
value type compound number of elements (always=2) value type integer requested time (in s) value type string edge id

edge effort information (0x59)

byte int byte int byte string
value type compound number of elements (always=2) value type integer requested time (in s) value type string edge id

leader (0x68)

byte double
value type double maximum look ahead distance (in m)


next TLS (0x70)

byte int byte int byte string byte int byte double byte byte
value type compound number of elements value type integer number of traffic light links ahead value type string TLS id value type int TLS link index value type double distance to TLS value type byte link state

The last 4 items occur multiple times according to the number of traffic lights ahead (2nd return value)

Device and LaneChangeModel Parameter Retrieval 0x7e

Vehicles supports retrieval of device parameters using the generic parameter retrieval call.

Supported Device Parameters

  • device.battery.energyConsumed
  • device.battery.energyCharged
  • device.battery.actualBatteryCapacity
  • device.battery.maximumBatteryCapacity
  • device.battery.chargingStationId
  • device.person.IDList
  • device.container.IDList
  • device.rerouting.period (returns individual rerouting period in seconds)
  • device.rerouting.edge:EDGE_ID (returns assumed travel time for rerouting where EDGE_ID is the id of a network edge)
  • has.DEVICENAME.device (returns "true" or "false" depending on whether a device with DEVICENAME is equipped)
Caution:
If the vehicles does not carry the respective device an error is returned when retrieving parameters with the device. prefix. This happens when requestion device.person.IDList for a vehicle that has not carried any persons up to that point. Either check for existence or handle the error (i.e. by catching TraCIException in the python client).

Supported LaneChangeModel Parameters