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(avoidance): fix a bug regarding the nearest search #5575

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
Original file line number Diff line number Diff line change
Expand Up @@ -2025,13 +2025,16 @@ PathWithLaneId AvoidanceModule::extendBackwardLength(const PathWithLaneId & orig
planner_data_->parameters.backward_path_length, longest_dist_to_shift_point + extra_margin);

const size_t orig_ego_idx = planner_data_->findEgoIndex(original_path.points);
const size_t prev_ego_idx = motion_utils::findFirstNearestSegmentIndexWithSoftConstraints(
const auto prev_ego_idx = motion_utils::findNearestSegmentIndex(
previous_path.points, getPose(original_path.points.at(orig_ego_idx)),
std::numeric_limits<double>::max(), planner_data_->parameters.ego_nearest_yaw_threshold);
if (!prev_ego_idx) {
return original_path;
}

size_t clip_idx = 0;
for (size_t i = 0; i < prev_ego_idx; ++i) {
if (backward_length > calcSignedArcLength(previous_path.points, clip_idx, prev_ego_idx)) {
if (backward_length > calcSignedArcLength(previous_path.points, clip_idx, *prev_ego_idx)) {
break;
}
clip_idx = i;
Expand All @@ -2041,7 +2044,7 @@ PathWithLaneId AvoidanceModule::extendBackwardLength(const PathWithLaneId & orig
{
extended_path.points.insert(
extended_path.points.end(), previous_path.points.begin() + clip_idx,
previous_path.points.begin() + prev_ego_idx);
previous_path.points.begin() + *prev_ego_idx);
}

// overwrite backward path velocity by latest one.
Expand Down