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

fix(behavior_path_planner): fix find nearest function from lateral distance #2499

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
4 changes: 3 additions & 1 deletion planning/behavior_path_planner/src/utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ size_t findNearestSegmentIndexFromLateralDistance(
{
size_t closest_idx = motion_utils::findNearestSegmentIndex(points, pose.position);
double min_lateral_dist =
motion_utils::calcLongitudinalOffsetToSegment(points, closest_idx, pose.position);
std::fabs(motion_utils::calcLateralOffset(points, pose.position, closest_idx));

for (size_t seg_idx = 0; seg_idx < points.size() - 1; ++seg_idx) {
const double lon_dist =
motion_utils::calcLongitudinalOffsetToSegment(points, seg_idx, pose.position);
Expand All @@ -94,6 +95,7 @@ size_t findNearestSegmentIndexFromLateralDistance(
std::fabs(motion_utils::calcLateralOffset(points, pose.position, seg_idx));
if (lat_dist < min_lateral_dist) {
closest_idx = seg_idx;
min_lateral_dist = lat_dist;
}
}

Expand Down