Skip to content

Commit 54d25a8

Browse files
authored
fix(behavior_path_planner): catch exception when calculating curvature (#6431)
Signed-off-by: Maxime CLEMENT <maxime.clement@tier4.jp>
1 parent 13b8bdc commit 54d25a8

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

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

+12-5
Original file line numberDiff line numberDiff line change
@@ -383,11 +383,18 @@ void expand_drivable_area(
383383

384384
stop_watch.tic("curvatures_expansion");
385385
// Only add curvatures for the new points. Curvatures of reused path points are not updated.
386-
const auto new_curvatures =
387-
calculate_smoothed_curvatures(path_poses, params.curvature_average_window);
388-
const auto first_new_point_idx = curvatures.size();
389-
curvatures.insert(
390-
curvatures.end(), new_curvatures.begin() + first_new_point_idx, new_curvatures.end());
386+
try {
387+
if (path_poses.size() > curvatures.size()) {
388+
const auto new_curvatures =
389+
calculate_smoothed_curvatures(path_poses, params.curvature_average_window);
390+
const auto first_new_point_idx = curvatures.size();
391+
curvatures.insert(
392+
curvatures.end(), new_curvatures.begin() + first_new_point_idx, new_curvatures.end());
393+
}
394+
} catch (const std::exception & e) {
395+
std::cerr << "[drivable_area_expansion] could not calculate path curvatures\n";
396+
curvatures.resize(path_poses.size(), 0.0);
397+
}
391398
auto expansion =
392399
calculate_expansion(path_poses, path.left_bound, path.right_bound, curvatures, params);
393400
const auto curvature_expansion_ms = stop_watch.toc("curvatures_expansion");

0 commit comments

Comments
 (0)