This method implements re-routing for vehicles approaching its destination. It finds a new target and computes another path to reach it. :param spawn_points: list of possible destinations for the agent
(self, spawn_points)
| 121 | self._local_planner.set_global_plan(route_trace, clean) |
| 122 | |
| 123 | def reroute(self, spawn_points): |
| 124 | """ |
| 125 | This method implements re-routing for vehicles approaching its destination. |
| 126 | It finds a new target and computes another path to reach it. |
| 127 | |
| 128 | :param spawn_points: list of possible destinations for the agent |
| 129 | """ |
| 130 | |
| 131 | print("Target almost reached, setting new destination...") |
| 132 | random.shuffle(spawn_points) |
| 133 | new_start = self._local_planner.waypoints_queue[-1][0].transform.location |
| 134 | destination = spawn_points[0].location if spawn_points[0].location != new_start else spawn_points[1].location |
| 135 | print("New destination: " + str(destination)) |
| 136 | |
| 137 | self.set_destination(new_start, destination) |
| 138 | |
| 139 | def _trace_route(self, start_waypoint, end_waypoint): |
| 140 | """ |
nothing calls this directly
no test coverage detected