Open DanielSioldea opened 5 months ago
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.
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?
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.
You will need to implement youself as @GoodarzMehr suggested. If you are fine with this answer, please feel free to close the issue
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.
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.
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)
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.