在静脉中,我可以用Coord.distance()函数计算出两个坐标之间的距离。然而,这个函数只是计算两点之间的笛卡尔距离。两辆车或一辆车与一个交叉口之间的实际距离取决于边缘形状(例如曲线边缘)。此外,它取决于边缘长度(SUMO参数)。它们在相扑或静脉中的作用是否考虑到了这些因素?
发布于 2018-07-10 19:11:37
我发现了我的错误!
为了获得车辆与另一个节点(特别是交通灯)之间的行驶距离,我必须估计一个有效的coord,它靠近交通灯,位于车辆路线上,与计算车辆与交通灯交界处的距离相反。
为了估计交通灯的有效交通信号灯,我使用了车辆将通过红绿灯的道路标识中任何车道的最后一个坐标。代码将如下所示:
// 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);
}
}发布于 2018-06-15 12:59:28
您可以使用相扑的距离请求TraCI呼叫,它可以计算空气距离以及两个任意位置之间的驾驶距离。在静脉中,此调用在TraCICommandInterface::getDistance()中实现。
double getDistance(const Coord& position1, const Coord& position2, bool returnDrivingDistance);https://stackoverflow.com/questions/50864775
复制相似问题