|
17 | 17 | #include "autoware/behavior_path_planner_common/utils/parking_departure/utils.hpp"
|
18 | 18 | #include "autoware/behavior_path_planner_common/utils/path_utils.hpp"
|
19 | 19 | #include "autoware/behavior_path_planner_common/utils/utils.hpp"
|
| 20 | +#include "autoware/motion_utils/trajectory/trajectory.hpp" |
20 | 21 | #include "autoware/universe_utils/geometry/geometry.hpp"
|
21 | 22 | #include "autoware/universe_utils/math/unit_conversion.hpp"
|
22 | 23 |
|
23 | 24 | #include <interpolation/spline_interpolation.hpp>
|
| 25 | +#include <lanelet2_extension/utility/query.hpp> |
24 | 26 | #include <lanelet2_extension/utility/utilities.hpp>
|
25 | 27 |
|
26 | 28 | #include <boost/geometry/algorithms/within.hpp>
|
@@ -333,8 +335,20 @@ std::optional<Pose> GeometricParallelParking::calcStartPose(
|
333 | 335 | }
|
334 | 336 | const double dx_sign = is_forward ? -1 : 1;
|
335 | 337 | 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); |
338 | 352 |
|
339 | 353 | return start_pose;
|
340 | 354 | }
|
|
0 commit comments