Once you call, setRedYellowGreenState sumo maintains that state until you change it with another call to setRedYellowGreenState or you hand control back to sumo with setProgram.
To perform green wave optimization do either of the following but only ONE of them: - use setPhase with an appropriate initial program as described here: https://sumo.dlr.de/wiki/Simulation/Traffic_Lights#Setting_the_phase (must be called again in every cycle) - use setDuration (called during the green phase) this must be called again in every cycle because the duration is reset to the original value in every cycle If the cycle duration is to be fixed, then calling setDuration once at the start of the simulation can be used to alter the offsets to achieve green waves as well. (But you don't even need TraCI for that since you can set the offset parameter in XML as well). regards, Jakob Am Mo., 6. Mai 2019 um 02:41 Uhr schrieb Sheshadri Kalkunte Ramachandra < [email protected]>: > 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* > Reference: > https://sumo.dlr.de/pydoc/traci._trafficlight.html#TrafficLightDomain-setRedYellowGreenState > > >>> 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 > _______________________________________________ > sumo-user mailing list > [email protected] > To change your delivery options, retrieve your password, or unsubscribe > from this list, visit > https://www.eclipse.org/mailman/listinfo/sumo-user >
_______________________________________________ sumo-user mailing list [email protected] To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/sumo-user
