Skip to content

Commit 3efb1fb

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 edb5d1b commit 3efb1fb

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
@@ -436,9 +436,17 @@ void PlannerServer::computePlanThroughPoses()
436436
throw nav2_core::NoValidPathCouldBeFound(goal->planner_id + " generated a empty path");
437437
}
438438

439-
// Concatenate paths together
440-
concat_path.poses.insert(
441-
concat_path.poses.end(), curr_path.poses.begin(), curr_path.poses.end());
439+
// Concatenate paths together, but skip the first pose of subsequent paths
440+
// to avoid duplicating the connection point
441+
if (i == 0) {
442+
// First path: add all poses
443+
concat_path.poses.insert(
444+
concat_path.poses.end(), curr_path.poses.begin(), curr_path.poses.end());
445+
} else if (curr_path.poses.size() > 1) {
446+
// Subsequent paths: skip the first pose to avoid duplication
447+
concat_path.poses.insert(
448+
concat_path.poses.end(), curr_path.poses.begin() + 1, curr_path.poses.end());
449+
}
442450
concat_path.header = curr_path.header;
443451
}
444452

0 commit comments

Comments
 (0)