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: add detected object feature remover #66

Closed
wants to merge 2 commits into from
Closed
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
31 changes: 31 additions & 0 deletions perception/detected_object_feature_remover/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
)
27 changes: 27 additions & 0 deletions perception/detected_object_feature_remover/README.md
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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 <rclcpp/rclcpp.hpp>

#include <autoware_auto_perception_msgs/msg/detected_objects.hpp>
#include <autoware_perception_msgs/msg/detected_objects_with_feature.hpp>

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<DetectedObjectsWithFeature>::SharedPtr sub_;
rclcpp::Publisher<DetectedObjects>::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_
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<launch>
<arg name="input" />
<arg name="output" />

<node pkg="detected_object_feature_remover" exec="detected_object_feature_remover" name="detected_object_feature_remover" output="screen">
<remap from="~/input" to="$(var input)"/>
<remap from="~/output" to="$(var output)"/>
</node>

</launch>
23 changes: 23 additions & 0 deletions perception/detected_object_feature_remover/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0"?>
<package format="2">
<name>detected_object_feature_remover</name>
<version>0.1.0</version>
<description>The detected_object_feature_remover package</description>
<maintainer email="tomoya.kimura@tier4.jp">Tomoya Kimura</maintainer>
<license>Apache License 2.0</license>

<buildtool_depend>ament_cmake</buildtool_depend>

<depend>autoware_auto_perception_msgs</depend>
<depend>autoware_perception_msgs</depend>
<depend>rclcpp</depend>
<depend>rclcpp_components</depend>

<test_depend>ament_cmake_gtest</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
@@ -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 <detected_object_feature_remover/detected_object_feature_remover.hpp>

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<DetectedObjects>("~/output", rclcpp::QoS(1));
sub_ = this->create_subscription<DetectedObjectsWithFeature>(
"~/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_macro.hpp>
RCLCPP_COMPONENTS_REGISTER_NODE(detected_object_feature_remover::DetectedObjectFeatureRemover)