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): catch exception when calculating curvature #6431

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
@@ -1,4 +1,4 @@
// Copyright 2023 TIER IV, Inc.

Check notice on line 1 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)

ℹ Getting worse: Overall Code Complexity

The mean cyclomatic complexity increases from 7.50 to 7.67, threshold = 4. This file has many conditional statements (e.g. if, for, while) across its implementation, leading to lower code health. Avoid adding more conditionals.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -383,11 +383,18 @@

stop_watch.tic("curvatures_expansion");
// Only add curvatures for the new points. Curvatures of reused path points are not updated.
const auto new_curvatures =
calculate_smoothed_curvatures(path_poses, params.curvature_average_window);
const auto first_new_point_idx = curvatures.size();
curvatures.insert(
curvatures.end(), new_curvatures.begin() + first_new_point_idx, new_curvatures.end());
try {
if (path_poses.size() > curvatures.size()) {
const auto new_curvatures =
calculate_smoothed_curvatures(path_poses, params.curvature_average_window);
const auto first_new_point_idx = curvatures.size();
curvatures.insert(
curvatures.end(), new_curvatures.begin() + first_new_point_idx, new_curvatures.end());
}
} catch (const std::exception & e) {
std::cerr << "[drivable_area_expansion] could not calculate path curvatures\n";
curvatures.resize(path_poses.size(), 0.0);
}

Check notice on line 397 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

expand_drivable_area 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 warning on line 397 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#L397

Added line #L397 was not covered by tests
auto expansion =
calculate_expansion(path_poses, path.left_bound, path.right_bound, curvatures, params);
const auto curvature_expansion_ms = stop_watch.toc("curvatures_expansion");
Expand Down
Loading