def publish_actor_list(self): """ publish list of carla actors :return: """ ros_actor_list = CarlaActorList() for actor_id in self.actors: actor = self.actors[actor_id].carla_actor ros_actor = CarlaActorInfo() ros_actor.id = actor.id ros_actor.type = actor.type_id try: ros_actor.rolename = str(actor.attributes.get('role_name')) except ValueError: pass if actor.parent: ros_actor.parent_id = actor.parent.id else: ros_actor.parent_id = 0 ros_actor_list.actors.append(ros_actor) self.actor_list_publisher.publish(ros_actor_list)
def publish_actor_list(self): """ publish list of carla actors :return: """ ros_actor_list = CarlaActorList() with self.update_lock: for actor_id in self.actors: actor = self.actors[actor_id].carla_actor ros_actor = CarlaActorInfo() ros_actor.id = actor.id ros_actor.type = actor.type_id try: ros_actor.rolename = str(actor.attributes.get('role_name')) except ValueError: pass if actor.parent: ros_actor.parent_id = actor.parent.id else: ros_actor.parent_id = 0 ros_actor_list.actors.append(ros_actor) self.comm.publish_message("/carla/actor_list", ros_actor_list, is_latched=True)
def update(self, frame, timestamp): """ Function (override) to update this object. """ ros_actor_list = CarlaActorList() for actor_id in self.actor_list.keys(): if not isinstance(self.actor_list[actor_id], Actor): continue actor = self.actor_list[actor_id].carla_actor ros_actor = CarlaActorInfo() ros_actor.id = actor.id ros_actor.type = actor.type_id try: ros_actor.rolename = str(actor.attributes.get('role_name')) except ValueError: pass if actor.parent: ros_actor.parent_id = actor.parent.id else: ros_actor.parent_id = 0 ros_actor_list.actors.append(ros_actor) self.actor_list_publisher.publish(ros_actor_list)