静脉中车辆状态的传递 [英] Transmission of vehicular status in Veins
问题描述
我想将给定汽车的车辆数据(例如vType
,瞬时speed
和position
)传输到静脉网中的RSU.
如何从SUMO获取数据并通过MiXiM方法将其发送到RSU节点?
要实现您的目标,您必须使用Veins
的TraCIMobility
组件.
您可以通过在节点的initialize()
方法中首先获取指向该组件的指针来做到这一点
cModule *tmpMobility = getParentModule()->getSubmodule("veinsmobility");
mobility = dynamic_cast<Veins::TraCIMobility*>(tmpMobility);
ASSERT(mobility);
一旦有了mobility
组件,就可以查询各种数据.
它可以提供的数据类型可以在TraCIMobility.h
例如,您可以这样做:
mobility->getCurrentSpeed().length()); /* will provide velocity vector */
mobility->getAngleRad()); /* will provide angle of movement */
然后,您可以将此数据附加到消息中,并将其发送到您选择的RSU.
如果这种精确的解决方案对您不起作用,可能是由于我使用了不同于您的Veins版本.
但是,您一定会在Veins项目的TraCIDemo11p.cc
或TraCIDemoRSU.cc
中找到所需的内容.
此外,TraCICommandInterface
是您应该看看的东西.
在Veins官方网站的文档部分下:
应用程序模块可以使用 TraCICommandInterface 类, 相关类,可从 TraCIMobility 方便地访问 与正在运行的模拟进行交互.以下示例显示了 使车辆意识到名为第二"的道路上的慢行交通 街道,可能会导致其更改路线以避开这条路.
mobility = TraCIMobilityAccess().get(getParentModule()); traci = mobility->getCommandInterface(); traciVehicle = mobility->getVehicleCommandInterface(); traciVehicle->changeRoute("Second Street", 3600);
其他一些与车辆有关的命令是 setSpeed 或 setParking . 整个模拟都可以使用类似的方法(例如, addVehicle , addPolygon ),道路( getMeanSpeed ),独立车道 ( getShape ),交通信号灯( setProgram ),多边形( setShape ),点 兴趣点,路口,路线,车辆类型或图形用户 界面.
如何使用这些模块已在 静脉教程示例.同样,所有80多种可用方法的列表可以 可以在 TraCICommandInterface.h 或自动生成的模块中找到 文档.
此处可能存在相关问题/答案: https://stackoverflow.com/a/29918148/4786271 >
I want to transmit a given car's vehicular data such as it's vType
, instantaneous speed
and position
to a RSU in a scenario in Veins.
How can I obtain the data from SUMO and send it through MiXiM methods to an RSU node?
To achieve your goal you have to use the TraCIMobility
component of Veins
.
You can do that by first getting a pointer to that component in the initialize()
method of your node
cModule *tmpMobility = getParentModule()->getSubmodule("veinsmobility");
mobility = dynamic_cast<Veins::TraCIMobility*>(tmpMobility);
ASSERT(mobility);
Once you have the mobility
component you can query it for various data.
The type of data that it can provide can be found in TraCIMobility.h
For example in your case you could do:
mobility->getCurrentSpeed().length()); /* will provide velocity vector */
mobility->getAngleRad()); /* will provide angle of movement */
Then you can attach this data to your message and send it to the RSU of your choice.
If this exact solution does not work for you that could be due to me using a different Veins version than yours.
However you will certainly find what you need in TraCIDemo11p.cc
or TraCIDemoRSU.cc
of your Veins project.
Also, TraCICommandInterface
is something you should have a look at.
In the official Veins website under the Documentation section it is said:
Application modules can use the TraCICommandInterface class and related classes, conveniently accessible from TraCIMobility, to interact with the running simulation. The following example shows how to make a vehicle aware of slow traffic on a road called Second Street, potentially causing it to change its route to avoid this road.
mobility = TraCIMobilityAccess().get(getParentModule()); traci = mobility->getCommandInterface(); traciVehicle = mobility->getVehicleCommandInterface(); traciVehicle->changeRoute("Second Street", 3600);
Some of the other vehicle related commands are setSpeed or setParking. Similar methods are available for the whole simulation (e.g., addVehicle, addPolygon), roads (getMeanSpeed), individual lanes (getShape), traffic lights (setProgram), polygons (setShape), points of interest, junctions, routes, vehicle types, or the graphical user interface.
How to use these modules is demonstrated in the source code of the Veins tutorial example. Again, a list of all 80+ available methods can be found in TraCICommandInterface.h or the autogenerated module documentation.
A potentially related question/answer here: https://stackoverflow.com/a/29918148/4786271
这篇关于静脉中车辆状态的传递的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!