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

chore: separate traffic_light_utils from perception_utils #4207

Merged
merged 13 commits into from
Jul 12, 2023
Merged
26 changes: 26 additions & 0 deletions common/object_recognition_utils/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
cmake_minimum_required(VERSION 3.14)
project(object_recognition_utils)

find_package(autoware_cmake REQUIRED)
autoware_package()

find_package(Boost REQUIRED)

ament_auto_add_library(object_recognition_utils SHARED
src/predicted_path_utils.cpp
src/conversion.cpp
)

if(BUILD_TESTING)
find_package(ament_cmake_ros REQUIRED)

file(GLOB_RECURSE test_files test/**/*.cpp)

ament_add_ros_isolated_gtest(test_object_recognition_utils ${test_files})

target_link_libraries(test_object_recognition_utils
object_recognition_utils
)
endif()

ament_auto_package()
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef PERCEPTION_UTILS__CONVERSION_HPP_
#define PERCEPTION_UTILS__CONVERSION_HPP_
#ifndef OBJECT_RECOGNITION_UTILS__CONVERSION_HPP_
#define OBJECT_RECOGNITION_UTILS__CONVERSION_HPP_

#include <autoware_auto_perception_msgs/msg/detected_objects.hpp>
#include <autoware_auto_perception_msgs/msg/tracked_objects.hpp>

namespace perception_utils
namespace object_recognition_utils
{
using autoware_auto_perception_msgs::msg::DetectedObject;
using autoware_auto_perception_msgs::msg::DetectedObjects;
Expand All @@ -29,6 +29,6 @@ DetectedObject toDetectedObject(const TrackedObject & tracked_object);
DetectedObjects toDetectedObjects(const TrackedObjects & tracked_objects);
TrackedObject toTrackedObject(const DetectedObject & detected_object);
TrackedObjects toTrackedObjects(const DetectedObjects & detected_objects);
} // namespace perception_utils
} // namespace object_recognition_utils

#endif // PERCEPTION_UTILS__CONVERSION_HPP_
#endif // OBJECT_RECOGNITION_UTILS__CONVERSION_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef PERCEPTION_UTILS__GEOMETRY_HPP_
#define PERCEPTION_UTILS__GEOMETRY_HPP_
#ifndef OBJECT_RECOGNITION_UTILS__GEOMETRY_HPP_
#define OBJECT_RECOGNITION_UTILS__GEOMETRY_HPP_

#include <autoware_auto_perception_msgs/msg/detected_object.hpp>
#include <autoware_auto_perception_msgs/msg/predicted_object.hpp>
#include <autoware_auto_perception_msgs/msg/tracked_object.hpp>
#include <geometry_msgs/msg/pose.hpp>

namespace perception_utils
namespace object_recognition_utils
{
template <class T>
geometry_msgs::msg::Pose getPose([[maybe_unused]] const T & p)
Expand Down Expand Up @@ -55,6 +55,6 @@ inline geometry_msgs::msg::Pose getPose(
{
return obj.kinematics.initial_pose_with_covariance.pose;
}
} // namespace perception_utils
} // namespace object_recognition_utils

#endif // PERCEPTION_UTILS__GEOMETRY_HPP_
#endif // OBJECT_RECOGNITION_UTILS__GEOMETRY_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef PERCEPTION_UTILS__MATCHING_HPP_
#define PERCEPTION_UTILS__MATCHING_HPP_
#ifndef OBJECT_RECOGNITION_UTILS__MATCHING_HPP_
#define OBJECT_RECOGNITION_UTILS__MATCHING_HPP_

#include "perception_utils/geometry.hpp"
#include "object_recognition_utils/geometry.hpp"
#include "tier4_autoware_utils/geometry/boost_geometry.hpp"
#include "tier4_autoware_utils/geometry/boost_polygon_utils.hpp"

Expand All @@ -26,7 +26,7 @@
#include <utility>
#include <vector>

namespace perception_utils
namespace object_recognition_utils
{
using tier4_autoware_utils::Polygon2d;

Expand Down Expand Up @@ -116,6 +116,6 @@ double get2dRecall(const T1 source_object, const T2 target_object)

return std::min(1.0, intersection_area / target_area);
}
} // namespace perception_utils
} // namespace object_recognition_utils

#endif // PERCEPTION_UTILS__MATCHING_HPP_
#endif // OBJECT_RECOGNITION_UTILS__MATCHING_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef PERCEPTION_UTILS__OBJECT_CLASSIFICATION_HPP_
#define PERCEPTION_UTILS__OBJECT_CLASSIFICATION_HPP_
#ifndef OBJECT_RECOGNITION_UTILS__OBJECT_CLASSIFICATION_HPP_
#define OBJECT_RECOGNITION_UTILS__OBJECT_CLASSIFICATION_HPP_

#include "autoware_auto_perception_msgs/msg/object_classification.hpp"

#include <string>
#include <vector>

namespace perception_utils
namespace object_recognition_utils
{
using autoware_auto_perception_msgs::msg::ObjectClassification;

Expand Down Expand Up @@ -169,6 +169,6 @@ inline std::string convertLabelToString(
return convertLabelToString(highest_prob_label);
}

} // namespace perception_utils
} // namespace object_recognition_utils

#endif // PERCEPTION_UTILS__OBJECT_CLASSIFICATION_HPP_
#endif // OBJECT_RECOGNITION_UTILS__OBJECT_CLASSIFICATION_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef PERCEPTION_UTILS__PERCEPTION_UTILS_HPP_
#define PERCEPTION_UTILS__PERCEPTION_UTILS_HPP_
#ifndef OBJECT_RECOGNITION_UTILS__OBJECT_RECOGNITION_UTILS_HPP_
#define OBJECT_RECOGNITION_UTILS__OBJECT_RECOGNITION_UTILS_HPP_

#include "perception_utils/conversion.hpp"
#include "perception_utils/geometry.hpp"
#include "perception_utils/matching.hpp"
#include "perception_utils/object_classification.hpp"
#include "perception_utils/predicted_path_utils.hpp"
#include "perception_utils/transform.hpp"
#include "object_recognition_utils/conversion.hpp"
#include "object_recognition_utils/geometry.hpp"
#include "object_recognition_utils/matching.hpp"
#include "object_recognition_utils/object_classification.hpp"
#include "object_recognition_utils/predicted_path_utils.hpp"
#include "object_recognition_utils/transform.hpp"

#endif // PERCEPTION_UTILS__PERCEPTION_UTILS_HPP_
#endif // OBJECT_RECOGNITION_UTILS__OBJECT_RECOGNITION_UTILS_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef PERCEPTION_UTILS__PREDICTED_PATH_UTILS_HPP_
#define PERCEPTION_UTILS__PREDICTED_PATH_UTILS_HPP_
#ifndef OBJECT_RECOGNITION_UTILS__PREDICTED_PATH_UTILS_HPP_
#define OBJECT_RECOGNITION_UTILS__PREDICTED_PATH_UTILS_HPP_

#include "tier4_autoware_utils/geometry/geometry.hpp"

Expand All @@ -24,7 +24,7 @@

#include <vector>

namespace perception_utils
namespace object_recognition_utils
{
/**
* @brief Calculate Interpolated Pose from predicted path by time
Expand Down Expand Up @@ -61,6 +61,6 @@ autoware_auto_perception_msgs::msg::PredictedPath resamplePredictedPath(
const autoware_auto_perception_msgs::msg::PredictedPath & path,
const double sampling_time_interval, const double sampling_horizon,
const bool use_spline_for_xy = true, const bool use_spline_for_z = false);
} // namespace perception_utils
} // namespace object_recognition_utils

#endif // PERCEPTION_UTILS__PREDICTED_PATH_UTILS_HPP_
#endif // OBJECT_RECOGNITION_UTILS__PREDICTED_PATH_UTILS_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef PERCEPTION_UTILS__TRANSFORM_HPP_
#define PERCEPTION_UTILS__TRANSFORM_HPP_
#ifndef OBJECT_RECOGNITION_UTILS__TRANSFORM_HPP_
#define OBJECT_RECOGNITION_UTILS__TRANSFORM_HPP_

#include <geometry_msgs/msg/transform.hpp>

Expand Down Expand Up @@ -41,13 +41,13 @@ namespace detail
target_frame_id, source_frame_id, time, rclcpp::Duration::from_seconds(0.5));
return self_transform_stamped.transform;
} catch (tf2::TransformException & ex) {
RCLCPP_WARN_STREAM(rclcpp::get_logger("perception_utils"), ex.what());
RCLCPP_WARN_STREAM(rclcpp::get_logger("object_recognition_utils"), ex.what());
return boost::none;
}
}
} // namespace detail

namespace perception_utils
namespace object_recognition_utils
{
template <class T>
bool transformObjects(
Expand Down Expand Up @@ -79,6 +79,6 @@ bool transformObjects(
}
return true;
}
} // namespace perception_utils
} // namespace object_recognition_utils

#endif // PERCEPTION_UTILS__TRANSFORM_HPP_
#endif // OBJECT_RECOGNITION_UTILS__TRANSFORM_HPP_
30 changes: 30 additions & 0 deletions common/object_recognition_utils/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>object_recognition_utils</name>
<version>0.1.0</version>
<description>The object_recognition_utils package</description>
<maintainer email="takayuki.murooka@tier4.jp">Takayuki Murooka</maintainer>
<maintainer email="satoshi.tanaka@tier4.jp">Satoshi Tanaka</maintainer>
<maintainer email="yusuke.muramatsu@tier4.jp">Yusuke Muramatsu</maintainer>
<maintainer email="shunsuke.miura@tier4.jp">Shunsuke Miura</maintainer>
<license>Apache License 2.0</license>

<buildtool_depend>ament_cmake_auto</buildtool_depend>
<buildtool_depend>autoware_cmake</buildtool_depend>

<depend>autoware_auto_perception_msgs</depend>
<depend>geometry_msgs</depend>
<depend>interpolation</depend>
<depend>libboost-dev</depend>
<depend>rclcpp</depend>
<depend>tier4_autoware_utils</depend>

<test_depend>ament_cmake_ros</test_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>autoware_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "perception_utils/conversion.hpp"
#include "object_recognition_utils/conversion.hpp"

namespace perception_utils
namespace object_recognition_utils
{
using autoware_auto_perception_msgs::msg::DetectedObject;
using autoware_auto_perception_msgs::msg::DetectedObjects;
Expand Down Expand Up @@ -79,4 +79,4 @@ TrackedObjects toTrackedObjects(const DetectedObjects & detected_objects)
}
return tracked_objects;
}
} // namespace perception_utils
} // namespace object_recognition_utils
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "perception_utils/predicted_path_utils.hpp"
#include "object_recognition_utils/predicted_path_utils.hpp"

#include "interpolation/linear_interpolation.hpp"
#include "interpolation/spherical_linear_interpolation.hpp"
#include "interpolation/spline_interpolation.hpp"

#include <algorithm>

namespace perception_utils
namespace object_recognition_utils
{
boost::optional<geometry_msgs::msg::Pose> calcInterpolatedPose(
const autoware_auto_perception_msgs::msg::PredictedPath & path, const double relative_time)
Expand Down Expand Up @@ -130,4 +130,4 @@ autoware_auto_perception_msgs::msg::PredictedPath resamplePredictedPath(
resampled_path.time_step = rclcpp::Duration::from_seconds(sampling_time_interval);
return resampled_path;
}
} // namespace perception_utils
} // namespace object_recognition_utils
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "perception_utils/conversion.hpp"
#include "object_recognition_utils/conversion.hpp"
#include "tier4_autoware_utils/geometry/geometry.hpp"

#include <gtest/gtest.h>
Expand Down Expand Up @@ -43,7 +43,7 @@ autoware_auto_perception_msgs::msg::ObjectClassification createObjectClassificat
TEST(conversion, test_toDetectedObject)
{
using autoware_auto_perception_msgs::msg::ObjectClassification;
using perception_utils::toDetectedObject;
using object_recognition_utils::toDetectedObject;

autoware_auto_perception_msgs::msg::TrackedObject tracked_obj;
// existence probability
Expand Down Expand Up @@ -161,7 +161,7 @@ TEST(conversion, test_toDetectedObject)
TEST(conversion, test_toTrackedObject)
{
using autoware_auto_perception_msgs::msg::ObjectClassification;
using perception_utils::toTrackedObject;
using object_recognition_utils::toTrackedObject;

autoware_auto_perception_msgs::msg::DetectedObject detected_obj;
// existence probability
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "perception_utils/geometry.hpp"
#include "object_recognition_utils/geometry.hpp"

#include <gtest/gtest.h>

#include <string>

TEST(geometry, getPose)
{
using perception_utils::getPose;
using object_recognition_utils::getPose;

const double x_ans = 1.0;
const double y_ans = 2.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "perception_utils/matching.hpp"
#include "object_recognition_utils/matching.hpp"
#include "tier4_autoware_utils/geometry/geometry.hpp"

#include <autoware_auto_perception_msgs/msg/detected_object.hpp>
Expand All @@ -38,7 +38,7 @@ geometry_msgs::msg::Pose createPose(const double x, const double y, const double
TEST(matching, test_get2dIoU)
{
using autoware_auto_perception_msgs::msg::DetectedObject;
using perception_utils::get2dIoU;
using object_recognition_utils::get2dIoU;

const double quart_circle = 0.16237976320958225;

Expand Down Expand Up @@ -91,9 +91,9 @@ TEST(matching, test_get2dIoU)
}
}

TEST(perception_utils, test_get2dGeneralizedIoU)
TEST(object_recognition_utils, test_get2dGeneralizedIoU)
{
using perception_utils::get2dGeneralizedIoU;
using object_recognition_utils::get2dGeneralizedIoU;
// TODO(Shin-kyoto):
// get2dGeneralizedIoU uses outer points of each polygon.
// But these points contain an sampling error of outer line,
Expand Down Expand Up @@ -154,7 +154,7 @@ TEST(perception_utils, test_get2dGeneralizedIoU)
TEST(matching, test_get2dPrecision)
{
using autoware_auto_perception_msgs::msg::DetectedObject;
using perception_utils::get2dPrecision;
using object_recognition_utils::get2dPrecision;
const double quart_circle = 0.16237976320958225;

{ // non overlapped
Expand Down Expand Up @@ -221,7 +221,7 @@ TEST(matching, test_get2dPrecision)
TEST(matching, test_get2dRecall)
{
using autoware_auto_perception_msgs::msg::DetectedObject;
using perception_utils::get2dRecall;
using object_recognition_utils::get2dRecall;
const double quart_circle = 0.16237976320958225;

{ // non overlapped
Expand Down
Loading