Skip to content

Commit 9cdd704

Browse files
kosuke55shmpwk
authored andcommitted
feat(goal_planner): allow shift pull over in parking lot outside lane (autowarefoundation#7140)
Signed-off-by: kosuke55 <kosuke.tnp@gmail.com>
1 parent 6e7182d commit 9cdd704

File tree

3 files changed

+52
-11
lines changed

3 files changed

+52
-11
lines changed

planning/behavior_path_goal_planner_module/include/behavior_path_goal_planner_module/util.hpp

+6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#define BEHAVIOR_PATH_GOAL_PLANNER_MODULE__UTIL_HPP_
1717

1818
#include "behavior_path_goal_planner_module/goal_searcher_base.hpp"
19+
#include "tier4_autoware_utils/geometry/boost_polygon_utils.hpp"
1920

2021
#include <lane_departure_checker/lane_departure_checker.hpp>
2122

@@ -41,6 +42,7 @@ using geometry_msgs::msg::Pose;
4142
using geometry_msgs::msg::Twist;
4243
using visualization_msgs::msg::Marker;
4344
using visualization_msgs::msg::MarkerArray;
45+
using Polygon2d = tier4_autoware_utils::Polygon2d;
4446

4547
lanelet::ConstLanelets getPullOverLanes(
4648
const RouteHandler & route_handler, const bool left_side, const double backward_distance,
@@ -85,6 +87,10 @@ PathWithLaneId extendPath(
8587
const PathWithLaneId & prev_module_path, const PathWithLaneId & reference_path,
8688
const Pose & extend_pose);
8789

90+
std::vector<Polygon2d> createPathFootPrints(
91+
const PathWithLaneId & path, const double base_to_front, const double base_to_rear,
92+
const double width);
93+
8894
// debug
8995
MarkerArray createPullOverAreaMarkerArray(
9096
const tier4_autoware_utils::MultiPolygon2d area_polygons, const std_msgs::msg::Header & header,

planning/behavior_path_goal_planner_module/src/shift_pull_over.cpp

+33-11
Original file line numberDiff line numberDiff line change
@@ -263,17 +263,39 @@ std::optional<PullOverPath> ShiftPullOver::generatePullOverPath(
263263
road_lane_reference_path_to_shift_end.points.back().point.pose);
264264
pull_over_path.debug_poses.push_back(prev_module_path_terminal_pose);
265265

266-
// check if the parking path will leave lanes
267-
const auto drivable_lanes =
268-
utils::generateDrivableLanesWithShoulderLanes(road_lanes, shoulder_lanes);
269-
const auto & dp = planner_data_->drivable_area_expansion_parameters;
270-
const auto expanded_lanes = utils::expandLanelets(
271-
drivable_lanes, dp.drivable_area_left_bound_offset, dp.drivable_area_right_bound_offset,
272-
dp.drivable_area_types_to_skip);
273-
const auto combined_drivable = utils::combineDrivableLanes(
274-
expanded_lanes, previous_module_output_.drivable_area_info.drivable_lanes);
275-
if (lane_departure_checker_.checkPathWillLeaveLane(
276-
utils::transformToLanelets(combined_drivable), pull_over_path.getParkingPath())) {
266+
// check if the parking path will leave drivable area and lanes
267+
const bool is_in_parking_lots = std::invoke([&]() -> bool {
268+
const auto & p = planner_data_->parameters;
269+
const auto parking_lot_polygons =
270+
lanelet::utils::query::getAllParkingLots(planner_data_->route_handler->getLaneletMapPtr());
271+
const auto path_footprints = goal_planner_utils::createPathFootPrints(
272+
pull_over_path.getParkingPath(), p.base_link2front, p.base_link2rear, p.vehicle_width);
273+
const auto is_footprint_in_any_polygon = [&parking_lot_polygons](const auto & footprint) {
274+
return std::any_of(
275+
parking_lot_polygons.begin(), parking_lot_polygons.end(),
276+
[&footprint](const auto & polygon) {
277+
return lanelet::geometry::within(footprint, lanelet::utils::to2D(polygon).basicPolygon());
278+
});
279+
};
280+
return std::all_of(
281+
path_footprints.begin(), path_footprints.end(),
282+
[&is_footprint_in_any_polygon](const auto & footprint) {
283+
return is_footprint_in_any_polygon(footprint);
284+
});
285+
});
286+
const bool is_in_lanes = std::invoke([&]() -> bool {
287+
const auto drivable_lanes =
288+
utils::generateDrivableLanesWithShoulderLanes(road_lanes, shoulder_lanes);
289+
const auto & dp = planner_data_->drivable_area_expansion_parameters;
290+
const auto expanded_lanes = utils::expandLanelets(
291+
drivable_lanes, dp.drivable_area_left_bound_offset, dp.drivable_area_right_bound_offset,
292+
dp.drivable_area_types_to_skip);
293+
const auto combined_drivable = utils::combineDrivableLanes(
294+
expanded_lanes, previous_module_output_.drivable_area_info.drivable_lanes);
295+
return !lane_departure_checker_.checkPathWillLeaveLane(
296+
utils::transformToLanelets(combined_drivable), pull_over_path.getParkingPath());
297+
});
298+
if (!is_in_parking_lots && !is_in_lanes) {
277299
return {};
278300
}
279301

planning/behavior_path_goal_planner_module/src/util.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -434,4 +434,17 @@ PathWithLaneId extendPath(
434434
return extendPath(target_path, reference_path, extend_distance);
435435
}
436436

437+
std::vector<Polygon2d> createPathFootPrints(
438+
const PathWithLaneId & path, const double base_to_front, const double base_to_rear,
439+
const double width)
440+
{
441+
std::vector<Polygon2d> footprints;
442+
for (const auto & point : path.points) {
443+
const auto & pose = point.point.pose;
444+
footprints.push_back(
445+
tier4_autoware_utils::toFootprint(pose, base_to_front, base_to_rear, width));
446+
}
447+
return footprints;
448+
}
449+
437450
} // namespace behavior_path_planner::goal_planner_utils

0 commit comments

Comments
 (0)