TraCI/Simulation Value Retrieval

Command 0xab: Get Simulation Variable#

ubyte string
Variable Simulation ID (always unused)

Asks for the value of a certain simulation variable

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

Overview Retrievable Simulation Variables

Variable

ValueType

Description

Python Method

current simulation time (0x66)

double

Returns the current simulation time (in s)

getTime

current simulation time (0x70) (deprecated)

int

Returns the current simulation time (in ms)

getCurrentTime

number of loaded vehicles (id 0x71)

int

The number of vehicles which were loaded in this time step.

getLoadedNumber

ids of loaded vehicles (id 0x72)

stringList

A list of ids of vehicles which were loaded in this time step.

getLoadedIDList

number of departed vehicles (id 0x73)

int

The number of vehicles which departed (were inserted into the road network) in this time step.

getDepartedNumber

ids of departed vehicles (id 0x74)

stringList

A list of ids of vehicles which departed (were inserted into the road network) in this time step.

getDepartedIDList

number of vehicles that start to teleport
(id 0x75)

int

The number of vehicles which started to teleport in this time step.

getStartingTeleportNumber

ids of vehicles that start to teleport (id 0x76)

stringList

A list of ids of vehicles which started to teleport in this time step.

getStartingTeleportIDList

number of vehicles that end being teleported
(id 0x77)

int

The number of vehicles which ended to be teleported in this time step.

getEndingTeleportNumber

ids of vehicles that end being teleported
(id 0x78)

stringList

A list of ids of vehicles which ended to be teleported in this time step.

getEndingTeleportIDList

number of arrived vehicles (id 0x79)

int

The number of vehicles which arrived (have reached their destination and are removed from the road network) in this time step.

getArrivedNumber

ids of arrived vehicles (id 0x7a)

stringList

A list of ids of vehicles which arrived (have reached their destination and are removed from the road network) in this time step.

getArrivedIDList

network bounding box (id 0x7c)

2D polygon

The lower left and the upper right corner of the bounding box of the simulation network.

getNetBoundary

minimum number of vehicles that are still expected to leave the net (id 0x7d)

int

The number of vehicles which are in the net plus the ones still waiting to start. This number may be smaller than the actual number of vehicles still to come because of delayed route file parsing.

getMinExpectedNumber

number of vehicles that begin a stop (id 0x68)

int

The number of vehicles that halted on a scheduled stop in this time step.

getStopStartingVehiclesNumber

ids of vehicles that begin a stop (id 0x69)

stringList

A list of ids of vehicles that halted on a scheduled stop in this time step.

getStopStartingVehiclesIDList

number of vehicles that end a stop (id 0x6a)

int

The number of vehicles that begin to continue their journey, leaving a scheduled stop in this time step.

getStopEndingVehiclesNumber

ids of vehicles that end a stop (id 0x6b)

stringList

A list of ids of vehicles that begin to continue their journey, leaving a scheduled stop in this time step.

getStopEndingVehiclesIDList

number of vehicles involved in a collision (id 0x80)

int

The number of vehicles that were involved in a collision in this time step.

getCollidingVehiclesNumber

ids of vehicles involved in a collision (id 0x81)

stringList

A list of ids of vehicles that were involved in a collision in this time step.

getCollidingVehiclesIDList

number of vehicles that begin to be parked
(id 0x6c)

int

The number of vehicles that enter a parking position in this time step.

getParkingStartingVehiclesNumber

ids of vehicles that begin to be parked
(id 0x6d)

stringList

A list of ids of vehicles that enter a parking position in this time step.

getParkingStartingVehiclesIDList

number of vehicles that end to be parked
(id 0x6e)

int

The number of vehicles that begin to continue their journey, leaving a scheduled parking in this time step.

getParkingEndingVehiclesNumber

ids of vehicles that end being parked (id 0x6f)

stringList

A list of ids of vehicles that begin to continue their journey, leaving a scheduled parking in this time step.

getParkingEndingVehiclesIDList

bus stop waiting (id 0x67)

int

Get the total number of waiting persons at the named bus stop.

getBusStopWaiting

bus stop waiting ids (id 0xef)

stringList

Get the ids of waiting persons at the named bus stop.

getBusStopWaitingIDList

delta T (id 0x7b)

double

Returns the length of one simulation step in seconds.

getDeltaT

parameter (0x7e)

string

Returns the value for the given string parameter

getParameter

Response 0xbb: Simulation Variable#

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

The respond to a "Command Get Simulation Variable".

Extended retrieval messages#

Some further messages require additional parameters.

Overview Extended Variables Retrieval

Variable

Request ValueType

Response ValueType

Description

Python Method

position conversion (0x82)

compound, see below

Position, as wished

Reads a position information and returns it converted into the given representation.

convert2D
convert3D
convertGeo
convertRoad

distance request (0x83)

compound, see below

double

Reads two positions and an indicator whether the air or the driving distance shall be computed. Returns the according distance.

getDistanceRoad
getDistance2D

find route (0x86)

compound, see below

compound, see below

Reads origin and destination edge together with some vehicle paramters and computes the currently fastest driving route for the vehicle (for pedestrians / passengers use find intermodal route).

findRoute

find intermodal route (0x87)

compound, see below

compound, see below

Reads origin and destination position together with usable modes and other person paramters and computes the currently fastest route for the person using the available modes.

findIntermodalRoute

Command 0x82: Position Conversion#

The request needs the following parameter:

byte integer Position byte ubyte
value type compound item number (always 2) position to convert value type ubyte Type of the Position to return

Use this command to convert between the different position types used by TraCI. The specified Position is converted into the requested format given through PositionId. When converting from coordinates to road positions, the result is the closest position that was found to match the given one. In all other cases, the conversion will give an exact match. The return values consists of the converted value only.

See TraCI/Protocol#Position Representations for available position formats.

Command 0x83: Distance Request#

The request needs the following parameter:

byte integer Position Position ubyte
value type compound item number (always 3) start position end position Distance Type

where

  • Distance Type==0: air distance
  • Distance Type==1: driving distance

The resulting distance is returned.

Command 0x86: Find Route#

byte integer byte string byte string byte string byte double byte integer
value type compound item number (always 5) value type string start edge value type string destination edge value type string vehicle type value type double departure time (s) value type integer routing mode (see below)

Caution

Routing mode shall be used to specify which data source to use for estimation of edge travel times. This is not yet implemented and the same data sources as for command vehicle.rerouteTraveltime is used.

The following response is returned:

type + string type + string type + stringList type + double type + double
type (always "driving") line (always "") edges travel time (s) travel time (s)

Note

The python and C++ client return a namedtuple / struct with field names stageType, line, destStop, edges, travelTime, cost.

Note

The seemingly unused/redundant fields are reserved for route-by-cost and intermodal routing (see below).

Command 0x87: Find Intermodal Route#

byte integer byte string byte string byte string byte double byte integer byte double byte double byte double byte double byte double byte string byte string
value type compound item number (always 12) value type string start edge value type string destination edge value type string available modes value type double departure time (s) value type integer routing mode (see above) value type double walking speed (m/s) value type double walk factor value type double depart position (m) value type double arrival position (m) value type double departPosLat (m) value type string vtype of the vehicle value type string vtype of the pedestrian

The available modes are "car", "public", "bicycle" or space separated combination. Walking is always considered possible and is the default (or used when giving an empty string). When "car" is an available mode the vehicle type can be given using the vtype parameter. If this is empty, the default vehicle type is used.

The response is a list of stages similar to the one returned by findRoute.

Generic Parameter Retrieval 0x7e#

The simulation supports retrieval of additional object parameters using the generic parameter retrieval call. The object id refers to the object (i.e. chargingStation) id. The following parameters are supported:

  • chargingStation.totalEnergyCharged
  • chargingStation.name
  • chargingStation.lane
  • parkingArea.capacity
  • parkingArea.occupancy
  • parkingArea.name
  • parkingArea.lane
  • busStop.name
  • busStop.lane