Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit de66bf6

Browse files
authoredMay 8, 2024
perf(route_handler): simplify queries on the road and shoulder lanelets (autowarefoundation#6885)
Signed-off-by: Maxime CLEMENT <maxime.clement@tier4.jp>
1 parent d2250ab commit de66bf6

File tree

3 files changed

+13
-35
lines changed

3 files changed

+13
-35
lines changed
 

‎planning/behavior_path_planner_common/src/utils/path_safety_checker/objects_filtering.cpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -354,11 +354,9 @@ TargetObjectsOnLane createTargetObjectsOnLane(
354354
};
355355

356356
const auto update_left_shoulder_lanelet = [&](const lanelet::ConstLanelet & target_lane) {
357-
lanelet::ConstLanelet neighbor_shoulder_lane{};
358-
const bool shoulder_lane_is_found =
359-
route_handler->getLeftShoulderLanelet(target_lane, &neighbor_shoulder_lane);
360-
if (shoulder_lane_is_found) {
361-
all_left_shoulder_lanelets.insert(all_left_shoulder_lanelets.end(), neighbor_shoulder_lane);
357+
const auto neighbor_shoulder_lane = route_handler->getLeftShoulderLanelet(target_lane);
358+
if (neighbor_shoulder_lane) {
359+
all_left_shoulder_lanelets.insert(all_left_shoulder_lanelets.end(), *neighbor_shoulder_lane);
362360
}
363361
};
364362

‎planning/behavior_path_planner_common/src/utils/path_utils.cpp

+4-7
Original file line numberDiff line numberDiff line change
@@ -645,15 +645,12 @@ BehaviorModuleOutput createGoalAroundPath(const std::shared_ptr<const PlannerDat
645645
const auto & modified_goal = planner_data->prev_modified_goal;
646646

647647
const Pose goal_pose = modified_goal ? modified_goal->pose : route_handler->getGoalPose();
648-
const auto shoulder_lanes = route_handler->getShoulderLanelets();
649648

650649
lanelet::ConstLanelet goal_lane;
651-
const bool is_failed_getting_lanelet = std::invoke([&]() {
652-
if (isInLanelets(goal_pose, shoulder_lanes)) {
653-
return !lanelet::utils::query::getClosestLanelet(shoulder_lanes, goal_pose, &goal_lane);
654-
}
655-
return !route_handler->getGoalLanelet(&goal_lane);
656-
});
650+
const auto shoulder_goal_lanes = route_handler->getShoulderLaneletsAtPose(goal_pose);
651+
if (!shoulder_goal_lanes.empty()) goal_lane = shoulder_goal_lanes.front();
652+
const auto is_failed_getting_lanelet =
653+
shoulder_goal_lanes.empty() && !route_handler->getGoalLanelet(&goal_lane);
657654
if (is_failed_getting_lanelet) {
658655
return output;
659656
}

‎planning/behavior_path_planner_common/src/utils/utils.cpp

+6-23
Original file line numberDiff line numberDiff line change
@@ -496,15 +496,12 @@ bool isEgoOutOfRoute(
496496
const Pose & goal_pose = (modified_goal && modified_goal->uuid == route_handler->getRouteUuid())
497497
? modified_goal->pose
498498
: route_handler->getGoalPose();
499-
const auto shoulder_lanes = route_handler->getShoulderLanelets();
500499

501500
lanelet::ConstLanelet goal_lane;
502-
const bool is_failed_getting_lanelet = std::invoke([&]() {
503-
if (utils::isInLanelets(goal_pose, shoulder_lanes)) {
504-
return !lanelet::utils::query::getClosestLanelet(shoulder_lanes, goal_pose, &goal_lane);
505-
}
506-
return !route_handler->getGoalLanelet(&goal_lane);
507-
});
501+
const auto shoulder_goal_lanes = route_handler->getShoulderLaneletsAtPose(goal_pose);
502+
if (!shoulder_goal_lanes.empty()) goal_lane = shoulder_goal_lanes.front();
503+
const auto is_failed_getting_lanelet =
504+
shoulder_goal_lanes.empty() && !route_handler->getGoalLanelet(&goal_lane);
508505
if (is_failed_getting_lanelet) {
509506
RCLCPP_WARN_STREAM(
510507
rclcpp::get_logger("behavior_path_planner").get_child("util"), "cannot find goal lanelet");
@@ -527,14 +524,7 @@ bool isEgoOutOfRoute(
527524

528525
// If ego vehicle is out of the closest lanelet, return true
529526
// Check if ego vehicle is in shoulder lane
530-
const bool is_in_shoulder_lane = std::invoke([&]() {
531-
lanelet::Lanelet closest_shoulder_lanelet;
532-
if (!lanelet::utils::query::getClosestLanelet(
533-
shoulder_lanes, self_pose, &closest_shoulder_lanelet)) {
534-
return false;
535-
}
536-
return lanelet::utils::isInLanelet(self_pose, closest_shoulder_lanelet);
537-
});
527+
const bool is_in_shoulder_lane = !route_handler->getShoulderLaneletsAtPose(self_pose).empty();
538528
// Check if ego vehicle is in road lane
539529
const bool is_in_road_lane = std::invoke([&]() {
540530
lanelet::ConstLanelet closest_road_lane;
@@ -1662,13 +1652,6 @@ bool isAllowedGoalModification(const std::shared_ptr<RouteHandler> & route_handl
16621652
bool checkOriginalGoalIsInShoulder(const std::shared_ptr<RouteHandler> & route_handler)
16631653
{
16641654
const Pose & goal_pose = route_handler->getOriginalGoalPose();
1665-
const auto shoulder_lanes = route_handler->getShoulderLanelets();
1666-
1667-
lanelet::ConstLanelet closest_shoulder_lane{};
1668-
if (lanelet::utils::query::getClosestLanelet(shoulder_lanes, goal_pose, &closest_shoulder_lane)) {
1669-
return lanelet::utils::isInLanelet(goal_pose, closest_shoulder_lane, 0.1);
1670-
}
1671-
1672-
return false;
1655+
return !route_handler->getShoulderLaneletsAtPose(goal_pose).empty();
16731656
}
16741657
} // namespace behavior_path_planner::utils

0 commit comments

Comments
 (0)
Please sign in to comment.