Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[sumo-user] Inquiry : Controlling traffic lights

Namaste,

We are trying to provide a green wave for a vehicle traveling from point A to point B. For that we need to turn the traffic lights in its path to Green .

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Requirement:

I read from the article https://sumo.dlr.de/wiki/Simulation/Traffic_Lights#Actuated_Traffic_Lights (Controlling traffic lights via TraCI) that we need to load a program that have green phases for long duration and then use setPhase() to switch to the next phase.

We tried to set the current traffic light to green and set its phase and set its phase duration. using the following code.

----------------------------------------------------------------------------------------------------------------------------------------------------------
Code:

Here '1024500711' is a valid traffic light

>>> traci.trafficlight.getCompleteRedYellowGreenDefinition('1024500711') # tried to obtain the definition to see what state it is in

O/P => [Logic(programID='0', type=2, currentPhaseIndex=0, phases=[Phase(duration=0.001, state='GG', minDur=0.001, maxDur=0.001, next=-1), Phase(duration=5.0, state='yy', minDur=5.0, maxDur=5.0, next=-1), Phase(duration=0.001, state='rr', minDur=0.001, maxDur=0.001, next=-1)], subParameter={})]

>>> traci.trafficlight.setRedYellowGreenState('1024500711','GGGGGG') # Wanted to set Green for all

>>> traci.trafficlight.getRedYellowGreenState('1024500711')
O/P =>'GGGGGG'

>>> traci.trafficlight.getCompleteRedYellowGreenDefinition('1024500711') # wanted to confirm whether the traffic changes got set

O/P =>[Logic(programID='0', type=2, currentPhaseIndex=0, phases=[Phase(duration=0.001, state='GG', minDur=0.001, maxDur=0.001, next=-1), Phase(duration=5.0, state='yy', minDur=5.0, maxDur=5.0, next=-1), Phase(duration=0.001, state='rr', minDur=0.001, maxDur=0.001, next=-1)], subParameter={}), Logic(programID='online', type=0, currentPhaseIndex=0, phases=[Phase(duration=1.0, state='GGGGGG', minDur=1.0, maxDur=1.0, next=-1)], subParameter={})]

>>> traci.trafficlight.setPhaseDuration('1024500711',165.5) # Wanted to set the Green phase for 165 seconds
>>> traci.trafficlight.getPhaseDuration('1024500711') # Not showing 165.5
O/P => 1.0

>>> traci.simulationStep() # Ran a traci simulation step
O/P =>[]
>>> traci.trafficlight.getPhaseDuration('1024500711') # Still no change
O/P =>1.0

>>> traci.trafficlight.getProgram('1024500711') # Not sure how to interpret this program Id
'online'
----------------------------------------------------------------------------------------------------------------------------------------------------------

Problem:
  • The traffic light phase duration is not getting updated even after running a sumulationStep().
  • How do we ensure that it remains green for a specified amount of time?
  • After specified amount of time, how to handover control to Sumo for automatically switching to Yellow and Red in future.
----------------------------------------------------------------------------------------------------------------------------------------------------------
Doubts:

Also, if we set a traffic signal state (like GgRrGg) and set phase duration, after the phase duration elapses, will Sumo take over control and resume with automatically switching traffic lights?

Can you provide any insights on how to control traffic lights using Traci api to provide greenwave?
 
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Regards,
Sheshadri K R

+91-9845213149


Back to the top