Skip to content

Commit d4d0804

Browse files
fix(avoidance): fix a bug regarding the nearest search (#5575)
* fix a bug regarding nearest search --------- Signed-off-by: Yuki Takagi <yuki.takagi@tier4.jp>
1 parent dc5d76a commit d4d0804

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

planning/behavior_path_planner/src/scene_module/avoidance/avoidance_module.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -2025,13 +2025,16 @@ PathWithLaneId AvoidanceModule::extendBackwardLength(const PathWithLaneId & orig
20252025
planner_data_->parameters.backward_path_length, longest_dist_to_shift_point + extra_margin);
20262026

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

20322035
size_t clip_idx = 0;
20332036
for (size_t i = 0; i < prev_ego_idx; ++i) {
2034-
if (backward_length > calcSignedArcLength(previous_path.points, clip_idx, prev_ego_idx)) {
2037+
if (backward_length > calcSignedArcLength(previous_path.points, clip_idx, *prev_ego_idx)) {
20352038
break;
20362039
}
20372040
clip_idx = i;
@@ -2041,7 +2044,7 @@ PathWithLaneId AvoidanceModule::extendBackwardLength(const PathWithLaneId & orig
20412044
{
20422045
extended_path.points.insert(
20432046
extended_path.points.end(), previous_path.points.begin() + clip_idx,
2044-
previous_path.points.begin() + prev_ego_idx);
2047+
previous_path.points.begin() + *prev_ego_idx);
20452048
}
20462049

20472050
// overwrite backward path velocity by latest one.

0 commit comments

Comments
 (0)