SUMO TraCI命令未给出所需结果

2024-04-27 14:59:17 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图得到下一个红绿灯,车辆将遇到在它的旅程。为此,我们使用了来自vehicle domain的getNextTLS。输出不显示路上的所有红绿灯,而是重复显示相同的红绿灯细节。即使我在许多模拟步骤中运行它,它也不能打印出所有的内容(即使在GUI中,它显然通过了这些步骤)

http://www.sumo.dlr.de/daily/pydoc/traci._vehicle.html#VehicleDomain-getNextTLS

while step < 1000:
traci.simulationStep()
#for id in t1.getIDList():
a=t1.getNextTLS(vehID= "202")
print("STEP:",step,"TLS:",a)

step += 1
traci.close(False)

注:t1为车辆域


Tags: http内容domainwwwstep步骤gui细节
1条回答
网友
1楼 · 发布于 2024-04-27 14:59:17

以下脚本在这里起作用:

import sys,os
sys.path.append(os.path.join(os.environ["SUMO_HOME"],"tools"))
import traci

traci.start(["sumo", "-c", "test.sumocfg"])
step = 0
while step < 1000:
    traci.simulationStep()
    a = traci.vehicle.getNextTLS(vehID= "1")
    print("STEP:",step,"TLS:",a)
    step += 1
traci.close(False)

我用

^{pr2}$

并使用以下路由文件

<routes>
    <vehicle id="1" depart="0">
        <route edges="A2toB2 B2toC2 C2toD2 D2toE2"/>
    </vehicle>
</routes>

看看你的车的路线会有帮助。在

相关问题 更多 >