Skip to content

Commit e158736

Browse files
fix(image_projection_based_fusion): revise message publishers (#9865)
* refactor: fix condition for publishing painted pointcloud message Signed-off-by: Taekjin LEE <taekjin.lee@tier4.jp> * fix: publish output revised Signed-off-by: Taekjin LEE <taekjin.lee@tier4.jp> * feat: fix condition for publishing painted pointcloud message Signed-off-by: Taekjin LEE <taekjin.lee@tier4.jp> * feat: roi-pointclout fusion - publish empty image even when there is no target roi Signed-off-by: Taekjin LEE <taekjin.lee@tier4.jp> * fix: remap output topic for clusters in roi_pointcloud_fusion Signed-off-by: Taekjin LEE <taekjin.lee@tier4.jp> * style(pre-commit): autofix Signed-off-by: Taekjin LEE <taekjin.lee@tier4.jp> * feat: fix condition for publishing painted pointcloud message Signed-off-by: Taekjin LEE <taekjin.lee@tier4.jp> * feat: Add debug publisher for internal debugging Signed-off-by: Taekjin LEE <taekjin.lee@tier4.jp> * feat: remove !! pointer to bool conversion Signed-off-by: Taekjin LEE <taekjin.lee@tier4.jp> --------- Signed-off-by: Taekjin LEE <taekjin.lee@tier4.jp> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 300ac7f commit e158736

File tree

12 files changed

+63
-51
lines changed

12 files changed

+63
-51
lines changed

launch/tier4_perception_launch/launch/object_recognition/detection/detector/camera_lidar_detector.launch.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@
181181
<arg name="input/image6" value="$(var input/camera6/image)"/>
182182
<arg name="input/image7" value="$(var input/camera7/image)"/>
183183
<arg name="input/pointcloud" value="$(var roi_cluster/input/pointcloud)"/>
184-
<arg name="output_clusters" value="$(var roi_cluster/output/clusters)"/>
184+
<arg name="output/clusters" value="$(var roi_cluster/output/clusters)"/>
185185
<arg name="param_path" value="$(var roi_pointcloud_fusion_param_path)"/>
186186
</include>
187187
</group>

perception/autoware_image_projection_based_fusion/docs/pointpainting-fusion.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@ The lidar points are projected onto the output of an image-only 2d object detect
1616

1717
| Name | Type | Description |
1818
| ------------------------ | -------------------------------------------------------- | --------------------------------------------------------- |
19-
| `input` | `sensor_msgs::msg::PointCloud2` | pointcloud |
19+
| `input/pointcloud` | `sensor_msgs::msg::PointCloud2` | pointcloud |
2020
| `input/camera_info[0-7]` | `sensor_msgs::msg::CameraInfo` | camera information to project 3d points onto image planes |
2121
| `input/rois[0-7]` | `tier4_perception_msgs::msg::DetectedObjectsWithFeature` | ROIs from each image |
2222
| `input/image_raw[0-7]` | `sensor_msgs::msg::Image` | images for visualization |
2323

2424
### Output
2525

26-
| Name | Type | Description |
27-
| ------------------------ | ------------------------------------------------ | ------------------------ |
28-
| `output` | `sensor_msgs::msg::PointCloud2` | painted pointcloud |
29-
| `~/output/objects` | `autoware_perception_msgs::msg::DetectedObjects` | detected objects |
30-
| `~/debug/image_raw[0-7]` | `sensor_msgs::msg::Image` | images for visualization |
26+
| Name | Type | Description |
27+
| -------------------------- | ------------------------------------------------ | ------------------------ |
28+
| `output/objects` | `autoware_perception_msgs::msg::DetectedObjects` | detected objects |
29+
| `debug/painted_pointcloud` | `sensor_msgs::msg::PointCloud2` | painted pointcloud |
30+
| `debug/image_raw[0-7]` | `sensor_msgs::msg::Image` | images for visualization |
3131

3232
## Parameters
3333

perception/autoware_image_projection_based_fusion/docs/roi-cluster-fusion.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ The clusters are projected onto image planes, and then if the ROIs of clusters a
2323

2424
### Output
2525

26-
| Name | Type | Description |
27-
| ------------------------ | -------------------------------------------------------- | -------------------------- |
28-
| `output` | `tier4_perception_msgs::msg::DetectedObjectsWithFeature` | labeled cluster pointcloud |
29-
| `~/debug/image_raw[0-7]` | `sensor_msgs::msg::Image` | images for visualization |
26+
| Name | Type | Description |
27+
| ---------------------- | -------------------------------------------------------- | -------------------------- |
28+
| `output` | `tier4_perception_msgs::msg::DetectedObjectsWithFeature` | labeled cluster pointcloud |
29+
| `debug/image_raw[0-7]` | `sensor_msgs::msg::Image` | images for visualization |
3030

3131
## Parameters
3232

perception/autoware_image_projection_based_fusion/docs/roi-detected-object-fusion.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ The DetectedObject has three possible shape choices/implementations, where the p
3030

3131
### Output
3232

33-
| Name | Type | Description |
34-
| ------------------------- | ------------------------------------------------ | -------------------------- |
35-
| `output` | `autoware_perception_msgs::msg::DetectedObjects` | detected objects |
36-
| `~/debug/image_raw[0-7]` | `sensor_msgs::msg::Image` | images for visualization, |
37-
| `~/debug/fused_objects` | `autoware_perception_msgs::msg::DetectedObjects` | fused detected objects |
38-
| `~/debug/ignored_objects` | `autoware_perception_msgs::msg::DetectedObjects` | not fused detected objects |
33+
| Name | Type | Description |
34+
| ----------------------- | ------------------------------------------------ | -------------------------- |
35+
| `output` | `autoware_perception_msgs::msg::DetectedObjects` | detected objects |
36+
| `debug/image_raw[0-7]` | `sensor_msgs::msg::Image` | images for visualization, |
37+
| `debug/fused_objects` | `autoware_perception_msgs::msg::DetectedObjects` | fused detected objects |
38+
| `debug/ignored_objects` | `autoware_perception_msgs::msg::DetectedObjects` | not fused detected objects |
3939

4040
## Parameters
4141

perception/autoware_image_projection_based_fusion/docs/roi-pointcloud-fusion.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,10 @@ The node `roi_pointcloud_fusion` is to cluster the pointcloud based on Region Of
2424

2525
### Output
2626

27-
| Name | Type | Description |
28-
| ----------------- | -------------------------------------------------------- | -------------------------------------------- |
29-
| `output` | `sensor_msgs::msg::PointCloud2` | output pointcloud as default of interface |
30-
| `output_clusters` | `tier4_perception_msgs::msg::DetectedObjectsWithFeature` | output clusters |
31-
| `debug/clusters` | `sensor_msgs/msg/PointCloud2` | colored cluster pointcloud for visualization |
27+
| Name | Type | Description |
28+
| ---------------- | -------------------------------------------------------- | -------------------------------------------- |
29+
| `output` | `tier4_perception_msgs::msg::DetectedObjectsWithFeature` | output clusters |
30+
| `debug/clusters` | `sensor_msgs/msg/PointCloud2` | colored cluster pointcloud for visualization |
3231

3332
## Parameters
3433

perception/autoware_image_projection_based_fusion/include/autoware/image_projection_based_fusion/fusion_node.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ class FusionNode : public rclcpp::Node
150150
// 2d detection management
151151
std::vector<Det2dStatus<Msg2D>> det2d_list_;
152152

153-
/** \brief A vector of subscriber. */
154-
typename rclcpp::Subscription<Msg3D>::SharedPtr sub_;
153+
// 3d detection subscription
154+
typename rclcpp::Subscription<Msg3D>::SharedPtr det3d_sub_;
155155

156156
// parameters for out_of_scope filter
157157
float filter_scope_min_x_;
@@ -166,6 +166,7 @@ class FusionNode : public rclcpp::Node
166166

167167
// debugger
168168
std::shared_ptr<Debugger> debugger_;
169+
std::unique_ptr<autoware::universe_utils::DebugPublisher> debug_internal_pub_;
169170

170171
/** \brief processing time publisher. **/
171172
std::unique_ptr<autoware::universe_utils::StopWatch<std::chrono::milliseconds>> stop_watch_ptr_;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class PointPaintingFusionNode : public FusionNode<PointCloudMsgType, RoiMsgType,
5757
void postprocess(
5858
const PointCloudMsgType & painted_pointcloud_msg, DetectedObjects & output_msg) override;
5959

60-
rclcpp::Publisher<PointCloudMsgType>::SharedPtr point_pub_ptr_;
60+
rclcpp::Publisher<PointCloudMsgType>::SharedPtr painted_point_pub_ptr_;
6161
std::unique_ptr<autoware::universe_utils::DiagnosticsInterface> diagnostics_interface_ptr_;
6262

6363
int omp_num_threads_{1};

perception/autoware_image_projection_based_fusion/launch/roi_pointcloud_fusion.launch.xml

+2-4
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
<arg name="input/rois7" default="rois7"/>
1818
<arg name="input/camera_info7" default="/camera_info7"/>
1919
<arg name="input/pointcloud" default="/perception/object_recognition/detection/pointcloud_map_filtered/pointcloud"/>
20-
<arg name="output/pointcloud" default="roi_pointcloud_fusion/output/pointcloud"/>
21-
<arg name="output_clusters" default="output_clusters"/>
20+
<arg name="output/clusters" default="output/clusters"/>
2221
<arg name="debug/clusters" default="roi_pointcloud_fusion/debug/clusters"/>
2322
<arg name="param_path" default="$(find-pkg-share autoware_image_projection_based_fusion)/config/roi_pointcloud_fusion.param.yaml"/>
2423
<arg name="sync_param_path" default="$(find-pkg-share autoware_image_projection_based_fusion)/config/fusion_common.param.yaml"/>
@@ -39,8 +38,7 @@
3938
<param from="$(var param_path)"/>
4039
<param from="$(var sync_param_path)"/>
4140
<remap from="input" to="$(var input/pointcloud)"/>
42-
<remap from="output" to="$(var output/pointcloud)"/>
43-
<remap from="output_clusters" to="$(var output_clusters)"/>
41+
<remap from="output" to="$(var output/clusters)"/>
4442
<remap from="debug/clusters" to="$(var debug/clusters)"/>
4543

4644
<!-- rois, camera and info -->

perception/autoware_image_projection_based_fusion/src/fusion_node.cpp

+15-11
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ FusionNode<Msg3D, Msg2D, ExportObj>::FusionNode(
105105
// subscribe 3d detection
106106
std::function<void(const typename Msg3D::ConstSharedPtr msg)> sub_callback =
107107
std::bind(&FusionNode::subCallback, this, std::placeholders::_1);
108-
sub_ = this->create_subscription<Msg3D>("input", rclcpp::QoS(1).best_effort(), sub_callback);
108+
det3d_sub_ =
109+
this->create_subscription<Msg3D>("input", rclcpp::QoS(1).best_effort(), sub_callback);
109110

110111
// Set timer
111112
const auto period_ns = std::chrono::duration_cast<std::chrono::nanoseconds>(
@@ -141,6 +142,10 @@ FusionNode<Msg3D, Msg2D, ExportObj>::FusionNode(
141142
static_cast<std::size_t>(declare_parameter<int32_t>("image_buffer_size"));
142143
debugger_ =
143144
std::make_shared<Debugger>(this, rois_number, image_buffer_size, input_camera_topics);
145+
146+
// input topic timing publisher
147+
debug_internal_pub_ =
148+
std::make_unique<autoware::universe_utils::DebugPublisher>(this, get_name());
144149
}
145150

146151
// time keeper
@@ -155,10 +160,9 @@ FusionNode<Msg3D, Msg2D, ExportObj>::FusionNode(
155160

156161
// initialize debug tool
157162
{
158-
using autoware::universe_utils::DebugPublisher;
159-
using autoware::universe_utils::StopWatch;
160-
stop_watch_ptr_ = std::make_unique<StopWatch<std::chrono::milliseconds>>();
161-
debug_publisher_ = std::make_unique<DebugPublisher>(this, get_name());
163+
stop_watch_ptr_ =
164+
std::make_unique<autoware::universe_utils::StopWatch<std::chrono::milliseconds>>();
165+
debug_publisher_ = std::make_unique<autoware::universe_utils::DebugPublisher>(this, get_name());
162166
stop_watch_ptr_->tic("cyclic_time");
163167
stop_watch_ptr_->tic("processing_time");
164168
}
@@ -347,11 +351,11 @@ void FusionNode<Msg3D, Msg2D, ExportObj>::subCallback(
347351
det2d.is_fused = true;
348352

349353
// add timestamp interval for debug
350-
if (debug_publisher_) {
354+
if (debug_internal_pub_) {
351355
double timestamp_interval_ms = (matched_stamp - timestamp_nsec) / 1e6;
352-
debug_publisher_->publish<tier4_debug_msgs::msg::Float64Stamped>(
356+
debug_internal_pub_->publish<tier4_debug_msgs::msg::Float64Stamped>(
353357
"debug/roi" + std::to_string(roi_i) + "/timestamp_interval_ms", timestamp_interval_ms);
354-
debug_publisher_->publish<tier4_debug_msgs::msg::Float64Stamped>(
358+
debug_internal_pub_->publish<tier4_debug_msgs::msg::Float64Stamped>(
355359
"debug/roi" + std::to_string(roi_i) + "/timestamp_interval_offset_ms",
356360
timestamp_interval_ms - det2d.input_offset_ms);
357361
}
@@ -412,11 +416,11 @@ void FusionNode<Msg3D, Msg2D, ExportObj>::roiCallback(
412416
fuseOnSingleImage(*(cached_det3d_msg_ptr_), det2d, *det2d_msg, *(cached_det3d_msg_ptr_));
413417
det2d.is_fused = true;
414418

415-
if (debug_publisher_) {
419+
if (debug_internal_pub_) {
416420
double timestamp_interval_ms = (timestamp_nsec - cached_det3d_msg_timestamp_) / 1e6;
417-
debug_publisher_->publish<tier4_debug_msgs::msg::Float64Stamped>(
421+
debug_internal_pub_->publish<tier4_debug_msgs::msg::Float64Stamped>(
418422
"debug/roi" + std::to_string(roi_i) + "/timestamp_interval_ms", timestamp_interval_ms);
419-
debug_publisher_->publish<tier4_debug_msgs::msg::Float64Stamped>(
423+
debug_internal_pub_->publish<tier4_debug_msgs::msg::Float64Stamped>(
420424
"debug/roi" + std::to_string(roi_i) + "/timestamp_interval_offset_ms",
421425
timestamp_interval_ms - det2d.input_offset_ms);
422426
}

perception/autoware_image_projection_based_fusion/src/pointpainting_fusion/node.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,13 @@ PointPaintingFusionNode::PointPaintingFusionNode(const rclcpp::NodeOptions & opt
158158
// subscriber
159159
std::function<void(const PointCloudMsgType::ConstSharedPtr msg)> sub_callback =
160160
std::bind(&PointPaintingFusionNode::subCallback, this, std::placeholders::_1);
161-
sub_ = this->create_subscription<PointCloudMsgType>(
161+
det3d_sub_ = this->create_subscription<PointCloudMsgType>(
162162
"~/input/pointcloud", rclcpp::SensorDataQoS().keep_last(3), sub_callback);
163163

164164
// publisher
165-
point_pub_ptr_ = this->create_publisher<PointCloudMsgType>("output", rclcpp::QoS{1});
166165
pub_ptr_ = this->create_publisher<DetectedObjects>("~/output/objects", rclcpp::QoS{1});
166+
painted_point_pub_ptr_ =
167+
this->create_publisher<PointCloudMsgType>("~/debug/painted_pointcloud", rclcpp::QoS{1});
167168

168169
detection_class_remapper_.setParameters(
169170
allow_remapping_by_area_matrix, min_area_matrix, max_area_matrix);
@@ -438,8 +439,8 @@ void PointPaintingFusionNode::postprocess(
438439
detection_class_remapper_.mapClasses(output_msg);
439440

440441
// publish debug message: painted pointcloud
441-
if (point_pub_ptr_->get_subscription_count() > 0) {
442-
point_pub_ptr_->publish(painted_pointcloud_msg);
442+
if (debugger_ && painted_point_pub_ptr_->get_subscription_count() > 0) {
443+
painted_point_pub_ptr_->publish(painted_pointcloud_msg);
443444
}
444445
diagnostics_interface_ptr_->publish(painted_pointcloud_msg.header.stamp);
445446
}

perception/autoware_image_projection_based_fusion/src/roi_detected_object_fusion/node.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,11 @@ void RoiDetectedObjectFusionNode::postprocess(
334334
debug_ignored_objects_msg.objects.emplace_back(obj);
335335
}
336336
}
337-
debug_publisher_->publish<DetectedObjects>("debug/fused_objects", debug_fused_objects_msg);
338-
debug_publisher_->publish<DetectedObjects>("debug/ignored_objects", debug_ignored_objects_msg);
337+
if (debug_internal_pub_) {
338+
debug_internal_pub_->publish<DetectedObjects>("debug/fused_objects", debug_fused_objects_msg);
339+
debug_internal_pub_->publish<DetectedObjects>(
340+
"debug/ignored_objects", debug_ignored_objects_msg);
341+
}
339342

340343
// clear flags
341344
passthrough_object_flags_map_.erase(timestamp_nsec);

perception/autoware_image_projection_based_fusion/src/roi_pointcloud_fusion/node.cpp

+11-5
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ RoiPointCloudFusionNode::RoiPointCloudFusionNode(const rclcpp::NodeOptions & opt
4545
cluster_2d_tolerance_ = declare_parameter<double>("cluster_2d_tolerance");
4646

4747
// publisher
48-
point_pub_ptr_ = this->create_publisher<PointCloudMsgType>("output", rclcpp::QoS{1});
49-
pub_ptr_ = this->create_publisher<ClusterMsgType>("output_clusters", rclcpp::QoS{1});
48+
pub_ptr_ = this->create_publisher<ClusterMsgType>("output", rclcpp::QoS{1});
5049
cluster_debug_pub_ = this->create_publisher<PointCloudMsgType>("debug/clusters", 1);
5150
}
5251

@@ -80,7 +79,15 @@ void RoiPointCloudFusionNode::fuseOnSingleImage(
8079
debug_image_rois.push_back(feature_obj.feature.roi);
8180
}
8281
}
82+
83+
// check if there is no object to fuse
8384
if (output_objs.empty()) {
85+
// publish debug image, which is empty
86+
if (debugger_) {
87+
debugger_->image_rois_ = debug_image_rois;
88+
debugger_->obstacle_points_ = debug_image_points;
89+
debugger_->publishImage(det2d.id, input_roi_msg.header.stamp);
90+
}
8491
return;
8592
}
8693

@@ -164,6 +171,8 @@ void RoiPointCloudFusionNode::fuseOnSingleImage(
164171
updateOutputFusedObjects(
165172
output_objs, clusters, clusters_data_size, input_pointcloud_msg, input_roi_msg.header,
166173
tf_buffer_, min_cluster_size_, max_cluster_size_, cluster_2d_tolerance_, output_fused_objects_);
174+
175+
// publish debug image
167176
if (debugger_) {
168177
debugger_->image_rois_ = debug_image_rois;
169178
debugger_->obstacle_points_ = debug_image_points;
@@ -188,9 +197,6 @@ void RoiPointCloudFusionNode::postprocess(
188197
autoware::euclidean_cluster::convertObjectMsg2SensorMsg(output_msg, debug_cluster_msg);
189198
cluster_debug_pub_->publish(debug_cluster_msg);
190199
}
191-
if (point_pub_ptr_->get_subscription_count() > 0) {
192-
point_pub_ptr_->publish(pointcloud_msg);
193-
}
194200
}
195201

196202
void RoiPointCloudFusionNode::publish(const ClusterMsgType & output_msg)

0 commit comments

Comments
 (0)