I have my own existing SUMO simulation for an intersection traffic control algorithm where I generate vehicles online, get their information, make planning decisions, and control every vehicle. I assumed perfect communication between vehicles and intersection agent in the simulation. Now I want to simulate the realistic communication using veins. However, after reading many posts and followed the veins tutorial successfully, I still don't have a clear idea how to implement it.
Roughly I learned that I have two options:
1. implement the algorithm using TraCIDemo11p files for car's behavior and TraCIDemoRSU11p files for the intersection agent. The problem is I need to do everything again using C++ and I am not an expert in C++.
2. I read a post:
https://groups.google.com/forum/#!topic/omnetpp/XEazGbgq3eA
The problem asked in the email is very similar to my problem. Christoph provided the following solution:
For such complex interaction, it is perhaps best to bundle all multiplexing functionality in your Python script and run the simulation without traci-launchd.
When Veins starts, it will try to connect to a configured TraCI server (localhost on TCP port 9999 by default), then send a TraCI command instructing the server to start SUMO, followed by a number of subscription requests.
In the course of your simulation, Veins will repeatedly send CMD_SIMSTEP commands and wait for subscription results (i.e., nodes departing, moving, arriving).
Your script could delay passing each CMD_SIMSTEP commands from Veins to SUMO (and relaying the results back to Veins) until it is ready to process the next timestep.
If your script listens on port 9999, reads TraCI commands, discards the very first message, then passes the remaining commands to an (already) running instance of SUMO, it can serve as this multiplexing point.
you can use a single additional stream of TraCI messages from Veins to your script that updates its stored copy of connectivity information at every time step.
Basically, I need to make veins and my simulation code both connect to SUMO. Every time veins reads movement traces from SUMO and simulate communication one timestep, then my algorithm reads communication data from veins and vehicle data from SUMO, then sends control command to SUMO. Finally, SUMO simulates one timestep and goes back to veins.
My questions are:
1. Are my understanding correct? Are these two approaches feasible?
2. I prefer the 2nd approach since it might need less time. But I don't know how can I separate CMD_SIMSTEP command from the data veins sends to SUMO? I believe I should modify forward_connection() function in sumo-launchd.py, but I am not sure how to change the data variable.
3. For the copy of connectivity information in veins, I don't have a clue where to get them?
Thank you so much for your help.
Update: from SUMO documentation:
The client has to trigger each simulation step in SUMO using the TraCI/Control-related commands#Command 0x02: Simulation Step command. If any subscriptions have been done, the subscribed values are returned. The simulation will advance to the next once all clients have sent the simulation step command.
So for the 2nd question, does this mean I don't need to modify anything in forward_connection() function. I only need to figure out how to connect SUMO with both clients (omnetpp and my algorithm program)?
Update: I was able to follow veins tutorial successfully and now I am able to modify sumo-launchd.py to allow another client to connect with SUMO. I am trying to find out how to get the communication data from veins/omnetpp.