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: Initialization the agent paramters, the local and the global planner.
  
      :param vehicle: actor to apply to agent logic onto
      :param target_speed: speed (in Km/h) at which the vehicle will move
      :param opt_dict: dictionary in case some of its parameters want to be changed.
          This also applies to parameters related to the LocalPlanner.
      :param map_inst: carla.Map instance to avoid the expensive call of getting it.
      :param grp_inst: GlobalRoutePlanner instance to avoid the expensive call of getting it.
docstr_tok: ["Initialization","the","agent","paramters",",","the","local","and","the","global","planner",".",":","param","vehicle",":","actor","to","apply","to","agent","logic","onto",":","param","target_speed",":","speed","(","in","Km\/h",")","at","which","the","vehicle","will","move",":","param","opt_dict",":","dictionary","in","case","some","of","its","parameters","want","to","be","changed",".","This","also","applies","to","parameters","related","to","the","LocalPlanner",".",":","param","map_inst",":","carla.Map","instance","to","avoid","the","expensive","call","of","getting","it",".",":","param","grp_inst",":","GlobalRoutePlanner","instance","to","avoid","the","expensive","call","of","getting","it","."]
code: def __init__(
      self,
      vehicle,
      target_speed=20,
      opt_dict={},
      map_inst=None,
      grp_inst=None,
  ):
      """
      Initialization the agent paramters, the local and the global planner.
  
          :param vehicle: actor to apply to agent logic onto
          :param target_speed: speed (in Km/h) at which the vehicle will move
          :param opt_dict: dictionary in case some of its parameters want to be changed.
              This also applies to parameters related to the LocalPlanner.
          :param map_inst: carla.Map instance to avoid the expensive call of getting it.
          :param grp_inst: GlobalRoutePlanner instance to avoid the expensive call of getting it.
  
      """
      self._vehicle = vehicle
      self._world = self._vehicle.get_world()
      if map_inst:
          if isinstance(map_inst, carla.Map):
              self._map = map_inst
          else:
              print(
                  "Warning: Ignoring the given map as it is not a 'carla.Map'"
              )
              self._map = self._world.get_map()
      else:
          self._map = self._world.get_map()
      self._last_traffic_light = None
  
      # Base parameters
      self._ignore_traffic_lights = False
      self._ignore_stop_signs = False
      self._ignore_vehicles = False
      self._use_bbs_detection = False
      self._target_speed = target_speed
      self._sampling_resolution = 2.0
      self._base_tlight_threshold = 5.0  # meters
      self._base_vehicle_threshold = 5.0  # meters
      self._speed_ratio = 1
      self._max_brake = 0.5
      self._offset = 0
  
      # Change parameters according to the dictionary
      opt_dict["target_speed"] = target_speed
      if "ignore_traffic_lights" in opt_dict:
          self._ignore_traffic_lights = opt_dict[
              "ignore_traffic_lights"
          ]
      if "ignore_stop_signs" in opt_dict:
          self._ignore_stop_signs = opt_dict["ignore_stop_signs"]
      if "ignore_vehicles" in opt_dict:
          self._ignore_vehicles = opt_dict["ignore_vehicles"]
      if "use_bbs_detection" in opt_dict:
          self._use_bbs_detection = opt_dict["use_bbs_detection"]
      if "sampling_resolution" in opt_dict:
          self._sampling_resolution = opt_dict["sampling_resolution"]
      if "base_tlight_threshold" in opt_dict:
          self._base_tlight_threshold = opt_dict[
              "base_tlight_threshold"
          ]
      if "base_vehicle_threshold" in opt_dict:
          self._base_vehicle_threshold = opt_dict[
              "base_vehicle_threshold"
          ]
      if "detection_speed_ratio" in opt_dict:
          self._speed_ratio = opt_dict["detection_speed_ratio"]
      if "max_brake" in opt_dict:
          self._max_brake = opt_dict["max_brake"]
      if "offset" in opt_dict:
          self._offset = opt_dict["offset"]
  
      # Initialize the planners
      self._local_planner = LocalPlanner(
          self._vehicle, opt_dict=opt_dict, map_inst=self._map
      )
      if grp_inst:
          if isinstance(grp_inst, GlobalRoutePlanner):
              self._global_planner = grp_inst
          else:
              print(
                  "Warning: Ignoring the given map as it is not a 'carla.Map'"
              )
              self._global_planner = GlobalRoutePlanner(
                  self._map, self._sampling_resolution
              )
      else:
          self._global_planner = GlobalRoutePlanner(
              self._map, self._sampling_resolution
          )
  
      # Get the static elements of the scene
      self._lights_list = self._world.get_actors().filter(
          "*traffic_light*"
      )
      self._lights_map = {}
  
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 1 to create a new BasicAgent object from inherited base classes: object with example: obj = BasicAgent(vehicle, target_speed, opt_dict, map_inst, grp_inst)