Skip to content

Commit d13ae2c

Browse files
committed
feat(lidar_centerpoint, pointpainting): add diag publisher for max voxel size
Signed-off-by: kminoda <koji.minoda@tier4.jp>
1 parent 40ff6d3 commit d13ae2c

File tree

6 files changed

+42
-5
lines changed

6 files changed

+42
-5
lines changed

perception/autoware_image_projection_based_fusion/include/autoware/image_projection_based_fusion/pointpainting_fusion/node.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include <autoware/lidar_centerpoint/centerpoint_trt.hpp>
2525
#include <autoware/lidar_centerpoint/detection_class_remapper.hpp>
2626

27+
#include <autoware/universe_utils/ros/diagnostics_module.hpp>
28+
2729
#include <map>
2830
#include <memory>
2931
#include <string>
@@ -44,6 +46,8 @@ inline bool isInsideBbox(
4446
class PointPaintingFusionNode
4547
: public FusionNode<sensor_msgs::msg::PointCloud2, DetectedObjects, DetectedObjectsWithFeature>
4648
{
49+
using DiagnosticsModule = autoware::universe_utils::DiagnosticsModule;
50+
4751
public:
4852
explicit PointPaintingFusionNode(const rclcpp::NodeOptions & options);
4953

@@ -75,6 +79,7 @@ class PointPaintingFusionNode
7579
autoware::lidar_centerpoint::DetectionClassRemapper detection_class_remapper_;
7680

7781
std::unique_ptr<image_projection_based_fusion::PointPaintingTRT> detector_ptr_{nullptr};
82+
std::unique_ptr<DiagnosticsModule> diagnostics_module_ptr_;
7883

7984
bool out_of_scope(const DetectedObjects & obj) override;
8085
};

perception/autoware_image_projection_based_fusion/src/pointpainting_fusion/node.cpp

+13-1
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ PointPaintingFusionNode::PointPaintingFusionNode(const rclcpp::NodeOptions & opt
193193
// create detector
194194
detector_ptr_ = std::make_unique<image_projection_based_fusion::PointPaintingTRT>(
195195
encoder_param, head_param, densification_param, config);
196+
diagnostics_module_ptr_ = std::make_unique<DiagnosticsModule>(this, "pointpainting_trt");
196197

197198
obj_pub_ptr_ = this->create_publisher<DetectedObjects>("~/output/objects", rclcpp::QoS{1});
198199

@@ -401,17 +402,28 @@ void PointPaintingFusionNode::postprocess(sensor_msgs::msg::PointCloud2 & painte
401402
return;
402403
}
403404

405+
diagnostics_module_ptr_->clear();
406+
404407
if (painted_pointcloud_msg.data.empty() || painted_pointcloud_msg.fields.empty()) {
405408
RCLCPP_WARN_STREAM_THROTTLE(
406409
this->get_logger(), *this->get_clock(), 1000, "Empty sensor points!");
407410
return;
408411
}
409412

410413
std::vector<autoware::lidar_centerpoint::Box3D> det_boxes3d;
411-
bool is_success = detector_ptr_->detect(painted_pointcloud_msg, tf_buffer_, det_boxes3d);
414+
bool is_num_pillars_within_range = true;
415+
bool is_success = detector_ptr_->detect(painted_pointcloud_msg, tf_buffer_, det_boxes3d, is_num_pillars_within_range);
412416
if (!is_success) {
413417
return;
414418
}
419+
diagnostics_module_ptr_->add_key_value("is_num_pillars_within_range", is_num_pillars_within_range);
420+
if (!is_num_pillars_within_range) {
421+
std::stringstream message;
422+
message << "PointPaintingTRT::detect: The actual number of pillars exceeds its maximum value, "
423+
<< "which may limit the detection performance.";
424+
diagnostics_module_ptr_->update_level_and_message(
425+
diagnostic_msgs::msg::DiagnosticStatus::WARN, message.str());
426+
}
415427

416428
std::vector<autoware_perception_msgs::msg::DetectedObject> raw_objects;
417429
raw_objects.reserve(det_boxes3d.size());

perception/autoware_lidar_centerpoint/include/autoware/lidar_centerpoint/centerpoint_trt.hpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "autoware/lidar_centerpoint/preprocess/voxel_generator.hpp"
2222
#include "pcl/point_cloud.h"
2323
#include "pcl/point_types.h"
24-
2524
#include "sensor_msgs/msg/point_cloud2.hpp"
2625

2726
#include <memory>
@@ -62,7 +61,7 @@ class CenterPointTRT
6261

6362
bool detect(
6463
const sensor_msgs::msg::PointCloud2 & input_pointcloud_msg, const tf2_ros::Buffer & tf_buffer,
65-
std::vector<Box3D> & det_boxes3d);
64+
std::vector<Box3D> & det_boxes3d, bool & is_num_pillars_within_range);
6665

6766
protected:
6867
void initPtr();

perception/autoware_lidar_centerpoint/include/autoware/lidar_centerpoint/node.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "autoware/lidar_centerpoint/detection_class_remapper.hpp"
2020
#include "autoware/lidar_centerpoint/postprocess/non_maximum_suppression.hpp"
2121

22+
#include <autoware/universe_utils/ros/diagnostics_module.hpp>
2223
#include <autoware/universe_utils/ros/debug_publisher.hpp>
2324
#include <autoware/universe_utils/ros/published_time_publisher.hpp>
2425
#include <autoware/universe_utils/system/stop_watch.hpp>
@@ -39,6 +40,8 @@ namespace autoware::lidar_centerpoint
3940

4041
class LidarCenterPointNode : public rclcpp::Node
4142
{
43+
using DiagnosticsModule = autoware::universe_utils::DiagnosticsModule;
44+
4245
public:
4346
explicit LidarCenterPointNode(const rclcpp::NodeOptions & node_options);
4447

@@ -59,6 +62,7 @@ class LidarCenterPointNode : public rclcpp::Node
5962
DetectionClassRemapper detection_class_remapper_;
6063

6164
std::unique_ptr<CenterPointTRT> detector_ptr_{nullptr};
65+
std::unique_ptr<DiagnosticsModule> diagnostics_module_ptr_;
6266

6367
// debugger
6468
std::unique_ptr<autoware::universe_utils::StopWatch<std::chrono::milliseconds>> stop_watch_ptr_{

perception/autoware_lidar_centerpoint/lib/centerpoint_trt.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,10 @@ void CenterPointTRT::initPtr()
127127

128128
bool CenterPointTRT::detect(
129129
const sensor_msgs::msg::PointCloud2 & input_pointcloud_msg, const tf2_ros::Buffer & tf_buffer,
130-
std::vector<Box3D> & det_boxes3d)
130+
std::vector<Box3D> & det_boxes3d, bool & is_num_pillars_within_range)
131131
{
132+
is_num_pillars_within_range = true;
133+
132134
CHECK_CUDA_ERROR(cudaMemsetAsync(
133135
encoder_in_features_d_.get(), 0, encoder_in_feature_size_ * sizeof(float), stream_));
134136
CHECK_CUDA_ERROR(
@@ -155,6 +157,7 @@ bool CenterPointTRT::detect(
155157
"The actual number of pillars (%u) exceeds its maximum value (%zu). "
156158
"Please considering increasing it since it may limit the detection performance.",
157159
num_pillars, config_.max_voxel_size_);
160+
is_num_pillars_within_range = false;
158161
}
159162

160163
return true;

perception/autoware_lidar_centerpoint/src/node.cpp

+15-1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ LidarCenterPointNode::LidarCenterPointNode(const rclcpp::NodeOptions & node_opti
107107
circle_nms_dist_threshold, yaw_norm_thresholds, has_variance_);
108108
detector_ptr_ =
109109
std::make_unique<CenterPointTRT>(encoder_param, head_param, densification_param, config);
110+
diagnostics_module_ptr_ = std::make_unique<DiagnosticsModule>(this, "centerpoint_trt");
110111

111112
pointcloud_sub_ = this->create_subscription<sensor_msgs::msg::PointCloud2>(
112113
"~/input/pointcloud", rclcpp::SensorDataQoS{}.keep_last(1),
@@ -145,11 +146,22 @@ void LidarCenterPointNode::pointCloudCallback(
145146
stop_watch_ptr_->toc("processing_time", true);
146147
}
147148

149+
diagnostics_module_ptr_->clear();
150+
148151
std::vector<Box3D> det_boxes3d;
149-
bool is_success = detector_ptr_->detect(*input_pointcloud_msg, tf_buffer_, det_boxes3d);
152+
bool is_num_pillars_within_range = true;
153+
bool is_success = detector_ptr_->detect(*input_pointcloud_msg, tf_buffer_, det_boxes3d, is_num_pillars_within_range);
150154
if (!is_success) {
151155
return;
152156
}
157+
diagnostics_module_ptr_->add_key_value("is_num_pillars_within_range", is_num_pillars_within_range);
158+
if (!is_num_pillars_within_range) {
159+
std::stringstream message;
160+
message << "CenterPointTRT::detect: The actual number of pillars exceeds its maximum value, "
161+
<< "which may limit the detection performance.";
162+
diagnostics_module_ptr_->update_level_and_message(
163+
diagnostic_msgs::msg::DiagnosticStatus::WARN, message.str());
164+
}
153165

154166
std::vector<autoware_perception_msgs::msg::DetectedObject> raw_objects;
155167
raw_objects.reserve(det_boxes3d.size());
@@ -170,6 +182,8 @@ void LidarCenterPointNode::pointCloudCallback(
170182
published_time_publisher_->publish_if_subscribed(objects_pub_, output_msg.header.stamp);
171183
}
172184

185+
diagnostics_module_ptr_->publish(input_pointcloud_msg->header.stamp);
186+
173187
// add processing time for debug
174188
if (debug_publisher_ptr_ && stop_watch_ptr_) {
175189
const double cyclic_time_ms = stop_watch_ptr_->toc("cyclic_time", true);

0 commit comments

Comments
 (0)