-
Notifications
You must be signed in to change notification settings - Fork 668
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(path_generator): add path_generator package #9216
feat(path_generator): add path_generator package #9216
Conversation
Thank you for contributing to the Autoware project! 🚧 If your pull request is in progress, switch it to draft mode. Please ensure:
|
return *this; | ||
} | ||
|
||
private: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seem several parameters which can be local variables.
IMO, increasing the member variables decreases the readability and maintainability since it's not clear that the variables are used and modified. So please try not to use the member variables as much as possible.
planning/autoware_path_generator/include/autoware/path_generator/node.hpp
Outdated
Show resolved
Hide resolved
|
||
// set yaw to each point | ||
{ | ||
auto it = path_points.begin(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be in for(here;...
const auto waypoint_groups = utils::getWaypointGroups(lanelet_sequence, *lanelet_map_ptr_); | ||
|
||
double s = 0.; | ||
for (const auto & lanelet : lanelet_sequence) { | ||
std::vector<geometry_msgs::msg::Point> reference_points; | ||
const auto & centerline = lanelet.centerline(); | ||
|
||
std::optional<size_t> overlapped_waypoint_group_index = std::nullopt; | ||
for (auto it = centerline.begin(); it != centerline.end(); ++it) { | ||
if (s <= s_end) { | ||
const lanelet::Point3d point(*it); | ||
if (s >= s_start) { | ||
for (size_t i = 0; i < waypoint_groups.size(); ++i) { | ||
const auto & [waypoints, interval] = waypoint_groups[i]; | ||
if (s >= interval.first && s <= interval.second) { | ||
overlapped_waypoint_group_index = i; | ||
break; | ||
} else if (i == overlapped_waypoint_group_index) { | ||
for (const auto & waypoint : waypoints) { | ||
reference_points.push_back(lanelet::utils::conversion::toGeomMsgPt(waypoint)); | ||
} | ||
overlapped_waypoint_group_index = std::nullopt; | ||
} | ||
} | ||
if (!overlapped_waypoint_group_index) { | ||
reference_points.push_back(lanelet::utils::conversion::toGeomMsgPt(point)); | ||
} | ||
} | ||
if (it == std::prev(centerline.end())) { | ||
break; | ||
} | ||
|
||
const lanelet::Point3d next_point(*std::next(it)); | ||
const auto distance = lanelet::geometry::distance2d(point, next_point); | ||
std::optional<double> s_interpolation = std::nullopt; | ||
if (s + distance > s_end) { | ||
s_interpolation = s_end - s; | ||
} else if (s < s_start && s + distance > s_start) { | ||
s_interpolation = s_start - s; | ||
} | ||
|
||
if (s_interpolation) { | ||
const auto interpolated_point = lanelet::geometry::interpolatedPointAtDistance( | ||
lanelet::ConstLineString3d{lanelet::InvalId, {point, next_point}}, *s_interpolation); | ||
reference_points.push_back(lanelet::utils::conversion::toGeomMsgPt(interpolated_point)); | ||
} | ||
s += distance; | ||
} else { | ||
break; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: No need to refactor here.
return waypoint_groups; | ||
} | ||
|
||
void removeOverlappingPoints(PathWithLaneId & path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mitukou1109 Please write unit tests for utils functions. Code quality and reliability is very important for this package. It's okay to add tests in other PR.
2b546d7
to
851c0bb
Compare
|
||
void PathGenerator::run() | ||
{ | ||
const auto input_data = takeData(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each variable in input_data may be nullptr. We should check whether the input_data is valid or not (= whether the input data is ready or not) here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The validation is now in the updatePlannerData.
I feel checking whether the input_data is valid or not should be before planPath
return std::nullopt; | ||
} | ||
|
||
auto path = utils::generateCenterLinePath(planner_data_); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const
lanelet::LaneletMapPtr lanelet_map_ptr{nullptr}; | ||
lanelet::traffic_rules::TrafficRulesPtr traffic_rules_ptr{nullptr}; | ||
lanelet::routing::RoutingGraphPtr routing_graph_ptr{nullptr}; | ||
|
||
geometry_msgs::msg::Pose current_pose; | ||
|
||
autoware_planning_msgs::msg::LaneletRoute::ConstSharedPtr route_ptr{nullptr}; | ||
|
||
lanelet::ConstLanelets route_lanelets; | ||
lanelet::ConstLanelets preferred_lanelets; | ||
lanelet::ConstLanelets start_lanelets; | ||
lanelet::ConstLanelets goal_lanelets; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel these variables do not have to be member variables.
planner_data_.start_lanelets.clear(); | ||
planner_data_.goal_lanelets.clear(); | ||
|
||
if (!planner_data_.route_ptr->segments.empty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use early return.
std::vector<std::pair<lanelet::ConstPoints3d, std::pair<double, double>>> getWaypointGroups( | ||
const lanelet::ConstLanelets & lanelet_sequence, const lanelet::LaneletMap & lanelet_map) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: No need to refactor and write a unit test for this function.
path_publisher_->publish(*path); | ||
} | ||
|
||
PathGenerator::InputData PathGenerator::takeData() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the snake case for all the functions.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9216 +/- ##
==========================================
- Coverage 29.76% 0.00% -29.77%
==========================================
Files 1444 87 -1357
Lines 108686 3866 -104820
Branches 42664 671 -41993
==========================================
- Hits 32352 0 -32352
+ Misses 73150 3866 -69284
+ Partials 3184 0 -3184
☔ View full report in Codecov by Sentry. |
e0f2caa
to
d2c2cda
Compare
6717500
to
6fe9161
Compare
if ( | ||
planner_data.preferred_lanelets.front().id() != lanelet.id() && | ||
exists(planner_data.route_lanelets, lanelet)) { | ||
return lanelet; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returning the first lanelet in the next lanelets is not good as a specification of the utility function.
Let's change the function to get_next_lanelets_within_route
, and the node side will use the first one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The next lanelet in a route should be single.
So, please add the error log like
RCLCPP_WARN(rclcpp::get_logger("path_generator.utils"), "The multiple next lanelets in a route are found not as expected. Internal calculation might have failed.");
when there are multiple next lanelets.
Returning the first lanelet in this case is fine.
Signed-off-by: mitukou1109 <[email protected]>
Signed-off-by: mitukou1109 <[email protected]>
Signed-off-by: mitukou1109 <[email protected]>
Signed-off-by: mitukou1109 <[email protected]>
Signed-off-by: mitukou1109 <[email protected]>
Signed-off-by: mitukou1109 <[email protected]>
Signed-off-by: mitukou1109 <[email protected]>
Signed-off-by: mitukou1109 <[email protected]>
Signed-off-by: mitukou1109 <[email protected]>
Signed-off-by: mitukou1109 <[email protected]>
Signed-off-by: mitukou1109 <[email protected]>
Signed-off-by: mitukou1109 <[email protected]>
Signed-off-by: mitukou1109 <[email protected]>
Signed-off-by: mitukou1109 <[email protected]>
Signed-off-by: mitukou1109 <[email protected]>
Signed-off-by: mitukou1109 <[email protected]>
Signed-off-by: mitukou1109 <[email protected]>
Signed-off-by: mitukou1109 <[email protected]>
Signed-off-by: mitukou1109 <[email protected]>
7b7dc3c
to
409a791
Compare
Signed-off-by: mitukou1109 <[email protected]>
Signed-off-by: mitukou1109 <[email protected]>
Signed-off-by: mitukou1109 <[email protected]>
New PR was created, so I close this PR. |
Description
This PR adds
path_generator
package, a simplified alternative ofbehavior_path_planner
.Related links
How was this PR tested?
Psim on a lanelet2 map with waypoints
Screencast.from.2024.11.29.16.11.24.webm
Notes for reviewers
None.
Interface changes
None.
Effects on system behavior
None.