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

fix(autoware_pure_pursuit): fix cppcheck unusedFunction #9276

Merged
merged 1 commit into from
Nov 11, 2024
Merged
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 @@ -74,55 +74,6 @@ std::pair<bool, int32_t> findClosestIdxWithDistAngThr(

int8_t getLaneDirection(const std::vector<geometry_msgs::msg::Pose> & poses, double th_dist = 0.5);

// cspell: ignore pointinpoly
// refer from apache's pointinpoly in http://www.visibone.com/inpoly/
template <typename T>
bool isInPolygon(const std::vector<T> & polygon, const T & point)
{
// polygons with fewer than 3 sides are excluded
if (polygon.size() < 3) {
return false;
}

bool in_poly = false;
double x1, x2, y1, y2;

uint32_t nr_poly_points = polygon.size();
// start with the last point to make the check last point<->first point the first one
double xold = polygon.at(nr_poly_points - 1).x();
double yold = polygon.at(nr_poly_points - 1).y();
for (const auto & poly_p : polygon) {
double xnew = poly_p.x();
double ynew = poly_p.y();
if (xnew > xold) {
x1 = xold;
x2 = xnew;
y1 = yold;
y2 = ynew;
} else {
x1 = xnew;
x2 = xold;
y1 = ynew;
y2 = yold;
}

if (
(xnew < point.x()) == (point.x() <= xold) &&
(point.y() - y1) * (x2 - x1) < (y2 - y1) * (point.x() - x1)) {
in_poly = !in_poly;
}
xold = xnew;
yold = ynew;
}

return in_poly;
}

template <>
bool isInPolygon(
const std::vector<geometry_msgs::msg::Point> & polygon, const geometry_msgs::msg::Point & point);

double kmph2mps(const double velocity_kmph);
double normalizeEulerAngle(const double euler);

geometry_msgs::msg::Point transformToAbsoluteCoordinate2D(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,25 +164,6 @@ int8_t getLaneDirection(const std::vector<geometry_msgs::msg::Pose> & poses, dou
return 2;
}

template <>
bool isInPolygon(
const std::vector<geometry_msgs::msg::Point> & polygon, const geometry_msgs::msg::Point & point)
{
std::vector<tf2::Vector3> polygon_conv;
for (const auto & el : polygon) {
polygon_conv.emplace_back(el.x, el.y, el.z);
}

tf2::Vector3 point_conv = tf2::Vector3(point.x, point.y, point.z);

return isInPolygon<tf2::Vector3>(polygon_conv, point_conv);
}

double kmph2mps(const double velocity_kmph)
{
return (velocity_kmph * 1000) / (60 * 60);
}

double normalizeEulerAngle(const double euler)
{
double res = euler;
Expand Down
Loading