Skip to content

Commit 7b2e1b6

Browse files
authored
fix(bpp): prevent accessing nullopt (autowarefoundation#9269) (#1632)
Signed-off-by: Shumpei Wakabayashi <shumpei.wakabayashi@tier4.jp>
1 parent f3fb4fa commit 7b2e1b6

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

planning/behavior_path_planner/autoware_behavior_path_planner_common/src/utils/traffic_light_utils.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ std::optional<double> calcDistanceToRedTrafficLight(
9797
}
9898

9999
const auto & ego_pos = planner_data->self_odometry->pose.pose.position;
100-
lanelet::ConstLineString3d stop_line = *(element->stopLine());
101-
if (!stop_line.empty()) return std::nullopt;
102-
const auto x = 0.5 * (stop_line.front().x() + stop_line.back().x());
103-
const auto y = 0.5 * (stop_line.front().y() + stop_line.back().y());
104-
const auto z = 0.5 * (stop_line.front().z() + stop_line.back().z());
100+
const auto & stop_line = element->stopLine();
101+
if (!stop_line || stop_line->empty()) return std::nullopt;
105102

103+
const auto x = 0.5 * (stop_line->front().x() + stop_line->back().x());
104+
const auto y = 0.5 * (stop_line->front().y() + stop_line->back().y());
105+
const auto z = 0.5 * (stop_line->front().z() + stop_line->back().z());
106106
return calcSignedArcLength(
107107
path.points, ego_pos, autoware::universe_utils::createPoint(x, y, z));
108108
}

0 commit comments

Comments
 (0)