Skip to content

Commit

Permalink
Add path compression to A*
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrahiminfinite authored and sea-bass committed Jul 4, 2023
1 parent 8ebdd64 commit 25b350e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions pyrobosim/examples/demo_astar.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def demo_astar():
),
"diagonal_motion": True,
"heuristic": "euclidean",
"compress_path": False,
}

planner = PathPlanner("astar", **planner_config)
Expand Down
6 changes: 5 additions & 1 deletion pyrobosim/pyrobosim/navigation/a_star.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import warnings
from astar import AStar
from pyrobosim.utils.pose import Pose
from pyrobosim.utils.motion import Path
from pyrobosim.utils.motion import Path, reduce_waypoints_grid
from pyrobosim.navigation.planner_base import PathPlannerBase


Expand Down Expand Up @@ -127,6 +127,10 @@ def plan(self, start, goal):
goal_grid = self.grid.world_to_grid((goal.x, goal.y))
path = self.astar(start_grid, goal_grid)

# Apply waypoint reduction if enabled.
if self.compress_path:
path = reduce_waypoints_grid(self.grid, list(path))

world_path = []
if path is not None:
for waypoint in path:
Expand Down

0 comments on commit 25b350e

Please sign in to comment.