class_docstr: LocalPlanner implements the basic behavior of following a
  trajectory of waypoints that is generated on-the-fly.
  
  The low-level motion of the vehicle is computed by using two PID controllers,
  one is used for the lateral control and the other for the longitudinal control (cruise speed).
  
  When multiple paths are available (intersections) this local planner makes a random choice,
  unless a given global plan has already been specified.
class_docstr_tok: ["LocalPlanner","implements","the","basic","behavior","of","following","a","trajectory","of","waypoints","that","is","generated","on-the-fly",".","The","low-level","motion","of","the","vehicle","is","computed","by","using","two","PID","controllers",",","one","is","used","for","the","lateral","control","and","the","other","for","the","longitudinal","control","(","cruise","speed",")",".","When","multiple","paths","are","available","(","intersections",")","this","local","planner","makes","a","random","choice",",","unless","a","given","global","plan","has","already","been","specified","."]
docstr: Execute one step of local planning which involves running the longitudinal and lateral PID controllers to
  follow the waypoints trajectory.
  
  :param debug: boolean flag to activate waypoints debugging
  :return: control to be applied
docstr_tok: ["Execute","one","step","of","local","planning","which","involves","running","the","longitudinal","and","lateral","PID","controllers","to","follow","the","waypoints","trajectory",".",":","param","debug",":","boolean","flag","to","activate","waypoints","debugging",":","return",":","control","to","be","applied"]
code: def run_step(self, debug=False):
      """
      Execute one step of local planning which involves running the longitudinal and lateral PID controllers to
      follow the waypoints trajectory.
  
      :param debug: boolean flag to activate waypoints debugging
      :return: control to be applied
      """
      if self._follow_speed_limits:
          self._target_speed = self._vehicle.get_speed_limit()
  
      # Add more waypoints too few in the horizon
      if (
          not self._stop_waypoint_creation
          and len(self._waypoints_queue)
          < self._min_waypoint_queue_length
      ):
          self._compute_next_waypoints(
              k=self._min_waypoint_queue_length
          )
  
      # Purge the queue of obsolete waypoints
      veh_location = self._vehicle.get_location()
      vehicle_speed = get_speed(self._vehicle) / 3.6
      self._min_distance = (
          self._base_min_distance + self._distance_ratio * vehicle_speed
      )
  
      num_waypoint_removed = 0
      for waypoint, _ in self._waypoints_queue:
          if len(self._waypoints_queue) - num_waypoint_removed == 1:
              min_distance = 1  # Don't remove the last waypoint until very close by
          else:
              min_distance = self._min_distance
  
          if (
              veh_location.distance(waypoint.transform.location)
              < min_distance
          ):
              num_waypoint_removed += 1
          else:
              break
  
      if num_waypoint_removed > 0:
          for _ in range(num_waypoint_removed):
              self._waypoints_queue.popleft()
  
      # Get the target waypoint and move using the PID controllers. Stop if no target waypoint
      if len(self._waypoints_queue) == 0:
          control = carla.VehicleControl()
          control.steer = 0.0
          control.throttle = 0.0
          control.brake = 1.0
          control.hand_brake = False
          control.manual_gear_shift = False
      else:
          (
              self.target_waypoint,
              self.target_road_option,
          ) = self._waypoints_queue[0]
          control = self._vehicle_controller.run_step(
              self._target_speed, self.target_waypoint
          )
  
      if debug:
          draw_waypoints(
              self._vehicle.get_world(), [self.target_waypoint], 1.0
          )
  
      return control
  
imports: from enum import IntEnum
  from collections import deque
  import random
  import carla
  from agents.navigation.controller import VehiclePIDController
  from agents.tools.misc import draw_waypoints, get_speed
label_desc: Use image node_id 9 for calling the LocalPlanner obj's underlying member method code with example usage: obj.run_step(debug) and returns: control