|
| 1 | +// Copyright 2021 Tier IV, Inc. |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +#include <detected_object_feature_remover/detected_object_feature_remover.hpp> |
| 16 | + |
| 17 | +namespace detected_object_feature_remover |
| 18 | +{ |
| 19 | +DetectedObjectFeatureRemover::DetectedObjectFeatureRemover(const rclcpp::NodeOptions & node_options) |
| 20 | +: Node("detected_object_feature_remover", node_options) |
| 21 | +{ |
| 22 | + using std::placeholders::_1; |
| 23 | + pub_ = this->create_publisher<DetectedObjects>("~/output", rclcpp::QoS(1)); |
| 24 | + sub_ = this->create_subscription<DetectedObjectsWithFeature>( |
| 25 | + "~/input", 1, std::bind(&DetectedObjectFeatureRemover::objectCallback, this, _1)); |
| 26 | +} |
| 27 | + |
| 28 | +void DetectedObjectFeatureRemover::objectCallback( |
| 29 | + const DetectedObjectsWithFeature::ConstSharedPtr input) |
| 30 | +{ |
| 31 | + DetectedObjects output; |
| 32 | + convert(*input, output); |
| 33 | + pub_->publish(output); |
| 34 | +} |
| 35 | + |
| 36 | +void DetectedObjectFeatureRemover::convert( |
| 37 | + const DetectedObjectsWithFeature & objs_with_feature, DetectedObjects & objs) |
| 38 | +{ |
| 39 | + objs.header = objs_with_feature.header; |
| 40 | + for (const auto & obj_with_feature : objs_with_feature.feature_objects) { |
| 41 | + objs.objects.emplace_back(obj_with_feature.object); |
| 42 | + } |
| 43 | +} |
| 44 | + |
| 45 | +} // namespace detected_object_feature_remover |
| 46 | + |
| 47 | +#include <rclcpp_components/register_node_macro.hpp> |
| 48 | +RCLCPP_COMPONENTS_REGISTER_NODE(detected_object_feature_remover::DetectedObjectFeatureRemover) |
0 commit comments