Merge branch 'optimize/ros2-image-transport-reuse' into v2/develop

This commit is contained in:
ob-yalian
2026-08-20 18:31:04 +08:00
4 changed files with 89 additions and 5 deletions
+7 -5
View File
@@ -5443,26 +5443,27 @@ void OBCameraNode::setupCameraInfo() {
}
void OBCameraNode::setupImagePublisher(const stream_index_pair &stream_index) {
const std::string topic = stream_name_[stream_index] + "/image_raw";
if (!enable_stream_[stream_index]) {
releaseGlobalImageTransportPublisher(*node_, topic);
image_publishers_.erase(stream_index);
compressed_image_publishers_.erase(stream_index);
return;
}
const std::string topic = stream_name_[stream_index] + "/image_raw";
const auto image_qos_profile = getImageQosProfile(stream_index);
const bool is_mjpg_color_stream =
(stream_index == COLOR || stream_index == COLOR_LEFT || stream_index == COLOR_RIGHT) &&
format_[stream_index] == OB_FORMAT_MJPG;
if (use_intra_process_ || is_mjpg_color_stream) {
releaseGlobalImageTransportPublisher(*node_, topic);
image_publishers_[stream_index] =
std::make_shared<image_rcl_publisher>(*node_, topic, image_qos_profile);
} else {
image_publishers_[stream_index] =
std::make_shared<image_transport_publisher>(*node_, topic, image_qos_profile);
getGlobalImageTransportPublisher(*node_, topic, image_qos_profile);
}
RCLCPP_INFO_STREAM(logger_,
topic << " QoS: " << getRMWQosProfileDescription(image_qos_profile));
RCLCPP_INFO_STREAM(logger_, topic << " QoS: " << getRMWQosProfileDescription(image_qos_profile));
if (is_mjpg_color_stream) {
compressed_image_publishers_[stream_index] =
@@ -5647,7 +5648,7 @@ void OBCameraNode::syncSoftwareAlignment() {
depth_unaligned_publisher_ = std::make_shared<image_rcl_publisher>(
*node_, "depth/image_unaligned", depth_image_qos_profile);
} else {
depth_unaligned_publisher_ = std::make_shared<image_transport_publisher>(
depth_unaligned_publisher_ = getGlobalImageTransportPublisher(
*node_, "depth/image_unaligned", depth_image_qos_profile);
}
}
@@ -5655,6 +5656,7 @@ void OBCameraNode::syncSoftwareAlignment() {
}
align_filter_.reset();
releaseGlobalImageTransportPublisher(*node_, "depth/image_unaligned");
depth_unaligned_publisher_.reset();
}