diff --git a/perception/detected_object_feature_remover/CMakeLists.txt b/perception/detected_object_feature_remover/CMakeLists.txt new file mode 100644 index 0000000000000..bcb9165ed5b6d --- /dev/null +++ b/perception/detected_object_feature_remover/CMakeLists.txt @@ -0,0 +1,31 @@ +cmake_minimum_required(VERSION 3.5) +project(detected_object_feature_remover) + +### Compile options +if(NOT CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 14) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + set(CMAKE_CXX_EXTENSIONS OFF) +endif() +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compile_options(-Wall -Wextra -Wpedantic -Werror) +endif() + +### Dependencies +find_package(ament_cmake_auto REQUIRED) +ament_auto_find_build_dependencies() + +# Generate exe file +ament_auto_add_library(detected_object_feature_remover_node SHARED + src/detected_object_feature_remover.cpp +) + +rclcpp_components_register_node(detected_object_feature_remover_node + PLUGIN "detected_object_feature_remover::DetectedObjectFeatureRemover" + EXECUTABLE detected_object_feature_remover +) + +ament_auto_package( + INSTALL_TO_SHARE + launch +) diff --git a/perception/detected_object_feature_remover/README.md b/perception/detected_object_feature_remover/README.md new file mode 100644 index 0000000000000..dd98f13c1599a --- /dev/null +++ b/perception/detected_object_feature_remover/README.md @@ -0,0 +1,27 @@ +# detected_object_feature_remover + +## Purpose + +The `detected_object_feature_remover` is a package to convert topic-type from `DetectedObjectWithFeatureArray` to `DetectedObjects`. + +## Inner-workings / Algorithms + +## Inputs / Outputs + +### Input + +| Name | Type | Description | +| --------- | --------------------------------------------------------------- | ----------------------------------- | +| `~/input` | `autoware_perception_msgs::msg::DetectedObjectWithFeatureArray` | detected objects with feature field | + +### Output + +| Name | Type | Description | +| ---------- | ----------------------------------------------------- | ---------------- | +| `~/output` | `autoware_auto_perception_msgs::msg::DetectedObjects` | detected objects | + +## Parameters + +None + +## Assumptions / Known limits diff --git a/perception/detected_object_feature_remover/include/detected_object_feature_remover/detected_object_feature_remover.hpp b/perception/detected_object_feature_remover/include/detected_object_feature_remover/detected_object_feature_remover.hpp new file mode 100644 index 0000000000000..74bb5df0f9752 --- /dev/null +++ b/perception/detected_object_feature_remover/include/detected_object_feature_remover/detected_object_feature_remover.hpp @@ -0,0 +1,42 @@ +// Copyright 2021 Tier IV, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef DETECTED_OBJECT_FEATURE_REMOVER__DETECTED_OBJECT_FEATURE_REMOVER_HPP_ +#define DETECTED_OBJECT_FEATURE_REMOVER__DETECTED_OBJECT_FEATURE_REMOVER_HPP_ + +#include + +#include +#include + +namespace detected_object_feature_remover +{ +using autoware_auto_perception_msgs::msg::DetectedObjects; +using autoware_perception_msgs::msg::DetectedObjectsWithFeature; + +class DetectedObjectFeatureRemover : public rclcpp::Node +{ +public: + explicit DetectedObjectFeatureRemover(const rclcpp::NodeOptions & node_options); + +private: + rclcpp::Subscription::SharedPtr sub_; + rclcpp::Publisher::SharedPtr pub_; + void objectCallback(const DetectedObjectsWithFeature::ConstSharedPtr input); + void convert(const DetectedObjectsWithFeature & objs_with_feature, DetectedObjects & objs); +}; + +} // namespace detected_object_feature_remover + +#endif // DETECTED_OBJECT_FEATURE_REMOVER__DETECTED_OBJECT_FEATURE_REMOVER_HPP_ diff --git a/perception/detected_object_feature_remover/launch/detected_object_feature_remover.launch.xml b/perception/detected_object_feature_remover/launch/detected_object_feature_remover.launch.xml new file mode 100644 index 0000000000000..81684ebd20eb4 --- /dev/null +++ b/perception/detected_object_feature_remover/launch/detected_object_feature_remover.launch.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/perception/detected_object_feature_remover/package.xml b/perception/detected_object_feature_remover/package.xml new file mode 100644 index 0000000000000..4b54614f56035 --- /dev/null +++ b/perception/detected_object_feature_remover/package.xml @@ -0,0 +1,23 @@ + + + detected_object_feature_remover + 0.1.0 + The detected_object_feature_remover package + Tomoya Kimura + Apache License 2.0 + + ament_cmake + + autoware_auto_perception_msgs + autoware_perception_msgs + rclcpp + rclcpp_components + + ament_cmake_gtest + ament_lint_auto + autoware_lint_common + + + ament_cmake + + diff --git a/perception/detected_object_feature_remover/src/detected_object_feature_remover.cpp b/perception/detected_object_feature_remover/src/detected_object_feature_remover.cpp new file mode 100644 index 0000000000000..d1e007d7ef65f --- /dev/null +++ b/perception/detected_object_feature_remover/src/detected_object_feature_remover.cpp @@ -0,0 +1,48 @@ +// Copyright 2021 Tier IV, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include + +namespace detected_object_feature_remover +{ +DetectedObjectFeatureRemover::DetectedObjectFeatureRemover(const rclcpp::NodeOptions & node_options) +: Node("detected_object_feature_remover", node_options) +{ + using std::placeholders::_1; + pub_ = this->create_publisher("~/output", rclcpp::QoS(1)); + sub_ = this->create_subscription( + "~/input", 1, std::bind(&DetectedObjectFeatureRemover::objectCallback, this, _1)); +} + +void DetectedObjectFeatureRemover::objectCallback( + const DetectedObjectsWithFeature::ConstSharedPtr input) +{ + DetectedObjects output; + convert(*input, output); + pub_->publish(output); +} + +void DetectedObjectFeatureRemover::convert( + const DetectedObjectsWithFeature & objs_with_feature, DetectedObjects & objs) +{ + objs.header = objs_with_feature.header; + for (const auto & obj_with_feature : objs_with_feature.feature_objects) { + objs.objects.emplace_back(obj_with_feature.object); + } +} + +} // namespace detected_object_feature_remover + +#include +RCLCPP_COMPONENTS_REGISTER_NODE(detected_object_feature_remover::DetectedObjectFeatureRemover)