carla icon indicating copy to clipboard operation
carla copied to clipboard

Get actors from parent actor id

Open gabrik opened this issue 2 years ago • 0 comments

Hi,

There is a simple way to get all the child actors given a parent actor id?

Let me explain my use case: I create the ego vehicle with all the attached sensors, then from the AV pipeline I would like to get those sensors, instead of creating new ones attached.

I was thinking that something like:

self.carla_world.get_actors(parent_id=vehicle.id)

But seems that get_actors can take only a list of ids as parameters. It is possible to achieve the same result with filtering?

I have a workaround but seems inefficient:

possible_cameras = self.carla_world.get_actors().filter(self.camera_type)
for camera in possible_cameras:
    if camera.parent.id == self.player.id:
         # do something

I'm using CARLA 0.9.13

gabrik avatar Sep 21 '22 07:09 gabrik