Skip to content

Commit 4d5fc85

Browse files
YoheiMishinamitsudome-rnnmmnik-tier4TakaHoribe
authored
feat: add euclidean cluster package (autowarefoundation#122)
* release v0.4.0 * remove ROS1 packages temporarily Signed-off-by: mitsudome-r <ryohsuke.mitsudome@tier4.jp> * Revert "remove ROS1 packages temporarily" This reverts commit d6a59ac4c3762cb58ce6ca3e2cb31b3b8fc810ea. Signed-off-by: mitsudome-r <ryohsuke.mitsudome@tier4.jp> * add COLCON_IGNORE to ros1 packages Signed-off-by: mitsudome-r <ryohsuke.mitsudome@tier4.jp> * Rename launch files to launch.xml (autowarefoundation#28) * Rename h files to hpp (autowarefoundation#142) * Change includes * Rename files * Adjustments to make things compile * Other packages * Adjust copyright notice on 532 out of 699 source files (autowarefoundation#143) * Use quotes for includes where appropriate (autowarefoundation#144) * Use quotes for includes where appropriate * Fix lint tests * Make tests pass hopefully * Port euclidean cluster (autowarefoundation#120) * porting CmakeLists.txt and package.xml in progress * ported CMakeLists.txt and package.xml to ROS2 * Ported euclidean_cluster from ROS1 to ROS2 * deleted unnecesary files * fixed transient_local Co-authored-by: Takamasa Horibe <horibe.takamasa@gmail.com> * Fix perception launches (autowarefoundation#240) * fix roi_cluster_fusion launch Signed-off-by: Takamasa Horibe <takamasa.horib@gmail.com> * add comment on launch Signed-off-by: Takamasa Horibe <takamasa.horib@gmail.com> Co-authored-by: Takamasa Horibe <takamasa.horib@gmail.com> * Ros2 v0.8.0 euclidean cluster (autowarefoundation#310) * restore euclidean cluster files for v0.8.0 update * fix typos in perception (autowarefoundation#862) * Feature/camera lidar perception (autowarefoundation#937) * add object splitter Signed-off-by: Yukihiro Saito <yukky.saito@gmail.com> * add object merger Signed-off-by: Yukihiro Saito <yukky.saito@gmail.com> * change pkg name Signed-off-by: Yukihiro Saito <yukky.saito@gmail.com> * cosmetic change Signed-off-by: Yukihiro Saito <yukky.saito@gmail.com> * add comment Signed-off-by: Yukihiro Saito <yukky.saito@gmail.com> * remove litter Signed-off-by: Yukihiro Saito <yukky.saito@gmail.com> * bug fix : debug code Signed-off-by: Yukihiro Saito <yukky.saito@gmail.com> * enable vehicle to unknown track Signed-off-by: Yukihiro Saito <yukky.saito@gmail.com> * bug fix * add object position in clustering * 🚮 * change param * fix name * bug fix * add install * Feature/fusion debug (autowarefoundation#1051) * add debuger * change param * add publisher * Revert "restore euclidean cluster files for v0.8.0 update" This reverts commit 894cb8746622b4eb88f2cf1b036cc8c94ab1ac96. * fix bug * use containter to launch nodelet * add line * [euclidean_cluster]: Fix launch python and CMakeLists.txt Signed-off-by: wep21 <border_goldenmarket@yahoo.co.jp> Co-authored-by: Kazuki Miyahara <kmiya@outlook.com> Co-authored-by: Yukihiro Saito <yukky.saito@gmail.com> Co-authored-by: wep21 <border_goldenmarket@yahoo.co.jp> * add use_sim-time option (autowarefoundation#454) * Format launch files (autowarefoundation#1219) Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Unify Apache-2.0 license name (autowarefoundation#1242) * Remove use_sim_time for set_parameter (autowarefoundation#1260) Signed-off-by: wep21 <border_goldenmarket@yahoo.co.jp> * Fix lint errors (autowarefoundation#1378) * Fix lint errors Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Fix variable names Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Porting euclidean cluster (autowarefoundation#1291) * create config for euclidean cluster (autowarefoundation#1206) * create config * fix EOF * fix cmake list (autowarefoundation#1208) * Add load_composable_node_param Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Use tier4 voxel grid filter Signed-off-by: wep21 <border_goldenmarket@yahoo.co.jp> * Refactor voxel grid based euclidean cluster launch Signed-off-by: wep21 <border_goldenmarket@yahoo.co.jp> * Fix launch xml tag Signed-off-by: wep21 <border_goldenmarket@yahoo.co.jp> * Add missing arguments Signed-off-by: wep21 <border_goldenmarket@yahoo.co.jp> * Fix pointcloud subscriber qos Signed-off-by: wep21 <border_goldenmarket@yahoo.co.jp> * Fix dependency in CMakeLists.txt Signed-off-by: wep21 <border_goldenmarket@yahoo.co.jp> Co-authored-by: Hiroki OTA <hiroki.ota@tier4.jp> Co-authored-by: Kenji Miyake <kenji.miyake@tier4.jp> Co-authored-by: wep21 <border_goldenmarket@yahoo.co.jp> * Fix -Wunused-parameter (autowarefoundation#1836) * Fix -Wunused-parameter Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Fix mistake Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * fix spell * Fix lint issues Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Ignore flake8 warnings Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> Co-authored-by: Hiroki OTA <hiroki.ota@tier4.jp> * Invoke code formatter at pre-commit (autowarefoundation#1935) * Run ament_uncrustify at pre-commit * Reformat existing files * Fix copyright and cpplint errors Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> Co-authored-by: Kenji Miyake <kenji.miyake@tier4.jp> * add sort-package-xml hook in pre-commit (autowarefoundation#1881) * add sort xml hook in pre-commit * change retval to exit_status * rename * add prettier plugin-xml * use early return * add license note * add tier4 license * restore prettier * change license order * move local hooks to public repo * move prettier-xml to pre-commit-hooks-ros * update version for bug-fix * apply pre-commit * Feature/clustering lib (autowarefoundation#1914) * change to lib for detection by tracking * refactor * apply format * Detection by tracker (autowarefoundation#1910) * initial commit * backup * apply format * cosmetic change * implement divided under segmenterd clusters * cosmetic change * bug fix * bug fix * bug fix * modify launch * add debug and bug fix * bug fix * bug fix * add no found tracked object * modify parameters and cmake * bug fix * remove debug info * add readme * modify clustering launch * run pre-commit * cosmetic change * cosmetic change * cosmetic change * apply markdownlint * modify launch * modify for cpplint * modify qos * change int to size_T * bug fix * change perception qos * Update perception/object_recognition/detection/detection_by_tracker/package.xml Co-authored-by: Daisuke Nishimatsu <42202095+wep21@users.noreply.github.com> * cosmetic change * cosmetic change * fix launch * Update perception/object_recognition/detection/detection_by_tracker/src/utils.cpp Co-authored-by: Daisuke Nishimatsu <42202095+wep21@users.noreply.github.com> * modify header include order * change include order * Update perception/object_recognition/detection/detection_by_tracker/src/detection_by_tracker_core.cpp Co-authored-by: Daisuke Nishimatsu <42202095+wep21@users.noreply.github.com> * change to std::optional * cosmetic change * Update perception/object_recognition/detection/detection_by_tracker/src/detection_by_tracker_core.cpp Co-authored-by: Daisuke Nishimatsu <42202095+wep21@users.noreply.github.com> * Update perception/object_recognition/detection/detection_by_tracker/src/detection_by_tracker_core.cpp Co-authored-by: Daisuke Nishimatsu <42202095+wep21@users.noreply.github.com> * bug fix * modify readme Co-authored-by: Daisuke Nishimatsu <42202095+wep21@users.noreply.github.com> * Change formatter to clang-format and black (autowarefoundation#2332) * Revert "Temporarily comment out pre-commit hooks" This reverts commit 748e9cdb145ce12f8b520bcbd97f5ff899fc28a3. * Replace ament_lint_common with autoware_lint_common Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Remove ament_cmake_uncrustify and ament_clang_format Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Apply Black Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Apply clang-format Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Fix build errors Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Fix for cpplint * Fix include double quotes to angle brackets Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Apply clang-format Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Fix build errors Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * Add COLCON_IGNORE (autowarefoundation#500) Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp> * port euclidean_cluster (autowarefoundation#533) * delete COLCON_IGNORE * change dynamic_object_with_feature_array to detected_objects_with_feature * add classification * add classification.probability * add README of euclidean_cluster (autowarefoundation#614) * add README of euclidean_cluster * add period Co-authored-by: Kazuki Miyahara <kmiya@outlook.com> * update README Co-authored-by: Kazuki Miyahara <kmiya@outlook.com> * auto fix no ground pointcloud topic name (autowarefoundation#704) * fix/rename segmentation namespace (autowarefoundation#742) * rename segmentation directory * fix namespace: system stack * fix namespace: planning * fix namespace: control stack * fix namespace: perception stack * fix readme Co-authored-by: mitsudome-r <ryohsuke.mitsudome@tier4.jp> Co-authored-by: Nikolai Morin <nnmmgit@gmail.com> Co-authored-by: nik-tier4 <71747268+nik-tier4@users.noreply.github.com> Co-authored-by: Takamasa Horibe <horibe.takamasa@gmail.com> Co-authored-by: Takamasa Horibe <takamasa.horib@gmail.com> Co-authored-by: tkimura4 <tomoya.kimura@tier4.jp> Co-authored-by: Kazuki Miyahara <kmiya@outlook.com> Co-authored-by: Yukihiro Saito <yukky.saito@gmail.com> Co-authored-by: wep21 <border_goldenmarket@yahoo.co.jp> Co-authored-by: Kenji Miyake <31987104+kenji-miyake@users.noreply.github.com> Co-authored-by: Daisuke Nishimatsu <42202095+wep21@users.noreply.github.com> Co-authored-by: Keisuke Shima <19993104+KeisukeShima@users.noreply.github.com> Co-authored-by: Hiroki OTA <hiroki.ota@tier4.jp> Co-authored-by: Kenji Miyake <kenji.miyake@tier4.jp> Co-authored-by: Takeshi Ishita <ishitah.takeshi@gmail.com> Co-authored-by: Yusuke Muramatsu <yukke42@users.noreply.github.com> Co-authored-by: Satoshi OTA <44889564+satoshi-ota@users.noreply.github.com>
1 parent 3895c0f commit 4d5fc85

23 files changed

+1293
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
cmake_minimum_required(VERSION 3.5)
2+
project(euclidean_cluster)
3+
4+
if(NOT CMAKE_CXX_STANDARD)
5+
set(CMAKE_CXX_STANDARD 14)
6+
endif()
7+
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
8+
add_compile_options(-Wall -Wextra -Wpedantic)
9+
endif()
10+
11+
find_package(ament_cmake_auto REQUIRED)
12+
find_package(PCL REQUIRED QUIET COMPONENTS common search filters segmentation)
13+
ament_auto_find_build_dependencies()
14+
15+
16+
include_directories(
17+
include
18+
${PCL_COMMON_INCLUDE_DIRS}
19+
${PCL_INCLUDE_DIRS}
20+
)
21+
22+
ament_auto_add_library(cluster_lib SHARED
23+
lib/utils.cpp
24+
lib/euclidean_cluster.cpp
25+
lib/voxel_grid_based_euclidean_cluster.cpp
26+
)
27+
28+
target_link_libraries(cluster_lib
29+
${PCL_LIBRARIES}
30+
)
31+
32+
target_include_directories(cluster_lib
33+
PUBLIC
34+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
35+
$<INSTALL_INTERFACE:include>
36+
)
37+
38+
ament_auto_add_library(euclidean_cluster_node_core SHARED
39+
src/euclidean_cluster_node.cpp
40+
)
41+
target_link_libraries(euclidean_cluster_node_core
42+
${PCL_LIBRARIES}
43+
cluster_lib
44+
)
45+
46+
rclcpp_components_register_node(euclidean_cluster_node_core
47+
PLUGIN "euclidean_cluster::EuclideanClusterNode"
48+
EXECUTABLE euclidean_cluster_node
49+
)
50+
51+
ament_auto_add_library(voxel_grid_based_euclidean_cluster_node_core SHARED
52+
src/voxel_grid_based_euclidean_cluster_node.cpp
53+
)
54+
target_link_libraries(voxel_grid_based_euclidean_cluster_node_core
55+
${PCL_LIBRARIES}
56+
cluster_lib
57+
)
58+
59+
rclcpp_components_register_node(voxel_grid_based_euclidean_cluster_node_core
60+
PLUGIN "euclidean_cluster::VoxelGridBasedEuclideanClusterNode"
61+
EXECUTABLE voxel_grid_based_euclidean_cluster_node
62+
)
63+
64+
ament_auto_package(INSTALL_TO_SHARE
65+
launch
66+
config
67+
)
+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# euclidean_cluster
2+
3+
## Purpose
4+
5+
euclidean_cluster is a package for clustering points into smaller parts to classify objects.
6+
7+
This package has two clustering methods: `euclidean_cluster` and `voxel_grid_based_euclidean_cluster`.
8+
9+
## Inner-workings / Algorithms
10+
11+
### euclidean_cluster
12+
13+
`pcl::EuclideanClusterExtraction` is applied to points. See [official document](https://pcl.readthedocs.io/en/latest/cluster_extraction.html) for details.
14+
15+
### voxel_grid_based_euclidean_cluster
16+
17+
1. A centroid in each voxel is calculated by `pcl::VoxelGrid`.
18+
2. The centroids are clustered by `pcl::EuclideanClusterExtraction`.
19+
3. The input points are clustered based on the clustered centroids.
20+
21+
## Inputs / Outputs
22+
23+
### Input
24+
25+
| Name | Type | Description |
26+
| ------- | ------------------------------- | ---------------- |
27+
| `input` | `sensor_msgs::msg::PointCloud2` | input pointcloud |
28+
29+
### Output
30+
31+
| Name | Type | Description |
32+
| ---------------- | ----------------------------------------------------------- | -------------------------------------------- |
33+
| `output` | `autoware_perception_msgs::msg::DetectedObjectsWithFeature` | cluster pointcloud |
34+
| `debug/clusters` | `sensor_msgs::msg::PointCloud2` | colored cluster pointcloud for visualization |
35+
36+
## Parameters
37+
38+
### Core Parameters
39+
40+
#### euclidean_cluster
41+
42+
| Name | Type | Description |
43+
| ------------------ | ----- | -------------------------------------------------------------------------------------------- |
44+
| `use_height` | bool | use point.z for clustering |
45+
| `min_cluster_size` | int | the minimum number of points that a cluster needs to contain in order to be considered valid |
46+
| `max_cluster_size` | int | the maximum number of points that a cluster needs to contain in order to be considered valid |
47+
| `tolerance` | float | the spatial cluster tolerance as a measure in the L2 Euclidean space |
48+
49+
#### voxel_grid_based_euclidean_cluster
50+
51+
| Name | Type | Description |
52+
| ----------------------------- | ----- | -------------------------------------------------------------------------------------------- |
53+
| `use_height` | bool | use point.z for clustering |
54+
| `min_cluster_size` | int | the minimum number of points that a cluster needs to contain in order to be considered valid |
55+
| `max_cluster_size` | int | the maximum number of points that a cluster needs to contain in order to be considered valid |
56+
| `tolerance` | float | the spatial cluster tolerance as a measure in the L2 Euclidean space |
57+
| `voxel_leaf_size` | float | the voxel leaf size of x and y |
58+
| `min_points_number_per_voxel` | int | the minimum number of points for a voxel |
59+
60+
## Assumptions / Known limits
61+
62+
<!-- Write assumptions and limitations of your implementation.
63+
64+
Example:
65+
This algorithm assumes obstacles are not moving, so if they rapidly move after the vehicle started to avoid them, it might collide with them.
66+
Also, this algorithm doesn't care about blind spots. In general, since too close obstacles aren't visible due to the sensing performance limit, please take enough margin to obstacles.
67+
-->
68+
69+
## (Optional) Error detection and handling
70+
71+
<!-- Write how to detect errors and how to recover from them.
72+
73+
Example:
74+
This package can handle up to 20 obstacles. If more obstacles found, this node will give up and raise diagnostic errors.
75+
-->
76+
77+
## (Optional) Performance characterization
78+
79+
<!-- Write performance information like complexity. If it wouldn't be the bottleneck, not necessary.
80+
81+
Example:
82+
### Complexity
83+
84+
This algorithm is O(N).
85+
86+
### Processing time
87+
88+
...
89+
-->
90+
91+
## (Optional) References/External links
92+
93+
<!-- Write links you referred to when you implemented.
94+
95+
Example:
96+
[1] {link_to_a_thesis}
97+
[2] {link_to_an_issue}
98+
-->
99+
100+
## (Optional) Future extensions / Unimplemented parts
101+
102+
The `use_height` option of `voxel_grid_based_euclidean_cluster` isn't implemented yet.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/**:
2+
ros__parameters:
3+
distance_threshold: 0.5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**:
2+
ros__parameters:
3+
max_cluster_size: 1000
4+
min_cluster_size: 10
5+
tolerance: 0.7
6+
use_height: false
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**:
2+
ros__parameters:
3+
input_frame: base_link
4+
output_frame: base_link
5+
voxel_size_x: 0.3
6+
voxel_size_y: 0.3
7+
voxel_size_z: 100.0
8+
voxel_points_threshold: 3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**:
2+
ros__parameters:
3+
input_frame: base_link
4+
output_frame: base_link
5+
voxel_size_x: 0.15
6+
voxel_size_y: 0.15
7+
voxel_size_z: 0.15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**:
2+
ros__parameters:
3+
tolerance: 0.7
4+
voxel_leaf_size: 0.3
5+
min_points_number_per_voxel: 1
6+
min_cluster_size: 10
7+
max_cluster_size: 3000
8+
use_height: false
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright 2020 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+
#pragma once
16+
17+
#include "euclidean_cluster/euclidean_cluster_interface.hpp"
18+
#include "euclidean_cluster/utils.hpp"
19+
20+
#include <pcl/point_types.h>
21+
22+
#include <vector>
23+
24+
namespace euclidean_cluster
25+
{
26+
class EuclideanCluster : public EuclideanClusterInterface
27+
{
28+
public:
29+
EuclideanCluster();
30+
EuclideanCluster(bool use_height, int min_cluster_size, int max_cluster_size);
31+
EuclideanCluster(bool use_height, int min_cluster_size, int max_cluster_size, float tolerance);
32+
bool cluster(
33+
const pcl::PointCloud<pcl::PointXYZ>::ConstPtr & pointcloud,
34+
std::vector<pcl::PointCloud<pcl::PointXYZ>> & clusters) override;
35+
void setTolerance(float tolerance) { tolerance_ = tolerance; }
36+
37+
private:
38+
float tolerance_;
39+
};
40+
41+
} // namespace euclidean_cluster
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
#pragma once
16+
17+
#include <rclcpp/rclcpp.hpp>
18+
19+
#include <pcl/point_cloud.h>
20+
#include <pcl/point_types.h>
21+
22+
#include <vector>
23+
24+
namespace euclidean_cluster
25+
{
26+
class EuclideanClusterInterface
27+
{
28+
public:
29+
EuclideanClusterInterface() = default;
30+
EuclideanClusterInterface(bool use_height, int min_cluster_size, int max_cluster_size)
31+
: use_height_(use_height),
32+
min_cluster_size_(min_cluster_size),
33+
max_cluster_size_(max_cluster_size)
34+
{
35+
}
36+
virtual ~EuclideanClusterInterface() = default;
37+
void setUseHeight(bool use_height) { use_height_ = use_height; }
38+
void setMinClusterSize(int size) { min_cluster_size_ = size; }
39+
void setMaxClusterSize(int size) { max_cluster_size_ = size; }
40+
virtual bool cluster(
41+
const pcl::PointCloud<pcl::PointXYZ>::ConstPtr & pointcloud,
42+
std::vector<pcl::PointCloud<pcl::PointXYZ>> & clusters) = 0;
43+
44+
protected:
45+
bool use_height_ = true;
46+
int min_cluster_size_;
47+
int max_cluster_size_;
48+
};
49+
50+
} // namespace euclidean_cluster
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
#pragma once
16+
17+
#include <autoware_perception_msgs/msg/detected_objects_with_feature.hpp>
18+
#include <geometry_msgs/msg/pose_stamped.hpp>
19+
#include <sensor_msgs/msg/point_cloud2.hpp>
20+
21+
#include <pcl/point_cloud.h>
22+
#include <pcl/point_types.h>
23+
#include <pcl_conversions/pcl_conversions.h>
24+
25+
#include <vector>
26+
27+
namespace euclidean_cluster
28+
{
29+
geometry_msgs::msg::Point getCentroid(const sensor_msgs::msg::PointCloud2 & pointcloud);
30+
void convertPointCloudClusters2Msg(
31+
const std_msgs::msg::Header & header,
32+
const std::vector<pcl::PointCloud<pcl::PointXYZ>> & clusters,
33+
autoware_perception_msgs::msg::DetectedObjectsWithFeature & msg);
34+
void convertObjectMsg2SensorMsg(
35+
const autoware_perception_msgs::msg::DetectedObjectsWithFeature & input,
36+
sensor_msgs::msg::PointCloud2 & output);
37+
} // namespace euclidean_cluster
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
#pragma once
16+
17+
#include "euclidean_cluster/euclidean_cluster_interface.hpp"
18+
#include "euclidean_cluster/utils.hpp"
19+
20+
#include <pcl/filters/voxel_grid.h>
21+
#include <pcl/point_types.h>
22+
23+
#include <vector>
24+
25+
namespace euclidean_cluster
26+
{
27+
class VoxelGridBasedEuclideanCluster : public EuclideanClusterInterface
28+
{
29+
public:
30+
VoxelGridBasedEuclideanCluster();
31+
VoxelGridBasedEuclideanCluster(bool use_height, int min_cluster_size, int max_cluster_size);
32+
VoxelGridBasedEuclideanCluster(
33+
bool use_height, int min_cluster_size, int max_cluster_size, float tolerance,
34+
float voxel_leaf_size, int min_points_number_per_voxel);
35+
bool cluster(
36+
const pcl::PointCloud<pcl::PointXYZ>::ConstPtr & pointcloud,
37+
std::vector<pcl::PointCloud<pcl::PointXYZ>> & clusters) override;
38+
void setVoxelLeafSize(float voxel_leaf_size) { voxel_leaf_size_ = voxel_leaf_size; }
39+
void setTolerance(float tolerance) { tolerance_ = tolerance; }
40+
void setMinPointsNumberPerVoxel(int min_points_number_per_voxel)
41+
{
42+
min_points_number_per_voxel_ = min_points_number_per_voxel;
43+
}
44+
45+
private:
46+
pcl::VoxelGrid<pcl::PointXYZ> voxel_grid_;
47+
float tolerance_;
48+
float voxel_leaf_size_;
49+
int min_points_number_per_voxel_;
50+
};
51+
52+
} // namespace euclidean_cluster

0 commit comments

Comments
 (0)