如何在Veins Car2X模拟器中从TraCIDemoRSU11p访问TraCI命令界面? [英] How to access TraCI command interface from TraCIDemoRSU11p in Veins Car2X simulator?

查看:253
本文介绍了如何在Veins Car2X模拟器中从TraCIDemoRSU11p访问TraCI命令界面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从Veins Source for OMNet ++的RSU模型的应用程序层访问TraCI的命令界面.但是我找不到.有人可以帮我吗?

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?

请注意,在RSU节点的情况下,我没有TraciMobility作为父模块.它只有BaseMobility,而这正是我想要的.现在,我想访问命令界面,以便该RSU可以执行相扑指令,例如更改交通信号灯并获取感应回路数据.

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.

推荐答案

Vesins 4.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);

这篇关于如何在Veins Car2X模拟器中从TraCIDemoRSU11p访问TraCI命令界面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆