Skip to content

Commit 7739960

Browse files
author
lei.gu
committed
feat(euclidean_cluster): diagnostics modified to remove redundant info
1 parent ac9620a commit 7739960

File tree

2 files changed

+12
-20
lines changed

2 files changed

+12
-20
lines changed

perception/autoware_euclidean_cluster/include/autoware/euclidean_cluster/voxel_grid_based_euclidean_cluster.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class VoxelGridBasedEuclideanCluster : public EuclideanClusterInterface
5858
int min_points_number_per_voxel_;
5959

6060
void publishDiagnosticsSummary(
61-
const std::vector<std::string> & warnings,
61+
size_t skipped_cluster_count,
6262
const sensor_msgs::msg::PointCloud2::ConstSharedPtr & pointcloud_msg);
6363
autoware_utils::DiagnosticsInterface * diagnostics_interface_ptr_{nullptr};
6464
};

perception/autoware_euclidean_cluster/lib/voxel_grid_based_euclidean_cluster.cpp

+11-19
Original file line numberDiff line numberDiff line change
@@ -46,30 +46,24 @@ VoxelGridBasedEuclideanCluster::VoxelGridBasedEuclideanCluster(
4646

4747
// After processing all clusters, publish a summary of diagnostics.
4848
void VoxelGridBasedEuclideanCluster::publishDiagnosticsSummary(
49-
const std::vector<std::string> & warnings,
49+
size_t skipped_cluster_count,
5050
const sensor_msgs::msg::PointCloud2::ConstSharedPtr & pointcloud_msg)
5151
{
5252
if (!diagnostics_interface_ptr_) {
5353
return;
5454
}
5555
diagnostics_interface_ptr_->clear();
56-
57-
std::stringstream summary;
58-
if (!warnings.empty()) {
59-
summary << warnings.size()
60-
<< " clusters skipped because cluster size exceeds the maximum allowed "
61-
<< max_cluster_size_ << " \n";
62-
for (const auto & warn : warnings) {
63-
summary << " - " << warn << "\n";
64-
}
56+
std::string summary;
57+
if (skipped_cluster_count > 0) {
58+
summary = std::to_string(skipped_cluster_count) + " clusters skipped because cluster point size exceeds the maximum allowed "
59+
+ std::to_string(max_cluster_size_);
6560
diagnostics_interface_ptr_->add_key_value("is_cluster_data_size_within_range", false);
6661
} else {
6762
diagnostics_interface_ptr_->add_key_value("is_cluster_data_size_within_range", true);
6863
}
6964
diagnostics_interface_ptr_->update_level_and_message(
70-
warnings.empty() ? static_cast<int8_t>(diagnostic_msgs::msg::DiagnosticStatus::OK)
71-
: static_cast<int8_t>(diagnostic_msgs::msg::DiagnosticStatus::WARN),
72-
summary.str());
65+
skipped_cluster_count > 0 ? static_cast<int8_t>(diagnostic_msgs::msg::DiagnosticStatus::WARN) : static_cast<int8_t>(diagnostic_msgs::msg::DiagnosticStatus::OK),
66+
summary);
7367
diagnostics_interface_ptr_->publish(pointcloud_msg->header.stamp);
7468
}
7569

@@ -168,8 +162,7 @@ bool VoxelGridBasedEuclideanCluster::cluster(
168162

169163
// build output and check cluster size
170164
{
171-
// At the start, create a container to collect warnings.
172-
std::vector<std::string> warning_messages;
165+
size_t skipped_cluster_count = 0; // Count the skipped clusters
173166
for (size_t i = 0; i < temporary_clusters.size(); ++i) {
174167
auto & i_cluster_data_size = clusters_data_size.at(i);
175168
int cluster_size = static_cast<int>(i_cluster_data_size / point_step);
@@ -179,8 +172,7 @@ bool VoxelGridBasedEuclideanCluster::cluster(
179172
}
180173
if (cluster_size > max_cluster_size_) {
181174
// Cluster size exceeds the maximum threshold; log a warning.
182-
warning_messages.push_back(
183-
" Cluster " + std::to_string(i) + " (" + std::to_string(cluster_size) + ").");
175+
skipped_cluster_count++;
184176
continue;
185177
}
186178
const auto & cluster = temporary_clusters.at(i);
@@ -205,8 +197,8 @@ bool VoxelGridBasedEuclideanCluster::cluster(
205197
objects.feature_objects.push_back(feature_object);
206198
}
207199
objects.header = pointcloud_msg->header;
208-
209-
publishDiagnosticsSummary(warning_messages, pointcloud_msg);
200+
// Publish the diagnostics summary.
201+
publishDiagnosticsSummary(skipped_cluster_count, pointcloud_msg);
210202
}
211203

212204
return true;

0 commit comments

Comments
 (0)