Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(autoware_path_generator): function to smooth the path #227

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
d12367c
feat: function to smooth the route (see below)
sasakisasaki Feb 26, 2025
04596a1
style(pre-commit): autofix
pre-commit-ci[bot] Feb 26, 2025
f1f499a
Merge branch 'main' into feat-embed-smooth-path-as-alpha-quality
sasakisasaki Feb 28, 2025
17054c9
bugs: fix remaining conflicts
sasakisasaki Feb 28, 2025
5a2766e
Update planning/autoware_path_generator/src/utils.cpp
sasakisasaki Feb 28, 2025
808fb5d
Update planning/autoware_path_generator/src/utils.cpp
sasakisasaki Feb 28, 2025
19185eb
refactor: as follows
sasakisasaki Feb 28, 2025
fc90ae4
Merge branch 'feat-embed-smooth-path-as-alpha-quality' of github.com:…
sasakisasaki Feb 28, 2025
c2e91f9
style(pre-commit): autofix
pre-commit-ci[bot] Feb 28, 2025
5945ef7
refactor: enhance error handling
sasakisasaki Mar 2, 2025
c4b3500
style(pre-commit): autofix
pre-commit-ci[bot] Mar 2, 2025
ace5fbe
bug: fix wrong function declaration in header
sasakisasaki Mar 4, 2025
0dee050
bug: fix wrong point index calculation
sasakisasaki Mar 4, 2025
b6a8492
bug: remove meaningless comment
sasakisasaki Mar 4, 2025
ea3bfed
fix: apply `pre-commit`
sasakisasaki Mar 4, 2025
a322d4d
fix: smooth path before cropping trajectory points
sasakisasaki Mar 4, 2025
865b38f
bug: fix shadow variable
sasakisasaki Mar 5, 2025
6851a32
bug: fix missing parameters for `autoware_path_generator`
sasakisasaki Mar 5, 2025
f743ea1
bug: fix by cpplint
sasakisasaki Mar 5, 2025
cc34c45
style(pre-commit): autofix
pre-commit-ci[bot] Mar 5, 2025
82f48df
bug: apply missing fix proposed by cpplint
sasakisasaki Mar 5, 2025
c7509ec
Merge branch 'feat-embed-smooth-path-as-alpha-quality' of github.com:…
sasakisasaki Mar 5, 2025
b2bc617
style(pre-commit): autofix
pre-commit-ci[bot] Mar 5, 2025
a902884
Merge branch 'main' into feat-embed-smooth-path-as-alpha-quality
sasakisasaki Mar 5, 2025
0e767d4
bug: `autoware_test_utils` should be in the `test_depend`
sasakisasaki Mar 5, 2025
023529c
fix(autoware_path_generator): add maintainer and author
sasakisasaki Mar 5, 2025
30b826c
style(pre-commit): autofix
pre-commit-ci[bot] Mar 5, 2025
e376cf6
fix: by pre-commit
sasakisasaki Mar 5, 2025
9d7b9d7
Merge branch 'feat-embed-smooth-path-as-alpha-quality' of github.com:…
sasakisasaki Mar 5, 2025
0a4c0db
Merge branch 'main' into feat-embed-smooth-path-as-alpha-quality
sasakisasaki Mar 5, 2025
2e286d9
fix: smooth path only when a goal point is included
sasakisasaki Mar 6, 2025
8093a99
bug: do error handling
sasakisasaki Mar 6, 2025
06c0532
style(pre-commit): autofix
pre-commit-ci[bot] Mar 6, 2025
9f217b3
bug: fix wrong distance calculation
sasakisasaki Mar 8, 2025
6509955
fix: remove sanity check temporary as following reasons
sasakisasaki Mar 8, 2025
daef6de
refactor: fix complexity
sasakisasaki Mar 8, 2025
764092b
bug: missing fixes in the include header
sasakisasaki Mar 8, 2025
4688b8b
bug: inconsistent function declaration
sasakisasaki Mar 8, 2025
576a002
Update planning/autoware_path_generator/include/autoware/path_generat…
sasakisasaki Mar 8, 2025
56f36c7
Update planning/autoware_path_generator/src/node.cpp
sasakisasaki Mar 8, 2025
5872f9c
Update planning/autoware_path_generator/src/utils.cpp
sasakisasaki Mar 8, 2025
468539c
Update planning/autoware_path_generator/src/utils.cpp
sasakisasaki Mar 8, 2025
fb39145
style(pre-commit): autofix
pre-commit-ci[bot] Mar 8, 2025
fa4522f
Merge branch 'feat-embed-smooth-path-as-alpha-quality' of github.com:…
sasakisasaki Mar 8, 2025
6b11019
Merge branch 'autowarefoundation:main' into feat-embed-smooth-path-as…
sasakisasaki Mar 8, 2025
933abd7
Merge branch 'feat-embed-smooth-path-as-alpha-quality' of github.com:…
sasakisasaki Mar 8, 2025
7d64da2
fix: apply comment in the following PR
sasakisasaki Mar 8, 2025
ed64aaf
fix: sorry, I was missing one comment to be applied
sasakisasaki Mar 8, 2025
d22762f
style(pre-commit): autofix
pre-commit-ci[bot] Mar 8, 2025
23b2efc
Merge branch 'feat-embed-smooth-path-as-alpha-quality' of github.com:…
sasakisasaki Mar 8, 2025
d9b3a8d
bug: fix wrong goal point interpolation
sasakisasaki Mar 8, 2025
d0c9592
feat: add test case (goal on left side)
sasakisasaki Mar 9, 2025
1b9417f
bug: fix as follows
sasakisasaki Mar 9, 2025
9fd4b81
bug: fix duplicated zero velocity set
sasakisasaki Mar 9, 2025
40d59bd
feat: add one test case (goal on left side)
sasakisasaki Mar 9, 2025
7ecfc0f
Update planning/autoware_path_generator/src/utils.cpp
sasakisasaki Mar 9, 2025
716237d
fix: apply comment from reviewer
sasakisasaki Mar 9, 2025
32dc196
Merge branch 'feat-embed-smooth-path-as-alpha-quality' of github.com:…
sasakisasaki Mar 9, 2025
66f24e6
fix(package.xml): update maintainer for the following packages
sasakisasaki Mar 10, 2025
05885f7
Update planning/autoware_path_generator/src/node.cpp
sasakisasaki Mar 10, 2025
f83965b
Update planning/autoware_path_generator/src/utils.cpp
sasakisasaki Mar 10, 2025
c95249c
Update planning/autoware_path_generator/src/utils.cpp
sasakisasaki Mar 10, 2025
75647bb
bug: fix missing header in the path
sasakisasaki Mar 10, 2025
f1c94a0
bug: fix an issue that smooth connection does not work
sasakisasaki Mar 10, 2025
b45ce8e
refactor: simplify code
sasakisasaki Mar 10, 2025
4d3d176
bug: fix wrong pose at the goal (see below)
sasakisasaki Mar 10, 2025
631637b
refactor: no need this line here
sasakisasaki Mar 10, 2025
f58ff37
Merge branch 'feat-embed-smooth-path-as-alpha-quality' of github.com:…
sasakisasaki Mar 10, 2025
14df169
style(pre-commit): autofix
pre-commit-ci[bot] Mar 10, 2025
cbd3cc3
bug: fix so we follow the provided review comments
sasakisasaki Mar 10, 2025
8318cf1
Merge branch 'feat-embed-smooth-path-as-alpha-quality' of github.com:…
sasakisasaki Mar 10, 2025
31875a9
bug: sorry, this is unsaved fix, ...
sasakisasaki Mar 10, 2025
d1f52ae
cosmetic: fix wrong comment
sasakisasaki Mar 10, 2025
c95effc
bug: unused function `get_goal_lanelet()` remaining
sasakisasaki Mar 10, 2025
b12c40c
bug: carefully handle the pre goal velocity
sasakisasaki Mar 10, 2025
c34c359
Update planning/autoware_path_generator/src/utils.cpp
sasakisasaki Mar 10, 2025
4938af7
Update planning/autoware_path_generator/src/utils.cpp
sasakisasaki Mar 10, 2025
03a75c5
style(pre-commit): autofix
pre-commit-ci[bot] Mar 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@
search_distance: 30.0
resampling_interval: 1.0
angle_threshold_deg: 15.0
refine_goal_search_radius_range: 7.5 # [m]
search_radius_decrement: 1.0
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include <autoware_internal_planning_msgs/msg/path_with_lane_id.hpp>
#include <autoware_vehicle_msgs/msg/turn_indicators_command.hpp>

#include <limits>
#include <memory>
#include <optional>
#include <string>
#include <unordered_map>
Expand Down Expand Up @@ -147,6 +149,97 @@ std::vector<geometry_msgs::msg::Point> get_path_bound(
const lanelet::CompoundLineString2d & lanelet_centerline, const double s_start,
const double s_end);

/**
* @brief Recreate the goal pose to prevent the goal point being too far from the lanelet, which
* causes the path to twist near the goal.
* @details Return the goal point projected on the straight line of the segment of lanelet
* closest to the original goal.
* @param [in] goal original goal pose
* @param [in] goal_lanelet lanelet containing the goal pose
*/
const geometry_msgs::msg::Pose refine_goal(
const geometry_msgs::msg::Pose & goal, const lanelet::ConstLanelet & goal_lanelet);

/**
* @brief Prepare the point before the goal point.
* @param goal Goal pose.
* @param lanes Lanelets.
* @return Pre-goal point.
*/
PathPointWithLaneId prepare_pre_goal(
const geometry_msgs::msg::Pose & goal, const lanelet::ConstLanelets & lanes);

/**
* @brief Get the index of the point closest to the circumference of the circle whose center is the
* goal and outside of it.
* @param points Points to search.
* @param goal Goal pose.
* @param goal_lane_id Lane ID of the goal.
* @param max_dist Maximum distance to search.
* @return Index of the point closest to the circumference of the circle whose center is the goal
* and outside of it.
*/
std::optional<size_t> find_index_out_of_goal_search_range(
const std::vector<PathPointWithLaneId> & points, const geometry_msgs::msg::Pose & goal,
const int64_t goal_lane_id, const double max_dist);

/**
* @brief Get the path up to just before the pre_goal.
* @param input Input path.
* @param refined_goal Goal pose.
* @return Recreated path
*/
std::optional<PathWithLaneId> get_path_up_to_just_before_pre_goal(
const PathWithLaneId & input, const geometry_msgs::msg::Pose & goal,
const lanelet::Id goal_lane_id, const double search_radius_range);

/**
* @brief Recreate the path with a given goal pose.
* @param input Input path.
* @param refined_goal Goal pose.
* @param planner_data Planner data.
* @return Recreated path
*/
PathWithLaneId refine_path_for_goal(
const PathWithLaneId & input, const geometry_msgs::msg::Pose & goal,
const PlannerData & planner_data);

/**
* @brief Extract lanelets from the path.
* @param path Input path.
* @param planner_data Planner data.
* @return Extracted lanelets
*/
std::optional<lanelet::ConstLanelets> extract_lanelets_from_path(
const PathWithLaneId & refined_path, const PlannerData & planner_data);

/**
* @brief Check if the pose is in the lanelets.
* @param pose Pose.
* @param lanes Lanelets.
* @return True if the pose is in the lanelets, false otherwise
*/
bool is_in_lanelets(const geometry_msgs::msg::Pose & pose, const lanelet::ConstLanelets & lanes);

/**
* @brief Check if the path is valid.
* @param refined_path Input path.
* @param planner_data Planner data.
* @return True if the path is valid, false otherwise
*/
bool is_path_valid(const PathWithLaneId & refined_path, const PlannerData & planner_data);

/**
* @brief Modify the path to connect smoothly to the goal.
* @param path Input path.
* @param planner_data Planner data.
* @param refine_goal_search_radius_range Refine goal search radius range.
* @return Modified path
*/
PathWithLaneId modify_path_for_smooth_goal_connection(
const PathWithLaneId & path, const PlannerData & planner_data,
const double refine_goal_search_radius_range);

/**
* @brief get earliest turn signal based on turn direction specified for lanelets
* @param path target path
Expand Down
4 changes: 3 additions & 1 deletion planning/autoware_path_generator/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
<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>
<maintainer email="junya.sasaki@tier4.jp">Junya Sasaki</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>
<author email="junya.sasaki@tier4.jp">Junya Sasaki</author>

<buildtool_depend>ament_cmake_auto</buildtool_depend>
<buildtool_depend>autoware_cmake</buildtool_depend>
Expand All @@ -22,7 +24,6 @@
<depend>autoware_lanelet2_extension</depend>
<depend>autoware_motion_utils</depend>
<depend>autoware_planning_test_manager</depend>
<depend>autoware_test_utils</depend>
<depend>autoware_trajectory</depend>
<depend>autoware_vehicle_info_utils</depend>
<depend>generate_parameter_library</depend>
Expand All @@ -32,6 +33,7 @@
<test_depend>ament_cmake_ros</test_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>autoware_lint_common</test_depend>
<test_depend>autoware_test_utils</test_depend>

<export>
<build_type>ament_cmake</build_type>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,9 @@ path_generator:

angle_threshold_deg:
type: double

refine_goal_search_radius_range:
type: double

search_radius_decrement:
type: double
50 changes: 43 additions & 7 deletions planning/autoware_path_generator/src/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@
vehicle_info_ = autoware::vehicle_info_utils::VehicleInfoUtils(*this).getVehicleInfo();

const auto params = param_listener_->get_params();

// Ensure that the refine_goal_search_radius_range and search_radius_decrement must be positive
if (params.refine_goal_search_radius_range <= 0 || params.search_radius_decrement <= 0) {
throw std::runtime_error(
"refine_goal_search_radius_range and search_radius_decrement must be positive");

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

View check run for this annotation

Codecov / codecov/patch

planning/autoware_path_generator/src/node.cpp#L64

Added line #L64 was not covered by tests
}

timer_ = rclcpp::create_timer(
this, get_clock(), rclcpp::Rate(params.planning_hz).period(),
std::bind(&PathGenerator::run, this));
Expand Down Expand Up @@ -364,18 +371,46 @@
return std::nullopt;
}

// Attach orientation for all the points
trajectory->align_orientation_with_trajectory_direction();

// Refine the trajectory by cropping
trajectory->crop(
s_offset + s_start -
get_arc_length_along_centerline(
extended_lanelet_sequence, lanelet::utils::conversion::toLaneletPoint(
path_points_with_lane_id.front().point.pose.position)),
s_end - s_start);

PathWithLaneId path{};
path.header.frame_id = planner_data_.route_frame_id;
path.header.stamp = now();
path.points = trajectory->restore();
// Compose the polished path
PathWithLaneId preprocessed_path{};
preprocessed_path.points = trajectory->restore();

PathWithLaneId finalized_path_with_lane_id{};

// Check if the goal point is in the search range
// Note: We only see if the goal is approaching the tail of the path.
const auto distance_to_goal = autoware_utils::calc_distance2d(
preprocessed_path.points.back().point.pose, planner_data_.goal_pose);

if (distance_to_goal < params.refine_goal_search_radius_range) {
// Perform smooth goal connection
const auto params = param_listener_->get_params();

finalized_path_with_lane_id = utils::modify_path_for_smooth_goal_connection(
std::move(preprocessed_path), planner_data_, params.refine_goal_search_radius_range);
} else {
finalized_path_with_lane_id = std::move(preprocessed_path);

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

View check run for this annotation

Codecov / codecov/patch

planning/autoware_path_generator/src/node.cpp#L403

Added line #L403 was not covered by tests
}

// check if the path is empty
if (finalized_path_with_lane_id.points.empty()) {
return std::nullopt;

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

View check run for this annotation

Codecov / codecov/patch

planning/autoware_path_generator/src/node.cpp#L408

Added line #L408 was not covered by tests
}

// Set header which is needed to engage
finalized_path_with_lane_id.header.frame_id = planner_data_.route_frame_id;
finalized_path_with_lane_id.header.stamp = now();

const auto get_path_bound = [&](const lanelet::CompoundLineString2d & lanelet_bound) {
const auto s_bound_start =
Expand All @@ -385,10 +420,11 @@
return utils::get_path_bound(
lanelet_bound, extended_lanelet_sequence.centerline2d(), s_bound_start, s_bound_end);
};
path.left_bound = get_path_bound(extended_lanelet_sequence.leftBound2d());
path.right_bound = get_path_bound(extended_lanelet_sequence.rightBound2d());
finalized_path_with_lane_id.left_bound = get_path_bound(extended_lanelet_sequence.leftBound2d());
finalized_path_with_lane_id.right_bound =
get_path_bound(extended_lanelet_sequence.rightBound2d());

return path;
return finalized_path_with_lane_id;
}
} // namespace autoware::path_generator

Expand Down
Loading
Loading