Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [sumo-user] How to get the desired phase from each lane or vehicle_id

Hi Lourens,


the answer is somewhat hidden in the function description. The signal index is the information you still need to process. In the sorted list of links, the signal index starts at 0 for the first element and then gets incremented for all the following. After that, you can choose the relevant signal index of your lane and scan all the phases for whether they show green for the given index (e.g. using the complete TL program info from traci.trafficlight.getCompleteRedYellowGreenDefinition).


Regards
Mirko


Am 15.02.2019 um 16:16 schrieb Lourens Pool:
Hi, 

I hope that I oversaw something. Making this an easy question :)

Question
Is it possible to easily determine the desired_phase_index for any given lane_id or maybe a vehicle_id ?
Ideally I would like to call get_phase(lane_id) and get all phase indexes that have a green light for this lane_id. 
traci.trafficlight.setPhase(desired_phase_index) would then give the green light for that lane_id.
Does SUMO have a built-in function for this ? Or is it easy to retrieve this ? 

I have tried the following function: traci.trafficlight.getControlledLinks(tl_id). Which claims to "return the links controlled by the traffic light, sorted by the signal index". But sofar I could not map this to a desired phase for each lane_id. 

Explanation 
I have attached a screenshot of my network below:
traffic light :  gneJ0  controls lanes:  {'west_in_0', 'west_in_1', 'east_in_1', 'east_in_0', 'south_in_0', 'north_in_0'}

My traffic light has three phases.
I would like to map:
{west_in_0, 'east_in_0'}:    --> Phase 0:  horizontal traffic
{'west_in_1', 'east_in_1'}    --> Phase 2:  horizontal traffic with left turn
{'south_in_0', 'north_in_0'} --> Phase 4:  vertical traffic

Please run python3 runner.py in the attached directory. 

Thanks for your time. 

Best regards, 

Lourens






_______________________________________________
sumo-user mailing list
sumo-user@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/sumo-user

Back to the top