Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(behavior_path_planner): add drivable area information (#3660) #421

Merged
merged 1 commit into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,7 @@ PathWithLaneId refinePathForGoal(

bool containsGoal(const lanelet::ConstLanelets & lanes, const lanelet::Id & goal_id);

PathWithLaneId createGoalAroundPath(
const std::shared_ptr<RouteHandler> & route_handler,
const std::optional<PoseWithUuidStamped> & modified_goal);
BehaviorModuleOutput createGoalAroundPath(const std::shared_ptr<const PlannerData> & planner_data);

bool isInLanelets(const Pose & pose, const lanelet::ConstLanelets & lanes);

Expand Down
6 changes: 1 addition & 5 deletions planning/behavior_path_planner/src/behavior_tree_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,7 @@ BehaviorModuleOutput BehaviorTreeManager::run(const std::shared_ptr<PlannerData>
!is_any_module_running &&
utils::isEgoOutOfRoute(
data->self_odometry->pose.pose, data->prev_modified_goal, data->route_handler)) {
BehaviorModuleOutput output{};
const auto output_path =
utils::createGoalAroundPath(data->route_handler, data->prev_modified_goal);
output.path = std::make_shared<PathWithLaneId>(output_path);
output.reference_path = std::make_shared<PathWithLaneId>(output_path);
BehaviorModuleOutput output = utils::createGoalAroundPath(data);
return output;
}

Expand Down
12 changes: 7 additions & 5 deletions planning/behavior_path_planner/src/planner_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,8 @@ BehaviorModuleOutput PlannerManager::run(const std::shared_ptr<PlannerData> & da
data->self_odometry->pose.pose, data->prev_modified_goal, data->route_handler);

if (!is_any_module_running && is_out_of_route) {
BehaviorModuleOutput output{};
const auto output_path =
utils::createGoalAroundPath(data->route_handler, data->prev_modified_goal);
output.path = std::make_shared<PathWithLaneId>(output_path);
output.reference_path = std::make_shared<PathWithLaneId>(output_path);
BehaviorModuleOutput output = utils::createGoalAroundPath(data);
generateCombinedDrivableArea(output, data);
return output;
}

Expand Down Expand Up @@ -129,6 +126,11 @@ BehaviorModuleOutput PlannerManager::run(const std::shared_ptr<PlannerData> & da
void PlannerManager::generateCombinedDrivableArea(
BehaviorModuleOutput & output, const std::shared_ptr<PlannerData> & data) const
{
if (output.path->points.empty()) {
RCLCPP_ERROR_STREAM(logger_, "[generateCombinedDrivableArea] Output path is empty!");
return;
}

const auto & di = output.drivable_area_info;
constexpr double epsilon = 1e-3;

Expand Down
36 changes: 29 additions & 7 deletions planning/behavior_path_planner/src/utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -936,10 +936,14 @@ bool containsGoal(const lanelet::ConstLanelets & lanes, const lanelet::Id & goal
return false;
}

PathWithLaneId createGoalAroundPath(
const std::shared_ptr<RouteHandler> & route_handler,
const std::optional<PoseWithUuidStamped> & modified_goal)
BehaviorModuleOutput createGoalAroundPath(const std::shared_ptr<const PlannerData> & planner_data)
{
BehaviorModuleOutput output;

const auto & p = planner_data->parameters;
const auto & route_handler = planner_data->route_handler;
const auto & modified_goal = planner_data->prev_modified_goal;

const Pose goal_pose = modified_goal ? modified_goal->pose : route_handler->getGoalPose();
const auto shoulder_lanes = route_handler->getShoulderLanelets();

Expand All @@ -951,16 +955,34 @@ PathWithLaneId createGoalAroundPath(
return !route_handler->getGoalLanelet(&goal_lane);
});
if (is_failed_getting_lanelet) {
PathWithLaneId path{};
return path;
return output;
}

constexpr double backward_length = 1.0;
const auto arc_coord = lanelet::utils::getArcCoordinates({goal_lane}, goal_pose);
const double s_start = std::max(arc_coord.length - backward_length, 0.0);
const double s_end = arc_coord.length;

return route_handler->getCenterLinePath({goal_lane}, s_start, s_end);
auto reference_path = route_handler->getCenterLinePath({goal_lane}, s_start, s_end);

const auto drivable_lanelets = getLaneletsFromPath(reference_path, route_handler);
const auto drivable_lanes = generateDrivableLanes(drivable_lanelets);

const auto & dp = planner_data->drivable_area_expansion_parameters;

const auto shorten_lanes = cutOverlappedLanes(reference_path, drivable_lanes);
const auto expanded_lanes = expandLanelets(
shorten_lanes, dp.drivable_area_left_bound_offset, dp.drivable_area_right_bound_offset,
dp.drivable_area_types_to_skip);

// for old architecture
generateDrivableArea(reference_path, expanded_lanes, false, p.vehicle_length, planner_data);

output.path = std::make_shared<PathWithLaneId>(reference_path);
output.reference_path = std::make_shared<PathWithLaneId>(reference_path);
output.drivable_area_info.drivable_lanes = drivable_lanes;

return output;
}

bool isInLanelets(const Pose & pose, const lanelet::ConstLanelets & lanes)
Expand Down Expand Up @@ -1531,7 +1553,7 @@ void makeBoundLongitudinallyMonotonic(PathWithLaneId & path, const bool is_bound
}
monotonic_bound.push_back(original_bound.at(b_idx));

// caculate bound pose and its laterally offset pose.
// calculate bound pose and its laterally offset pose.
const auto bound_pose = [&]() {
geometry_msgs::msg::Pose pose;
pose.position = original_bound.at(b_idx);
Expand Down