Skip to content

Commit

Permalink
use utils
Browse files Browse the repository at this point in the history
Signed-off-by: kosuke55 <[email protected]>
  • Loading branch information
kosuke55 committed Jan 11, 2024
1 parent f9e82d5 commit 460ad01
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ class ShiftPullOver : public PullOverPlannerBase
protected:
PathWithLaneId generateReferencePath(
const lanelet::ConstLanelets & road_lanes, const Pose & end_pose) const;
std::optional<PathWithLaneId> extendPrevModulePath(
const PathWithLaneId & road_lane_reference_path_to_shift_end, const Pose & shift_end_pose,
const PathWithLaneId & prev_module_path) const;
std::optional<PathWithLaneId> cropPrevModulePath(
const PathWithLaneId & prev_module_path, const Pose & shift_end_pose) const;
std::optional<PullOverPath> generatePullOverPath(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ PathWithLaneId extendPath(
PathWithLaneId extendPath(
const PathWithLaneId & prev_module_path, const PathWithLaneId & reference_path,
const Pose & extend_pose);
std::optional<PathWithLaneId> cropPath(const PathWithLaneId & path, const Pose & end_pose);

// debug
MarkerArray createPullOverAreaMarkerArray(
Expand Down
43 changes: 3 additions & 40 deletions planning/behavior_path_goal_planner_module/src/shift_pull_over.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,43 +99,6 @@ PathWithLaneId ShiftPullOver::generateReferencePath(
return road_lane_reference_path;
}

// generate path after previous module path terminal pose by adding clipped shifted road lane
std::optional<PathWithLaneId> ShiftPullOver::extendPrevModulePath(
const PathWithLaneId & road_lane_reference_path_to_shift_end, const Pose & shift_end_pose,
const PathWithLaneId & prev_module_path) const
{
const auto & ref_path = road_lane_reference_path_to_shift_end;
const auto & prev_path = prev_module_path;
const auto & prev_terminal_pose = prev_path.points.back().point.pose;

// generate clipped road lane reference path from previous module path terminal pose to shift end
const size_t prev_module_path_terminal_idx =
motion_utils::findNearestSegmentIndex(ref_path.points, prev_terminal_pose.position) + 1;
const double distance_to_terminal_to_shift_end = motion_utils::calcSignedArcLength(
ref_path.points, prev_module_path_terminal_idx, shift_end_pose.position);
PathWithLaneId clipped_path{};
clipped_path.points = motion_utils::cropPoints(
ref_path.points, prev_terminal_pose.position, prev_module_path_terminal_idx,
distance_to_terminal_to_shift_end, 0.0);

// shift clipped path to previous module path terminal pose
const double lateral_shift_from_reference_path =
motion_utils::calcLateralOffset(ref_path.points, prev_terminal_pose.position);
for (auto & p : clipped_path.points) {
p.point.pose =
tier4_autoware_utils::calcOffsetPose(p.point.pose, 0, lateral_shift_from_reference_path, 0);
}

auto extended_prev_module_path = prev_module_path;
for (const auto & p : clipped_path.points) {
extended_prev_module_path.points.push_back(p);
}
extended_prev_module_path.points =
motion_utils::removeOverlapPoints(extended_prev_module_path.points);

return extended_prev_module_path;
}

std::optional<PathWithLaneId> ShiftPullOver::cropPrevModulePath(

Check warning on line 102 in planning/behavior_path_goal_planner_module/src/shift_pull_over.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/shift_pull_over.cpp#L102

Added line #L102 was not covered by tests
const PathWithLaneId & prev_module_path, const Pose & shift_end_pose) const
{
Expand Down Expand Up @@ -187,10 +150,10 @@ std::optional<PullOverPath> ShiftPullOver::generatePullOverPath(
lanelet::utils::getArcCoordinates(road_lanes, shift_end_pose).length >
lanelet::utils::getArcCoordinates(road_lanes, prev_module_path_terminal_pose).length;
if (extend_previous_module_path) { // case1
return extendPrevModulePath(
road_lane_reference_path_to_shift_end, shift_end_pose, prev_module_path);
return goal_planner_utils::extendPath(
prev_module_path, road_lane_reference_path_to_shift_end, shift_end_pose);

Check warning on line 154 in planning/behavior_path_goal_planner_module/src/shift_pull_over.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/shift_pull_over.cpp#L150-L154

Added lines #L150 - L154 were not covered by tests
} else { // case2
return cropPrevModulePath(prev_module_path, shift_end_pose);
return goal_planner_utils::cropPath(prev_module_path, shift_end_pose);

Check warning on line 156 in planning/behavior_path_goal_planner_module/src/shift_pull_over.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/shift_pull_over.cpp#L156

Added line #L156 was not covered by tests
}
});
if (!processed_prev_module_path || processed_prev_module_path->points.empty()) {

Check warning on line 159 in planning/behavior_path_goal_planner_module/src/shift_pull_over.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/shift_pull_over.cpp#L158-L159

Added lines #L158 - L159 were not covered by tests
Expand Down
23 changes: 23 additions & 0 deletions planning/behavior_path_goal_planner_module/src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,4 +282,27 @@ PathWithLaneId extendPath(
return extendPath(reference_path, target_path, extend_distance);

Check warning on line 282 in planning/behavior_path_goal_planner_module/src/util.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/util.cpp#L282

Added line #L282 was not covered by tests
}

std::optional<PathWithLaneId> cropPath(const PathWithLaneId & path, const Pose & end_pose)

Check warning on line 285 in planning/behavior_path_goal_planner_module/src/util.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/util.cpp#L285

Added line #L285 was not covered by tests
{
const size_t shift_end_idx =
motion_utils::findNearestSegmentIndex(path.points, end_pose.position);

Check warning on line 288 in planning/behavior_path_goal_planner_module/src/util.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/util.cpp#L288

Added line #L288 was not covered by tests
std::vector<PathPointWithLaneId> clipped_points{
path.points.begin(), path.points.begin() + shift_end_idx};
if (clipped_points.empty()) {
return std::nullopt;

Check warning on line 292 in planning/behavior_path_goal_planner_module/src/util.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/util.cpp#L290-L292

Added lines #L290 - L292 were not covered by tests
}

// add projected shift end pose to clipped points
PathPointWithLaneId projected_point = clipped_points.back();
const double offset =
motion_utils::calcSignedArcLength(path.points, shift_end_idx, end_pose.position);

Check warning on line 298 in planning/behavior_path_goal_planner_module/src/util.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/util.cpp#L298

Added line #L298 was not covered by tests
projected_point.point.pose =
tier4_autoware_utils::calcOffsetPose(clipped_points.back().point.pose, offset, 0, 0);
clipped_points.push_back(projected_point);
auto clipped_path = path;
clipped_path.points = clipped_points;

Check warning on line 303 in planning/behavior_path_goal_planner_module/src/util.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/util.cpp#L300-L303

Added lines #L300 - L303 were not covered by tests

return clipped_path;
}

Check warning on line 306 in planning/behavior_path_goal_planner_module/src/util.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_goal_planner_module/src/util.cpp#L306

Added line #L306 was not covered by tests

} // namespace behavior_path_planner::goal_planner_utils

0 comments on commit 460ad01

Please sign in to comment.