Skip to content

Commit c9bd02d

Browse files
committed
feat: add cropboxes filter nodelet
Signed-off-by: yoshiri <yoshiyoshidetteiu@gmail.com>
1 parent 78eea31 commit c9bd02d

File tree

3 files changed

+522
-0
lines changed

3 files changed

+522
-0
lines changed

sensing/pointcloud_preprocessor/CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ ament_auto_add_library(pointcloud_preprocessor_filter SHARED
6262
src/concatenate_data/concatenate_pointclouds.cpp
6363
src/time_synchronizer/time_synchronizer_nodelet.cpp
6464
src/crop_box_filter/crop_box_filter_nodelet.cpp
65+
src/crop_box_filter/crop_boxes_filter_nodelet.cpp
6566
src/downsample_filter/voxel_grid_downsample_filter_nodelet.cpp
6667
src/downsample_filter/random_downsample_filter_nodelet.cpp
6768
src/downsample_filter/approximate_downsample_filter_nodelet.cpp
@@ -108,6 +109,10 @@ rclcpp_components_register_node(pointcloud_preprocessor_filter
108109
PLUGIN "pointcloud_preprocessor::CropBoxFilterComponent"
109110
EXECUTABLE crop_box_filter_node)
110111

112+
rclcpp_components_register_node(pointcloud_preprocessor_filter
113+
PLUGIN "pointcloud_preprocessor::CropBoxesFilterComponent"
114+
EXECUTABLE crop_boxes_filter_node)
115+
111116
# ========== Down Sampler Filter ==========
112117
# -- Voxel Grid Downsample Filter --
113118
rclcpp_components_register_node(pointcloud_preprocessor_filter
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
// Copyright 2023 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+
/*
16+
*
17+
* Software License Agreement (BSD License)
18+
*
19+
* Copyright (c) 2010, Willow Garage, Inc.
20+
* All rights reserved.
21+
*
22+
* Redistribution and use in source and binary forms, with or without
23+
* modification, are permitted provided that the following conditions
24+
* are met:
25+
*
26+
* * Redistributions of source code must retain the above copyright
27+
* notice, this list of conditions and the following disclaimer.
28+
* * Redistributions in binary form must reproduce the above
29+
* copyright notice, this list of conditions and the following
30+
* disclaimer in the documentation and/or other materials provided
31+
* with the distribution.
32+
* * Neither the name of Willow Garage, Inc. nor the names of its
33+
* contributors may be used to endorse or promote products derived
34+
* from this software without specific prior written permission.
35+
*
36+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
37+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
38+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
39+
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
40+
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
41+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
42+
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
44+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
45+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
46+
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
47+
* POSSIBILITY OF SUCH DAMAGE.
48+
*
49+
* $Id: cropboxes.cpp
50+
*
51+
*/
52+
53+
#ifndef POINTCLOUD_PREPROCESSOR__CROP_BOX_FILTER__CROP_BOXES_FILTER_NODELET_HPP_
54+
#define POINTCLOUD_PREPROCESSOR__CROP_BOX_FILTER__CROP_BOXES_FILTER_NODELET_HPP_
55+
56+
#include "pointcloud_preprocessor/filter.hpp"
57+
#include "pointcloud_preprocessor/transform_info.hpp"
58+
59+
#include <geometry_msgs/msg/polygon_stamped.hpp>
60+
61+
#include <pcl/filters/crop_box.h>
62+
63+
#include <string>
64+
#include <unordered_map>
65+
#include <vector>
66+
67+
namespace pointcloud_preprocessor
68+
{
69+
class CropBoxesFilterComponent : public pointcloud_preprocessor::Filter
70+
{
71+
protected:
72+
bool load_crop_boxes_parameters();
73+
74+
virtual void filter(
75+
const PointCloud2ConstPtr & input, const IndicesPtr & indices, PointCloud2 & output);
76+
77+
// TODO(sykwer): Temporary Implementation: Remove this interface when all the filter nodes conform
78+
// to new API
79+
virtual void faster_filter(
80+
const PointCloud2ConstPtr & input, const IndicesPtr & indices, PointCloud2 & output,
81+
const TransformInfo & transform_info);
82+
83+
void publishCropBoxPolygons();
84+
85+
private:
86+
struct CropBoxParam
87+
{
88+
float min_x;
89+
float max_x;
90+
float min_y;
91+
float max_y;
92+
float min_z;
93+
float max_z;
94+
bool negative{false};
95+
};
96+
97+
std::unordered_map<std::string, CropBoxParam> crop_box_params_;
98+
99+
std::unordered_map<std::string, rclcpp::Publisher<geometry_msgs::msg::PolygonStamped>::SharedPtr>
100+
crop_box_polygon_pubs_;
101+
102+
/** \brief Parameter service callback result : needed to be hold */
103+
OnSetParametersCallbackHandle::SharedPtr set_param_res_;
104+
105+
/** \brief Parameter service callback */
106+
rcl_interfaces::msg::SetParametersResult paramCallback(const std::vector<rclcpp::Parameter> & p);
107+
108+
public:
109+
PCL_MAKE_ALIGNED_OPERATOR_NEW
110+
explicit CropBoxesFilterComponent(const rclcpp::NodeOptions & options);
111+
};
112+
} // namespace pointcloud_preprocessor
113+
114+
#endif // POINTCLOUD_PREPROCESSOR__CROP_BOX_FILTER__CROP_BOXES_FILTER_NODELET_HPP_

0 commit comments

Comments
 (0)