Closed TerzaSlayer2000 closed 2 weeks ago
By default, netconvert detects roundabouts based on road geometry and topology and then assigns right-of-way to the edges inside the roundabout, regardless of the priority attribute of the edges. If you want to give some preference to one of the incoming edges, consider a roundabout with traffic lights or increase the number of lanes.
Thank you for your response. Can we use induction loop detectors just before the roundabout edges and gives priority to those detectors instead and implement the priority logic using TraCI in a python script. Below is the code :
import traci import sumolib
sumoBinary = sumolib.checkBinary('sumo-gui') traci.start([sumoBinary, "-c", "sample.sumocfg"])
def control_roundabout_with_priority():
high_priority_detectors = ["e1_1", "e1_5"] # Lanes 835504481_1 and 835504479_1
low_priority_detectors = ["e1_2", "e1_6"] # Lanes -123554671#0_1 and 835504475#2_1
# Initialize a list to keep track of which detector has a vehicle stopped
vehicle_waiting = {det: None for det in high_priority_detectors + low_priority_detectors}
# Define the maximum time step (in this case, 10,000)
max_timesteps = 10000
while traci.simulation.getMinExpectedNumber() > 0:
current_step = traci.simulation.getTime() # Get the current simulation time step
if current_step >= max_timesteps:
break # Exit the loop if the max timestep is reached
traci.simulationStep()
# Process high-priority vehicles first
for detector in high_priority_detectors:
vehicles = traci.inductionloop.getLastStepVehicleIDs(detector)
if vehicles:
vehicle_id = vehicles[0]
if vehicle_waiting[detector] is None:
# Stop the vehicle at the detector
traci.vehicle.slowDown(vehicle_id, 0, 1) # Set speed to 0 over 1 second
vehicle_waiting[detector] = vehicle_id
else:
if vehicle_waiting[detector] is not None:
# Check if the vehicle is still in the simulation by checking if it's in the list of active vehicles
active_vehicles = traci.vehicle.getIDList()
if vehicle_waiting[detector] in active_vehicles:
# Allow the waiting vehicle to proceed
max_speed = traci.vehicle.getMaxSpeed(vehicle_waiting[detector])
traci.vehicle.slowDown(vehicle_waiting[detector], max_speed, 1) # Reset speed to max_speed
vehicle_waiting[detector] = None
# Process low-priority vehicles if no high-priority vehicles are waiting
high_priority_busy = any(vehicle_waiting[det] is not None for det in high_priority_detectors)
if not high_priority_busy:
for detector in low_priority_detectors:
vehicles = traci.inductionloop.getLastStepVehicleIDs(detector)
if vehicles:
vehicle_id = vehicles[0]
if vehicle_waiting[detector] is None:
# Stop the vehicle at the detector
traci.vehicle.slowDown(vehicle_id, 0, 1) # Set speed to 0 over 1 second
vehicle_waiting[detector] = vehicle_id
else:
if vehicle_waiting[detector] is not None:
# Check if the vehicle is still in the simulation by checking if it's in the list of active vehicles
active_vehicles = traci.vehicle.getIDList()
if vehicle_waiting[detector] in active_vehicles:
# Allow the waiting vehicle to proceed
max_speed = traci.vehicle.getMaxSpeed(vehicle_waiting[detector])
traci.vehicle.slowDown(vehicle_waiting[detector], max_speed, 1) # Reset speed to max_speed
vehicle_waiting[detector] = None
traci.close()
if name == "main": control_roundabout_with_priority()
Hello Sumo Community, in my four way roundabout intersection if i set the junction type as priority, will it prioritize road edges connected to the roundabout which have higher priority values? Actually my road edges are having the same priority values which is 10 for now, suppose if i set one of the edges with a higher priority value like 11, will SUMO allow that road edge to cross the roundabout intersection more frequently than the other edges which have low priority value? Thank you.
SUMO-version: 1.18.0
operating system: Windows 11