在VANET中,我试图模拟一个场景,在这个场景中,如果道路被封锁,那么在特定的时间后,汽车会广播一条消息,其中包括被封锁的roadId和周围100米的车辆数量。
在TraCIDemo11p应用程序中,当汽车停下来超过10秒时,它会将节点颜色更改为红色(以显示事故),并向其他汽车发送一条包含阻塞道路id的消息,所有这些都是在handlePositionUpdate方法中完成的:
findHost()->getDisplayString().updateWith("r=16,red");
sentMessage = true;
WaveShortMessage* wsm = new WaveShortMessage();
populateWSM(wsm);
wsm->setWsmData(mobility->getRoadId().c_str());
//host is standing still due to crash
if (dataOnSch) {
startService(Channels::SCH2, 42, "Traffic Information Service");
//started service and server advertising, schedule message to self to send later
scheduleAt(computeAsynchronousSendingTime(1,type_SCH),wsm);
}
else {
//send right away on CCH, because channel switching is disabled
sendDown(wsm);
}
100m的限制可以通过更新.ini文件中的maxInterfDist值来设置
*.connectionManager.maxInterfDist = 100m
现在我的问题是如何获得车辆的数量和100米的面积,我有一个想法,这将使用TraCI和最有可能使用LaneAreaDetector's getJamLengthVehicle,但我不知道这将如何在静脉中完成,他们是否有任何等效的方法或我在寻找错误的方向?
发布于 2018-02-28 22:47:42
您可以使用TraCIScenarioManager::getManagedHosts方法获取OMNeT++模拟中所有车辆的列表。从那里,计算任意两个主机之间的距离应该很简单(它们在OMNeT++画布上的位置等于它们的位置,以米为单位测量)。
https://stackoverflow.com/questions/49021921
复制相似问题