class_docstr: This class provides a very high level route plan.
class_docstr_tok: ["This","class","provides","a","very","high","level","route","plan","."]
docstr: This method returns the turn decision (RoadOption) for pair of edges
  around current index of route list
docstr_tok: ["This","method","returns","the","turn","decision","(","RoadOption",")","for","pair","of","edges","around","current","index","of","route","list"]
code: def _turn_decision(self, index, route, threshold=math.radians(35)):
      """
      This method returns the turn decision (RoadOption) for pair of edges
      around current index of route list
      """
  
      decision = None
      previous_node = route[index - 1]
      current_node = route[index]
      next_node = route[index + 1]
      next_edge = self._graph.edges[current_node, next_node]
      if index > 0:
          if (
              self._previous_decision != RoadOption.VOID
              and self._intersection_end_node > 0
              and self._intersection_end_node != previous_node
              and next_edge["type"] == RoadOption.LANEFOLLOW
              and next_edge["intersection"]
          ):
              decision = self._previous_decision
          else:
              self._intersection_end_node = -1
              current_edge = self._graph.edges[
                  previous_node, current_node
              ]
              calculate_turn = (
                  current_edge["type"] == RoadOption.LANEFOLLOW
                  and not current_edge["intersection"]
                  and next_edge["type"] == RoadOption.LANEFOLLOW
                  and next_edge["intersection"]
              )
              if calculate_turn:
                  (
                      last_node,
                      tail_edge,
                  ) = self._successive_last_intersection_edge(
                      index, route
                  )
                  self._intersection_end_node = last_node
                  if tail_edge is not None:
                      next_edge = tail_edge
                  cv, nv = (
                      current_edge["exit_vector"],
                      next_edge["exit_vector"],
                  )
                  if cv is None or nv is None:
                      return next_edge["type"]
                  cross_list = []
                  for neighbor in self._graph.successors(current_node):
                      select_edge = self._graph.edges[
                          current_node, neighbor
                      ]
                      if select_edge["type"] == RoadOption.LANEFOLLOW:
                          if neighbor != route[index + 1]:
                              sv = select_edge["net_vector"]
                              cross_list.append(np.cross(cv, sv)[2])
                  next_cross = np.cross(cv, nv)[2]
                  deviation = math.acos(
                      np.clip(
                          np.dot(cv, nv)
                          / (np.linalg.norm(cv) * np.linalg.norm(nv)),
                          -1.0,
                          1.0,
                      )
                  )
                  if not cross_list:
                      cross_list.append(0)
                  if deviation < threshold:
                      decision = RoadOption.STRAIGHT
                  elif cross_list and next_cross < min(cross_list):
                      decision = RoadOption.LEFT
                  elif cross_list and next_cross > max(cross_list):
                      decision = RoadOption.RIGHT
                  elif next_cross < 0:
                      decision = RoadOption.LEFT
                  elif next_cross > 0:
                      decision = RoadOption.RIGHT
              else:
                  decision = next_edge["type"]
  
      else:
          decision = next_edge["type"]
  
      self._previous_decision = decision
      return decision
  
file_path: carla/PythonAPI/carla/agents/navigation/global_route_planner.py
imports: import math
  import numpy
  import networkx
  import carla
  from agents.navigation.local_planner import RoadOption
  from agents.tools.misc import vector
label_desc: Use image node_id 11 for calling the GlobalRoutePlanner obj's underlying member method code with example usage: obj._turn_decision(index, route, threshold) and returns: decision, next_edge