ros/src/tl_detector/tl_detector.py
def process_traffic_lights(self):
        """Finds closest visible traffic light, if one exists, and determines its
            location and color

        Returns:
            int: index of waypoint closes to the upcoming stop line for a traffic light (-1 if none exists)
            int: ID of traffic light color (specified in styx_msgs/TrafficLight)

        """
        closest_light = None
        # each traffic light comes with a traffic line which is 
        # the stop line for the traffic light => we need the index 
        # of the closest traffic line to us
        line_wp_idx = None 

        # List of positions that correspond to the line to stop in front of for a given intersection
        stop_line_positions = self.config['stop_line_positions']
        if(self.pose):
            car_wp_idx = self.get_closest_waypoint(self.pose.pose.position.x, 
                                                     self.pose.pose.position.y)


            # find the closest visible traffic light (if one exists)
            diff = len(self.waypoints.waypoints)
            for i, light in enumerate(self.lights):
                # get stop line waypoint
                line = stop_line_positions[i]
                temp_wp_idx = self.get_closest_waypoint(line[0], line[1])
                # find closest stop line wyapoint index
                d = temp_wp_idx - car_wp_idx
                if d >= 0 and d < diff:
                    diff = d
                    closest_light = light
                    line_wp_idx = temp_wp_idx

        if closest_light:
            state = self.get_light_state(closest_light)
            return line_wp_idx, state

        return -1, TrafficLight.UNKNOWN
Finds closest visible traffic light, if one exists, and determines its
            location and color

        Returns:
            int: index of waypoint closes to the upcoming stop line for a traffic light (-1 if none exists)
            int: ID of traffic light color (specified in styx_msgs/TrafficLight)

        
Finds closest visible traffic light, if one exists, and determines its
location and color
Finds closest visible traffic light if one exists and determines its location and color
def process_traffic_lights(self):
        closest_light = None
        line_wp_idx = None 
        stop_line_positions = self.config['stop_line_positions']
        if(self.pose):
            car_wp_idx = self.get_closest_waypoint(self.pose.pose.position.x, 
                                                     self.pose.pose.position.y)
            diff = len(self.waypoints.waypoints)
            for i, light in enumerate(self.lights):
                line = stop_line_positions[i]
                temp_wp_idx = self.get_closest_waypoint(line[0], line[1])
                d = temp_wp_idx - car_wp_idx
                if d >= 0 and d < diff:
                    diff = d
                    closest_light = light
                    line_wp_idx = temp_wp_idx
        if closest_light:
            state = self.get_light_state(closest_light)
            return line_wp_idx, state
        return -1, TrafficLight.UNKNOWN
def process_traffic_lights ( self ) : closest_light = None line_wp_idx = None stop_line_positions = self . config [ 'stop_line_positions' ] if ( self . pose ) : car_wp_idx = self . get_closest_waypoint ( self . pose . pose . position . x , self . pose . pose . position . y ) diff = len ( self . waypoints . waypoints ) for i , light in enumerate ( self . lights ) : line = stop_line_positions [ i ] temp_wp_idx = self . get_closest_waypoint ( line [ 0 ] , line [ 1 ] ) d = temp_wp_idx - car_wp_idx if d >= 0 and d < diff : diff = d closest_light = light line_wp_idx = temp_wp_idx if closest_light : state = self . get_light_state ( closest_light ) return line_wp_idx , state return - 1 , TrafficLight . UNKNOWN
Finds closest visible traffic light, if one exists, and determines its
location and color
Finds closest visible traffic light if one exists and determines its location and color
"""Finds closest visible traffic light, if one exists, and determines its
            location and color

        Returns:
            int: index of waypoint closes to the upcoming stop line for a traffic light (-1 if none exists)
            int: ID of traffic light color (specified in styx_msgs/TrafficLight)

        """ # each traffic light comes with a traffic line which is  # the stop line for the traffic light => we need the index  # of the closest traffic line to us # List of positions that correspond to the line to stop in front of for a given intersection # find the closest visible traffic light (if one exists) # get stop line waypoint # find closest stop line wyapoint index
index of waypoint closes to the upcoming stop line for a traffic light (-1 if none exists)
int: ID of traffic light color (specified in styx_msgs/TrafficLight)
index of waypoint closes to the upcoming stop line for a traffic light ( - 1 if none exists ) int : ID of traffic light color ( specified in styx_msgs / TrafficLight )
int
self