How can I determine the ID for traffic lights?

Hi. I am trying to create traffic lights from Town01 within a Sumo co-simulation. To do this I need to get the IDs for each traffic light within Town01. What is the best way to do this? Where are the IDs for traffic lights stored, and how do they map to objects within the map?

Many thanks for any advice.

I think the IDs for traffic light actors can be found using the Unreal Editor. Can I import or open Carla maps directly in the UE Editor?

Hi! What is your final purpose? The netconvert_carla script (https://github.com/carla-simulator/carla/blob/master/Co-Simulation/Sumo/util/netconvert_carla.py) is already taking into account traffic lights and inserting them manually in the SUMO net.

In the resulting SUMO net, the tlLogic tag, has an additional parameter to link a SUMO signal to a specific landmark id:

<tlLogic id=".." type="static" programId="0" offset="0">
  <phase state="..." duration="..."/>
  ...
  <param key:"linkSignalID:0" value="100"/>
  ...
</tlLogic>

This information is then used to synchronise the state of the traffic lights between SUMO and CARLA during the co-simulation.

Thanks for the response. Yes I am trying to add traffic lights into the SUMO net file myself… I didn’t know the netconvert_carla script would do this for me. I had already determined by putting debug into the run_synchronizationpy script that I needed to put a param node in the xml file, and had tested it on a single traffic light. But figuring out the ID of the traffic light (the value of “100” in your example above) was painful. I essentially put a camera in front of one traffic light and tried different values from the possible list of traffic light IDs until I observed it was in synch.

While I test that script you mentioned, do you know how/where the traffic light ID is mapped to the actual Actor in the UE4 editor? I’ve been trying to compile UE4 and Carla myself on Windows so I can open the project in UE4 and see if the ID is stored in the level itself. I may not need it if the script works, but I’d sure like to understand this.

Hi! You can directly use the CARLA PythonAPI to map OpenDrive landmarks with traffic light actors in CARLA.

You can retrieve all the landmarks of type traffic light in the following way:

landmarks = carla_map.get_all_landmarks_of_type('1000001'):

Then, for each landmark, you can get the associated traffic light actor in CARLA:

traffic_light = carla_world.get_traffic_light(landmark)

Normally, traffic lights are defined inside intersections. That means that you will obtain multiple landmarks that refers to the same traffic light (one for each one of the possible directions in the intersection). The method carla_world.get_traffic_light(landmark) will return the same traffic light actor for all these landmarks.

Thanks for this explanation Joel. I’m still not sure what it is about the Xodr file that allows you to map these two different identifiers (sumo vs Carla) for the same object in their respective simulations. But the beauty of open source is… I can go and look for myself! :slight_smile: