Skip to content

Commit

Permalink
Merge pull request #112 from HARPLab/auto-nav-sign
Browse files Browse the repository at this point in the history
Scenario runner improvements
  • Loading branch information
ajdroid committed May 25, 2023
2 parents 95d1b26 + fd593dc commit 76da276
Show file tree
Hide file tree
Showing 7 changed files with 1,381 additions and 60 deletions.
16 changes: 12 additions & 4 deletions ScenarioRunner/carla_data_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,13 @@ def get_map(world=None):

return CarlaDataProvider._map

@staticmethod
def get_random_seed():
"""
@return true if syncronuous mode is used
"""
return CarlaDataProvider._rng

@staticmethod
def is_sync_mode():
"""
Expand All @@ -235,7 +242,8 @@ def find_weather_presets():
Get weather presets from CARLA
"""
rgx = re.compile('.+?(?:(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])|$)')
name = lambda x: ' '.join(m.group(0) for m in rgx.finditer(x))
def name(x:str) -> str:
return ' '.join(m.group(0) for m in rgx.finditer(x))
presets = [x for x in dir(carla.WeatherParameters) if re.match('[A-Z].+', x)]
return [(getattr(carla.WeatherParameters, x), name(x)) for x in presets]

Expand All @@ -251,7 +259,7 @@ def prepare_map():
# Parse all traffic lights
CarlaDataProvider._traffic_light_map.clear()
for traffic_light in CarlaDataProvider._world.get_actors().filter('*traffic_light*'):
if traffic_light not in CarlaDataProvider._traffic_light_map.keys():
if traffic_light not in list(CarlaDataProvider._traffic_light_map):
CarlaDataProvider._traffic_light_map[traffic_light] = traffic_light.get_transform()
else:
raise KeyError(
Expand Down Expand Up @@ -691,7 +699,7 @@ def request_new_batch_actors(model, amount, spawn_points, autopilot=False,
print("The amount of spawn points is lower than the amount of vehicles spawned")
break

if spawn_point and "dreyevr" not in blueprint.id:
if spawn_point:
batch.append(SpawnActor(blueprint, spawn_point).then(
SetAutopilot(FutureActor, autopilot,
CarlaDataProvider._traffic_manager_port)))
Expand Down Expand Up @@ -797,7 +805,7 @@ def cleanup():
for actor_id in CarlaDataProvider._carla_actor_pool.copy():
actor = CarlaDataProvider._carla_actor_pool[actor_id]
# don't delete the DReyeVR ego vehicle bc it becomes awkward to continue playing
if actor is not None and actor.is_alive and actor.type_id != CarlaDataProvider.ego_DReyeVR:
if actor is not None and actor.is_alive and "dreyevr" not in actor.type_id:
batch.append(DestroyActor(actor))

if CarlaDataProvider._client:
Expand Down
Loading

0 comments on commit 76da276

Please sign in to comment.