From 2cd88691e688505b6dbc93f63d17538674f1e051 Mon Sep 17 00:00:00 2001 From: Shumpei Wakabayashi <42209144+shmpwk@users.noreply.github.com> Date: Fri, 1 Nov 2024 19:21:45 +0900 Subject: [PATCH] fix(bpp): prevent accessing nullopt (#9204) (#1619) fix(bpp): calcDistanceToRedTrafficLight null Signed-off-by: Shumpei Wakabayashi --- .../src/utils/traffic_light_utils.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/planning/behavior_path_planner/autoware_behavior_path_planner_common/src/utils/traffic_light_utils.cpp b/planning/behavior_path_planner/autoware_behavior_path_planner_common/src/utils/traffic_light_utils.cpp index 40802558c0b38..39e5ae79edc33 100644 --- a/planning/behavior_path_planner/autoware_behavior_path_planner_common/src/utils/traffic_light_utils.cpp +++ b/planning/behavior_path_planner/autoware_behavior_path_planner_common/src/utils/traffic_light_utils.cpp @@ -94,6 +94,7 @@ std::optional calcDistanceToRedTrafficLight( const auto & ego_pos = planner_data->self_odometry->pose.pose.position; lanelet::ConstLineString3d stop_line = *(element->stopLine()); + if (!stop_line.empty()) return std::nullopt; const auto x = 0.5 * (stop_line.front().x() + stop_line.back().x()); const auto y = 0.5 * (stop_line.front().y() + stop_line.back().y()); const auto z = 0.5 * (stop_line.front().z() + stop_line.back().z());