Skip to content

Commit

Permalink
fix segfault when path is empty (ros-navigation#3484) (ros-navigation…
Browse files Browse the repository at this point in the history
…#3485)

a

Co-authored-by: Guillaume Doisy <guillaume@dexory.com>
(cherry picked from commit 26ac810)

Co-authored-by: Guillaume Doisy <doisyg@users.noreply.github.com>
  • Loading branch information
2 people authored and shrijitsingh99 committed Aug 29, 2023
1 parent 1847c6e commit 1ac78af
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions nav2_mppi_controller/src/critics/path_follow_critic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,16 @@ void PathFollowCritic::initialize()

void PathFollowCritic::score(CriticData & data)
{
if (!enabled_ ||
const size_t path_size = data.path.x.shape(0) - 1;

if (!enabled_ || path_size == 0 ||
utils::withinPositionGoalTolerance(threshold_to_consider_, data.state.pose.pose, data.path))
{
return;
}

utils::setPathFurthestPointIfNotSet(data);
utils::setPathCostsIfNotSet(data, costmap_ros_);
const size_t path_size = data.path.x.shape(0) - 1;

auto offseted_idx = std::min(
*data.furthest_reached_path_point + offset_from_furthest_, path_size);
Expand Down

0 comments on commit 1ac78af

Please sign in to comment.