Skip to content

Commit ff80727

Browse files
authored
Replace last pose if only orientation differs in Navfn (#5490)
Signed-off-by: mini-1235 <[email protected]>
1 parent 7603938 commit ff80727

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

nav2_navfn_planner/src/navfn_planner.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,18 +353,23 @@ NavfnPlanner::smoothApproachToGoal(
353353
const geometry_msgs::msg::Pose & goal,
354354
nav_msgs::msg::Path & plan)
355355
{
356-
// Replace the last pose of the computed path if it's actually further away
357-
// to the second to last pose than the goal pose.
358356
if (plan.poses.size() >= 2) {
359357
auto second_to_last_pose = plan.poses.end()[-2];
360358
auto last_pose = plan.poses.back();
359+
// Replace the last pose of the computed path if it's actually further away
360+
// to the second to last pose than the goal pose.
361361
if (
362362
squared_distance(last_pose.pose, second_to_last_pose.pose) >
363363
squared_distance(goal, second_to_last_pose.pose))
364364
{
365365
plan.poses.back().pose = goal;
366366
return;
367367
}
368+
// Replace the last pose of the computed path if its position matches but orientation differs
369+
if (squared_distance(last_pose.pose, goal) < 1e-6) {
370+
plan.poses.back().pose = goal;
371+
return;
372+
}
368373
}
369374
geometry_msgs::msg::PoseStamped goal_copy;
370375
goal_copy.pose = goal;

0 commit comments

Comments
 (0)