Skip to content

Commit

Permalink
add path_generator package
Browse files Browse the repository at this point in the history
Signed-off-by: mitukou1109 <mitukou1109@gmail.com>

fix spell check error

Signed-off-by: mitukou1109 <mitukou1109@gmail.com>

include necessary headers

Signed-off-by: mitukou1109 <mitukou1109@gmail.com>

change package version to 0.0.0

Co-authored-by: Yutaka Kondo <yutaka.kondo@youtalk.jp>
Signed-off-by: mitukou1109 <mitukou1109@gmail.com>

fix include guard name

Co-authored-by: Yutaka Kondo <yutaka.kondo@youtalk.jp>
Signed-off-by: mitukou1109 <mitukou1109@gmail.com>

replace flowchart uml with pre-generated image

Co-authored-by: Yutaka Kondo <yutaka.kondo@youtalk.jp>
Signed-off-by: mitukou1109 <mitukou1109@gmail.com>

style(pre-commit): autofix

Signed-off-by: mitukou1109 <mitukou1109@gmail.com>

replace tier4_planning_msgs with autoware_internal_planning_msgs

Signed-off-by: mitukou1109 <mitukou1109@gmail.com>

style(pre-commit): autofix

Signed-off-by: mitukou1109 <mitukou1109@gmail.com>

use LaneletSequence instead of ConstLanelets

Signed-off-by: mitukou1109 <mitukou1109@gmail.com>

set orientation to path points

Signed-off-by: mitukou1109 <mitukou1109@gmail.com>

crop path bound to fit trajectory

Signed-off-by: mitukou1109 <mitukou1109@gmail.com>

offset path bound

Signed-off-by: mitukou1109 <mitukou1109@gmail.com>

no need to make return value optional

Signed-off-by: mitukou1109 <mitukou1109@gmail.com>

address deprecation warning

Signed-off-by: mitukou1109 <mitukou1109@gmail.com>

add doxygen comments

Signed-off-by: mitukou1109 <mitukou1109@gmail.com>

support multiple previous/next lanelets

Signed-off-by: mitukou1109 <mitukou1109@gmail.com>

fix path bound cut issue

Signed-off-by: mitukou1109 <mitukou1109@gmail.com>

group parameters

Signed-off-by: mitukou1109 <mitukou1109@gmail.com>

add path cut feature

Signed-off-by: mitukou1109 <mitukou1109@gmail.com>

ensure s_end is not negative

Signed-off-by: mitukou1109 <mitukou1109@gmail.com>

simplify return value selection

Signed-off-by: mitukou1109 <mitukou1109@gmail.com>

add doxygen comments

Signed-off-by: mitukou1109 <mitukou1109@gmail.com>
  • Loading branch information
mitukou1109 authored and kosuke55 committed Feb 25, 2025
1 parent b27283b commit b9dd1c4
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,30 @@ std::vector<std::pair<lanelet::ConstPoints3d, std::pair<double, double>>> get_wa
const lanelet::LaneletSequence & lanelet_sequence, const lanelet::LaneletMap & lanelet_map,
const double group_separation_threshold, const double interval_margin_ratio);

/**
* @brief get position of first self-intersection (point where return
* path intersects outward path) of lanelet sequence in arc length
* @param lanelet_sequence target lanelet sequence (both left and right bound are
* considered)
* @param s_start longitudinal distance of point to start searching for self-intersections
* @param s_end longitudinal distance of point to end search
* @return longitudinal distance of self-intersecting point (std::nullopt if no
* self-intersection)
*/
std::optional<double> get_first_self_intersection_arc_length(
const lanelet::LaneletSequence & lanelet_sequence, const double s_start, const double s_end);

/**
* @brief get position of first self-intersection of line string in arc length
* @param line_string target line string
* @param s_start longitudinal distance of point to start searching for self-intersections
* @param s_end longitudinal distance of point to end search
* @return longitudinal distance of self-intersecting point (std::nullopt if no
* self-intersection)
*/
std::optional<double> get_first_self_intersection_arc_length(
const lanelet::BasicLineString2d & line_string, const double s_start, const double s_end);

/**
* @brief get bound of path cropped within specified range
* @param lanelet_bound original bound of lanelet
Expand Down
2 changes: 2 additions & 0 deletions planning/autoware_path_generator/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
<maintainer email="satoshi.ota@tier4.jp">Satoshi Ota</maintainer>
<maintainer email="takayuki.murooka@tier4.jp">Takayuki Murooka</maintainer>
<maintainer email="mitsuhiro.sakamoto@tier4.jp">Mitsuhiro Sakamoto</maintainer>
<maintainer email="kosuke.takeuchi@tier4.jp">Kosuke Takeuchi</maintainer>
<license>Apache License 2.0</license>

<author email="satoshi.ota@tier4.jp">Satoshi Ota</author>
<author email="takayuki.murooka@tier4.jp">Takayuki Murooka</author>
<author email="mitsuhiro.sakamoto@tier4.jp">Mitsuhiro Sakamoto</author>
<author email="kosuke.takeuchi@tier4.jp">Kosuke Takeuchi</author>

<buildtool_depend>ament_cmake_auto</buildtool_depend>
<buildtool_depend>autoware_cmake</buildtool_depend>
Expand Down
6 changes: 6 additions & 0 deletions planning/autoware_path_generator/src/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@ std::optional<PathWithLaneId> PathGenerator::generate_path(
s_end = std::min(s_end, goal_arc_coordinates.length);
}

if (
const auto s_intersection =
utils::get_first_self_intersection_arc_length(lanelet_sequence, s_start, s_end)) {
s_end = std::clamp(s_end, 0.0, *s_intersection - vehicle_info_.max_longitudinal_offset_m);

Check warning on line 251 in planning/autoware_path_generator/src/node.cpp

View check run for this annotation

Codecov / codecov/patch

planning/autoware_path_generator/src/node.cpp#L250-L251

Added lines #L250 - L251 were not covered by tests
}

return s_end;
}();

Expand Down
45 changes: 45 additions & 0 deletions planning/autoware_path_generator/src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include <lanelet2_core/geometry/Lanelet.h>

#include <algorithm>
#include <utility>
#include <vector>

Expand Down Expand Up @@ -166,6 +167,50 @@ std::optional<lanelet::ConstLanelet> get_next_lanelet_within_route(
return *next_lanelet_itr;
}

std::optional<double> get_first_self_intersection_arc_length(

Check warning on line 170 in planning/autoware_path_generator/src/utils.cpp

View check run for this annotation

Codecov / codecov/patch

planning/autoware_path_generator/src/utils.cpp#L170

Added line #L170 was not covered by tests
const lanelet::LaneletSequence & lanelet_sequence, const double s_start, const double s_end)
{
const auto s_left = get_first_self_intersection_arc_length(
lanelet_sequence.leftBound2d().basicLineString(), s_start, s_end);
const auto s_right = get_first_self_intersection_arc_length(
lanelet_sequence.rightBound2d().basicLineString(), s_start, s_end);

Check warning on line 176 in planning/autoware_path_generator/src/utils.cpp

View check run for this annotation

Codecov / codecov/patch

planning/autoware_path_generator/src/utils.cpp#L173-L176

Added lines #L173 - L176 were not covered by tests

if (s_left && s_right) {
return std::min(*s_left, *s_right);

Check warning on line 179 in planning/autoware_path_generator/src/utils.cpp

View check run for this annotation

Codecov / codecov/patch

planning/autoware_path_generator/src/utils.cpp#L179

Added line #L179 was not covered by tests
}
return s_left ? s_left : s_right;

Check warning on line 181 in planning/autoware_path_generator/src/utils.cpp

View check run for this annotation

Codecov / codecov/patch

planning/autoware_path_generator/src/utils.cpp#L181

Added line #L181 was not covered by tests
}

std::optional<double> get_first_self_intersection_arc_length(

Check warning on line 184 in planning/autoware_path_generator/src/utils.cpp

View check run for this annotation

Codecov / codecov/patch

planning/autoware_path_generator/src/utils.cpp#L184

Added line #L184 was not covered by tests
const lanelet::BasicLineString2d & line_string, const double s_start, const double s_end)
{
const auto tree = lanelet::geometry::internal::makeIndexedSegmenTree(line_string);

Check warning on line 187 in planning/autoware_path_generator/src/utils.cpp

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (Segmen)

Check warning on line 187 in planning/autoware_path_generator/src/utils.cpp

View check run for this annotation

Codecov / codecov/patch

planning/autoware_path_generator/src/utils.cpp#L187

Added line #L187 was not covered by tests
std::optional<std::pair<size_t, double>> last_intersection = std::nullopt;
auto s = 0.;

for (size_t i = 1; i < line_string.size() - 1; ++i) {
if (last_intersection && i == last_intersection->first) {
return s + last_intersection->second;

Check warning on line 193 in planning/autoware_path_generator/src/utils.cpp

View check run for this annotation

Codecov / codecov/patch

planning/autoware_path_generator/src/utils.cpp#L193

Added line #L193 was not covered by tests
}
s += lanelet::geometry::distance2d(line_string.at(i - 1), line_string.at(i));

Check warning on line 195 in planning/autoware_path_generator/src/utils.cpp

View check run for this annotation

Codecov / codecov/patch

planning/autoware_path_generator/src/utils.cpp#L195

Added line #L195 was not covered by tests
if (s < s_start) {
continue;

Check warning on line 197 in planning/autoware_path_generator/src/utils.cpp

View check run for this annotation

Codecov / codecov/patch

planning/autoware_path_generator/src/utils.cpp#L197

Added line #L197 was not covered by tests
}
if (s > s_end) {
break;
}
const auto self_intersections = lanelet::geometry::internal::getSelfIntersectionsAt(
tree, 0, lanelet::BasicSegment2d{line_string.at(i - 1), line_string.at(i)});

Check warning on line 203 in planning/autoware_path_generator/src/utils.cpp

View check run for this annotation

Codecov / codecov/patch

planning/autoware_path_generator/src/utils.cpp#L203

Added line #L203 was not covered by tests
if (self_intersections.empty()) {
continue;
}
last_intersection = {
self_intersections.front().lastSegment.idx, self_intersections.front().lastSegment.s};
}

return std::nullopt;

Check warning on line 211 in planning/autoware_path_generator/src/utils.cpp

View check run for this annotation

Codecov / codecov/patch

planning/autoware_path_generator/src/utils.cpp#L211

Added line #L211 was not covered by tests
}

std::vector<std::pair<lanelet::ConstPoints3d, std::pair<double, double>>> get_waypoint_groups(
const lanelet::LaneletSequence & lanelet_sequence, const lanelet::LaneletMap & lanelet_map,
const double group_separation_threshold, const double interval_margin_ratio)
Expand Down

0 comments on commit b9dd1c4

Please sign in to comment.