Skip to content

Commit

Permalink
Return a straight line path when pathfinding to same navgrid node
Browse files Browse the repository at this point in the history
  • Loading branch information
mjansen4857 committed Jan 1, 2024
1 parent 48bc7e9 commit d5aa10a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pathplannerlib-python/pathplannerlib/pathfinders.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ def _doWork(self, needs_reset: bool, do_minor: bool, do_major: bool, s_start: Gr
def _extractPath(self, s_start: GridPosition, s_goal: GridPosition, obstacles: Set[GridPosition]) -> List[
GridPosition]:
if s_goal == s_start:
return []
return [s_start, s_goal]

path = [s_start]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ private void doWork(
private List<GridPosition> extractPath(
GridPosition sStart, GridPosition sGoal, Set<GridPosition> obstacles) {
if (sGoal.equals(sStart)) {
return new ArrayList<>();
return List.of(sStart, sGoal);
}

List<GridPosition> path = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,10 @@ std::vector<GridPosition> LocalADStar::extractPath(const GridPosition &sStart,
const GridPosition &sGoal,
const std::unordered_set<GridPosition> &obstacles) {
if (sGoal == sStart) {
return std::vector<GridPosition>();
std::vector < GridPosition > ret;
ret.emplace_back(sStart);
ret.emplace_back(sGoal);
return ret;
}

std::vector < GridPosition > path;
Expand Down

0 comments on commit d5aa10a

Please sign in to comment.