Skip to content

Commit

Permalink
Correctly use the max expansion distance when smoothing over arc lengths
Browse files Browse the repository at this point in the history
Signed-off-by: Maxime CLEMENT <[email protected]>
  • Loading branch information
maxime-clem committed Dec 18, 2023
1 parent 9b272a7 commit 576e947
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ void apply_extra_arc_length(
const auto & bound_projections =
side == LEFT ? expansion.left_projections : expansion.right_projections;
auto & bound_expansions = side == LEFT ? expansion.left_distances : expansion.right_distances;
const auto original_expansions = bound_expansions;
for (auto path_idx = 0UL; path_idx < bound_indexes.size(); ++path_idx) {
const auto bound_idx = bound_indexes[path_idx];
auto arc_length = boost::geometry::distance(
Expand All @@ -164,15 +165,16 @@ void apply_extra_arc_length(
arc_length +=
tier4_autoware_utils::calcDistance2d(bound[up_bound_idx - 1], bound[up_bound_idx]);
if (arc_length > extra_arc_length) break;
bound_expansions[up_bound_idx] = bound_expansions[bound_idx];
bound_expansions[up_bound_idx] =
std::max(bound_expansions[up_bound_idx], original_expansions[bound_idx]);

Check warning on line 169 in planning/behavior_path_planner_common/src/utils/drivable_area_expansion/drivable_area_expansion.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_planner_common/src/utils/drivable_area_expansion/drivable_area_expansion.cpp#L168-L169

Added lines #L168 - L169 were not covered by tests
}
arc_length =
boost::geometry::distance(bound_projections[path_idx].point, convert_point(bound[bound_idx]));
for (auto down_offset_idx = 1LU; down_offset_idx < bound_idx; ++down_offset_idx) {
const auto idx = bound_idx - down_offset_idx;
arc_length += tier4_autoware_utils::calcDistance2d(bound[idx - 1], bound[idx]);
if (arc_length > extra_arc_length) break;
bound_expansions[idx] = bound_expansions[bound_idx];
bound_expansions[idx] = std::max(bound_expansions[idx], original_expansions[bound_idx]);

Check warning on line 177 in planning/behavior_path_planner_common/src/utils/drivable_area_expansion/drivable_area_expansion.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_planner_common/src/utils/drivable_area_expansion/drivable_area_expansion.cpp#L177

Added line #L177 was not covered by tests
}
}
}

Check notice on line 180 in planning/behavior_path_planner_common/src/utils/drivable_area_expansion/drivable_area_expansion.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ New issue: Complex Method

apply_extra_arc_length has a cyclomatic complexity of 9, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.

Check notice on line 180 in planning/behavior_path_planner_common/src/utils/drivable_area_expansion/drivable_area_expansion.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ New issue: Bumpy Road Ahead

apply_extra_arc_length has 2 blocks with nested conditional logic. Any nesting of 2 or deeper is considered. Threshold is one single, nested block per function. The Bumpy Road code smell is a function that contains multiple chunks of nested conditional logic. The deeper the nesting and the more bumps, the lower the code health.
Expand Down

0 comments on commit 576e947

Please sign in to comment.