0

I am trying to get next traffic light that a vehicle will encounter during it's journey. For this we used getNextTLS from vehicle domain. The output does not show all the traffic lights on the way rather shows the same traffic light details repeatedly. Even when I run it for many simulation steps it doesn't print all (even though in GUI it clearly passes through them)

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)

Note: t1 is vehicledomain

Aditi
  • 820
  • 11
  • 27

1 Answers1

0

The following script works here:

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)

I generated the network using

netgenerate --grid.alphanumerical-ids --grid --default-junction-type traffic_light

and used the following route file

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

It would help to see the route of your vehicle.

Michael
  • 3,510
  • 1
  • 11
  • 23