Skip to content

Commit

Permalink
fix(behavior_path_planner): add empty guard to combinePath (autowaref…
Browse files Browse the repository at this point in the history
…oundation#5147)

Signed-off-by: kosuke55 <kosuke.tnp@gmail.com>
  • Loading branch information
kosuke55 committed Sep 27, 2023
1 parent 1ce6bde commit 006e09d
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ using geometry_msgs::msg::Twist;
using visualization_msgs::msg::Marker;
using visualization_msgs::msg::MarkerArray;

// TODO(sugahara) move to util
PathWithLaneId combineReferencePath(const PathWithLaneId & path1, const PathWithLaneId & path2);
lanelet::ConstLanelets getPullOverLanes(
const RouteHandler & route_handler, const bool left_side, const double backward_distance,
const double forward_distance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ std::vector<std::vector<int64_t>> getSortedLaneIds(
const RouteHandler & route_handler, const lanelet::ConstLanelets & current_lanes,
const lanelet::ConstLanelets & target_lanes, const double rough_shift_length);

PathWithLaneId combineReferencePath(const PathWithLaneId & path1, const PathWithLaneId & path2);

lanelet::ConstLanelets getTargetPreferredLanes(
const RouteHandler & route_handler, const lanelet::ConstLanelets & current_lanes,
const lanelet::ConstLanelets & target_lanes, const Direction & direction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ PathWithLaneId calcCenterLinePath(
const std::shared_ptr<const PlannerData> & planner_data, const Pose & ref_pose,
const double longest_dist_to_shift_line,
const std::optional<PathWithLaneId> & prev_module_path = std::nullopt);

PathWithLaneId combinePath(const PathWithLaneId & path1, const PathWithLaneId & path2);
} // namespace behavior_path_planner::utils

#endif // BEHAVIOR_PATH_PLANNER__UTILS__PATH_UTILS_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ using geometry_msgs::msg::Pose;
using geometry_msgs::msg::Twist;
using route_handler::RouteHandler;

PathWithLaneId combineReferencePath(const PathWithLaneId path1, const PathWithLaneId path2);
PathWithLaneId getBackwardPath(
const RouteHandler & route_handler, const lanelet::ConstLanelets & target_lanes,
const Pose & current_pose, const Pose & backed_pose, const double velocity);
Expand Down
10 changes: 0 additions & 10 deletions planning/behavior_path_planner/src/utils/goal_planner/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,6 @@ namespace behavior_path_planner
{
namespace goal_planner_utils
{
PathWithLaneId combineReferencePath(const PathWithLaneId & path1, const PathWithLaneId & path2)
{
PathWithLaneId path;
path.points.insert(path.points.end(), path1.points.begin(), path1.points.end());

// skip overlapping point
path.points.insert(path.points.end(), next(path2.points.begin()), path2.points.end());

return path;
}

lanelet::ConstLanelets getPullOverLanes(
const RouteHandler & route_handler, const bool left_side, const double backward_distance,
Expand Down
13 changes: 1 addition & 12 deletions planning/behavior_path_planner/src/utils/lane_change/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,6 @@ std::vector<double> getAccelerationValues(
return sampled_values;
}

PathWithLaneId combineReferencePath(const PathWithLaneId & path1, const PathWithLaneId & path2)
{
PathWithLaneId path;
path.points.insert(path.points.end(), path1.points.begin(), path1.points.end());

// skip overlapping point
path.points.insert(path.points.end(), next(path2.points.begin()), path2.points.end());

return path;
}

lanelet::ConstLanelets getTargetPreferredLanes(
const RouteHandler & route_handler, const lanelet::ConstLanelets & current_lanes,
const lanelet::ConstLanelets & target_lanes, const Direction & direction,
Expand Down Expand Up @@ -289,7 +278,7 @@ std::optional<LaneChangePath> constructCandidatePath(
return std::nullopt;
}

candidate_path.path = combineReferencePath(prepare_segment, shifted_path.path);
candidate_path.path = utils::combinePath(prepare_segment, shifted_path.path);
candidate_path.shifted_path = shifted_path;

return std::optional<LaneChangePath>{candidate_path};
Expand Down
21 changes: 21 additions & 0 deletions planning/behavior_path_planner/src/utils/path_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,4 +538,25 @@ PathWithLaneId calcCenterLinePath(

return centerline_path;
}

PathWithLaneId combinePath(const PathWithLaneId & path1, const PathWithLaneId & path2)
{
if (path1.points.empty()) {
return path2;
}
if (path2.points.empty()) {
return path1;
}

PathWithLaneId path{};
path.points.insert(path.points.end(), path1.points.begin(), path1.points.end());

// skip overlapping point
path.points.insert(path.points.end(), next(path2.points.begin()), path2.points.end());

PathWithLaneId filtered_path = path;
filtered_path.points = motion_utils::removeOverlapPoints(filtered_path.points);
return filtered_path;
}

} // namespace behavior_path_planner::utils
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ boost::optional<PullOutPath> FreespacePullOut::plan(const Pose start_pose, const
const bool path_terminal_is_goal = path_end_info.second;

const auto road_center_line_path = route_handler->getCenterLinePath(road_lanes, s_start, s_end);
last_path = start_planner_utils::combineReferencePath(last_path, road_center_line_path);
last_path =
utils::resamplePathWithSpline(utils::combinePath(last_path, road_center_line_path), 1.0);

const double original_terminal_velocity = last_path.points.back().point.longitudinal_velocity_mps;
utils::correctDividedPathVelocity(partial_paths);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "behavior_path_planner/utils/start_planner/geometric_pull_out.hpp"

#include "behavior_path_planner/utils/path_safety_checker/objects_filtering.hpp"
#include "behavior_path_planner/utils/path_utils.hpp"
#include "behavior_path_planner/utils/start_planner/util.hpp"
#include "behavior_path_planner/utils/utils.hpp"

Expand All @@ -26,7 +27,6 @@ using tier4_autoware_utils::calcDistance2d;
using tier4_autoware_utils::calcOffsetPose;
namespace behavior_path_planner
{
using start_planner_utils::combineReferencePath;
using start_planner_utils::getPullOutLanes;

GeometricPullOut::GeometricPullOut(rclcpp::Node & node, const StartPlannerParameters & parameters)
Expand Down Expand Up @@ -103,7 +103,7 @@ boost::optional<PullOutPath> GeometricPullOut::plan(Pose start_pose, Pose goal_p
std::make_pair(velocity, velocity * velocity / (2 * arc_length_on_second_arc_path)));
} else {
const auto partial_paths = planner_.getPaths();
const auto combined_path = combineReferencePath(partial_paths.at(0), partial_paths.at(1));
const auto combined_path = utils::combinePath(partial_paths.at(0), partial_paths.at(1));
output.partial_paths.push_back(combined_path);

// Calculate the acceleration required to reach the forward parking velocity at the center of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ using tier4_autoware_utils::calcDistance2d;
using tier4_autoware_utils::calcOffsetPose;
namespace behavior_path_planner
{
using start_planner_utils::combineReferencePath;
using start_planner_utils::getPullOutLanes;

ShiftPullOut::ShiftPullOut(
Expand Down
14 changes: 0 additions & 14 deletions planning/behavior_path_planner/src/utils/start_planner/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,6 @@

namespace behavior_path_planner::start_planner_utils
{
using behavior_path_planner::utils::path_safety_checker::EgoPredictedPathParams;
PathWithLaneId combineReferencePath(const PathWithLaneId path1, const PathWithLaneId path2)
{
PathWithLaneId path;
path.points.insert(path.points.end(), path1.points.begin(), path1.points.end());

// skip overlapping point
path.points.insert(path.points.end(), next(path2.points.begin()), path2.points.end());

PathWithLaneId filtered_path = path;
filtered_path.points = motion_utils::removeOverlapPoints(filtered_path.points);
return filtered_path;
}

PathWithLaneId getBackwardPath(
const RouteHandler & route_handler, const lanelet::ConstLanelets & shoulder_lanes,
const Pose & current_pose, const Pose & backed_pose, const double velocity)
Expand Down

0 comments on commit 006e09d

Please sign in to comment.