|
| 1 | +from PathPlanning.TimeBasedPathPlanning.GridWithDynamicObstacles import ( |
| 2 | + Grid, |
| 3 | + NodePath, |
| 4 | + ObstacleArrangement, |
| 5 | + Position, |
| 6 | +) |
| 7 | +from PathPlanning.TimeBasedPathPlanning.BaseClasses import StartAndGoal |
| 8 | +from PathPlanning.TimeBasedPathPlanning import PriorityBasedPlanner as m |
| 9 | +from PathPlanning.TimeBasedPathPlanning.SafeInterval import SafeIntervalPathPlanner |
| 10 | +import numpy as np |
| 11 | +import conftest |
| 12 | + |
| 13 | + |
| 14 | +def test_1(): |
| 15 | + grid_side_length = 21 |
| 16 | + |
| 17 | + start_and_goals = [StartAndGoal(i, Position(1, i), Position(19, 19-i)) for i in range(1, 16)] |
| 18 | + obstacle_avoid_points = [pos for item in start_and_goals for pos in (item.start, item.goal)] |
| 19 | + |
| 20 | + grid = Grid( |
| 21 | + np.array([grid_side_length, grid_side_length]), |
| 22 | + num_obstacles=250, |
| 23 | + obstacle_avoid_points=obstacle_avoid_points, |
| 24 | + obstacle_arrangement=ObstacleArrangement.ARRANGEMENT1, |
| 25 | + ) |
| 26 | + |
| 27 | + grid_side_length = 21 |
| 28 | + grid = Grid( |
| 29 | + np.array([grid_side_length, grid_side_length]), |
| 30 | + obstacle_arrangement=ObstacleArrangement.ARRANGEMENT1, |
| 31 | + ) |
| 32 | + |
| 33 | + m.show_animation = False |
| 34 | + |
| 35 | + start_and_goals: list[StartAndGoal] |
| 36 | + paths: list[NodePath] |
| 37 | + start_and_goals, paths = m.PriorityBasedPlanner.plan(grid, start_and_goals, SafeIntervalPathPlanner, False) |
| 38 | + |
| 39 | + # All paths should start at the specified position and reach the goal |
| 40 | + for i, start_and_goal in enumerate(start_and_goals): |
| 41 | + assert paths[i].path[0].position == start_and_goal.start |
| 42 | + assert paths[i].path[-1].position == start_and_goal.goal |
| 43 | + |
| 44 | +if __name__ == "__main__": |
| 45 | + conftest.run_this_test(__file__) |
0 commit comments