carla
carla copied to clipboard
actor.bounding_box.extent has the wrong size
Carla version: 0.9.14 and 0.9.15 OS: Ubuntu 20.04 and 22.04
The bounding box size is not right, if we use the Python API to get the bounding_box of the objects.
We are getting the bounding box with the following script
...
actors = world.get_actors()
object_list = []
for actor in actors:
if actor.type_id.startswith("sensor."):
continue
if actor.type_id in ["spectator", "static.trigger.friction"]:
continue
vel_carla = actor.get_velocity()
vel_temp = [vel_carla.x, vel_carla.y, vel_carla.z]
actor_transform = actor.get_transform()
actor_dict = dict(
translation={"x": actor_transform.location.x,
"y": -actor_transform.location.y, # transformation to right handed coordinate system
"z": actor_transform.location.z},
size={"x": actor.bounding_box.extent.x,
"y": actor.bounding_box.extent.y,
"z": actor.bounding_box.extent.z},
rotation={"roll": actor_transform.rotation.roll,
"pitch": actor_transform.rotation.pitch,
"yaw": actor_transform.rotation.yaw},
# transformation to right handed coordinate system
object_id=20 if len(actor.semantic_tags) < 1 else actor.semantic_tags[0], # could be more semantic tags
velocity={
"x": vel_temp[0],
"y": vel_temp[1],
"z": vel_temp[2]},
object_name=actor.type_id
)
object_list.append(actor_dict)
I got a bit deeper into this topic.
At first, the documentation told me that actor.bounding_box.extent.x
should be actor.bounding_box.extent.x * 2
After fixing the rotation problem on our side and updating the script, the bounding_box was still not completely right.
I created a mini tool which is using the semantic lidar sensors to get the right size of the carla actors and compared the difference.
Actor amount: 190 (we added 5-10 actors)
max_allowed_difference = 0.1 (meter)
Good bounding box: 102
Bad bounding box: 88
I looked for wrong center points and wrong sizes.
max_allowed_difference = 0.01 (meter)
Good bounding box: 54
Bad bounding box: 136
With the "traffic.speed_limit.50" not having a blueprint, I still need to calculate the traffic objects. (if needed) We can use the calculated Actor information now, but it would be good if Carla has the right data itself.
I got the permission to share the script. calculate_carla_actor_bounding_box.zip
To be able to work, you need a free place with no objects nearby, and only road or ground. (you could spam the actor in the air) I made a small change to be able the change the "actor_transform" where the objects spawn, and select the tags that should be ignored.
I found a bug in my code and created an updated version. The ZIP includes the code, and a json with the calculated bounding box. New version: calculate_carla_actor_bounding_box_v2.zip