|
1 | 1 | """ |
2 | | -TODO - doc comment |
| 2 | +Priority Based Planner for multi agent path planning. |
| 3 | +The planner generates an order to plan in, and generates plans for the robots in that order. Each planned |
| 4 | +path is reserved in the grid, and all future plans must avoid that path. |
3 | 5 |
|
4 | | -sort of outlined in this paper: https://pure.tudelft.nl/ws/portalfiles/portal/67074672/07138650.pdf |
5 | | -better paper: https://people.csail.mit.edu/tlp/publications/01087401.pdf |
| 6 | +Algorithm outlined in section III of this paper: https://pure.tudelft.nl/ws/portalfiles/portal/67074672/07138650.pdf |
6 | 7 | """ |
7 | 8 |
|
8 | 9 | import numpy as np |
|
16 | 17 | from PathPlanning.TimeBasedPathPlanning.Node import NodePath |
17 | 18 | from PathPlanning.TimeBasedPathPlanning.BaseClasses import SingleAgentPlanner |
18 | 19 | from PathPlanning.TimeBasedPathPlanning.SafeInterval import SafeIntervalPathPlanner |
19 | | -from PathPlanning.TimeBasedPathPlanning.SpaceTimeAStar import SpaceTimeAStar |
20 | 20 | from PathPlanning.TimeBasedPathPlanning.Plotting import PlotNodePaths |
21 | 21 | import time |
22 | 22 |
|
23 | 23 | class PriorityBasedPlanner(MultiAgentPlanner): |
24 | 24 |
|
25 | | - def plan(grid: Grid, start_and_goals: list[StartAndGoal], single_agent_planner_class: SingleAgentPlanner, verbose: bool) -> list[NodePath]: # TODO: list of what |
| 25 | + def plan(grid: Grid, start_and_goals: list[StartAndGoal], single_agent_planner_class: SingleAgentPlanner, verbose: bool) -> list[NodePath]: |
26 | 26 |
|
27 | 27 | print(f"Using planner: {single_agent_planner_class}") |
28 | 28 |
|
29 | 29 | # Reserve initial positions |
30 | 30 | for start_and_goal in start_and_goals: |
31 | 31 | grid.reserve_position(start_and_goal.start, start_and_goal.index, Interval(0, 10)) |
32 | 32 |
|
33 | | - # TODO: smarter ordering |
| 33 | + # Plan in descending order of distance from start to goal |
| 34 | + start_and_goals = sorted(start_and_goals, |
| 35 | + key=lambda item: item.distance_start_to_goal(), |
| 36 | + reverse=True) |
| 37 | + |
34 | 38 | paths = [] |
35 | 39 | for start_and_goal in start_and_goals: |
36 | 40 | if True: |
|
0 commit comments