Skip to content

Commit c4ac8ca

Browse files
Fix duplicate poses with computePlanThroughPoses (#5488)
* fix-duplicate-poses Signed-off-by: Tony Najjar <tony.najjar.1997@gmail.com> * Update nav2_planner/src/planner_server.cpp Co-authored-by: Steve Macenski <stevenmacenski@gmail.com> Signed-off-by: Tony Najjar <tony.najjar.1997@gmail.com> --------- Signed-off-by: Tony Najjar <tony.najjar.1997@gmail.com> Co-authored-by: Steve Macenski <stevenmacenski@gmail.com>
1 parent 7e0945d commit c4ac8ca

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
@@ -432,9 +432,17 @@ void PlannerServer::computePlanThroughPoses()
432432
throw nav2_core::NoValidPathCouldBeFound(goal->planner_id + " generated a empty path");
433433
}
434434

435-
// Concatenate paths together
436-
concat_path.poses.insert(
437-
concat_path.poses.end(), curr_path.poses.begin(), curr_path.poses.end());
435+
// Concatenate paths together, but skip the first pose of subsequent paths
436+
// to avoid duplicating the connection point
437+
if (i == 0) {
438+
// First path: add all poses
439+
concat_path.poses.insert(
440+
concat_path.poses.end(), curr_path.poses.begin(), curr_path.poses.end());
441+
} else if (curr_path.poses.size() > 1) {
442+
// Subsequent paths: skip the first pose to avoid duplication
443+
concat_path.poses.insert(
444+
concat_path.poses.end(), curr_path.poses.begin() + 1, curr_path.poses.end());
445+
}
438446
concat_path.header = curr_path.header;
439447
}
440448

0 commit comments

Comments
 (0)