From fe67e68be72ce0c51c4e55c7befa11670d591049 Mon Sep 17 00:00:00 2001 From: beginningfan <103237402+beginningfan@users.noreply.github.com> Date: Tue, 2 Jul 2024 07:30:32 +0800 Subject: [PATCH] fix(euclidean_cluster): fix euclidean cluster params (#7662) * fix(euclidean_cluster): fix max and min cluster size Signed-off-by: beginningfan * fix(gnss_poser): fix a typo Signed-off-by: beginningfan * fix(euclidean_cluster): fix min cluster size Signed-off-by: beginningfan * style(pre-commit): autofix --------- Signed-off-by: beginningfan Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .../lib/voxel_grid_based_euclidean_cluster.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/perception/euclidean_cluster/lib/voxel_grid_based_euclidean_cluster.cpp b/perception/euclidean_cluster/lib/voxel_grid_based_euclidean_cluster.cpp index 40699fd6e27ab..34c52bb7836b8 100644 --- a/perception/euclidean_cluster/lib/voxel_grid_based_euclidean_cluster.cpp +++ b/perception/euclidean_cluster/lib/voxel_grid_based_euclidean_cluster.cpp @@ -106,7 +106,7 @@ bool VoxelGridBasedEuclideanCluster::cluster( temporary_cluster.height = pointcloud_msg->height; temporary_cluster.fields = pointcloud_msg->fields; temporary_cluster.point_step = point_step; - temporary_cluster.data.resize(max_cluster_size_ * point_step); + temporary_cluster.data.resize(cluster.indices.size() * point_step); clusters_data_size.push_back(0); } @@ -124,6 +124,10 @@ bool VoxelGridBasedEuclideanCluster::cluster( &temporary_clusters.at(map[index]).data[cluster_data_size], &pointcloud_msg->data[i * point_step], point_step); cluster_data_size += point_step; + if (cluster_data_size == temporary_clusters.at(map[index]).data.size()) { + temporary_clusters.at(map[index]) + .data.resize(temporary_clusters.at(map[index]).data.size() * 2); + } } }