Skip to content

Commit

Permalink
fix(behavior_path_planner): save original route goal pose (#4876)
Browse files Browse the repository at this point in the history
* fix(behavior_path_planner): save original route goal pose

Signed-off-by: kosuke55 <[email protected]>

* fix return

Signed-off-by: kosuke55 <[email protected]>

---------

Signed-off-by: kosuke55 <[email protected]>
  • Loading branch information
kosuke55 authored Sep 5, 2023
1 parent 46a263c commit 30ec8f7
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ bool GoalPlannerModule::isExecutionRequested() const

const auto & route_handler = planner_data_->route_handler;
const Pose & current_pose = planner_data_->self_odometry->pose.pose;
const Pose & goal_pose = route_handler->getGoalPose();
const Pose & goal_pose = route_handler->getOriginalGoalPose();

// check if goal_pose is in current_lanes.
lanelet::ConstLanelet current_lane{};
Expand Down Expand Up @@ -511,7 +511,7 @@ void GoalPlannerModule::generateGoalCandidates()
}

// calculate goal candidates
const Pose goal_pose = route_handler->getGoalPose();
const Pose goal_pose = route_handler->getOriginalGoalPose();
refined_goal_pose_ = calcRefinedGoal(goal_pose);
if (goal_planner_utils::isAllowedGoalModification(route_handler)) {
goal_searcher_->setPlannerData(planner_data_);
Expand Down Expand Up @@ -1548,7 +1548,7 @@ void GoalPlannerModule::printParkingPositionError() const
bool GoalPlannerModule::checkOriginalGoalIsInShoulder() const
{
const auto & route_handler = planner_data_->route_handler;
const Pose & goal_pose = route_handler->getGoalPose();
const Pose & goal_pose = route_handler->getOriginalGoalPose();

const lanelet::ConstLanelets pull_over_lanes =
goal_planner_utils::getPullOverLanes(*(route_handler), left_side_parking_);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ PathWithLaneId combineReferencePath(const PathWithLaneId & path1, const PathWith

lanelet::ConstLanelets getPullOverLanes(const RouteHandler & route_handler, const bool left_side)
{
const Pose goal_pose = route_handler.getGoalPose();
const Pose goal_pose = route_handler.getOriginalGoalPose();

lanelet::ConstLanelet target_shoulder_lane{};
if (route_handler::RouteHandler::getPullOverTarget(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class RouteHandler
Pose getGoalPose() const;
Pose getStartPose() const;
Pose getOriginalStartPose() const;
Pose getOriginalGoalPose() const;
lanelet::Id getGoalLaneId() const;
bool getGoalLanelet(lanelet::ConstLanelet * goal_lanelet) const;
std::vector<lanelet::ConstLanelet> getLanesBeforePose(
Expand Down Expand Up @@ -378,6 +379,7 @@ class RouteHandler

// save original(not modified) route start pose for start planer execution
Pose original_start_pose_;
Pose original_goal_pose_;

// non-const methods
void setLaneletsFromRouteMsg();
Expand Down
14 changes: 14 additions & 0 deletions planning/route_handler/src/route_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ void RouteHandler::setRoute(const LaneletRoute & route_msg)
// if get not modified route but new route, reset original start pose
if (!route_ptr_ || route_ptr_->uuid != route_msg.uuid) {
original_start_pose_ = route_msg.start_pose;
original_goal_pose_ = route_msg.goal_pose;
}
route_ptr_ = std::make_shared<LaneletRoute>(route_msg);
is_handler_ready_ = false;
Expand Down Expand Up @@ -433,6 +434,10 @@ Pose RouteHandler::getStartPose() const

Pose RouteHandler::getOriginalStartPose() const
{
if (!route_ptr_) {
RCLCPP_WARN(logger_, "[Route Handler] getOriginalStartPose: Route has not been set yet");
return Pose();
}
return original_start_pose_;
}

Expand All @@ -445,6 +450,15 @@ Pose RouteHandler::getGoalPose() const
return route_ptr_->goal_pose;
}

Pose RouteHandler::getOriginalGoalPose() const
{
if (!route_ptr_) {
RCLCPP_WARN(logger_, "[Route Handler] getOriginalGoalPose: Route has not been set yet");
return Pose();
}
return original_goal_pose_;
}

lanelet::Id RouteHandler::getGoalLaneId() const
{
if (!route_ptr_ || route_ptr_->segments.empty()) {
Expand Down

0 comments on commit 30ec8f7

Please sign in to comment.