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

feat(behavior_path_planner): add combineLanelets #4657

Merged
merged 2 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,9 @@ void makeBoundLongitudinallyMonotonic(
std::optional<lanelet::Polygon3d> getPolygonByPoint(
const std::shared_ptr<RouteHandler> & route_handler, const lanelet::ConstPoint3d & point,
const std::string & polygon_name);

lanelet::ConstLanelets combineLanelets(
const lanelet::ConstLanelets & base_lanes, const lanelet::ConstLanelets & added_lanes);
Comment on lines +426 to +427
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not used anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will replace

// combine road lane and pull out lane
const double backward_path_length =
planner_data_->parameters.backward_path_length + parameters_.max_back_distance;
const auto road_lanes = utils::getExtendedCurrentLanes(
planner_data_, backward_path_length, std::numeric_limits<double>::max(),
/*forward_only_in_route*/ true);
const auto pull_out_lanes = getPullOutLanes(planner_data_, backward_path_length);
auto lanes = road_lanes;
for (const auto & pull_out_lane : pull_out_lanes) {
auto it = std::find_if(
lanes.begin(), lanes.end(), [&pull_out_lane](const lanelet::ConstLanelet & lane) {
return lane.id() == pull_out_lane.id();
});
if (it == lanes.end()) {
lanes.push_back(pull_out_lane);
}
}
in oher PR and use in #4610

} // namespace behavior_path_planner::utils

#endif // BEHAVIOR_PATH_PLANNER__UTILS__UTILS_HPP_
17 changes: 17 additions & 0 deletions planning/behavior_path_planner/src/utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3347,4 +3347,21 @@ void extractObstaclesFromDrivableArea(
bound = drivable_area_processing::updateBoundary(bound, unique_polygons);
}
}

lanelet::ConstLanelets combineLanelets(
const lanelet::ConstLanelets & base_lanes, const lanelet::ConstLanelets & added_lanes)
{
lanelet::ConstLanelets combined_lanes = base_lanes;
for (const auto & added_lane : added_lanes) {
const auto it = std::find_if(
combined_lanes.begin(), combined_lanes.end(),
[&added_lane](const lanelet::ConstLanelet & lane) { return lane.id() == added_lane.id(); });
if (it == combined_lanes.end()) {
combined_lanes.push_back(added_lane);
}
}

return combined_lanes;
}

} // namespace behavior_path_planner::utils