def __init__(self, parent, node, actor_list): """ Constructor :param parent: the parent of this :type parent: carla_ros_bridge.Parent :param node: node-handle :type node: carla_ros_bridge.CarlaRosBridge :param actor_list: current list of actors :type actor_list: map(carla-actor-id -> python-actor-object) """ super(TrafficLightsSensor, self).__init__(parent=parent, node=node, prefix="") self.actor_list = actor_list self.traffic_light_status = CarlaTrafficLightStatusList() self.traffic_light_actors = [] self.traffic_lights_info_publisher = rospy.Publisher( self.get_topic_prefix() + "traffic_lights_info", CarlaTrafficLightInfoList, queue_size=10, latch=True) self.traffic_lights_status_publisher = rospy.Publisher( self.get_topic_prefix() + "traffic_lights", CarlaTrafficLightStatusList, queue_size=10, latch=True)
def __init__(self, uid, name, parent, node, actor_list): """ Constructor :param uid: unique identifier for this object :type uid: int :param name: name identiying the sensor :type name: string :param parent: the parent of this :type parent: carla_ros_bridge.Parent :param node: node-handle :type node: CompatibleNode :param actor_list: current list of actors :type actor_list: map(carla-actor-id -> python-actor-object) """ super(TrafficLightsSensor, self).__init__(uid=uid, name=name, parent=parent, node=node) self.actor_list = actor_list self.traffic_light_status = CarlaTrafficLightStatusList() self.traffic_light_actors = [] self.traffic_lights_info_publisher = node.new_publisher( CarlaTrafficLightInfoList, self.get_topic_prefix() + "/info", qos_profile=QoSProfile(depth=10, durability=latch_on)) self.traffic_lights_status_publisher = node.new_publisher( CarlaTrafficLightStatusList, self.get_topic_prefix() + "/status", qos_profile=QoSProfile(depth=10, durability=latch_on))
def __init__(self, uid, name, parent, node, actor_list): """ Constructor :param uid: unique identifier for this object :type uid: int :param name: name identiying the sensor :type name: string :param parent: the parent of this :type parent: carla_ros_bridge.Parent :param node: node-handle :type node: carla_ros_bridge.CarlaRosBridge :param actor_list: current list of actors :type actor_list: map(carla-actor-id -> python-actor-object) """ super(TrafficLightsSensor, self).__init__(uid=uid, name=name, parent=parent, node=node) self.actor_list = actor_list self.traffic_light_status = CarlaTrafficLightStatusList() self.traffic_light_actors = [] self.traffic_lights_info_publisher = rospy.Publisher( self.get_topic_prefix() + "/info", CarlaTrafficLightInfoList, queue_size=10, latch=True) self.traffic_lights_status_publisher = rospy.Publisher( self.get_topic_prefix() + "/status", CarlaTrafficLightStatusList, queue_size=10, latch=True)
def update(self, frame, timestamp): """ Get the state of all known traffic lights """ traffic_lights = CarlaTrafficLightStatusList() for actor_id in self.actor_list: actor = self.actor_list[actor_id] if isinstance(actor, TrafficLight): traffic_lights.traffic_lights.append(actor.get_status()) self.publish_message(self.get_topic_prefix(), traffic_lights)
def __init__(self, parent, communication, actor_list): """ Constructor :param parent: the parent of this :type parent: carla_ros_bridge.Parent :param communication: communication-handle :type communication: carla_ros_bridge.communication :param actor_list: current list of actors :type actor_list: map(carla-actor-id -> python-actor-object) """ super(TrafficLightsSensor, self).__init__(parent=parent, communication=communication, prefix="") self.actor_list = actor_list self.traffic_light_status = CarlaTrafficLightStatusList() self.traffic_light_actors = []
def update(self, frame, timestamp): """ Get the state of all known traffic lights """ traffic_light_status = CarlaTrafficLightStatusList() traffic_light_actors = [] for actor_id in self.actor_list: actor = self.actor_list[actor_id] if isinstance(actor, TrafficLight): traffic_light_actors.append(actor) traffic_light_status.traffic_lights.append(actor.get_status()) if traffic_light_actors != self.traffic_light_actors: self.traffic_light_actors = traffic_light_actors traffic_light_info_list = CarlaTrafficLightInfoList() for traffic_light in traffic_light_actors: traffic_light_info_list.traffic_lights.append(traffic_light.get_info()) self.traffic_lights_info_publisher.publish(traffic_light_info_list) if traffic_light_status != self.traffic_light_status: self.traffic_light_status = traffic_light_status self.traffic_lights_status_publisher.publish(traffic_light_status)
def update(self, frame, timestamp): """ Get the state of all known traffic lights """ traffic_light_status = CarlaTrafficLightStatusList() traffic_light_actors = [] for actor_id in self.actor_list: actor = self.actor_list[actor_id] if isinstance(actor, TrafficLight): traffic_light_actors.append(actor) traffic_light_status.traffic_lights.append(actor.get_status()) if traffic_light_actors != self.traffic_light_actors: self.traffic_light_actors = traffic_light_actors traffic_light_info_list = CarlaTrafficLightInfoList() for traffic_light in traffic_light_actors: traffic_light_info_list.traffic_lights.append(traffic_light.get_info()) self.publish_message(self.get_topic_prefix() + "traffic_lights_info", traffic_light_info_list, is_latched=True) if traffic_light_status != self.traffic_light_status: self.traffic_light_status = traffic_light_status self.publish_message(self.get_topic_prefix() + "traffic_lights", traffic_light_status, is_latched=True)