From 7b935b7b72eaf5b919d72c71385700e8f6298406 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 26 Jun 2024 17:10:04 +0200 Subject: [PATCH] Dead actor cleaning in CDP._actor_*_maps --- srunner/scenariomanager/carla_data_provider.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/srunner/scenariomanager/carla_data_provider.py b/srunner/scenariomanager/carla_data_provider.py index 58ba533cd..9e9993c20 100644 --- a/srunner/scenariomanager/carla_data_provider.py +++ b/srunner/scenariomanager/carla_data_provider.py @@ -137,18 +137,24 @@ def on_carla_tick(): Callback from CARLA """ with CarlaDataProvider._lock: - for actor in CarlaDataProvider._actor_velocity_map: + for actor in CarlaDataProvider._actor_velocity_map.copy(): if actor is not None and actor.is_alive: CarlaDataProvider._actor_velocity_map[actor] = calculate_velocity(actor) + else: + del CarlaDataProvider._actor_velocity_map[actor] - for actor in CarlaDataProvider._actor_location_map: + for actor in CarlaDataProvider._actor_location_map.copy(): if actor is not None and actor.is_alive: CarlaDataProvider._actor_location_map[actor] = actor.get_location() + else: + del CarlaDataProvider._actor_location_map[actor] - for actor in CarlaDataProvider._actor_transform_map: + for actor in CarlaDataProvider._actor_transform_map.copy(): if actor is not None and actor.is_alive: CarlaDataProvider._actor_transform_map[actor] = actor.get_transform() - + else: + del CarlaDataProvider._actor_transform_map[actor] + world = CarlaDataProvider._world if world is None: print("WARNING: CarlaDataProvider couldn't find the world")