Omnet++ 如何获得静脉中两个节点(如车辆)之间的距离或行程时间?
在纹理中,我可以使用坐标距离函数计算两个坐标之间的距离。但是,此函数仅计算两点之间的笛卡尔距离。两辆车或一辆车与交叉口之间的实际距离取决于边缘形状,例如曲线边缘。此外,它还取决于边长度相扑参数。它们在相扑或静脉中的作用是否考虑了这些因素 你可以用相扑来计算空中距离和两个任意位置之间的驾驶距离。在以下情况下,此调用在中实现:Omnet++ 如何获得静脉中两个节点(如车辆)之间的距离或行程时间?,omnet++,veins,sumo,Omnet++,Veins,Sumo,在纹理中,我可以使用坐标距离函数计算两个坐标之间的距离。但是,此函数仅计算两点之间的笛卡尔距离。两辆车或一辆车与交叉口之间的实际距离取决于边缘形状,例如曲线边缘。此外,它还取决于边长度相扑参数。它们在相扑或静脉中的作用是否考虑了这些因素 你可以用相扑来计算空中距离和两个任意位置之间的驾驶距离。在以下情况下,此调用在中实现: 我发现了我的错误 为了获得车辆与另一个节点(特别是红绿灯)之间的行驶距离,我必须估算一个靠近红绿灯且位于车辆路线上的有效坐标,与计算车辆与红绿灯交叉点坐标之间的距离相反 为了
我发现了我的错误 为了获得车辆与另一个节点(特别是红绿灯)之间的行驶距离,我必须估算一个靠近红绿灯且位于车辆路线上的有效坐标,与计算车辆与红绿灯交叉点坐标之间的距离相反 为了估计红绿灯的有效坐标,我使用了道路id中车辆将通过红绿灯的任何车道的最后一个坐标。代码如下所示:
// get traffic light controlled lanes
Veins::TraCICommandInterface::Trafficlight traciTL = traci->trafficlight(trafficLightID);
// controlled lanes
std::list<std::string> lanes = traciTL.getControlledLanes();
for(auto lane : lanes){
// which controlled lane in the road_id
if(traci->lane(lane).getRoadId() == road_id){ // found
// return last Coord of this lane
std::list<Coord> laneCoords = traci->lane(lane).getShape();
return getDistance(vehicle_Coord, laneCoords.back(),true);
}
}
此方法适用于空中距离,即returnDrivingDistance=false。但是,如果我将returnDrivingDistance设置为true,它会返回错误的数字,当汽车接近我感兴趣的路口或道路坐标时,这些数字会上下移动。您好,我在返回行驶距离时遇到了相同的问题,它给出了错误的值!你解决问题了吗???
// get traffic light controlled lanes
Veins::TraCICommandInterface::Trafficlight traciTL = traci->trafficlight(trafficLightID);
// controlled lanes
std::list<std::string> lanes = traciTL.getControlledLanes();
for(auto lane : lanes){
// which controlled lane in the road_id
if(traci->lane(lane).getRoadId() == road_id){ // found
// return last Coord of this lane
std::list<Coord> laneCoords = traci->lane(lane).getShape();
return getDistance(vehicle_Coord, laneCoords.back(),true);
}
}