From ec4fdd71f55b096e602d594bfb2853e61b4e8ddb Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Tue, 16 Apr 2019 09:45:30 +0530 Subject: [PATCH] Fixed false straights --- .../agents/navigation/global_route_planner.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/PythonAPI/carla/agents/navigation/global_route_planner.py b/PythonAPI/carla/agents/navigation/global_route_planner.py index 6bb5e8454..ed3f0084e 100644 --- a/PythonAPI/carla/agents/navigation/global_route_planner.py +++ b/PythonAPI/carla/agents/navigation/global_route_planner.py @@ -86,17 +86,17 @@ class GlobalRoutePlanner(object): road_id_to_edge[road_id][section_id] = dict() road_id_to_edge[road_id][section_id][lane_id] = (n1, n2) + entry_carla_vector = entry_wp.transform.rotation.get_forward_vector() + exit_carla_vector = exit_wp.transform.rotation.get_forward_vector() # Adding edge with attributes graph.add_edge( n1, n2, length=len(path) + 1, path=path, entry_waypoint=entry_wp, exit_waypoint=exit_wp, - entry_vector=vector( - entry_wp.transform.location, - path[0].transform.location if len(path) > 0 else exit_wp.transform.location), - exit_vector=vector( - path[-1].transform.location if len(path) > 0 else entry_wp.transform.location, - exit_wp.transform.location), + entry_vector=np.array( + [entry_carla_vector.x, entry_carla_vector.y, entry_carla_vector.z]), + exit_vector=np.array( + [exit_carla_vector.x, exit_carla_vector.y, exit_carla_vector.z]), net_vector=vector(entry_wp.transform.location, exit_wp.transform.location), intersection=intersection, type=RoadOption.LANEFOLLOW) @@ -309,6 +309,10 @@ class GlobalRoutePlanner(object): 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: