Search code examples
omnet++veins

Handling traci in the RSU module


CONTEXT:

In my program I have an intersection with a traffic light that coordinates vehicles movement.

On the vertical lane, not that frequently trams will cross. On the horizontal lane, frequent cars.

In my communication simulation experiment, tram has higher priority than cars.

So when it approaches the intersection the idea is that tram crosses without stopping.

Near the intersection there a RSU that monitors tram coordinates and when the tram is close enough

It will send a message to this RSU.

I could successfully control traffic lights from the vehicles (because they have access to traci).

But my next goal is to make the RSU to coordinate the traffic lights after receiving the message.

QUESTION:

How can I make the RSU module to handle traci at the same time vehicles are using it?

ATTEMPT:

Following this question I tried to implement the code to handle traci in the RSU, but it didn't work

The problem was this one: Why I get an error code 139 if I run this code?

//written in the TraCIDemoRSU11p.h
TraCIScenarioManager* manager;
TraCICommandInterface* traci;

.

//written in the TraCIDemoRSU11p.cc
void TraCIDemoRSU11p::initialize(int stage) 
{
    ...
    manager = TraCIScenarioManagerAccess().get();
    traci = manager->getCommandInterface();
    ...
}

SUMMARIZING:

Is there anyone that know how to use traci in RSU and could help me to use it as well?

That would be very helpful to my project, thanks!

DETAIL:

The error doesn't occur exactly when I initialize and try to get TraCI command interface,

But when I try to use it to change traffic light program and phases.


Solution

  • You are most likely trying to use the TraCI interface before it has initialized and connected to SUMO. This happens at a user-configurable time, but after all modules have been initialized.

    Running your simulation in a debugger or in valgrind will point you to where the error occurs. You can refer to the FAQ for help on how to launch a simulation in either mode.