How to call TraCICommandInterface::Trafficlight::setProgram() from TraCIDemoRSU11p::onWSM in veins?

75 views
Skip to first unread message

Chakky

unread,
Jun 26, 2018, 11:33:45 AM6/26/18
to OMNeT++ Users
Dear All,

I have founded that there are some functions related to the traffic light already implemented in veins as follows;

std::list<std::string> getTrafficlightIds();
class Trafficlight {

......
void setProgram(std::string program);/**< set/switch to different program */

void setProgrambyTlId(std::string programId, std::string TlId);/**< MY Function used to set/switch to different program  using Traffic light ID*/
.......
};

In my project, I want to set the traffic light to green (when the RSU receives any WSMs from  any approaching vehicles) and then turn back to a normal program after some period of time. I have already defined 2 programs (S1 and S2) of the traffic light in .net.xml as follow;

   <tlLogic id="cluster_15159499_18038479_21113262_347787163_8851291" type="static" programID="S1" offset="0"> <!-- S1-Green program-->
        <phase duration="25" state="rrrrGGGggrrrrGGGgg"/>
   </tlLogic>
   <tlLogic id="cluster_15159499_18038479_21113262_347787163_8851291" type="static" programID="S2" offset="0"> <!-- S2-normal program"-->
        <phase duration="25" state="rrrrGGGggrrrrGGGgg"/>
<phase duration="5" state="rrrryyyyyrrrryyyyy"/>
        <phase duration="25" state="GGggrrrrrGGggrrrrr"/>
        <phase duration="5" state="yyyyrrrrryyyyrrrrr"/>
    </tlLogic>
<WAUT startProg="S2" refTime="0" id="w1">
<wautSwitch to="S1" time="2000"></wautSwitch>            <!-- S1 will never been used, since the simulation runs only for 1000 s-->
<wautSwitch to="S2" time="2100"></wautSwitch>
</WAUT>


I can check if RSU receives any WSMs in TraCIDemoRSU11p::onWSM(WaveShortMessage* wsm). 

However, I am not sure how to call setProgram or setProgrambyTlId (my function) in the TraCIDemoRSU11p::onWSM(WaveShortMessage* wsm).

I have observed that we can call changeRoute(wsm->getWsmData(), 9999) in TraCIDemo11p::onWSM(WaveShortMessage* wsm) using traciVehicle->...... 

Does any one could kindly suggest or share a simple code how to call these traffic light functions? I need only a simple suggestion or code to get some idea how to use them.

I will really appreciate all reply.
Chakky

Fady Samann

unread,
Apr 30, 2022, 2:20:49 AM4/30/22
to OMNeT++ Users
The issue is adding TraCI access to the RSU. In Veins, only vehicles has this access to send and receive commands to/from SUMO. I tried the following solutions on StackOverFlow, but I get an error of the traci is not connected. Please share your solution if you found one. thanks
Reply all
Reply to author
Forward
0 new messages