问题
I've tried using the solution presented in the following question (How can I get a traffic light that exists in sumo and change its phase in veins?), however, the following error appears about the command "myProgramGreenRed" not existing for tl "n7", when I try to change the program
The traffic lights ids are n7, n8, and n9 and the piece of code that gives me trouble is :
tl.setProgram("myProgramGreenRed");
tl.setPhaseIndex(1);
and the tls.tls.xml file looks like the following
<tls>
<tlLogic id="10" type="static" programID="myProgramRed" offset="0">
<phase duration="999" state="GggGGgrrr"/>
<phase duration="999" state="GggGGgrrr"/>
</tlLogic>
<tlLogic id="10" type="static" programID="myProgramGreen" offset="0">
<phase duration="999" state="rrrrrrGGG"/>
<phase duration="999" state="rrrrrrGGG"/>
</tlLogic>
<tlLogic id="n7" type="static" programID="myProgramGreenRed" offset="0">
<phase duration="999" state="rrrrrrrrr"/>
<phase duration="999" state="rrrrrrrrr"/>
</tlLogic>
<tlLogic id="10" type="static" programID="myProgramGreenRed" offset="0">
<phase duration="999" state="rrrrrrGGG"/>
<phase duration="999" state="GggGGgrrr"/>
</tlLogic>
<tlLogic id="n9" type="static" programID="myProgramCRL" offset="0">
<phase duration="999" state="rrrrrrrrr"/>
<phase duration="999" state="rrrrrrrrr"/>
</tlLogic>
<tlLogic id="n8" type="static" programID="myProgramCRL" offset="0">
<phase duration="999" state="rrrrrrrrr"/>
<phase duration="999" state="rrrrrrrrr"/>
</tlLogic>
<tlLogic id="n7" type="static" programID="myProgramCRL" offset="0">
<phase duration="999" state="rrrrrrrrr"/>
<phase duration="999" state="rrrrrrrrr"/>
</tlLogic>
</tls>
Does anybody know what can I do to make this work, or if I'm using the wrong approach to achieve the changing of the traffic lights colours.
Thanks in advance!
回答1:
If I read your tls.tls.xml file right, your traffic light "n7" has, indeed, only one program to choose from. Only traffic light "10" has three programs to choose from.
来源:https://stackoverflow.com/questions/54992801/changing-traffic-light-colour-error-in-omnet-veins-sumo