class_docstr: BasicAgent implements an agent that navigates the scene.
  This agent respects traffic lights and other vehicles, but ignores stop signs.
  It has several functions available to specify the route that the agent must follow,
  as well as to change its parameters in case a different driving mode is desired.
class_docstr_tok: ["BasicAgent","implements","an","agent","that","navigates","the","scene",".","This","agent","respects","traffic","lights","and","other","vehicles",",","but","ignores","stop","signs",".","It","has","several","functions","available","to","specify","the","route","that","the","agent","must","follow",",","as","well","as","to","change","its","parameters","in","case","a","different","driving","mode","is","desired","."]
docstr: Method to check if there is a red light affecting the vehicle.
  
      :param lights_list (list of carla.TrafficLight): list containing TrafficLight objects.
          If None, all traffic lights in the scene are used
      :param max_distance (float): max distance for traffic lights to be considered relevant.
          If None, the base threshold value is used
docstr_tok: ["Method","to","check","if","there","is","a","red","light","affecting","the","vehicle",".",":","param","lights_list","(","list","of","carla.TrafficLight",")",":","list","containing","TrafficLight","objects",".","If","None",",","all","traffic","lights","in","the","scene","are","used",":","param","max_distance","(","float",")",":","max","distance","for","traffic","lights","to","be","considered","relevant",".","If","None",",","the","base","threshold","value","is","used"]
code: def _affected_by_traffic_light(
      self, lights_list=None, max_distance=None
  ):
      """
      Method to check if there is a red light affecting the vehicle.
  
          :param lights_list (list of carla.TrafficLight): list containing TrafficLight objects.
              If None, all traffic lights in the scene are used
          :param max_distance (float): max distance for traffic lights to be considered relevant.
              If None, the base threshold value is used
      """
      if self._ignore_traffic_lights:
          return (False, None)
  
      if not lights_list:
          lights_list = self._world.get_actors().filter(
              "*traffic_light*"
          )
  
      if not max_distance:
          max_distance = self._base_tlight_threshold
  
      if self._last_traffic_light:
          if (
              self._last_traffic_light.state
              != carla.TrafficLightState.Red
          ):
              self._last_traffic_light = None
          else:
              return (True, self._last_traffic_light)
  
      ego_vehicle_location = self._vehicle.get_location()
      ego_vehicle_waypoint = self._map.get_waypoint(
          ego_vehicle_location
      )
  
      for traffic_light in lights_list:
          if traffic_light.id in self._lights_map:
              trigger_wp = self._lights_map[traffic_light.id]
          else:
              trigger_location = get_trafficlight_trigger_location(
                  traffic_light
              )
              trigger_wp = self._map.get_waypoint(trigger_location)
              self._lights_map[traffic_light.id] = trigger_wp
  
          if (
              trigger_wp.transform.location.distance(
                  ego_vehicle_location
              )
              > max_distance
          ):
              continue
  
          if trigger_wp.road_id != ego_vehicle_waypoint.road_id:
              continue
  
          ve_dir = ego_vehicle_waypoint.transform.get_forward_vector()
          wp_dir = trigger_wp.transform.get_forward_vector()
          dot_ve_wp = (
              ve_dir.x * wp_dir.x
              + ve_dir.y * wp_dir.y
              + ve_dir.z * wp_dir.z
          )
  
          if dot_ve_wp < 0:
              continue
  
          if traffic_light.state != carla.TrafficLightState.Red:
              continue
  
          if is_within_distance(
              trigger_wp.transform,
              self._vehicle.get_transform(),
              max_distance,
              [0, 90],
          ):
              self._last_traffic_light = traffic_light
              return (True, traffic_light)
  
      return (False, None)
  
imports: import carla
  from shapely.geometry import Polygon
  from agents.navigation.local_planner import LocalPlanner, RoadOption
  from agents.navigation.global_route_planner import GlobalRoutePlanner
  from agents.tools.misc import get_speed, is_within_distance, get_trafficlight_trigger_location, compute_distance
label_desc: Use image node_id 17 for calling the BasicAgent obj's underlying member method code with example usage: obj._affected_by_traffic_light(lights_list, max_distance) and returns: False,  None, False,  None, True,  self, True,  traffic_light