Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [sumo-user] How do I get the time duration of green traffic light on a particular edge via traci4matlab?

Dear Lawrence.

I have implemented this command in the latest TraCI4Matlab version.

Best Regards!

2017-09-19 2:54 GMT-05:00 Jakob Erdmann <namdre.sumo@xxxxxxxxxxxxxx>:
Sorry for that,
I had assumed that these basic functions were implemented in the matlab client but did not check. If you must use matlab, petition the maintainer Andres for a patch (or maybe send him a patch yourself so he can integrate it).


2017-09-19 5:41 GMT+02:00 Lawrence Soon <lawrencesoon86@xxxxxxxxxxx>:

Hi Jakob,

I typed help traci.trafficlights yet I could not be able to find the functions traci.trafficlights.getPhaseDuration() and  traci.trafficlights.getDuration  in traci4matlab. How to get them?

Logic                          - constructs a Logic object.
Phase                          - Construct a Phase object for TraCI traffic lights.
getCompleteRedYellowGreenDefinition - Get the complete traffic lights definition.
getContextSubscriptionResults  - Get the context subscription results for the
getControlledLanes             - Get the controlled lanes.
getControlledLinks             - Get the links controlled by the traffic light.
getIDList                      - Get the IDs of the traffic lights in the network.
getNextSwitch                  - Returns the time in ms at which the next phase change will
getPhase                       - Get the phase index.
getProgram                     - Returns the id of the current program.
getRedYellowGreenState         - Get the traffic lights' state.
getSubscriptionResults         - Get the subscription results for the last time step.
getUniversal                   - An internal function to send the get command and read the 
readLinks                      - Internal function to read the links controlled by the traffic lights.   
readLogics                     - Internal function to read the complete program of the traffic lights.
setCompleteRedYellowGreenDefinition - Set the complete definition of the traffic light.
setPhase                       - Set the phase index of the traffic light.
setPhaseDuration               - Set the phase duration traffic light.
setProgram                     - Sets the id of the current program.
setRedYellowGreenState         - Set the state of the traffic lights.
subscribe                      - Subscribe to traffic lights variable.
subscribeContext               - Subscribe to a traffic lights's context variable.

From: Jakob Erdmann <namdre.sumo@xxxxxxxxxxxxxx>
Sent: Tuesday, September 19, 2017 3:55 AM
To: Lawrence Soon; Sumo project User discussions
Cc: sumo-user@xxxxxxxxxxxxxxxxxxxxt
Subject: Re: [sumo-user] How do I get the time duration of green traffic light on a particular edge via traci4matlab?
First you need to determine the traffic-light index which corresponds to that edge (or rather to the lane-to-lane connections from that edge because each connection has it's own index).
This is done by calling the function trafficlights.getControlledLinks.

Then you can retrieve the state with getgetRedYellowGreenState and interpret it using the respective index)
By calling getDuration getNextSwitch you can figure out all there is to know about spend and remaining duration (see the explanation at getPhaseDuration)


2017-09-18 15:27 GMT+02:00 Lawrence Soon via sumo-user <>:

I realised that in net.xml file, the trafficlight control does not specify which edge is the phase for, as shown below as an example:

<tlLogic id="232207810" type="static" programID="0" offset="0">
        <phase duration="36" state="GGGGGrrrrr"/>
        <phase duration="9" state="yyyyyrrrrr"/>
        <phase duration="36" state="rrrrrGGGGG"/>
        <phase duration="9" state="rrrrryyyyy"/>

and let the edge is defined this way:

<edge id="street5leftleft" from="232207810" to="233432379" priority="9" type="highway.primary" spreadType="center" shape="509.17,869.74 519.11,881.80 567.57,936.91 604.90,975.02 611.28,982.15 616.33,987.82 645.59,1020.13 664.22,1040.70">
        <lane id="street5leftleft_0" index="0" disallow="tram rail_urban rail rail_electric ship" speed="27.78" length="213.48" shape="517.39,874.53 521.62,879.66 569.99,934.66 607.31,972.76 613.74,979.95 618.79,985.61 648.04,1017.91 660.99,1032.21"/>
        <lane id="street5leftleft_1" index="1" disallow="tram rail_urban rail rail_electric ship" speed="27.78" length="213.48" shape="514.84,876.62 519.11,881.80 567.57,936.91 604.90,975.02 611.28,982.15 616.33,987.82 645.59,1020.13 658.54,1034.43"/>
        <lane id="street5leftleft_2" index="2" disallow="tram rail_urban rail rail_electric ship" speed="27.78" length="213.48" shape="512.30,878.72 516.60,883.94 565.15,939.16 602.49,977.28 608.82,984.35 613.87,990.03 643.14,1022.35 656.10,1036.64"/>

junction is defined as :

<junction id="232207810" type="traffic_light" x="509.17" y="869.74" incLanes="juncons35_0 juncons35_1 juncons35_2 juncons35_3 street3leftleft2_0 street3leftleft2_1 street3leftleft2_2" intLanes=":232207810_0_0 :232207810_1_0 :232207810_1_1 :232207810_1_2 :232207810_1_3 :232207810_5_0 :232207810_5_1 :232207810_5_2 :232207810_8_0 :232207810_8_1" shape="511.06,879.74 518.63,873.51 518.97,871.59 512.34,860.29 509.50,860.22 500.93,864.96 500.37,867.06 506.61,878.58">
        <request index="0" response="0000000000" foes="0011100000" cont="0"/>
        <request index="1" response="0000000000" foes="1111100000" cont="0"/>
        <request index="2" response="0000000000" foes="1111100000" cont="0"/>
        <request index="3" response="0000000000" foes="1111100000" cont="0"/>
        <request index="4" response="0000000000" foes="1111100000" cont="0"/>
        <request index="5" response="0000011111" foes="0000011111" cont="0"/>
        <request index="6" response="0000011111" foes="0000011111" cont="0"/>
        <request index="7" response="0000011111" foes="0000011111" cont="0"/>
        <request index="8" response="0000011110" foes="0000011110" cont="0"/>
        <request index="9" response="0000011110" foes="0000011110" cont="0"/>

So how do I get the time duration of green traffic light on a particular edge via traci4matlab?

Thanks and have a great day!

Check out the vibrant tech community on one of the world's most
engaging tech sites,!
sumo-user mailing list
sumo-user mailing list
To change your delivery options, retrieve your password, or unsubscribe from this list, visit

Andres Felipe Acosta Gil, MSc student - Software developer
Universidad Nacional de Colombia - Medellín
Facultad de Minas
Tel: +57 (4) 4255092
Institutional e-mail: afacostag@xxxxxxxxxxx

Back to the top