【发布时间】:2021-03-15 03:01:30
【问题描述】:
我想编写一个通过 TraCI 重新初始化相扑模拟的方法。为此,我需要从模拟中移除所有车辆,然后再次添加其中一些车辆。
I do this by calling
import traci
conn = traci.connect(port)
conn.vehicle.remove("55")
conn.vehicle.add("55", route_id)
# This throws an exception
引发的异常是:
traci.exceptions.TraCIException: The vehicle '55' to add already exists.
如果我在 remove 和 add 方法之间调用 conn.simulationStep(),则不会引发此异常。这在技术上是可行的,但我不希望在移除和添加车辆之间增加模拟。
当我删除车辆55 后输出traci.vehicles.getIDList() 时,我可以看到它已成功删除。那么,add 方法为什么会失败并告诉我这辆车确实存在?
【问题讨论】: