Skip to content

Commit 407e186

Browse files
committed
fix(start/goal_planner): align geometric parall parking start pose with center line (autowarefoundation#8326)
Signed-off-by: kosuke55 <kosuke.tnp@gmail.com>
1 parent 0e539d1 commit 407e186

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

planning/behavior_path_planner/autoware_behavior_path_planner_common/src/utils/parking_departure/geometric_parallel_parking.cpp

+16-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717
#include "autoware/behavior_path_planner_common/utils/parking_departure/utils.hpp"
1818
#include "autoware/behavior_path_planner_common/utils/path_utils.hpp"
1919
#include "autoware/behavior_path_planner_common/utils/utils.hpp"
20+
#include "autoware/motion_utils/trajectory/trajectory.hpp"
2021
#include "autoware/universe_utils/geometry/geometry.hpp"
2122
#include "autoware/universe_utils/math/unit_conversion.hpp"
2223

2324
#include <interpolation/spline_interpolation.hpp>
25+
#include <lanelet2_extension/utility/query.hpp>
2426
#include <lanelet2_extension/utility/utilities.hpp>
2527

2628
#include <boost/geometry/algorithms/within.hpp>
@@ -333,8 +335,20 @@ std::optional<Pose> GeometricParallelParking::calcStartPose(
333335
}
334336
const double dx_sign = is_forward ? -1 : 1;
335337
const double dx = 2 * std::sqrt(squared_distance_to_arc_connect) * dx_sign;
336-
const Pose start_pose =
337-
calcOffsetPose(goal_pose, dx + start_pose_offset, -arc_coordinates.distance, 0);
338+
339+
// Assuming parallel poses, calculate the approximate start pose on the centerline from the goal
340+
// pose
341+
const Pose approximate_start_pose = calcOffsetPose(goal_pose, dx, -arc_coordinates.distance, 0);
342+
lanelet::ConstLanelet closest_road_lane{};
343+
344+
// Calculate start pose on the centerline, then offset it.
345+
lanelet::utils::query::getClosestLanelet(road_lanes, approximate_start_pose, &closest_road_lane);
346+
const Pose start_pose_no_offset =
347+
lanelet::utils::getClosestCenterPose(closest_road_lane, approximate_start_pose.position);
348+
const auto road_lane_path = planner_data_->route_handler->getCenterLinePath(
349+
road_lanes, 0.0, std::numeric_limits<double>::max());
350+
const auto start_pose = autoware::motion_utils::calcLongitudinalOffsetPose(
351+
road_lane_path.points, start_pose_no_offset.position, start_pose_offset);
338352

339353
return start_pose;
340354
}

0 commit comments

Comments
 (0)