Search code examples
pythonsumo

Why lane changing doesn't perform in sumo?


I have a simple three lanes network all of which are in the same direction. According to the following code, a vehicle that is supposed to experience lane changing is entered into an empty network but nothing happens. Could you tell me what the issue is?

def run():
    traci.start(sumoCmd)
    traci.vehicle.add('vehicle_0','route_1','emergency','50')
    traci.vehicle.changeLane('vehicle_0', '2', '10')
    step = 0
    while traci.simulation.step(100):           
        traci.simulationStep()
        print(step)
        step = 1
        step += 1
    traci.close()
    sys.stdout.flush()

Solution

  • The function simulation.step returns the subscription results, which is an empty list in your case (since you don't have any subscriptions). So your while loop terminates immediately.