ros/src/tl_detector/tl_detector.py
def image_cb(self, msg):
        """Identifies red lights in the incoming camera image and publishes the index
            of the waypoint closest to the red light's stop line to /traffic_waypoint

        Args:
            msg (Image): image from car-mounted camera

        """
        self.has_image = True
        self.camera_image = msg
        light_wp, state, score = self.process_traffic_lights()
        rospy.loginfo('Current detection state: {}, Light waypoint index: {}'.format(
                                            self.light_name_dict[state],
                                            light_wp))
        '''
        Publish upcoming red lights at camera frequency.
        Each predicted state has to eiher occur `STATE_COUNT_THRESHOLD` number
        of times or has a high predicted score till we start using it.
        Otherwise the previous stable state is used.
        '''
        if (self.state != state) and (score < self.light_score_confidence_threshold):
            self.state_count = 1
            self.state = state
        elif (self.state_count >= STATE_COUNT_THRESHOLD) or (
            score >= self.light_score_confidence_threshold):
            self.last_state = self.state
            light_wp = light_wp if state in (
                TrafficLight.RED, TrafficLight.YELLOW) else -1
            self.last_wp = light_wp
            self.upcoming_red_light_pub.publish(Int32(light_wp))
        else:
            self.upcoming_red_light_pub.publish(Int32(self.last_wp))
        self.state_count += 1

        if self.last_wp == -1:
            rospy.loginfo('Execution: continue driving')
        else:
            rospy.loginfo('Execution: STOPPING')
Identifies red lights in the incoming camera image and publishes the index
            of the waypoint closest to the red light's stop line to /traffic_waypoint

        Args:
            msg (Image): image from car-mounted camera

        
Identifies red lights in the incoming camera image and publishes the index
of the waypoint closest to the red light's stop line to /traffic_waypoint
Identifies red lights in the incoming camera image and publishes the index of the waypoint closest to the red light ' s stop line to / traffic_waypoint
def image_cb(self, msg):
        self.has_image = True
        self.camera_image = msg
        light_wp, state, score = self.process_traffic_lights()
        rospy.loginfo('Current detection state: {}, Light waypoint index: {}'.format(
                                            self.light_name_dict[state],
                                            light_wp))
        if (self.state != state) and (score < self.light_score_confidence_threshold):
            self.state_count = 1
            self.state = state
        elif (self.state_count >= STATE_COUNT_THRESHOLD) or (
            score >= self.light_score_confidence_threshold):
            self.last_state = self.state
            light_wp = light_wp if state in (
                TrafficLight.RED, TrafficLight.YELLOW) else -1
            self.last_wp = light_wp
            self.upcoming_red_light_pub.publish(Int32(light_wp))
        else:
            self.upcoming_red_light_pub.publish(Int32(self.last_wp))
        self.state_count += 1
        if self.last_wp == -1:
            rospy.loginfo('Execution: continue driving')
        else:
            rospy.loginfo('Execution: STOPPING')
def image_cb ( self , msg ) : self . has_image = True self . camera_image = msg light_wp , state , score = self . process_traffic_lights ( ) rospy . loginfo ( 'Current detection state: {}, Light waypoint index: {}' . format ( self . light_name_dict [ state ] , light_wp ) ) '''
        Publish upcoming red lights at camera frequency.
        Each predicted state has to eiher occur `STATE_COUNT_THRESHOLD` number
        of times or has a high predicted score till we start using it.
        Otherwise the previous stable state is used.
        ''' if ( self . state != state ) and ( score < self . light_score_confidence_threshold ) : self . state_count = 1 self . state = state elif ( self . state_count >= STATE_COUNT_THRESHOLD ) or ( score >= self . light_score_confidence_threshold ) : self . last_state = self . state light_wp = light_wp if state in ( TrafficLight . RED , TrafficLight . YELLOW ) else - 1 self . last_wp = light_wp self . upcoming_red_light_pub . publish ( Int32 ( light_wp ) ) else : self . upcoming_red_light_pub . publish ( Int32 ( self . last_wp ) ) self . state_count += 1 if self . last_wp == - 1 : rospy . loginfo ( 'Execution: continue driving' ) else : rospy . loginfo ( 'Execution: STOPPING' )
Identifies red lights in the incoming camera image and publishes the index
of the waypoint closest to the red light's stop line to /traffic_waypoint
Identifies red lights in the incoming camera image and publishes the index of the waypoint closest to the red light ' s stop line to / traffic_waypoint
"""Identifies red lights in the incoming camera image and publishes the index
            of the waypoint closest to the red light's stop line to /traffic_waypoint

        Args:
            msg (Image): image from car-mounted camera

        """ '''
        Publish upcoming red lights at camera frequency.
        Each predicted state has to eiher occur `STATE_COUNT_THRESHOLD` number
        of times or has a high predicted score till we start using it.
        Otherwise the previous stable state is used.
        '''
self
msg
image from car-mounted camera
image from car - mounted camera