47 const std::string& rgb_base_topic,
const std::string& depth_base_topic,
size_t queue_size,
59 this->
impl->hasPcl =
false;
63 const auto rgb_image_topic = rgb_nh.
resolveName(rgb_base_topic);
65 const auto depth_image_topic = depth_nh.
resolveName(depth_base_topic);
69 rgb_image_topic, queue_size, rgb_connect_cb, rgb_disconnect_cb, tracked_object, latch);
70 this->
impl->rgbInfoPub = rgb_nh.
advertise<sensor_msgs::CameraInfo>(
71 rgb_info_topic, queue_size, rgb_info_connect_cb, rgb_info_disconnect_cb, tracked_object, latch);
73 depth_image_topic, queue_size, depth_connect_cb, depth_disconnect_cb, tracked_object, latch);
74 this->
impl->depthInfoPub = depth_nh.
advertise<sensor_msgs::CameraInfo>(
75 depth_info_topic, queue_size, depth_info_connect_cb, depth_info_disconnect_cb, tracked_object, latch);
79 const std::string& rgb_base_topic,
const std::string& depth_base_topic,
const std::string& pcl_topic,
94 this->
impl->hasPcl =
true;
98 const auto rgb_image_topic = rgb_nh.
resolveName(rgb_base_topic);
100 const auto depth_image_topic = depth_nh.
resolveName(depth_base_topic);
104 rgb_image_topic, queue_size, rgb_connect_cb, rgb_disconnect_cb, tracked_object, latch);
105 this->
impl->rgbInfoPub = rgb_nh.
advertise<sensor_msgs::CameraInfo>(
106 rgb_info_topic, queue_size, rgb_info_connect_cb, rgb_info_disconnect_cb, tracked_object, latch);
108 depth_image_topic, queue_size, depth_connect_cb, depth_disconnect_cb, tracked_object, latch);
109 this->
impl->depthInfoPub = depth_nh.
advertise<sensor_msgs::CameraInfo>(
110 depth_info_topic, queue_size, depth_info_connect_cb, depth_info_disconnect_cb, tracked_object, latch);
111 this->
impl->pclPub = pcl_nh.
advertise<sensor_msgs::PointCloud2>(
112 pcl_topic, queue_size, pcl_connect_cb, pcl_disconnect_cb, tracked_object, latch);
118 return std::max(std::max(
119 std::max(
impl->rgbPub.getNumSubscribers(),
impl->rgbInfoPub.getNumSubscribers()),
120 std::max(
impl->depthPub.getNumSubscribers(),
impl->depthInfoPub.getNumSubscribers())
121 ), (this->impl->hasPcl ?
impl->pclPub.getNumSubscribers() : 0));
127 if (
impl)
return impl->rgbPub.getTopic();
133 if (
impl)
return impl->rgbInfoPub.getTopic();
139 if (
impl)
return impl->depthPub.getTopic();
145 if (
impl)
return impl->depthInfoPub.getTopic();
151 if (
impl &&
impl->hasPcl)
return impl->pclPub.getTopic();
156 const sensor_msgs::Image& depth_image,
const sensor_msgs::CameraInfo& depth_info)
const
159 ROS_ASSERT_MSG(
false,
"Call to publish() on an invalid image_transport::RgbdCameraPublisher");
163 impl->rgbPub.publish(rgb_image);
164 impl->rgbInfoPub.publish(rgb_info);
166 impl->depthPub.publish(depth_image);
167 impl->depthInfoPub.publish(depth_info);
171 const sensor_msgs::Image& depth_image,
const sensor_msgs::CameraInfo& depth_info,
172 const sensor_msgs::PointCloud2& pcl)
const
175 ROS_ASSERT_MSG(
false,
"Call to publish() on an invalid image_transport::RgbdCameraPublisher");
179 impl->rgbPub.publish(rgb_image);
180 impl->rgbInfoPub.publish(rgb_info);
182 impl->depthPub.publish(depth_image);
183 impl->depthInfoPub.publish(depth_info);
185 impl->pclPub.publish(pcl);
189 const sensor_msgs::ImageConstPtr& depth_image,
const sensor_msgs::CameraInfoConstPtr& depth_info)
const
192 ROS_ASSERT_MSG(
false,
"Call to publish() on an invalid image_transport::RgbdCameraPublisher");
196 impl->rgbPub.publish(rgb_image);
197 impl->rgbInfoPub.publish(rgb_info);
199 impl->depthPub.publish(depth_image);
200 impl->depthInfoPub.publish(depth_info);
204 const sensor_msgs::ImageConstPtr& depth_image,
const sensor_msgs::CameraInfoConstPtr& depth_info,
205 const sensor_msgs::PointCloud2ConstPtr& pcl)
const
208 ROS_ASSERT_MSG(
false,
"Call to publish() on an invalid image_transport::RgbdCameraPublisher");
212 impl->rgbPub.publish(rgb_image);
213 impl->rgbInfoPub.publish(rgb_info);
215 impl->depthPub.publish(depth_image);
216 impl->depthInfoPub.publish(depth_info);
218 impl->pclPub.publish(pcl);
222 sensor_msgs::Image& depth_image, sensor_msgs::CameraInfo& depth_info,
ros::Time stamp)
const
225 ROS_ASSERT_MSG(
false,
"Call to publish() on an invalid image_transport::RgbdCameraPublisher");
229 rgb_image.header.stamp = stamp;
230 rgb_info.header.stamp = stamp;
231 depth_image.header.stamp = stamp;
232 depth_info.header.stamp = stamp;
234 this->
publish(rgb_image, rgb_info, depth_image, depth_info);
238 sensor_msgs::Image& depth_image, sensor_msgs::CameraInfo& depth_info,
239 sensor_msgs::PointCloud2& pcl,
ros::Time stamp)
const
242 ROS_ASSERT_MSG(
false,
"Call to publish() on an invalid image_transport::RgbdCameraPublisher");
246 rgb_image.header.stamp = stamp;
247 rgb_info.header.stamp = stamp;
248 depth_image.header.stamp = stamp;
249 depth_info.header.stamp = stamp;
250 pcl.header.stamp = stamp;
252 this->
publish(rgb_image, rgb_info, depth_image, depth_info, stamp);
263 RgbdCameraPublisher::operator
void*()
const
265 return (impl && impl->isValid()) ? (
void*)1 : (
void*)0;