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: apply splitting of autoware_utils_geometry #10270

Merged
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 @@ -36,14 +36,19 @@
#include <string>
#include <vector>

namespace autoware_utils
namespace autoware_utils_geometry
{

template <>
geometry_msgs::msg::Point get_point(const autoware::path_optimizer::ReferencePoint & p);

template <>
geometry_msgs::msg::Pose get_pose(const autoware::path_optimizer::ReferencePoint & p);
} // namespace autoware_utils

template <>
double get_longitudinal_velocity(const autoware::path_optimizer::ReferencePoint & p);

} // namespace autoware_utils_geometry

namespace autoware::path_optimizer
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "autoware/motion_utils/trajectory/trajectory.hpp"
#include "autoware/path_optimizer/common_structs.hpp"
#include "autoware/path_optimizer/type_alias.hpp"
#include "autoware/path_optimizer/utils/geometry_utils.hpp"
#include "autoware_utils/geometry/geometry.hpp"

#include <Eigen/Core>
Expand All @@ -36,18 +37,6 @@
#include <string>
#include <vector>

namespace autoware_utils
{
template <>
geometry_msgs::msg::Point get_point(const autoware::path_optimizer::ReferencePoint & p);

template <>
geometry_msgs::msg::Pose get_pose(const autoware::path_optimizer::ReferencePoint & p);

template <>
double get_longitudinal_velocity(const autoware::path_optimizer::ReferencePoint & p);
} // namespace autoware_utils

namespace autoware::path_optimizer
{
namespace trajectory_utils
Expand Down Expand Up @@ -107,13 +96,7 @@ TrajectoryPoint convertToTrajectoryPoint(const T & point)
}

template <>
inline TrajectoryPoint convertToTrajectoryPoint(const ReferencePoint & ref_point)
{
TrajectoryPoint traj_point;
traj_point.pose = autoware_utils::get_pose(ref_point);
traj_point.longitudinal_velocity_mps = autoware_utils::get_longitudinal_velocity(ref_point);
return traj_point;
}
TrajectoryPoint convertToTrajectoryPoint(const ReferencePoint & ref_point);

template <typename T>
std::vector<TrajectoryPoint> convertToTrajectoryPoints(const std::vector<T> & points)
Expand Down
23 changes: 23 additions & 0 deletions planning/autoware_path_optimizer/src/utils/geometry_utils.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 TIER IV, Inc.

Check warning on line 1 in planning/autoware_path_optimizer/src/utils/geometry_utils.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Overall Code Complexity

This module has a mean cyclomatic complexity of 4.29 across 7 functions. The mean complexity threshold is 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 @@ -36,6 +36,29 @@
#include <stack>
#include <vector>

namespace autoware_utils_geometry
{

template <>
geometry_msgs::msg::Point get_point(const autoware::path_optimizer::ReferencePoint & p)
{
return p.pose.position;
}

template <>
geometry_msgs::msg::Pose get_pose(const autoware::path_optimizer::ReferencePoint & p)
{
return p.pose;
}

template <>
double get_longitudinal_velocity(const autoware::path_optimizer::ReferencePoint & p)
{
return p.longitudinal_velocity_mps;
}

} // namespace autoware_utils_geometry

namespace autoware::path_optimizer
{
namespace bg = boost::geometry;
Expand Down
24 changes: 7 additions & 17 deletions planning/autoware_path_optimizer/src/utils/trajectory_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,21 @@
#include <stack>
#include <vector>

namespace autoware_utils
{
template <>
geometry_msgs::msg::Point get_point(const autoware::path_optimizer::ReferencePoint & p)
namespace autoware::path_optimizer
{
return p.pose.position;
}

template <>
geometry_msgs::msg::Pose get_pose(const autoware::path_optimizer::ReferencePoint & p)
namespace trajectory_utils
{
return p.pose;
}

template <>
double get_longitudinal_velocity(const autoware::path_optimizer::ReferencePoint & p)
TrajectoryPoint convertToTrajectoryPoint(const ReferencePoint & ref_point)
{
return p.longitudinal_velocity_mps;
TrajectoryPoint traj_point;
traj_point.pose = autoware_utils::get_pose(ref_point);
traj_point.longitudinal_velocity_mps = autoware_utils::get_longitudinal_velocity(ref_point);
return traj_point;
}
} // namespace autoware_utils

namespace autoware::path_optimizer
{
namespace trajectory_utils
{
ReferencePoint convertToReferencePoint(const TrajectoryPoint & traj_point)
{
ReferencePoint ref_point;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include <utility>
#include <vector>

namespace autoware_utils
namespace autoware_utils_geometry
{

template <>
Expand All @@ -52,7 +52,7 @@ inline geometry_msgs::msg::Point get_point(const lanelet::ConstPoint3d & p)
return point;
}

} // namespace autoware_utils
} // namespace autoware_utils_geometry

namespace
{
Expand Down
Loading