From 4d4d6e367b909d3bf512ba538c4af349eab15478 Mon Sep 17 00:00:00 2001 From: kosuke55 Date: Mon, 18 Nov 2024 17:46:32 +0900 Subject: [PATCH] fix(goal_planner): fix multiple lane ids of shift pull over Signed-off-by: kosuke55 fix vel --- .../src/pull_over_planner/shift_pull_over.cpp | 36 +++++++++---------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/src/pull_over_planner/shift_pull_over.cpp b/planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/src/pull_over_planner/shift_pull_over.cpp index f70dbbd9c1e50..5d38b1188d2ee 100644 --- a/planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/src/pull_over_planner/shift_pull_over.cpp +++ b/planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/src/pull_over_planner/shift_pull_over.cpp @@ -221,14 +221,23 @@ std::optional ShiftPullOver::generatePullOverPath( shifted_path.path.points.push_back(p); } + // combine road lanes and shoulder lanes to find closest lanelet id + const auto lanes = std::invoke([&]() -> lanelet::ConstLanelets { + auto lanes = road_lanes; + lanes.insert(lanes.end(), shoulder_lanes.begin(), shoulder_lanes.end()); + return std::move(lanes); + }); + // set goal pose with velocity 0 { PathPointWithLaneId p{}; p.point.longitudinal_velocity_mps = 0.0; p.point.pose = goal_pose; - p.lane_ids = shifted_path.path.points.back().lane_ids; - for (const auto & lane : shoulder_lanes) { - p.lane_ids.push_back(lane.id()); + lanelet::Lanelet goal_lanelet{}; + if (lanelet::utils::query::getClosestLanelet(lanes, goal_pose, &goal_lanelet)) { + p.lane_ids = {goal_lanelet.id()}; + } else { + p.lane_ids = shifted_path.path.points.back().lane_ids; } shifted_path.path.points.push_back(p); } @@ -237,24 +246,13 @@ std::optional ShiftPullOver::generatePullOverPath( for (size_t i = path_shifter.getShiftLines().front().start_idx; i < shifted_path.path.points.size() - 1; ++i) { auto & point = shifted_path.path.points.at(i); - // set velocity point.point.longitudinal_velocity_mps = std::min(point.point.longitudinal_velocity_mps, static_cast(pull_over_velocity)); - - // add target lanes to points after shift start - // add road lane_ids if not found - for (const auto id : shifted_path.path.points.back().lane_ids) { - if (std::find(point.lane_ids.begin(), point.lane_ids.end(), id) == point.lane_ids.end()) { - point.lane_ids.push_back(id); - } - } - // add shoulder lane_id if not found - for (const auto & lane : shoulder_lanes) { - if ( - std::find(point.lane_ids.begin(), point.lane_ids.end(), lane.id()) == - point.lane_ids.end()) { - point.lane_ids.push_back(lane.id()); - } + lanelet::Lanelet lanelet{}; + if (lanelet::utils::query::getClosestLanelet(lanes, point.point.pose, &lanelet)) { + point.lane_ids = {lanelet.id()}; // overwrite lane_ids + } else { + point.lane_ids = shifted_path.path.points.at(i - 1).lane_ids; } }