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(route_handler): closest road lanelet with yaw #7123

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -277,7 +277,8 @@ class RouteHandler
std::optional<lanelet::ConstLanelet> getPullOverTarget(const Pose & goal_pose) const;
std::optional<lanelet::ConstLanelet> getPullOutStartLane(
const Pose & pose, const double vehicle_width) const;
lanelet::ConstLanelets getRoadLaneletsAtPose(const Pose & pose) const;
lanelet::ConstLanelets getRoadLaneletsAtPose(
const Pose & pose, const std::optional<double> & yaw_threshold = std::nullopt) const;
std::optional<lanelet::ConstLanelet> getLeftShoulderLanelet(
const lanelet::ConstLanelet & lanelet) const;
std::optional<lanelet::ConstLanelet> getRightShoulderLanelet(
Expand Down
12 changes: 11 additions & 1 deletion planning/route_handler/src/route_handler.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021-2023 Tier IV, Inc.

Check notice on line 1 in planning/route_handler/src/route_handler.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Lines of Code in a Single File

The lines of code increases from 1609 to 1617, improve code health by reducing it to 1000. The number of Lines of Code in a single file. More Lines of Code lowers the code health.

Check notice on line 1 in planning/route_handler/src/route_handler.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ Getting better: Code Duplication

reduced similar code in: RouteHandler::getRoadLaneletsAtPose,RouteHandler::getShoulderLaneletsAtPose. Avoid duplicated, aka copy-pasted, code inside the module. More duplication lowers the code health.

Check notice on line 1 in planning/route_handler/src/route_handler.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Overall Code Complexity

The mean cyclomatic complexity increases from 4.56 to 4.60, threshold = 4. This file has many conditional statements (e.g. if, for, while) across its implementation, leading to lower code health. Avoid adding more conditionals.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -689,14 +689,24 @@
return lanelet_sequence;
}

lanelet::ConstLanelets RouteHandler::getRoadLaneletsAtPose(const Pose & pose) const
lanelet::ConstLanelets RouteHandler::getRoadLaneletsAtPose(
const Pose & pose, const std::optional<double> & yaw_threshold) const
{
lanelet::ConstLanelets road_lanelets_at_pose;
const lanelet::BasicPoint2d p{pose.position.x, pose.position.y};
const auto lanelets_at_pose = lanelet_map_ptr_->laneletLayer.search(lanelet::BoundingBox2d(p));
for (const auto & lanelet_at_pose : lanelets_at_pose) {
// confirm that the pose is inside the lanelet since "search" does an approximation with boxes
const auto is_pose_inside_lanelet = lanelet::geometry::inside(lanelet_at_pose, p);

if (yaw_threshold) {
const auto lane_yaw = lanelet::utils::getLaneletAngle(lanelet_at_pose, pose.position);
const double yaw = tf2::getYaw(pose.orientation);
if (*yaw_threshold < std::abs(tier4_autoware_utils::normalizeRadian(lane_yaw - yaw))) {
continue;
}
}

if (is_pose_inside_lanelet && isRoadLanelet(lanelet_at_pose))
road_lanelets_at_pose.push_back(lanelet_at_pose);
}
Expand Down
Loading