Skip to content

Commit

Permalink
fix(avoidance): fix a bug regarding the nearest search (autowarefound…
Browse files Browse the repository at this point in the history
…ation#5575)

* fix a bug regarding nearest search

---------

Signed-off-by: Yuki Takagi <[email protected]>
  • Loading branch information
yuki-takagi-66 committed Nov 14, 2023
1 parent e0f8769 commit 07582e9
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2147,13 +2147,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 @@ -2163,7 +2166,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

0 comments on commit 07582e9

Please sign in to comment.