Skip to content

Commit f4efb91

Browse files
authored
fix(autoware_behavior_velocity_speed_bump_module): fix containerOutOfBounds warning (#7671)
fix(autoware_behavior_velocity_speed_bump_module): fix containerOutOfBounds Signed-off-by: Ryuta Kambe <ryuta.kambe@tier4.jp>
1 parent a7e83ff commit f4efb91

File tree

1 file changed

+23
-17
lines changed
  • planning/behavior_velocity_planner/autoware_behavior_velocity_speed_bump_module/src

1 file changed

+23
-17
lines changed

planning/behavior_velocity_planner/autoware_behavior_velocity_speed_bump_module/src/util.cpp

+23-17
Original file line numberDiff line numberDiff line change
@@ -95,25 +95,31 @@ PathPolygonIntersectionStatus getPathPolygonIntersectionStatus(
9595
auto const & is_first_path_point_inside_polygon = bg::within(first_path_point, polygon);
9696
auto const & is_last_path_point_inside_polygon = bg::within(last_path_point, polygon);
9797

98-
if (
99-
intersects.empty() && is_first_path_point_inside_polygon && is_last_path_point_inside_polygon) {
100-
polygon_intersection_status.is_path_inside_of_polygon = true;
101-
} else {
102-
// classify first and second intersection points
103-
for (size_t i = 0; i < intersects.size(); ++i) {
104-
const auto & p = intersects.at(i);
105-
if (
106-
(intersects.size() == 2 && i == 0) ||
107-
(intersects.size() == 1 && is_last_path_point_inside_polygon)) {
108-
polygon_intersection_status.first_intersection_point = createPoint(p.x(), p.y(), ego_pos.z);
109-
} else if (
110-
(intersects.size() == 2 && i == 1) ||
111-
(intersects.size() == 1 && is_first_path_point_inside_polygon)) {
112-
polygon_intersection_status.second_intersection_point =
113-
createPoint(p.x(), p.y(), ego_pos.z);
114-
}
98+
// classify first and second intersection points
99+
if (intersects.empty()) {
100+
if (is_first_path_point_inside_polygon && is_last_path_point_inside_polygon) {
101+
polygon_intersection_status.is_path_inside_of_polygon = true;
102+
} else {
103+
// do nothing
104+
}
105+
} else if (intersects.size() == 1) {
106+
const auto & p = intersects.at(0);
107+
if (is_last_path_point_inside_polygon) {
108+
polygon_intersection_status.first_intersection_point = createPoint(p.x(), p.y(), ego_pos.z);
109+
} else if (is_first_path_point_inside_polygon) {
110+
polygon_intersection_status.second_intersection_point = createPoint(p.x(), p.y(), ego_pos.z);
111+
} else {
112+
// do nothing
115113
}
114+
} else if (intersects.size() == 2) {
115+
const auto & p0 = intersects.at(0);
116+
const auto & p1 = intersects.at(1);
117+
polygon_intersection_status.first_intersection_point = createPoint(p0.x(), p0.y(), ego_pos.z);
118+
polygon_intersection_status.second_intersection_point = createPoint(p1.x(), p1.y(), ego_pos.z);
119+
} else {
120+
// do nothing
116121
}
122+
117123
return polygon_intersection_status;
118124
}
119125

0 commit comments

Comments
 (0)