【问题标题】:SUMO TraCI command not giving desired resultSUMO TraCI 命令未给出预期结果
【发布时间】:2018-03-31 04:13:00
【问题描述】:

我正在尝试获取车辆在行驶过程中遇到的下一个红绿灯。为此,我们使用来自车辆域的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 是车辆域

【问题讨论】:

    标签: python sumo


    【解决方案1】:

    以下脚本在这里工作:

    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)
    

    我使用

    生成了网络
    netgenerate --grid.alphanumerical-ids --grid --default-junction-type traffic_light
    

    并使用了以下路由文件

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

    这将有助于查看您的车辆路线。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-09-15
      • 2016-01-30
      • 2021-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多