Skip to content

Commit 8765a25

Browse files
blacksoul000crthilakrajchikmagalore.thilak
authored
Issue 1608 segmentation fault planner server node master (#1612) (#1767)
* corrected wrong indexing in NavfnPlanner::smoothApproachToGoal function * resolved uncrustify errors * corrected the condition inside NavfnPlanner::smoothApproachToGoal to replace last pose of computed path Co-authored-by: chikmagalore.thilak <chikmagalore.thilak@bshg.com> Co-authored-by: crthilakraj <crthilakraj@users.noreply.github.com> Co-authored-by: chikmagalore.thilak <chikmagalore.thilak@bshg.com>
1 parent 1a96da4 commit 8765a25

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

‎nav2_navfn_planner/src/navfn_planner.cpp‎

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -246,19 +246,20 @@ NavfnPlanner::smoothApproachToGoal(
246246
{
247247
// Replace the last pose of the computed path if it's actually further away
248248
// to the second to last pose than the goal pose.
249-
250-
auto second_to_last_pose = plan.poses.end()[-2];
251-
auto last_pose = plan.poses.back();
252-
if (
253-
squared_distance(last_pose.pose, second_to_last_pose.pose) >
254-
squared_distance(goal, second_to_last_pose.pose))
255-
{
256-
plan.poses.back().pose = goal;
257-
} else {
258-
geometry_msgs::msg::PoseStamped goal_copy;
259-
goal_copy.pose = goal;
260-
plan.poses.push_back(goal_copy);
249+
if (plan.poses.size() >= 2) {
250+
auto second_to_last_pose = plan.poses.end()[-2];
251+
auto last_pose = plan.poses.back();
252+
if (
253+
squared_distance(last_pose.pose, second_to_last_pose.pose) >
254+
squared_distance(goal, second_to_last_pose.pose))
255+
{
256+
plan.poses.back().pose = goal;
257+
return;
258+
}
261259
}
260+
geometry_msgs::msg::PoseStamped goal_copy;
261+
goal_copy.pose = goal;
262+
plan.poses.push_back(goal_copy);
262263
}
263264

264265
bool

0 commit comments

Comments
 (0)