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(lanelet2_extension)!: remove dependency on autoware_utils #47

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
25 changes: 20 additions & 5 deletions autoware_lanelet2_extension/lib/query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@
#include "autoware_lanelet2_extension/utility/message_conversion.hpp"
#include "autoware_lanelet2_extension/utility/utilities.hpp"

#include <Eigen/Eigen>
#include <autoware_utils/autoware_utils.hpp>

#include <lanelet2_core/LaneletMap.h>
#include <lanelet2_core/geometry/Lanelet.h>
#include <lanelet2_core/primitives/Lanelet.h>
Expand All @@ -54,6 +51,24 @@

using lanelet::utils::to2D;

namespace
{

inline double normalize_radian(const double rad)

Check warning on line 57 in autoware_lanelet2_extension/lib/query.cpp

View check run for this annotation

Codecov / codecov/patch

autoware_lanelet2_extension/lib/query.cpp#L57

Added line #L57 was not covered by tests
{
constexpr double pi = 3.14159265358979323846; // To be replaced by std::numbers::pi in C++20
constexpr double min_rad = -pi;
const auto max_rad = min_rad + 2 * pi;

const auto value = std::fmod(rad, 2 * pi);

Check warning on line 63 in autoware_lanelet2_extension/lib/query.cpp

View check run for this annotation

Codecov / codecov/patch

autoware_lanelet2_extension/lib/query.cpp#L63

Added line #L63 was not covered by tests
if (min_rad <= value && value < max_rad) {
return value;
}

return value - std::copysign(2 * pi, value);

Check warning on line 68 in autoware_lanelet2_extension/lib/query.cpp

View check run for this annotation

Codecov / codecov/patch

autoware_lanelet2_extension/lib/query.cpp#L68

Added line #L68 was not covered by tests
}
} // namespace

namespace lanelet::utils
{

Expand Down Expand Up @@ -934,7 +949,7 @@
if (!segment.empty()) {
double segment_angle = std::atan2(
segment.back().y() - segment.front().y(), segment.back().x() - segment.front().x());
angle_diff = std::abs(autoware_utils::normalize_radian(segment_angle - pose_yaw));
angle_diff = std::abs(::normalize_radian(segment_angle - pose_yaw));

Check warning on line 952 in autoware_lanelet2_extension/lib/query.cpp

View check run for this annotation

Codecov / codecov/patch

autoware_lanelet2_extension/lib/query.cpp#L952

Added line #L952 was not covered by tests
}
if (angle_diff < min_angle) {
min_angle = angle_diff;
Expand Down Expand Up @@ -996,7 +1011,7 @@
const auto & distance = llt_pair.second;

double lanelet_angle = getLaneletAngle(llt_pair.first, search_pose.position);
double angle_diff = std::abs(autoware_utils::normalize_radian(lanelet_angle - pose_yaw));
double angle_diff = std::abs(::normalize_radian(lanelet_angle - pose_yaw));

Check warning on line 1014 in autoware_lanelet2_extension/lib/query.cpp

View check run for this annotation

Codecov / codecov/patch

autoware_lanelet2_extension/lib/query.cpp#L1014

Added line #L1014 was not covered by tests

if (angle_diff > std::abs(yaw_threshold)) continue;
if (min_distance < distance) break;
Expand Down
1 change: 0 additions & 1 deletion autoware_lanelet2_extension/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

<depend>autoware_map_msgs</depend>
<depend>autoware_planning_msgs</depend>
<depend>autoware_utils</depend>
<depend>geographiclib</depend>
<depend>geometry_msgs</depend>
<depend>lanelet2_core</depend>
Expand Down
Loading