Skip to content

Commit 83a1b44

Browse files
Daraanglopezdiest
andauthored
Faster information retrieval if actor key is present (#1098)
Co-authored-by: glopezdiest <[email protected]>
1 parent e2df7d0 commit 83a1b44

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

srunner/scenariomanager/carla_data_provider.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ def get_velocity(actor):
160160
"""
161161
returns the absolute velocity for the given actor
162162
"""
163+
if actor in CarlaDataProvider._actor_velocity_map:
164+
return CarlaDataProvider._actor_velocity_map[actor]
165+
# Look for same actor, but stored as different python object
163166
for key in CarlaDataProvider._actor_velocity_map:
164167
if key.id == actor.id:
165168
return CarlaDataProvider._actor_velocity_map[key]
@@ -174,6 +177,8 @@ def get_location(actor):
174177
"""
175178
returns the location for the given actor
176179
"""
180+
if actor in CarlaDataProvider._actor_location_map:
181+
return CarlaDataProvider._actor_location_map[actor]
177182
for key in CarlaDataProvider._actor_location_map:
178183
if key.id == actor.id:
179184
return CarlaDataProvider._actor_location_map[key]
@@ -189,6 +194,8 @@ def get_transform(actor):
189194
"""
190195
returns the transform for the given actor
191196
"""
197+
if actor in CarlaDataProvider._actor_transform_map:
198+
return CarlaDataProvider._actor_transform_map[actor] or actor.get_transform()
192199
for key in CarlaDataProvider._actor_transform_map:
193200
if key.id == actor.id:
194201
# The velocity location information is the entire behavior tree updated every tick

0 commit comments

Comments
 (0)