Skip to content

Commit e8a309f

Browse files
author
beyza
committed
consider all overlap lanelets as a goal lanelet
Signed-off-by: beyza <bnk@leodrive.ai>
1 parent a09b8e5 commit e8a309f

File tree

1 file changed

+30
-21
lines changed

1 file changed

+30
-21
lines changed

planning/mission_planner/src/lanelet2_plugins/default_planner.cpp

+30-21
Original file line numberDiff line numberDiff line change
@@ -334,9 +334,13 @@ bool DefaultPlanner::is_goal_valid(
334334
}
335335
}
336336

337-
lanelet::Lanelet closest_lanelet;
338-
if (!lanelet::utils::query::getClosestLanelet(road_lanelets_, goal, &closest_lanelet)) {
339-
return false;
337+
lanelet::ConstLanelet goal_lanelet;
338+
lanelet::ConstLanelets goal_lanelets;
339+
if (!lanelet::utils::query::getCurrentLanelets(road_lanelets_, goal, &goal_lanelets)) {
340+
if (!lanelet::utils::query::getClosestLanelet(road_lanelets_, goal, &goal_lanelet)) {
341+
return false;
342+
}
343+
goal_lanelets = {goal_lanelet};
340344
}
341345

342346
const auto local_vehicle_footprint = vehicle_info_.createFootprint();
@@ -346,29 +350,34 @@ bool DefaultPlanner::is_goal_valid(
346350
const auto polygon_footprint = convert_linear_ring_to_polygon(goal_footprint);
347351

348352
double next_lane_length = 0.0;
353+
bool is_goal_valid = false;
349354
// combine calculated route lanelets
350355
lanelet::ConstLanelet combined_prev_lanelet = combine_lanelets(path_lanelets);
351356

352357
// check if goal footprint exceeds lane when the goal isn't in parking_lot
353-
if (
354-
param_.check_footprint_inside_lanes &&
355-
!check_goal_footprint(
356-
closest_lanelet, combined_prev_lanelet, polygon_footprint, next_lane_length) &&
357-
!is_in_parking_lot(
358-
lanelet::utils::query::getAllParkingLots(lanelet_map_ptr_),
359-
lanelet::utils::conversion::toLaneletPoint(goal.position))) {
360-
RCLCPP_WARN(logger, "Goal's footprint exceeds lane!");
361-
return false;
362-
}
358+
for (const auto & gl_llt : goal_lanelets) {
359+
if (
360+
param_.check_footprint_inside_lanes &&
361+
!check_goal_footprint(
362+
gl_llt, combined_prev_lanelet, polygon_footprint, next_lane_length) &&
363+
!is_in_parking_lot(
364+
lanelet::utils::query::getAllParkingLots(lanelet_map_ptr_),
365+
lanelet::utils::conversion::toLaneletPoint(goal.position))) {
366+
RCLCPP_WARN(logger, "Goal's footprint exceeds lane!");
367+
is_goal_valid = false;
368+
} else {
369+
is_goal_valid = true;
370+
}
363371

364-
if (is_in_lane(closest_lanelet, goal_lanelet_pt)) {
365-
const auto lane_yaw = lanelet::utils::getLaneletAngle(closest_lanelet, goal.position);
366-
const auto goal_yaw = tf2::getYaw(goal.orientation);
367-
const auto angle_diff = tier4_autoware_utils::normalizeRadian(lane_yaw - goal_yaw);
372+
if (is_in_lane(gl_llt, goal_lanelet_pt)) {
373+
const auto lane_yaw = lanelet::utils::getLaneletAngle(gl_llt, goal.position);
374+
const auto goal_yaw = tf2::getYaw(goal.orientation);
375+
const auto angle_diff = tier4_autoware_utils::normalizeRadian(lane_yaw - goal_yaw);
368376

369-
const double th_angle = tier4_autoware_utils::deg2rad(param_.goal_angle_threshold_deg);
370-
if (std::abs(angle_diff) < th_angle) {
371-
return true;
377+
const double th_angle = tier4_autoware_utils::deg2rad(param_.goal_angle_threshold_deg);
378+
if (std::abs(angle_diff) < th_angle) {
379+
return true;
380+
}
372381
}
373382
}
374383

@@ -384,7 +393,7 @@ bool DefaultPlanner::is_goal_valid(
384393
return true;
385394
}
386395

387-
return false;
396+
return is_goal_valid;
388397
}
389398

390399
PlannerPlugin::LaneletRoute DefaultPlanner::plan(const RoutePoints & points)

0 commit comments

Comments
 (0)