Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[sumo-user] TraCi priority vehicle traffic light changing

Hello all,
I am aiming to create a simulation that is a variation of the following tutorial:  https://sumo.dlr.de/docs/Tutorials/TraCI4Traffic_Lights.html
I want to recreate something very similar to the simulation described in the following paper:

My aim is to modify this tutorial so that ambulances (priority vehicles) and cars may come from both east-west directions AND north-south direction.  In this tutorial, cars only come from east-west, and ambulances only come from north-south.

I have already been able to implement both cars and ambulances arriving from both directions, but now I am having trouble figuring out how to have the lights change in a way that accounts for the priority of the ambulances.  

This is the TraCi control loop that is in the tutorial:
def run():
"""execute the TraCI control loop"""
step = 0
# we start with phase 2 where EW has green
traci.trafficlight.setPhase("0", 2)
while traci.simulation.getMinExpectedNumber() > 0:
traci.simulationStep()
if traci.trafficlight.getPhase("0") == 2:
# we are not already switching
if traci.inductionloop.getLastStepVehicleNumber("0") > 0:
# there is a vehicle from the north, switch
traci.trafficlight.setPhase("0", 3)
else:
# otherwise try to keep green for EW
traci.trafficlight.setPhase("0", 2)
step += 1
traci.close()
sys.stdout.flush()

What I want to have happen is for the traffic lights to treat ambulances with priority, whether they come either from the north south direction, or the east west direction.  I notice that the current ambulance detection is based on an induction loop, so this would have trouble distinguishing between cars and ambulances if they are on the same road segment. This makes me think I need to find a different approach to the traffic light control loop.

I know that this is possible since it is done in the aforementioned "A Smart Traffic Solution for High Priority Vehicles" paper.  I was wondering if someone would be able to point me in the right direction of how to tackle this!

Thank you,
Billy

Back to the top