sumo - 如何使用 TraCi 获取边缘的 id?
问题描述
我正在使用带有 traci 库的 python 代码来了解是否有任何车辆靠近所选车辆一定距离,以测试我正在尝试实施的解决方案我需要知道车辆的当前边缘。
我在 Ubuntu 18.04.3 LTS 上,使用 sublime 编辑代码和 os、sys、optparse、subprocess、random、math 库。我试过使用getLaneId
and getEdgeId
,最后一个不在文档中,但我很难在某处看到它并尝试对其进行测试。. 我曾经使用的另一个选项,getNeighbors
但我不知道如何使用它,它返回与以前的命令相同的错误消息。
def run():
step = 0
while traci.simulation.getMinExpectedNumber() > 0:
traci.simulationStep()
print(step)
print(distancia("veh1","veh0"))
step += 1
if step > 2:
print(traci.vehicle.getLaneId("veh0"))
traci.close()
sys.stdout.flush()
他们都返回以下错误消息:AttributeError: VehicleDomain instance has no attribute 'getLaneId'
。但我认为车辆域确实具有该getLaneId
属性,因为它在文档中:https ://sumo.dlr.de/pydoc/traci._vehicle.html#VehicleDomain-getSpeed 。我期待它返回边缘的ID。请我需要帮助来解决这个问题。先感谢您。
解决方案
edgeID 的 TraCI 命令可以在_vehicle.VehicleDomain
模块中找到。语法如下:
traci._vehicle.VehicleDomain.getRoadID(self, vehicleID)
推荐阅读
- flutter - Flutter 中的神经拟态设计
- reactjs - 无法从@mui 缩小代码,而 npm run build
- python - 有没有办法改变 Celery + RabbitMQ 的队列消费顺序?
- swiftui - 从多个图层制作收藏按钮并使用 EnvironmentObject 绑定两个列表
- angular - 子文件夹路由问题中的 Angular 应用程序
- python - 如果我在 django 中有 JSON,如何进行 post call
- node.js - Jest 测试在同时运行所有测试时随机失败
- javascript - 如何将此 item.id 值传递给 axios.get('http://localhost:5000/api/kam/:Id')
- sql - 如何从oracle sql中的内部查询输出中删除单引号
- amazon-web-services - 当我从 EC2 实例调用 s3 存储桶时,调用将通过公共互联网进行还是通过 AWS 内的私有调用进行?