mirror of
https://github.com/orbbec/OrbbecSDK_ROS2.git
synced 2026-10-12 23:39:50 +08:00
Add topic initialization judgment
This commit is contained in:
@@ -1265,11 +1265,13 @@ void OBCameraNode::setupPublishers() {
|
|||||||
camera_info_qos_profile));
|
camera_info_qos_profile));
|
||||||
|
|
||||||
auto image_h264_qos_profile = getRMWQosProfileFromString(image_qos);
|
auto image_h264_qos_profile = getRMWQosProfileFromString(image_qos);
|
||||||
camera_h26x_publishers_[stream_index] =
|
if (format_str_[stream_index] == "H264" || format_str_[stream_index] == "H265") {
|
||||||
node_->create_publisher<sensor_msgs::msg::CompressedImage>(
|
camera_h26x_publishers_[stream_index] =
|
||||||
"/camera/color/h26x_encoded_data",
|
node_->create_publisher<sensor_msgs::msg::CompressedImage>(
|
||||||
rclcpp::QoS(rclcpp::QoSInitialization::from_rmw(image_h264_qos_profile),
|
"/camera/color/h26x_encoded_data",
|
||||||
image_h264_qos_profile));
|
rclcpp::QoS(rclcpp::QoSInitialization::from_rmw(image_h264_qos_profile),
|
||||||
|
image_h264_qos_profile));
|
||||||
|
}
|
||||||
if (isGemini335PID(pid)) {
|
if (isGemini335PID(pid)) {
|
||||||
metadata_publishers_[stream_index] =
|
metadata_publishers_[stream_index] =
|
||||||
node_->create_publisher<orbbec_camera_msgs::msg::Metadata>(
|
node_->create_publisher<orbbec_camera_msgs::msg::Metadata>(
|
||||||
@@ -1809,7 +1811,10 @@ bool OBCameraNode::decodeColorFrameToBuffer(const std::shared_ptr<ob::Frame> &fr
|
|||||||
}
|
}
|
||||||
CHECK_NOTNULL(image_publishers_[COLOR]);
|
CHECK_NOTNULL(image_publishers_[COLOR]);
|
||||||
bool has_subscriber = image_publishers_[COLOR]->get_subscription_count() > 0;
|
bool has_subscriber = image_publishers_[COLOR]->get_subscription_count() > 0;
|
||||||
has_subscriber = has_subscriber || camera_h26x_publishers_[COLOR]->get_subscription_count() > 0;
|
if (camera_h26x_publishers_[COLOR] &&
|
||||||
|
camera_h26x_publishers_[COLOR]->get_subscription_count() > 0) {
|
||||||
|
has_subscriber = true;
|
||||||
|
}
|
||||||
if (enable_colored_point_cloud_ && depth_registration_cloud_pub_->get_subscription_count() > 0) {
|
if (enable_colored_point_cloud_ && depth_registration_cloud_pub_->get_subscription_count() > 0) {
|
||||||
has_subscriber = true;
|
has_subscriber = true;
|
||||||
}
|
}
|
||||||
@@ -1905,8 +1910,8 @@ void OBCameraNode::onNewFrameCallback(const std::shared_ptr<ob::Frame> &frame,
|
|||||||
has_subscriber =
|
has_subscriber =
|
||||||
has_subscriber || (metadata_publishers_.count(stream_index) &&
|
has_subscriber || (metadata_publishers_.count(stream_index) &&
|
||||||
metadata_publishers_[stream_index]->get_subscription_count() > 0);
|
metadata_publishers_[stream_index]->get_subscription_count() > 0);
|
||||||
has_subscriber =
|
has_subscriber = has_subscriber || (camera_h26x_publishers_[COLOR] &&
|
||||||
has_subscriber || camera_h26x_publishers_[stream_index]->get_subscription_count() > 0;
|
camera_h26x_publishers_[COLOR]->get_subscription_count() > 0);
|
||||||
if (!has_subscriber) {
|
if (!has_subscriber) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1986,7 +1991,8 @@ void OBCameraNode::onNewFrameCallback(const std::shared_ptr<ob::Frame> &frame,
|
|||||||
}
|
}
|
||||||
CHECK_NOTNULL(image_publishers_[stream_index]);
|
CHECK_NOTNULL(image_publishers_[stream_index]);
|
||||||
if (image_publishers_[stream_index]->get_subscription_count() == 0 &&
|
if (image_publishers_[stream_index]->get_subscription_count() == 0 &&
|
||||||
camera_h26x_publishers_[stream_index]->get_subscription_count() == 0) {
|
(!camera_h26x_publishers_[COLOR] &&
|
||||||
|
camera_h26x_publishers_[COLOR]->get_subscription_count() == 0)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto &image = images_[stream_index];
|
auto &image = images_[stream_index];
|
||||||
|
|||||||
Reference in New Issue
Block a user