Skip to content

Commit

Permalink
fix(utils): drivable area generation supports anti-clockwise polygon (a…
Browse files Browse the repository at this point in the history
…utowarefoundation#4678)

Signed-off-by: satoshi-ota <[email protected]>
  • Loading branch information
satoshi-ota authored and tkimura4 committed Sep 15, 2023
1 parent 3bf4673 commit d9b3b20
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion planning/behavior_path_planner/src/utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1537,6 +1537,10 @@ std::vector<geometry_msgs::msg::Point> calcBound(
const auto polygon =
route_handler->getLaneletMapPtr()->polygonLayer.get(std::atoi(id.c_str()));

const auto is_clockwise_polygon =
boost::geometry::is_valid(lanelet::utils::to2D(polygon.basicPolygon()));
const auto is_clockwise_iteration = is_clockwise_polygon ? is_left : !is_left;

const auto start_itr = std::find_if(polygon.begin(), polygon.end(), [&bound](const auto & p) {
return p.id() == bound.front().id();
});
Expand All @@ -1552,7 +1556,8 @@ std::vector<geometry_msgs::msg::Point> calcBound(
// extract line strings between start_idx and end_idx.
const size_t start_idx = std::distance(polygon.begin(), start_itr);
const size_t end_idx = std::distance(polygon.begin(), end_itr);
for (const auto & point : extract_bound_from_polygon(polygon, start_idx, end_idx, is_left)) {
for (const auto & point :
extract_bound_from_polygon(polygon, start_idx, end_idx, is_clockwise_iteration)) {
output_points.push_back(point);
}

Expand Down

0 comments on commit d9b3b20

Please sign in to comment.