TraCI/Vehicle Value Retrieval

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
id list (0x00) stringList Returns a list of ids of all vehicles currently running within the scenario (the given vehicle ID is ignored)
count (0x01) int Returns the number of vehicles currently running within the scenario (the given vehicle ID is ignored)
speed (0x40) double Returns the speed of the named vehicle within the last step [m/s]; error value: -1001
position (0x42) position Returns the position(two doubles) of the named vehicle within the last step [m,m]; error value: [-1001,-1001]
angle (0x43) double Returns the angle of the named vehicle within the last step [°]; error value: -1001
road id (0x50) string Returns the id of the edge the named vehicle was at within the last step; error value: ""
lane id (0x51) string Returns the id of the lane the named vehicle was at within the last step; error value: ""
lane index (0x52) int Returns the index of the lane the named vehicle was at within the last step; error value: -1001
type id (0x4f) string Returns the id of the type of the named vehicle
route id (0x53) string Returns the id of the route of the named vehicle
edges (0x54) stringList Returns the ids of the edges the vehicle's route is made of
color (0x45) ubyte,ubyte,ubyte,ubyte Returns the vehicle's color (RGBA).
lane position (0x56) double The position of the vehicle along the lane (in [m]); error value: -1001
signal states (0x5b) int An integer encoding the state of a vehicle's signals, see TraCI/Vehicle Signalling for more information.
CO2 emissions (id 0x60) double Vehicle's CO2 emissions in mg during this time step, computed based on HBEFA; error value: -1001
CO emissions (id 0x61) double Vehicle's CO emissions in mg during this time step, computed based on HBEFA; error value: -1001
HC emissions (id 0x62) double Vehicle's HC emissions in mg during this time step, computed based on HBEFA; error value: -1001
PMx emissions (id 0x63) double Vehicle's PMx emissions in mg during this time step, computed based on HBEFA; error value: -1001
NOx emissions (id 0x64) double Vehicle's NOx emissions in mg during this time step, computed based on HBEFA; error value: -1001
fuel consumption (id 0x65) double Vehicle's fuel consumption in ml during this time step, computed based on HBEFA; error value: -1001
noise emission (id 0x66) double Noise generated by the vehicle in dBA, computed based on Harmonoise; error value: -1001
best lanes (id 0xb2) complex Information about the wish to use subsequent edges' lanes.


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
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.
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.


The request message contents are as following:

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

This page was last modified on 25 March 2013, at 08:10.