Skip to content

Commit

Permalink
feat(behavior_path_planner): add getCurrentLanes with length args (#4108
Browse files Browse the repository at this point in the history
)

Signed-off-by: kosuke55 <kosuke.tnp@gmail.com>
  • Loading branch information
kosuke55 authored Jun 28, 2023
1 parent 1b69779 commit 2919364
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,9 @@ BehaviorModuleOutput getReferencePath(
// object label
std::uint8_t getHighestProbLabel(const std::vector<ObjectClassification> & classification);

lanelet::ConstLanelets getCurrentLanes(
const std::shared_ptr<const PlannerData> & planner_data, const double backward_path_length,
const double forward_path_length);
lanelet::ConstLanelets getCurrentLanes(const std::shared_ptr<const PlannerData> & planner_data);

lanelet::ConstLanelets getCurrentLanesFromPath(
Expand Down
21 changes: 15 additions & 6 deletions planning/behavior_path_planner/src/utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2573,23 +2573,32 @@ std::uint8_t getHighestProbLabel(const std::vector<ObjectClassification> & class
return label;
}

lanelet::ConstLanelets getCurrentLanes(const std::shared_ptr<const PlannerData> & planner_data)
lanelet::ConstLanelets getCurrentLanes(
const std::shared_ptr<const PlannerData> & planner_data, const double backward_path_length,
const double forward_path_length)
{
const auto & route_handler = planner_data->route_handler;
const auto current_pose = planner_data->self_odometry->pose.pose;
const auto & common_parameters = planner_data->parameters;

lanelet::ConstLanelet current_lane;
if (!route_handler->getClosestLaneletWithinRoute(current_pose, &current_lane)) {
// RCLCPP_ERROR(getLogger(), "failed to find closest lanelet within route!!!");
std::cerr << "failed to find closest lanelet within route!!!" << std::endl;
auto clock{rclcpp::Clock{RCL_ROS_TIME}};
RCLCPP_ERROR_STREAM_THROTTLE(
rclcpp::get_logger("behavior_path_planner").get_child("utils"), clock, 1000,
"failed to find closest lanelet within route!!!");
return {}; // TODO(Horibe) what should be returned?
}

// For current_lanes with desired length
return route_handler->getLaneletSequence(
current_lane, current_pose, common_parameters.backward_path_length,
common_parameters.forward_path_length);
current_lane, current_pose, backward_path_length, forward_path_length);
}

lanelet::ConstLanelets getCurrentLanes(const std::shared_ptr<const PlannerData> & planner_data)
{
const auto & common_parameters = planner_data->parameters;
return getCurrentLanes(
planner_data, common_parameters.backward_path_length, common_parameters.forward_path_length);
}

lanelet::ConstLanelets getCurrentLanesFromPath(
Expand Down

0 comments on commit 2919364

Please sign in to comment.