Skip to content

Commit

Permalink
feat(goal_planner): ensure stop while path candidates are empty (auto…
Browse files Browse the repository at this point in the history
…warefoundation#10101)

Signed-off-by: Mamoru Sobue <mamoru.sobue@tier4.jp>
  • Loading branch information
soblin committed Feb 12, 2025
1 parent 6efa878 commit 4eef2c7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class GoalSearcher

// todo(kosuke55): Functions for this specific use should not be in the interface,
// so it is better to consider interface design when we implement other goal searchers.
GoalCandidate getClosetGoalCandidateAlongLanes(
std::optional<GoalCandidate> getClosestGoalCandidateAlongLanes(
const GoalCandidates & goal_candidates,
const std::shared_ptr<const PlannerData> & planner_data) const;
bool isSafeGoalWithMarginScaleFactor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1464,7 +1464,9 @@ BehaviorModuleOutput GoalPlannerModule::planPullOverAsCandidate(

// if pull over path candidates generation is not finished, use previous module output
if (context_data.lane_parking_response.pull_over_path_candidates.empty()) {
return getPreviousModuleOutput();
auto stop_path = getPreviousModuleOutput();
stop_path.path = generateStopPath(context_data, detail);
return stop_path;
}

BehaviorModuleOutput output{};
Expand Down Expand Up @@ -1735,11 +1737,13 @@ PathWithLaneId GoalPlannerModule::generateStopPath(
// calculate search start offset pose from the closest goal candidate pose with
// approximate_pull_over_distance_ ego vehicle decelerates to this position. or if no feasible
// stop point is found, stop at this position.
const auto closest_goal_candidate =
goal_searcher.getClosetGoalCandidateAlongLanes(goal_candidates_, planner_data_);
const auto closest_searched_goal_candidate =
goal_searcher.getClosestGoalCandidateAlongLanes(goal_candidates_, planner_data_);
const auto closest_goal_candidate = closest_searched_goal_candidate
? closest_searched_goal_candidate.value().goal_pose
: route_handler->getOriginalGoalPose();
const auto decel_pose = calcLongitudinalOffsetPose(
extended_prev_path.points, closest_goal_candidate.goal_pose.position,
-approximate_pull_over_distance_);
extended_prev_path.points, closest_goal_candidate.position, -approximate_pull_over_distance_);

// if not approved stop road lane.
// stop point priority is
Expand Down Expand Up @@ -2066,12 +2070,18 @@ double GoalPlannerModule::calcSignedArcLengthFromEgo(
void GoalPlannerModule::deceleratePath(PullOverPath & pull_over_path) const
{
universe_utils::ScopedTimeTrack st(__func__, *time_keeper_);
assert(goal_searcher_);
const auto & goal_searcher = goal_searcher_.value();

// decelerate before the search area start
const auto closest_goal_candidate =
goal_searcher_->getClosetGoalCandidateAlongLanes(goal_candidates_, planner_data_);
const auto & route_handler = planner_data_->route_handler;
const auto closest_searched_goal_candidate =
goal_searcher.getClosestGoalCandidateAlongLanes(goal_candidates_, planner_data_);
const auto closest_goal_candidate = closest_searched_goal_candidate
? closest_searched_goal_candidate.value().goal_pose
: route_handler->getOriginalGoalPose();
const auto decel_pose = calcLongitudinalOffsetPose(
pull_over_path.full_path().points, closest_goal_candidate.goal_pose.position,
pull_over_path.full_path().points, closest_goal_candidate.position,
-approximate_pull_over_distance_);
auto & first_path = pull_over_path.partial_paths().front();
if (decel_pose) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ void GoalSearcher::createAreaPolygons(
}
}

GoalCandidate GoalSearcher::getClosetGoalCandidateAlongLanes(
std::optional<GoalCandidate> GoalSearcher::getClosestGoalCandidateAlongLanes(
const GoalCandidates & goal_candidates,
const std::shared_ptr<const PlannerData> & planner_data) const
{
Expand Down

0 comments on commit 4eef2c7

Please sign in to comment.