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

时光怂恿深爱的人放手 提交于 2019-11-30 17:51:14

问题


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:


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



回答2:


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.



来源:https://stackoverflow.com/questions/35790944/how-to-access-traci-command-interface-from-tracidemorsu11p-in-veins-car2x-simula

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!