5

I want to access the command interface of TraCI from the application layer of RSU model in Veins Source for OMNet++. But I am unable to find so. Can anyone please help me do so?

Please note that I am not having TraciMobility as parent module in case of RSU Node. It is having only the BaseMobility which is what I want it to have. Now I want to access the command interface so that this RSU can perform the sumo instructions like change traffic light and get induction loop data.

  • 1
    It would be good to add some information about the versions of veins and omnet you're using, IIRC there were some changes to the TraCI code recently, with the release of the new veins version. – Rens van der Heijden Mar 04 '16 at 18:26

2 Answers2

3

Veins 4.3 provides a TraCIScenarioManagerAccess helper class, which can be used to quickly get access to the class handling TraCI (and, via this, to the class wrapping the command interface) in the code.

For an example of how to use this interface, see the following code in TraCIScreenRecorder:

#include "veins/modules/mobility/traci/TraCIScenarioManager.h"
#include "veins/modules/mobility/traci/TraCICommandInterface.h"
[...]
TraCIScenarioManager* manager = TraCIScenarioManagerAccess().get();
ASSERT(manager);
TraCICommandInterface* traci = manager->getCommandInterface();
if (!traci) {
    error("Cannot create screenshot: TraCI is not connected yet");
}
TraCICommandInterface::GuiView view = traci->guiView(par("viewName"));
view.takeScreenshot(filename);
Christoph Sommer
  • 6,893
  • 1
  • 17
  • 35
  • I tried your code in different locations but I always get "TraCI is not connected yet". I don't think that it would work becasue in line 34 of the DemoBaseApplLayer.cc the existance of TraCIMobility is checked and if it does not then variables (traci, mobility and traciVehicle) will get a null pointer. So, unless it is a vehicle with viens mobility module then it does not have access to SUMO interface. However, I found this page (https://sumo.dlr.de/docs/Simulation/Bluetooth.html) which recommand having a parked vehicle for V2I communication. Could you please explain what do they mean ? – Fady Samann May 01 '22 at 07:39
1

in veins 4.4, i try to access TraCI command interface from TraCIDemoRSU11p. And finally I was able to access, i'm insert the following code in TraCIDemoRSU11p.h:

#include "veins/modules/mobility/traci/TraCICommandInterface.h"
[...]
using Veins::TraCICommandInterface;
[...]   
protected:
        TraCICommandInterface* traci;

then, you can access to TraCICommandInterface. Good Luck.

rakhsha
  • 99
  • 7
  • 1
    Although access is available, some functions are not executed.for example: getJunctionIds.Because some functions depend on vehicle mobility. Good Luck. – rakhsha Jan 08 '19 at 11:35