Files
PythonRobotics/tests/test_space_time_astar.py
Jonathan Schwartz 0c8ff11645 Space-Time AStar (#1170)
* wip - sketch out obstacles

* move to correct path

* better animation

* clean up

* use np to sample points

* implemented time-based A*

* cleaning up Grid + adding new obstacle arrangement

* added unit test

* formatting p1

* format STA* file

* remove newlines by docstrings

* linter

* working on typehints

* fix linter errors

* lint some more

* appease AppVeyor

* dataclasses are 🔥

* back to @total_ordering

* trailing whitespace

* add docs page on SpaceTimeA*

* docs lint

* remove trailing newlines in doc

* address comments

* Update docs/modules/5_path_planning/time_based_grid_search/time_based_grid_search_main.rst

---------

Co-authored-by: Atsushi Sakai <asakai.amsl+github@gmail.com>
2025-02-25 20:53:36 +09:00

34 lines
789 B
Python

from PathPlanning.TimeBasedPathPlanning.GridWithDynamicObstacles import (
Grid,
ObstacleArrangement,
Position,
)
from PathPlanning.TimeBasedPathPlanning import SpaceTimeAStar as m
import numpy as np
import conftest
def test_1():
start = Position(1, 11)
goal = Position(19, 19)
grid_side_length = 21
grid = Grid(
np.array([grid_side_length, grid_side_length]),
obstacle_arrangement=ObstacleArrangement.ARRANGEMENT1,
)
m.show_animation = False
planner = m.SpaceTimeAStar(grid, start, goal)
path = planner.plan(False)
# path should have 28 entries
assert len(path.path) == 31
# path should end at the goal
assert path.path[-1].position == goal
if __name__ == "__main__":
conftest.run_this_test(__file__)