Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MPPI] Fix segfault in path_follow_critic when path is empty #3484

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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