Skip to content

Commit c057c95

Browse files
Fix duplicate poses with computePlanThroughPoses (#5488)
* fix-duplicate-poses Signed-off-by: Tony Najjar <[email protected]> * Update nav2_planner/src/planner_server.cpp Co-authored-by: Steve Macenski <[email protected]> Signed-off-by: Tony Najjar <[email protected]> --------- Signed-off-by: Tony Najjar <[email protected]> Co-authored-by: Steve Macenski <[email protected]>
1 parent ff80727 commit c057c95

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

nav2_planner/src/planner_server.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,17 @@ void PlannerServer::computePlanThroughPoses()
428428
throw nav2_core::NoValidPathCouldBeFound(goal->planner_id + " generated a empty path");
429429
}
430430

431-
// Concatenate paths together
432-
concat_path.poses.insert(
433-
concat_path.poses.end(), curr_path.poses.begin(), curr_path.poses.end());
431+
// Concatenate paths together, but skip the first pose of subsequent paths
432+
// to avoid duplicating the connection point
433+
if (i == 0) {
434+
// First path: add all poses
435+
concat_path.poses.insert(
436+
concat_path.poses.end(), curr_path.poses.begin(), curr_path.poses.end());
437+
} else if (curr_path.poses.size() > 1) {
438+
// Subsequent paths: skip the first pose to avoid duplication
439+
concat_path.poses.insert(
440+
concat_path.poses.end(), curr_path.poses.begin() + 1, curr_path.poses.end());
441+
}
434442
concat_path.header = curr_path.header;
435443
}
436444

0 commit comments

Comments
 (0)