【发布时间】:2019-02-22 14:29:34
【问题描述】:
我正在尝试在 omnet++ 中从 sumo 运行行人模拟。为了简单起见(我是初学者),我决定使用带有静脉的 Erlangen 示例并用几个行人扩展它。我在相扑中添加了行人并运行它。它工作得很好: You can see the pedestrians and cars in this picture
接下来我尝试在 omnet++ 中运行整个程序。我也设法做到了,但没有显示行人。只是汽车。我阅读了这两个主题:
- Communication between a car and a pedestrian in Veins
- Veins Multiple Applications in multiples Vehicle types
并将这些行添加到示例的 omnetpp.ini 中:
*.manager.moduleType = "vtype0=org.car2x.veins.nodes.Car ped_pedestrian=org.car2x.veins.nodes.Pedestrian"
*.manager.moduleName = "vtype0=carNode ped_pedestrian=pedestrianNode"
*.manager.moduleDisplayString = "vtype0=carNode ped_pedestrian=pedestrianNode"
我还将 omnetpp.ini 中“node”的每个外观都更改为“carNode”,并为“pedestrianNode”创建了新条目,并复制了 Car.ned 文件并将文件名更改为 Pedestrian.ned 并将模块名称更改为“Pedestrian”。然后我再次运行整个程序,但除了汽车的图像(如模拟所示)变为灰色框外,没有任何变化。
为什么没有显示行人? (我错过了什么?) 我是否必须告诉静脉(或相扑)才能将行人位置传达给 omnet++? 为什么模拟中的汽车图标变成了灰色框?
这是我添加/修改的文件:
编辑:
我研究了TraCI definition并调试了[静脉源代码]。我找到了these lines 的订阅完成的代码:
{
// subscribe to list of departed and arrived vehicles, as well as simulation time
simtime_t beginTime = 0;
simtime_t endTime = SimTime::getMaxTime();
std::string objectId = "";
uint8_t variableNumber = 7;
uint8_t variable1 = VAR_DEPARTED_VEHICLES_IDS;
uint8_t variable2 = VAR_ARRIVED_VEHICLES_IDS;
uint8_t variable3 = commandInterface->getTimeStepCmd();
uint8_t variable4 = VAR_TELEPORT_STARTING_VEHICLES_IDS;
uint8_t variable5 = VAR_TELEPORT_ENDING_VEHICLES_IDS;
uint8_t variable6 = VAR_PARKING_STARTING_VEHICLES_IDS;
uint8_t variable7 = VAR_PARKING_ENDING_VEHICLES_IDS;
TraCIBuffer buf = connection->query(CMD_SUBSCRIBE_SIM_VARIABLE, TraCIBuffer() << beginTime << endTime << objectId << variableNumber << variable1 << variable2 << variable3 << variable4 << variable5 << variable6 << variable7);
processSubcriptionResult(buf);
ASSERT(buf.eof());
}
{
// subscribe to list of vehicle ids
simtime_t beginTime = 0;
simtime_t endTime = SimTime::getMaxTime();
std::string objectId = "";
uint8_t variableNumber = 1;
uint8_t variable1 = ID_LIST;
TraCIBuffer buf = connection->query(CMD_SUBSCRIBE_VEHICLE_VARIABLE, TraCIBuffer() << beginTime << endTime << objectId << variableNumber << variable1);
processSubcriptionResult(buf);
ASSERT(buf.eof());
}
我将其与 sumo wiki 上的 TraCI 文档进行了比较:
* 模拟订阅第一块:https://sumo.dlr.de/wiki/TraCI/Simulation_Value_Retrieval
* 车辆订阅第二段代码:https://sumo.dlr.de/wiki/TraCI/Vehicle_Value_Retrieval
在我看来,行人不包括在内,因为人/行人有不同的 api (https://sumo.dlr.de/wiki/TraCI/Person_Value_Retrieval),它没有在订阅页面 (https://sumo.dlr.de/wiki/TraCI/Object_Variable_Subscription) 上列出。
在完成人员订阅的静脉源代码中我遗漏了什么吗?
是否可以在 TraCI 中订阅人员?
【问题讨论】: