File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -161,11 +161,23 @@ def run_scenario(
161161 # update the world
162162 CarlaDataProvider .set_world (self .carla_world )
163163
164- logger .info ("Spawning ego..." )
165- ego = EgoVehicle (env_config )
166- actor = ego .spawn ()
167- self .ego_vehicles .append (actor )
168- logger .info (f"Spawned ego with id: { actor .id } " )
164+ # attempt to spawn the ego 3 times for redundancy
165+ max_attempts = 3
166+ for attempt in range (max_attempts ):
167+ try :
168+ logger .info ("Spawning ego..." )
169+ ego = EgoVehicle (env_config )
170+ actor = ego .spawn ()
171+ self .ego_vehicles .append (actor )
172+ logger .info (f"Spawned ego with id: { actor .id } " )
173+ except Exception as e :
174+ logger .error (f"Failed to spawn ego on attempt { attempt + 1 } : { e } " )
175+ if attempt == max_attempts - 1 :
176+ logger .error (
177+ "Failed to spawn ego: Terminating scenario. This is most likely an issue with CARLA"
178+ )
179+ raise
180+ time .sleep (2 )
169181
170182 # client must tick to spawn actors
171183 self ._tick_carla ()
Original file line number Diff line number Diff line change @@ -147,6 +147,9 @@ def is_scenario_at_route(trigger_transform, route):
147147 """
148148 Check if the scenario is affecting the route.
149149 This is true if the trigger position is very close to any route point
150+
151+ TODO:
152+ - Add logging to inform if a scenario is not part of the route (debug)
150153 """
151154
152155 def is_trigger_close (trigger_transform , route_transform ):
You can’t perform that action at this time.
0 commit comments