TraCI/Traffic Lights Value Retrieval
Contents |
Command 0xa2: Get Traffic Lights Variable
| ubyte | string |
| Variable | Traffic Lights ID |
|---|
Asks for the value of a certain variable of the named traffic light. The value returned is the state of the asked variable/value within the last simulation step. The following variable values can be retrieved, the type of the return value is also shown in the table.
| Variable | ValueType | Description |
|---|---|---|
| id list (0x00) | stringList | Returns a list of ids of all traffic lights within the scenario (the given Traffic Lights ID is ignored) |
| count (0x01) | int | Returns the number of traffic lights within the scenario (the given Traffic Lights ID is ignored) |
| state (light/priority tuple) (0x20) | string | Returns the named tl's state as a tuple of light definitions from rRgGyYoO, for red, green, yellow, off, where lower case letters mean that the stream has to decelerate |
| default current phase duration (0x24) | int | Returns the default duration of the currently active phase [s]; note that this is not the remaining duration, but the complete; use "assumed time till next switch (0x2d)" for obtaining the remaining duration |
| controlled lanes (0x26) | stringList | Returns the list of lanes which are controlled by the named traffic light |
| controlled links (0x27) | compound object | Returns the links controlled by the traffic light, sorted by the signal index and described by giving the incoming, outgoing, and via lane |
| current phase (0x28) | int | Returns the index of the current phase in the current program |
| current program (0x29) | string | Returns the id of the current program |
| complete definition (light/priority tuple) (0x2b) | compound object | Returns the complete traffic light program, structure described under data types |
| assumed time of next switch (0x2d) | int | Returns the assumed time (in milliseconds) at which the tls changes the phase. Please note that the time to switch is not relative to current simulation step (the result returned by the query will be absolute time, counting from simulation start); to obtain relative time, one needs to subtract current simulation time from the result returned by this query. Please also note that the time may vary in the case of actuated/adaptive traffic lights |
Response 0xb2: Traffic Lights Variable
| ubyte | string | ubyte | <return_type> |
| Variable | Traffic Light ID | Return type of the variable | <RETURN_VALUE> |
|---|
The respond to a "Command Get Traffic Lights Variable".
Structure of compound object traffic light program (both 0x25 and 0x2b)
If you request a complete traffic light program, the compound object is structured as following. Attention, each part is fowarded by a byte which represents its data type, except "length".
| integer | type + integer | logic | ... | logic |
| Length | Number of logics | logic 1 | ... | logic n |
|---|
where logic is decribed by:
| type + string | type + integer | type + compound | type + integer | type + integer | phase | ... | phase |
| SubID | Type | SubParameter | Current phase index | Number of phases | Phase 1 | ... | Phase n |
|---|
Type and SubParameter aren't currently implemented therefore they are 0.
where phase is described by:
| type + integer | type + integer | type + integer | type + stringList |
| Duration | Duration 1 | Duration 2 | Phase definition |
|---|
Duration 1 and 2 are currently not implemented. The pahse definition differs for 0x25 and 0x2b. The first (0x25) contains the old, deprecated definition which uses three strings that describe the tl's state, the first green y/n, the second for brake y/n, the third for yellow y/n. The second (0x2b) contains a single string representing the lights. Note, that the first (0x25) is also reversed.
Structure of compound object controlled links
If you request the list of links, the compound object is structured as following. Attention, each part is fowarded by a byte which represents its data type, except "length".
| integer | controlled links | ... | controlled links |
| Length (number of signals) | links controlled by signal 0 | ... | links controlled by signal n-1 |
|---|
Controlled links:
| int | stringlist | ... | stringlist |
| number of controlled links | link 0 | ... | link n-1 |
|---|
Each link is described by a string list with three entries: the lane which is incoming into the junction, the lane which is outgoing from the junction, and the lane across the junction (junction-internal). Empty strings indicate missing lanes.