How to access TraCI command interface from TraCIDemoRSU11p in Veins Car2X simulator?

后端 未结 2 968
梦谈多话
梦谈多话 2021-01-06 04:49

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

2条回答
  •  独厮守ぢ
    2021-01-06 05:29

    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);
    

提交回复
热议问题