eclipse-sumo/sumo

Problem about GLOSA

Closed this issue · 2 comments

image This is my network, S means the busstops, J means the junctions, D means the distances.

I wrote some code to apply GLOSA on my vehicle. The idea is when the vehicle is at the busstop, it will calculate all the advised speed(Uti) for each of the next distances(Di) before next busstop. After it depart the busstop, it will stop the calculation until it arrive at next busstop. And the vehicle's speed is Uti when it is at Di.

Below is a simplified version of my script:

calculate_speed = False
#simulation start...
tls_data = traci.vehicle.getNextTLS(vehID)
#tuple tls_data and make lists of IDs, distances...etc
#D1 = distance_list[0], Di+1 = distance_list[i+1]-distance[i](for i>=1)
stop_state = traci.vehicle.isAtBusStop(veh)
Ut_list=[]
if stop_state:
    calculate_speed = True
#other calculation...
if calculate_speed:
    #D1 = distance_list[0], Di+1 = distance_list[i+1]-distance[i](for i>=1)
    if D1:
        #calculate the Ut1 for D1....
        Ut_list.append(Ut)
    if Di+1:
        #calculate the Uti+1 for Di+1.... 
        Ut_list.append(Ut)

But I have some problem now:
1.
traci.vehicle.getNextTLS can get the data of all the next junctions. But I want to get the data of junctions between busstops.
eg. When the vehicle is at S1, it get the data of J1, J2, J3.
When the vehicle is at S2, it get the data of J4.
Also I hope the code can still work even if I add more junctions and busstops after J4.

I don't know how to do "After it depart the busstop, it will stop the calculation until it arrive at next busstop. And I want the vehicle's speed is Uti when it is at Di." part.
I have tried something like

if Di+1:
    #calculation
calculate_speed = False
if not calculate_speed:
    traci.vehicle.setSpeed(vehID,Ut)

but I still can't get the result I wanted.

I'm not good at python and my native language is not english, sorry if the above description is too confusing.

You simply have to know which intersections are relevant for your task. Some help in this regard:

  • query the next stops with traci.vehicle.getNextStops (ref)
  • deduce the edge from the lane obtained in the previous step
  • query the vehicle's route using traci.vehicle.getRoute (ref) and similar functions
  • check which junctions are controlled with traffic lights from traci.vehicle.getNextTLS (e.g. using sumolib)
    For the second problem, you have to work a bit on your update condition. You can check whether the vehicle changed from driving to stopped condition (see traci.vehicle.isStopped ref) (or reverse) and only then compute xour GLOSA.

Thanks for the comment!