Skip to content

Commit

Permalink
fix(behavior_path_planner): extract obstacles from drivable area with…
Browse files Browse the repository at this point in the history
…out intersection (autowarefoundation#3741)

* fix(behavior_path_planner): extract obstacles from drivable area without intersection

Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com>

* update

Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com>

---------

Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com>
  • Loading branch information
takayuki5168 authored and jpntaxi committed May 25, 2023
1 parent 2c57919 commit 79d8340
Showing 1 changed file with 16 additions and 1 deletion.
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

0 comments on commit 79d8340

Please sign in to comment.