class_docstr: BehaviorAgent implements an agent that navigates scenes to reach a given
  target destination, by computing the shortest possible path to it.
  This agent can correctly follow traffic signs, speed limitations,
  traffic lights, while also taking into account nearby vehicles. Lane changing
  decisions can be taken by analyzing the surrounding environment such as tailgating avoidance.
  Adding to these are possible behaviors, the agent can also keep safety distance
  from a car in front of it by tracking the instantaneous time to collision
  and keeping it in a certain range. Finally, different sets of behaviors
  are encoded in the agent, from cautious to a more aggressive ones.
class_docstr_tok: ["BehaviorAgent","implements","an","agent","that","navigates","scenes","to","reach","a","given","target","destination",",","by","computing","the","shortest","possible","path","to","it",".","This","agent","can","correctly","follow","traffic","signs",",","speed","limitations",",","traffic","lights",",","while","also","taking","into","account","nearby","vehicles",".","Lane","changing","decisions","can","be","taken","by","analyzing","the","surrounding","environment","such","as","tailgating","avoidance",".","Adding","to","these","are","possible","behaviors",",","the","agent","can","also","keep","safety","distance","from","a","car","in","front","of","it","by","tracking","the","instantaneous","time","to","collision","and","keeping","it","in","a","certain","range",".","Finally",",","different","sets","of","behaviors","are","encoded","in","the","agent",",","from","cautious","to","a","more","aggressive","ones","."]
docstr: Execute one step of navigation.
  
      :param debug: boolean for debugging
      :return control: carla.VehicleControl
docstr_tok: ["Execute","one","step","of","navigation",".",":","param","debug",":","boolean","for","debugging",":","return","control",":","carla.VehicleControl"]
code: def run_step(self, debug=False):
      """
      Execute one step of navigation.
  
          :param debug: boolean for debugging
          :return control: carla.VehicleControl
      """
      self._update_information()
  
      control = None
      if self._behavior.tailgate_counter > 0:
          self._behavior.tailgate_counter -= 1
  
      ego_vehicle_loc = self._vehicle.get_location()
      ego_vehicle_wp = self._map.get_waypoint(ego_vehicle_loc)
  
      # 1: Red lights and stops behavior
      if self.traffic_light_manager():
          return self.emergency_stop()
  
      # 2.1: Pedestrian avoidance behaviors
      walker_state, walker, w_distance = self.pedestrian_avoid_manager(
          ego_vehicle_wp
      )
  
      if walker_state:
          # Distance is computed from the center of the two cars,
          # we use bounding boxes to calculate the actual distance
          distance = (
              w_distance
              - max(
                  walker.bounding_box.extent.y,
                  walker.bounding_box.extent.x,
              )
              - max(
                  self._vehicle.bounding_box.extent.y,
                  self._vehicle.bounding_box.extent.x,
              )
          )
  
          # Emergency brake if the car is very close.
          if distance < self._behavior.braking_distance:
              return self.emergency_stop()
  
      # 2.2: Car following behaviors
      (
          vehicle_state,
          vehicle,
          distance,
      ) = self.collision_and_car_avoid_manager(ego_vehicle_wp)
  
      if vehicle_state:
          # Distance is computed from the center of the two cars,
          # we use bounding boxes to calculate the actual distance
          distance = (
              distance
              - max(
                  vehicle.bounding_box.extent.y,
                  vehicle.bounding_box.extent.x,
              )
              - max(
                  self._vehicle.bounding_box.extent.y,
                  self._vehicle.bounding_box.extent.x,
              )
          )
  
          # Emergency brake if the car is very close.
          if distance < self._behavior.braking_distance:
              return self.emergency_stop()
          else:
              control = self.car_following_manager(vehicle, distance)
  
      # 3: Intersection behavior
      elif self._incoming_waypoint.is_junction and (
          self._incoming_direction
          in [RoadOption.LEFT, RoadOption.RIGHT]
      ):
          target_speed = min(
              [self._behavior.max_speed, self._speed_limit - 5]
          )
          self._local_planner.set_speed(target_speed)
          control = self._local_planner.run_step(debug=debug)
  
      # 4: Normal behavior
      else:
          target_speed = min(
              [
                  self._behavior.max_speed,
                  self._speed_limit - self._behavior.speed_lim_dist,
              ]
          )
          self._local_planner.set_speed(target_speed)
          control = self._local_planner.run_step(debug=debug)
  
      return control
  
file_path: carla/PythonAPI/carla/agents/navigation/behavior_agent.py
imports: import random
  import numpy
  import carla
  from agents.navigation.basic_agent import BasicAgent
  from agents.navigation.local_planner import RoadOption
  from agents.navigation.behavior_types import Cautious, Aggressive, Normal
  from agents.tools.misc import get_speed, positive, is_within_distance, compute_distance
label_desc: Use image node_id 8 for calling the BehaviorAgent obj's underlying member method code with example usage: obj.run_step(debug) and returns: control, self, self, self