Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replicate SUMO light sequence in CARLA Editor #7807

Open
DanielSioldea opened this issue Jun 18, 2024 · 6 comments
Open

Replicate SUMO light sequence in CARLA Editor #7807

DanielSioldea opened this issue Jun 18, 2024 · 6 comments

Comments

@DanielSioldea
Copy link

I am trying to find a way to link the traffic lights between SUMO and CARLA, so that the CARLA lights follow the sequence and colours in the SUMO simulation. I created a map in Roadrunner and imported it into CARLA, and I am able to run co-simulations just fine, with the vehicles following the light logic from SUMO using the --tls-manager argument. However I am just not sure how to replicate the lights in the actual CARLA editor environment so that when there is a red light in SUMO, the corresponding light in CARLA is also red, and so on and so forth. Any advice would be appreciated as I do not have any prior knowledge of Unreal Engine or CARLA. I have added some pictures of my setup so far, but if more are needed for clarity please let me know.

CARLA Unreal setup: Manually placed traffic lights, grouped together in a junction (BP_TrafficLightGroup)
Screenshot 2024-06-18 154928

SUMO Setup: .net.xml file was generated using the netconvert script provided by CARLA. TLS logic was edited manually to suit my needs. .rou.xml files were created manually through Netedit's demand planner.
Screenshot 2024-06-18 155402

@GoodarzMehr
Copy link

You can use the carla.TrafficLight class' methods (set_state in particular) to synchronize the visual appearance of each traffic light with its state in SUMO.

@DanielSioldea
Copy link
Author

You can use the carla.TrafficLight class' methods (set_state in particular) to synchronize the visual appearance of each traffic light with its state in SUMO.

I'm sorry for the question, I am still learning where everything is with CARLA, but would I just include this as an argument when calling "run_syncronization.py", or is there another way to go about doing this?

@GoodarzMehr
Copy link

I think you have to implement this yourself, i.e. write some code that gets the state of each traffic light from SUMO and then sets the state of the corresponding traffic light in CARLA. There may be a simpler way of doing this (e.g. by passing an argument) but I'm not aware if it.

@Blyron
Copy link
Contributor

Blyron commented Jun 19, 2024

You will need to implement youself as @GoodarzMehr suggested. If you are fine with this answer, please feel free to close the issue

@DanielSioldea
Copy link
Author

You will need to implement youself as @GoodarzMehr suggested. If you are fine with this answer, please feel free to close the issue

I am able to get SUMO states through the TraCI API. I have an idea of how to link the SUMO states to the CARLA states using the code snippet from the carla.TrafficLight.set_state. However I am still a bit lost on how to link that to the lights placed in Unreal Engine. Any further information, examples, or references would be much appreciated. Thank you again.

@GoodarzMehr
Copy link

The carla.World object has several methods for getting traffic lights during a simulation, and if I understand your problem correctly the get_traffic_lights_in_junction() method in particular (and maybe get_traffic_light_from_opendrive_id()) can be useful in your case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants