From f8a7f6b14a6d2dac3f9e39efee073a5cbe3e1192 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 5 Jul 2024 19:18:56 +0200 Subject: [PATCH] Faster information retrieval if actor key is present --- srunner/scenariomanager/carla_data_provider.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/srunner/scenariomanager/carla_data_provider.py b/srunner/scenariomanager/carla_data_provider.py index 9e5e23d39..45e557fb9 100644 --- a/srunner/scenariomanager/carla_data_provider.py +++ b/srunner/scenariomanager/carla_data_provider.py @@ -160,6 +160,9 @@ def get_velocity(actor): """ returns the absolute velocity for the given actor """ + if actor in CarlaDataProvider._actor_velocity_map: + return CarlaDataProvider._actor_velocity_map[actor] + # Look for same actor, but stored as different python object for key in CarlaDataProvider._actor_velocity_map: if key.id == actor.id: return CarlaDataProvider._actor_velocity_map[key] @@ -174,6 +177,8 @@ def get_location(actor): """ returns the location for the given actor """ + if actor in CarlaDataProvider._actor_location_map: + return CarlaDataProvider._actor_location_map[actor] for key in CarlaDataProvider._actor_location_map: if key.id == actor.id: return CarlaDataProvider._actor_location_map[key] @@ -189,6 +194,8 @@ def get_transform(actor): """ returns the transform for the given actor """ + if actor in CarlaDataProvider._actor_transform_map: + return CarlaDataProvider._actor_transform_map[actor] or actor.get_transform() for key in CarlaDataProvider._actor_transform_map: if key.id == actor.id: # The velocity location information is the entire behavior tree updated every tick