Skip to content

Commit b5adf61

Browse files
authored
navfn : fix performance issue (#4945)
Signed-off-by: Yancey <135342560+Yancey2023@users.noreply.github.com>
1 parent 6513b51 commit b5adf61

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

nav2_navfn_planner/src/navfn_planner.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,13 @@ NavfnPlanner::makePlan(
293293
p.position.x = goal.position.x - tolerance;
294294
while (p.position.x <= goal.position.x + tolerance) {
295295
potential = getPointPotential(p.position);
296-
double sdist = squared_distance(p, goal);
297-
if (potential < POT_HIGH && sdist < best_sdist) {
298-
best_sdist = sdist;
299-
best_pose = p;
300-
found_legal = true;
296+
if (potential < POT_HIGH) {
297+
double sdist = squared_distance(p, goal);
298+
if (sdist < best_sdist) {
299+
best_sdist = sdist;
300+
best_pose = p;
301+
found_legal = true;
302+
}
301303
}
302304
p.position.x += resolution;
303305
}

0 commit comments

Comments
 (0)