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): extract obstacles from drivable area without intersection #3741

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
17 changes: 16 additions & 1 deletion planning/behavior_path_planner/src/utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ std::vector<PolygonPoint> generatePolygonInsideBounds(
full_polygon.push_back(polygon_point);
}

// 1. check the case where the polygon intersects the bound
std::vector<PolygonPoint> inside_poly;
bool has_intersection = false; // NOTE: between obstacle polygon and bound
for (int i = 0; i < static_cast<int>(full_polygon.size()); ++i) {
Expand Down Expand Up @@ -262,10 +263,24 @@ std::vector<PolygonPoint> generatePolygonInsideBounds(
inside_poly.push_back(intersect_point);
continue;
}

if (has_intersection) {
return inside_poly;
}

// 2. check the case where the polygon does not intersect the bound
const bool is_polygon_fully_inside_bounds = [&]() {
for (const auto & curr_poly : full_polygon) {
const bool is_curr_outside = curr_poly.is_outside_bounds(is_object_right);
if (is_curr_outside) {
return false;
}
}
return true;
}();
if (is_polygon_fully_inside_bounds) {
return full_polygon;
}

return std::vector<PolygonPoint>{};
}

Expand Down