Search code examples
omnet++veinssumo

Changing Traffic Light Colour ERROR in Omnet++/Veins, SUMO


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!


Solution

  • 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.