Veins 中的车辆状态传输

Transmission of vehicular status in Veins

我想将给定汽车的车辆数据(例如 vType、瞬时 speedposition 传输到 Veins 场景中的 RSU。

如何从 SUMO 获取数据并通过 MiXiM 方法将其发送到 RSU 节点?

要实现您的目标,您必须使用 VeinsTraCIMobility 组件。

您可以通过首先在节点的 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.ccTraCIDemoRSU.cc 中找到您需要的东西。

另外,TraCICommandInterface 是你应该看看的东西。


在 Veins 官方网站的 Documentation 部分中说:

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.

这里有一个可能相关的 question/answer: