1

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 Answers1

0

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.

Christoph Sommer
  • 6,893
  • 1
  • 17
  • 35
  • Thanks for the quick reply, @Cristoph Sommer, I'm sorry but I presented an outdated piece of the xml file, I've edited it, so now it's exactly as it should be, however the same error occurs – precisoDeTirarDuvidas Mar 05 '19 at 23:37