Skip to content

Commit 45de1e4

Browse files
authoredMar 24, 2025
Merge branch 'main' into fix/autoware_ekf_localizer
2 parents 6d7044e + 81d8f9d commit 45de1e4

File tree

5 files changed

+410
-125
lines changed

5 files changed

+410
-125
lines changed
 

‎planning/autoware_path_generator/include/autoware/path_generator/utils.hpp

+49-22
Original file line numberDiff line numberDiff line change
@@ -113,42 +113,69 @@ std::vector<std::pair<lanelet::ConstPoints3d, std::pair<double, double>>> get_wa
113113
const double group_separation_threshold, const double interval_margin_ratio);
114114

115115
/**
116-
* @brief get position of first self-intersection (point where return
117-
* path intersects outward path) of lanelet sequence in arc length
118-
* @param lanelet_sequence target lanelet sequence (both left and right bound are
119-
* considered)
120-
* @param s_start longitudinal distance of point to start searching for self-intersections
116+
* @brief get position of first intersection (including self-intersection) in lanelet sequence in
117+
* arc length
118+
* @param lanelet_sequence target lanelet sequence
119+
* @param s_start longitudinal distance of point to start searching for intersections
121120
* @param s_end longitudinal distance of point to end search
122-
* @return longitudinal distance of self-intersecting point (std::nullopt if no
123-
* self-intersection)
121+
* @param vehicle_length vehicle length
122+
* @return longitudinal distance of intersecting point (std::nullopt if no intersection)
124123
*/
125-
std::optional<double> get_first_self_intersection_arc_length(
126-
const lanelet::LaneletSequence & lanelet_sequence, const double s_start, const double s_end);
124+
std::optional<double> get_first_intersection_arc_length(
125+
const lanelet::LaneletSequence & lanelet_sequence, const double s_start, const double s_end,
126+
const double vehicle_length);
127127

128128
/**
129-
* @brief get position of first self-intersection of line string in arc length
129+
* @brief get position of first self-intersection (point where return
130+
* path intersects outward path) of line string in arc length
130131
* @param line_string target line string
131-
* @param s_start longitudinal distance of point to start searching for self-intersections
132-
* @param s_end longitudinal distance of point to end search
133132
* @return longitudinal distance of self-intersecting point (std::nullopt if no
134133
* self-intersection)
135134
*/
136135
std::optional<double> get_first_self_intersection_arc_length(
137-
const lanelet::BasicLineString2d & line_string, const double s_start, const double s_end);
136+
const lanelet::BasicLineString2d & line_string);
137+
138+
/**
139+
* @brief get path bounds for PathWithLaneId cropped within specified range
140+
* @param lanelet_sequence lanelet sequence
141+
* @param s_start longitudinal distance of start of bound on centerline
142+
* @param s_end longitudinal distance of end of bound on centerline
143+
* @return cropped bounds (left / right)
144+
*/
145+
std::array<std::vector<geometry_msgs::msg::Point>, 2> get_path_bounds(
146+
const lanelet::LaneletSequence & lanelet_sequence, const double s_start, const double s_end);
138147

139148
/**
140-
* @brief get path bound for PathWithLaneId cropped within specified range
141-
* @param lanelet_bound original bound of lanelet
142-
* @param lanelet_centerline centerline of lanelet
143-
* @param s_start longitudinal distance of start of bound
144-
* @param s_end longitudinal distance of end of bound
145-
* @return cropped bound
149+
* @brief crop line string
150+
* @param line_string line string
151+
* @param s_start longitudinal distance to crop from
152+
* @param s_end longitudinal distance to crop to
153+
* @return cropped line string
146154
*/
147-
std::vector<geometry_msgs::msg::Point> get_path_bound(
148-
const lanelet::CompoundLineString3d & lanelet_bound,
149-
const lanelet::CompoundLineString2d & lanelet_centerline, const double s_start,
155+
std::vector<geometry_msgs::msg::Point> crop_line_string(
156+
const std::vector<geometry_msgs::msg::Point> & line_string, const double s_start,
150157
const double s_end);
151158

159+
/**
160+
* @brief get positions of given point on centerline projected to left / right bound in arc length
161+
* @param lanelet_sequence lanelet sequence
162+
* @param s_centerline longitudinal distance of point on centerline
163+
* @return longitudinal distance of projected point (left / right)
164+
*/
165+
std::array<double, 2> get_arc_length_on_bounds(
166+
const lanelet::LaneletSequence & lanelet_sequence, const double s_centerline);
167+
168+
/**
169+
* @brief get positions of given point on left / right bound projected to centerline in arc length
170+
* @param lanelet_sequence lanelet sequence
171+
* @param s_left_bound longitudinal distance of point on left bound
172+
* @param s_right_bound longitudinal distance of point on left bound
173+
* @return longitudinal distance of projected point (left / right)
174+
*/
175+
std::array<std::optional<double>, 2> get_arc_length_on_centerline(
176+
const lanelet::LaneletSequence & lanelet_sequence, const std::optional<double> & s_left_bound,
177+
const std::optional<double> & s_right_bound);
178+
152179
/**
153180
* @brief Recreate the goal pose to prevent the goal point being too far from the lanelet, which
154181
* causes the path to twist near the goal.

‎planning/autoware_path_generator/src/node.cpp

+10-11
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,11 @@ std::optional<PathWithLaneId> PathGenerator::generate_path(
272272
}
273273

274274
if (
275-
const auto s_intersection =
276-
utils::get_first_self_intersection_arc_length(lanelet_sequence, s_start, s_end)) {
277-
s_end = std::clamp(s_end, 0.0, *s_intersection - vehicle_info_.max_longitudinal_offset_m);
275+
const auto s_intersection = utils::get_first_intersection_arc_length(
276+
lanelet_sequence, std::max(0., s_start - vehicle_info_.max_longitudinal_offset_m),
277+
s_end + vehicle_info_.max_longitudinal_offset_m, vehicle_info_.vehicle_length_m)) {
278+
s_end =
279+
std::min(s_end, std::max(0., *s_intersection - vehicle_info_.max_longitudinal_offset_m));
278280
}
279281

280282
return s_end;
@@ -443,14 +445,11 @@ std::optional<PathWithLaneId> PathGenerator::generate_path(
443445
finalized_path_with_lane_id.header.frame_id = planner_data_.route_frame_id;
444446
finalized_path_with_lane_id.header.stamp = now();
445447

446-
const auto s_bound_start_offset = std::max(0., s_offset + s_bound_start);
447-
const auto s_bound_end_offset = std::max(0., s_offset + s_bound_end);
448-
finalized_path_with_lane_id.left_bound = utils::get_path_bound(
449-
extended_lanelet_sequence.leftBound(), extended_lanelet_sequence.centerline2d(),
450-
s_bound_start_offset, s_bound_end_offset);
451-
finalized_path_with_lane_id.right_bound = utils::get_path_bound(
452-
extended_lanelet_sequence.rightBound(), extended_lanelet_sequence.centerline2d(),
453-
s_bound_start_offset, s_bound_end_offset);
448+
const auto [left_bound, right_bound] = utils::get_path_bounds(
449+
extended_lanelet_sequence, std::max(0., s_offset + s_bound_start),
450+
std::max(0., s_offset + s_bound_end));
451+
finalized_path_with_lane_id.left_bound = left_bound;
452+
finalized_path_with_lane_id.right_bound = right_bound;
454453

455454
return finalized_path_with_lane_id;
456455
}

0 commit comments

Comments
 (0)