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

Scenario runner improvements #112

Merged
merged 4 commits into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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