Skip to content

Commit 5efef23

Browse files
soblinSakodaShintaro
authored andcommitted
fix(goal_planner): check usage of bus_stop_area by goal_pose (autowarefoundation#10041)
Signed-off-by: Mamoru Sobue <mamoru.sobue@tier4.jp>
1 parent 8b9b332 commit 5efef23

File tree

6 files changed

+32
-11
lines changed

6 files changed

+32
-11
lines changed

planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/include/autoware/behavior_path_goal_planner_module/goal_planner_module.hpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,8 @@ class GoalPlannerModule : public SceneModuleInterface
338338
std::shared_ptr<GoalSearcherBase> goal_searcher_;
339339
GoalCandidates goal_candidates_{};
340340

341+
bool use_bus_stop_area_{false};
342+
341343
// NOTE: this is latest occupancy_grid_map pointer which the local planner_data on
342344
// onFreespaceParkingTimer thread storage may point to while calculation.
343345
// onTimer/onFreespaceParkingTimer and their callees MUST NOT use this
@@ -362,7 +364,7 @@ class GoalPlannerModule : public SceneModuleInterface
362364
mutable GoalPlannerDebugData debug_data_;
363365

364366
// goal seach
365-
GoalCandidates generateGoalCandidates() const;
367+
GoalCandidates generateGoalCandidates(const bool use_bus_stop_area) const;
366368

367369
/*
368370
* state transitions and plan function used in each state

planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/include/autoware/behavior_path_goal_planner_module/goal_searcher.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ class GoalSearcher : public GoalSearcherBase
3030
public:
3131
GoalSearcher(const GoalPlannerParameters & parameters, const LinearRing2d & vehicle_footprint);
3232

33-
GoalCandidates search(const std::shared_ptr<const PlannerData> & planner_data) override;
33+
GoalCandidates search(
34+
const std::shared_ptr<const PlannerData> & planner_data, const bool use_bus_stop_area) override;
3435
void update(
3536
GoalCandidates & goal_candidates,
3637
const std::shared_ptr<OccupancyGridBasedCollisionDetector> occupancy_grid_map,

planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/include/autoware/behavior_path_goal_planner_module/goal_searcher_base.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ class GoalSearcherBase
4747
virtual ~GoalSearcherBase() = default;
4848

4949
MultiPolygon2d getAreaPolygons() const { return area_polygons_; }
50-
virtual GoalCandidates search(const std::shared_ptr<const PlannerData> & planner_data) = 0;
50+
virtual GoalCandidates search(
51+
const std::shared_ptr<const PlannerData> & planner_data, const bool use_bus_stop_area) = 0;
5152
virtual void update(
5253
[[maybe_unused]] GoalCandidates & goal_candidates,
5354
[[maybe_unused]] const std::shared_ptr<OccupancyGridBasedCollisionDetector> occupancy_grid_map,

planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/include/autoware/behavior_path_goal_planner_module/thread_data.hpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ class LaneParkingRequest
3333
public:
3434
LaneParkingRequest(
3535
const autoware::universe_utils::LinearRing2d & vehicle_footprint,
36-
const GoalCandidates & goal_candidates, const BehaviorModuleOutput & upstream_module_output)
36+
const GoalCandidates & goal_candidates, const BehaviorModuleOutput & upstream_module_output,
37+
const bool use_bus_stop_area)
3738
: vehicle_footprint_(vehicle_footprint),
3839
goal_candidates_(goal_candidates),
40+
use_bus_stop_area_(use_bus_stop_area),
3941
upstream_module_output_(upstream_module_output)
4042
{
4143
}
@@ -48,6 +50,7 @@ class LaneParkingRequest
4850

4951
const autoware::universe_utils::LinearRing2d vehicle_footprint_;
5052
const GoalCandidates goal_candidates_;
53+
const bool use_bus_stop_area_;
5154

5255
const std::shared_ptr<PlannerData> & get_planner_data() const { return planner_data_; }
5356
const ModuleStatus & get_current_status() const { return current_status_; }

planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/src/goal_planner_module.cpp

+18-5
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ void LaneParkingPlanner::onTimer()
319319
const auto & pull_over_path_opt = local_request.get_pull_over_path();
320320
const auto & prev_data = local_request.get_prev_data();
321321
const auto trigger_thread_on_approach = local_request.trigger_thread_on_approach();
322+
const auto use_bus_stop_area = local_request.use_bus_stop_area_;
322323

323324
if (!trigger_thread_on_approach) {
324325
return;
@@ -385,7 +386,7 @@ void LaneParkingPlanner::onTimer()
385386
std::vector<PullOverPath> path_candidates{};
386387
std::optional<Pose> closest_start_pose{};
387388
std::optional<std::vector<size_t>> sorted_indices_opt{std::nullopt};
388-
if (parameters_.bus_stop_area.use_bus_stop_area && switch_bezier_) {
389+
if (use_bus_stop_area && switch_bezier_) {
389390
bezier_planning_helper(
390391
local_planner_data, goal_candidates, upstream_module_output, current_lanes,
391392
closest_start_pose, path_candidates, sorted_indices_opt);
@@ -658,7 +659,7 @@ std::pair<LaneParkingResponse, FreespaceParkingResponse> GoalPlannerModule::sync
658659
std::lock_guard<std::mutex> guard(lane_parking_mutex_);
659660
if (!lane_parking_request_) {
660661
lane_parking_request_.emplace(
661-
vehicle_footprint_, goal_candidates_, getPreviousModuleOutput());
662+
vehicle_footprint_, goal_candidates_, getPreviousModuleOutput(), use_bus_stop_area_);
662663
}
663664
// NOTE: for the above reasons, PlannerManager/behavior_path_planner_node ensure that
664665
// planner_data_ is not nullptr, so it is OK to copy as value
@@ -713,7 +714,19 @@ void GoalPlannerModule::updateData()
713714

714715
// update goal searcher and generate goal candidates
715716
if (goal_candidates_.empty()) {
716-
goal_candidates_ = generateGoalCandidates();
717+
const auto pull_over_lanes = goal_planner_utils::getPullOverLanes(
718+
*(planner_data_->route_handler), left_side_parking_, parameters_.backward_goal_search_length,
719+
parameters_.forward_goal_search_length);
720+
const auto bus_stop_area_polygons = goal_planner_utils::getBusStopAreaPolygons(pull_over_lanes);
721+
use_bus_stop_area_ =
722+
parameters_.bus_stop_area.use_bus_stop_area &&
723+
std::any_of(
724+
bus_stop_area_polygons.begin(), bus_stop_area_polygons.end(), [&](const auto & area) {
725+
const auto & goal_position = planner_data_->route_handler->getOriginalGoalPose().position;
726+
return boost::geometry::within(
727+
universe_utils::Point2d{goal_position.x, goal_position.y}, area);
728+
});
729+
goal_candidates_ = generateGoalCandidates(use_bus_stop_area_);
717730
}
718731

719732
const lanelet::ConstLanelets current_lanes =
@@ -982,14 +995,14 @@ bool GoalPlannerModule::canReturnToLaneParking(const PullOverContextData & conte
982995
return true;
983996
}
984997

985-
GoalCandidates GoalPlannerModule::generateGoalCandidates() const
998+
GoalCandidates GoalPlannerModule::generateGoalCandidates(const bool use_bus_stop_area) const
986999
{
9871000
universe_utils::ScopedTimeTrack st(__func__, *time_keeper_);
9881001

9891002
// calculate goal candidates
9901003
const auto & route_handler = planner_data_->route_handler;
9911004
if (utils::isAllowedGoalModification(route_handler)) {
992-
return goal_searcher_->search(planner_data_);
1005+
return goal_searcher_->search(planner_data_, use_bus_stop_area);
9931006
}
9941007

9951008
// NOTE:

planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/src/goal_searcher.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ GoalSearcher::GoalSearcher(
100100
{
101101
}
102102

103-
GoalCandidates GoalSearcher::search(const std::shared_ptr<const PlannerData> & planner_data)
103+
GoalCandidates GoalSearcher::search(
104+
const std::shared_ptr<const PlannerData> & planner_data, const bool use_bus_stop_area)
104105
{
105106
GoalCandidates goal_candidates{};
106107

@@ -118,7 +119,7 @@ GoalCandidates GoalSearcher::search(const std::shared_ptr<const PlannerData> & p
118119
const double forward_length = parameters_.forward_goal_search_length;
119120
const double backward_length = parameters_.backward_goal_search_length;
120121
const double margin_from_boundary = parameters_.margin_from_boundary;
121-
const bool use_bus_stop_area = parameters_.bus_stop_area.use_bus_stop_area;
122+
122123
const double lateral_offset_interval = use_bus_stop_area
123124
? parameters_.bus_stop_area.lateral_offset_interval
124125
: parameters_.lateral_offset_interval;

0 commit comments

Comments
 (0)