Skip to content

Commit

Permalink
removing hypotf from smac planner heuristic computation (ros-navigati…
Browse files Browse the repository at this point in the history
…on#3217)

* removing hypotf

* swapping to node2d sqrt
  • Loading branch information
SteveMacenski authored and Joshua Wallace committed Dec 14, 2022
1 parent f2713f7 commit b45381d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion nav2_smac_planner/src/node_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ float Node2D::getHeuristicCost(
{
// Using Moore distance as it more accurately represents the distances
// even a Van Neumann neighborhood robot can navigate.
return hypotf(goal_coordinates.x - node_coords.x, goal_coordinates.y - node_coords.y);
auto dx = goal_coordinates.x - node_coords.x;
auto dy = goal_coordinates.y - node_coords.y;
return std::sqrt(dx * dx + dy * dy);
}

void Node2D::initMotionModel(
Expand Down
6 changes: 3 additions & 3 deletions nav2_smac_planner/src/node_hybrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,9 @@ inline float distanceHeuristic2D(
const unsigned int idx, const unsigned int size_x,
const unsigned int target_x, const unsigned int target_y)
{
return std::hypotf(
static_cast<int>(idx % size_x) - static_cast<int>(target_x),
static_cast<int>(idx / size_x) - static_cast<int>(target_y));
int dx = static_cast<int>(idx % size_x) - static_cast<int>(target_x);
int dy = static_cast<int>(idx / size_x) - static_cast<int>(target_y);
return std::sqrt(dx * dx + dy * dy);
}

void NodeHybrid::resetObstacleHeuristic(
Expand Down
2 changes: 2 additions & 0 deletions tools/planner_benchmarking/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def getPlannerResults(navigator, initial_pose, goal_pose, planners):
path = navigator._getPathImpl(initial_pose, goal_pose, planner, use_start=True)
if path is not None:
results.append(path)
else:
return results
return results


Expand Down

0 comments on commit b45381d

Please sign in to comment.