0

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.

Community
  • 1
  • 1
pb772
  • 539
  • 1
  • 3
  • 14
  • Did you try using asserts after your allocations, as I mentioned in the last question? This will avoid segmentation fault error codes and give you an assert error instead. – Julian Heinovski Mar 14 '17 at 08:41
  • See [this post](http://stackoverflow.com/questions/35790944/how-to-access-traci-command-interface-from-tracidemorsu11p-in-veins-car2x-simula?noredirect=1&lq=1) on how to use asserts in this situation. – Julian Heinovski Mar 14 '17 at 08:53
  • I will check tomorrow, I thought assert was just to check if the operation was successfully done. It might work, thanks. What is the meaning of assert error? Does the simulation runs if there is an assert error? – pb772 Mar 14 '17 at 09:13
  • Well, I suggest you do some research on asserts (in C++) first and then consider updating this post. – Julian Heinovski Mar 14 '17 at 09:15
  • Hello, so I ran using asserts but the error that I still get is the Run#0. Have you ever used traci in the RSU module and it worked? Just wondering it should be possible right? – pb772 Mar 15 '17 at 01:46

1 Answers1

1

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.

Christoph Sommer
  • 6,893
  • 1
  • 17
  • 35
  • I ran using valgrind and in the `if(!traci)` I get the following error: `conditional jump or move depends on uninitialised value(s) {PID: 24643].` How can I be sure that TraCI can be used after SUMO has been started? – pb772 Mar 16 '17 at 01:01
  • I will use try to get the traci interface after receiving a message and it should work. Yes it worked, althought I am getting traci interface everytime RSU receives a message it is working, Thanks, I will now find new ways to get traci, only once. – pb772 Mar 16 '17 at 01:08
  • dear @pd772 did you managed to solve this issue?? I want my RSU to be aware of the road length covered by its transmission. I tried your code in stage 0 and 1, and onBSM() but I still get "Cannot create screenshot: TraCI is not connected yet" error from testing (!traci) – Fady Samann Apr 29 '22 at 17:11