如何获得特定范围内的汽车数量

问题描述 投票:1回答:1

在静脉中,我正在尝试模拟VANET场景,如果道路被阻挡,那么在特定时间之后,汽车会广播一条消息,其中包括封锁的roadId和100米左右的车辆数量。

在TraCIDemo11p应用程序中,当汽车停止时间超过10秒时,它将节点颜色更改为红色(显示事故)并向包含被阻止的道路ID的其他汽车发送消息,所有这些都在handlePositionUpdate mehtod中完成:

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);
}

可以通过更新.ini文件中的maxInterfDist值来设置100m的限制

*.connectionManager.maxInterfDist = 100m

现在我的问题是如何获得车辆的数量和100米的面积,我有一个想法,这将使用TraCI完成,最有可能使用LaneAreaDetector's getJamLengthVehicle但我不知道如何在静脉中完成,是他们的任何等效的方法或我正在寻找错误的方向?

c++ simulation omnet++ veins sumo
1个回答
4
投票

您可以使用TraCIScenarioManager::getManagedHosts方法获取OMNeT ++模拟中所有车辆的列表。从那里开始,计算任意两台主机之间的距离应该很简单(它们在OMNeT ++画布上的位置相当于它们的位置,以米为单位)。

© www.soinside.com 2019 - 2024. All rights reserved.