Skip to content

Commit 568a02d

Browse files
committed
use route_handler to get the left/right shoulder lanelet
Signed-off-by: Maxime CLEMENT <maxime.clement@tier4.jp>
1 parent 5c1b948 commit 568a02d

File tree

3 files changed

+18
-30
lines changed

3 files changed

+18
-30
lines changed

planning/mission_planner/src/lanelet2_plugins/default_planner.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ bool DefaultPlanner::check_goal_footprint_inside_lanes(
281281
lanelets.push_back(combined_prev_lanelet);
282282
lanelets.push_back(next_lane);
283283
lanelet::ConstLanelet combined_lanelets =
284-
combine_lanelets_with_shoulder(lanelets, shoulder_lanelets_);
284+
combine_lanelets_with_shoulder(lanelets, route_handler_);
285285

286286
// if next lanelet length is longer than vehicle longitudinal offset
287287
if (vehicle_info_.max_longitudinal_offset_m + search_margin < next_lane_length) {
@@ -352,7 +352,7 @@ bool DefaultPlanner::is_goal_valid(
352352
double next_lane_length = 0.0;
353353
// combine calculated route lanelets
354354
const lanelet::ConstLanelet combined_prev_lanelet =
355-
combine_lanelets_with_shoulder(path_lanelets, shoulder_lanelets_);
355+
combine_lanelets_with_shoulder(path_lanelets, route_handler_);
356356

357357
// check if goal footprint exceeds lane when the goal isn't in parking_lot
358358
if (

planning/mission_planner/src/lanelet2_plugins/utility_functions.cpp

+13-26
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void insert_marker_array(
4242
}
4343

4444
lanelet::ConstLanelet combine_lanelets_with_shoulder(
45-
const lanelet::ConstLanelets & lanelets, const lanelet::ConstLanelets & shoulder_lanelets)
45+
const lanelet::ConstLanelets & lanelets, const route_handler::RouteHandler & route_handler)
4646
{
4747
lanelet::Points3d lefts;
4848
lanelet::Points3d rights;
@@ -57,30 +57,18 @@ lanelet::ConstLanelet combine_lanelets_with_shoulder(
5757
}
5858
}
5959

60+
// lambda to add bound to target_bound
61+
const auto add_bound = [](const auto & bound, auto & target_bound) {
62+
std::transform(
63+
bound.begin(), bound.end(), std::back_inserter(target_bound),
64+
[](const auto & pt) { return lanelet::Point3d(pt); });
65+
};
6066
for (const auto & llt : lanelets) {
61-
// lambda to check if shoulder lane which share left bound with lanelets exist
62-
const auto find_bound_shared_shoulder =
63-
[&shoulder_lanelets](const auto & lanelet_bound, const auto & get_shoulder_bound) {
64-
return std::find_if(
65-
shoulder_lanelets.begin(), shoulder_lanelets.end(),
66-
[&lanelet_bound, &get_shoulder_bound](const auto & shoulder_llt) {
67-
return lanelet_bound.id() == get_shoulder_bound(shoulder_llt).id();
68-
});
69-
};
70-
71-
// lambda to add bound to target_bound
72-
const auto add_bound = [](const auto & bound, auto & target_bound) {
73-
std::transform(
74-
bound.begin(), bound.end(), std::back_inserter(target_bound),
75-
[](const auto & pt) { return lanelet::Point3d(pt); });
76-
};
77-
7867
// check if shoulder lanelets which has RIGHT bound same to LEFT bound of lanelet exist
79-
const auto left_shared_shoulder_it = find_bound_shared_shoulder(
80-
llt.leftBound(), [](const auto & shoulder_llt) { return shoulder_llt.rightBound(); });
81-
if (left_shared_shoulder_it != shoulder_lanelets.end()) {
68+
const auto left_shared_shoulder = route_handler.getLeftShoulderLanelet(llt);
69+
if (left_shared_shoulder) {
8270
// if exist, add left bound of SHOULDER lanelet to lefts
83-
add_bound(left_shared_shoulder_it->leftBound(), lefts);
71+
add_bound(left_shared_shoulder->leftBound(), lefts);
8472
} else if (
8573
// if not exist, add left bound of lanelet to lefts
8674
// if the **left** of this lanelet does not match any of the **right** bounds of `lanelets`,
@@ -90,11 +78,10 @@ lanelet::ConstLanelet combine_lanelets_with_shoulder(
9078
}
9179

9280
// check if shoulder lanelets which has LEFT bound same to RIGHT bound of lanelet exist
93-
const auto right_shared_shoulder_it = find_bound_shared_shoulder(
94-
llt.rightBound(), [](const auto & shoulder_llt) { return shoulder_llt.leftBound(); });
95-
if (right_shared_shoulder_it != shoulder_lanelets.end()) {
81+
const auto right_shared_shoulder = route_handler.getRightShoulderLanelet(llt);
82+
if (right_shared_shoulder) {
9683
// if exist, add right bound of SHOULDER lanelet to rights
97-
add_bound(right_shared_shoulder_it->rightBound(), rights);
84+
add_bound(right_shared_shoulder->rightBound(), rights);
9885
} else if (
9986
// if not exist, add right bound of lanelet to rights
10087
// if the **right** of this lanelet does not match any of the **left** bounds of `lanelets`,

planning/mission_planner/src/lanelet2_plugins/utility_functions.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#define LANELET2_PLUGINS__UTILITY_FUNCTIONS_HPP_
1717

1818
#include <rclcpp/rclcpp.hpp>
19+
#include <route_handler/route_handler.hpp>
1920
#include <tier4_autoware_utils/geometry/geometry.hpp>
2021
#include <vehicle_info_util/vehicle_info_util.hpp>
2122

@@ -50,10 +51,10 @@ void insert_marker_array(
5051
* @brief create a single merged lanelet whose left/right bounds consist of the leftmost/rightmost
5152
* bound of the original lanelets or the left/right bound of its adjacent road_shoulder respectively
5253
* @param lanelets topologically sorted sequence of lanelets
53-
* @param shoulder_lanelets list of possible road_shoulder lanelets to combine with lanelets
54+
* @param route_handler route handler to query the lanelet map
5455
*/
5556
lanelet::ConstLanelet combine_lanelets_with_shoulder(
56-
const lanelet::ConstLanelets & lanelets, const lanelet::ConstLanelets & shoulder_lanelets);
57+
const lanelet::ConstLanelets & lanelets, const route_handler::RouteHandler & route_handler);
5758

5859
std::vector<geometry_msgs::msg::Point> convertCenterlineToPoints(const lanelet::Lanelet & lanelet);
5960
geometry_msgs::msg::Pose convertBasicPoint3dToPose(

0 commit comments

Comments
 (0)