9 #include <sensor_msgs/PointCloud2.h>
21 explicit Impl(
size_t queue_size)
55 "[rgbd_image_transport] Topics '%s', '%s', '%s', '%s'%s do not appear to be synchronized. "
57 "\tRGB messages received: %d\n"
58 "\tRGB CameraInfo messages received: %d\n"
59 "\tDepth messages received: %d\n"
60 "\tDepth CameraInfo messages received: %d\n"
62 "\tSynchronized pairs: %d",
65 (this->hasPcl ?
" and '" +
pclSub.
getTopic() +
"'" : std::string()).c_str(),
67 (this->hasPcl ? (std::string(
"\tPointcloud messages received: ") +
cras::to_string(
pclReceived) +
"\n") : std::string()).c_str(),
88 const std::string& rgb_base_topic,
const std::string& depth_base_topic,
size_t queue_size,
92 : impl(new
Impl(queue_size))
94 this->
impl->hasPcl =
false;
98 const auto rgb_topic = rgb_nh.
resolveName(rgb_base_topic);
100 const auto depth_topic = depth_nh.
resolveName(depth_base_topic);
103 impl->rgbSub.subscribe(image_it, rgb_topic, queue_size, transport_hints_rgb);
104 impl->rgbInfoSub.subscribe(rgb_nh, rgb_info_topic, queue_size, transport_hints_rgb.
getRosHints());
105 impl->depthSub.subscribe(image_it, depth_topic, queue_size, transport_hints_depth);
106 impl->depthInfoSub.subscribe(depth_nh, depth_info_topic, queue_size, transport_hints_depth.
getRosHints());
109 impl->sync.registerCallback(boost::bind(callback, _1, _2, _3, _4));
113 impl->rgbInfoSub.registerCallback(boost::bind(
increment, &
impl->rgbInfoReceived));
115 impl->depthInfoSub.registerCallback(boost::bind(
increment, &
impl->depthInfoReceived));
122 const std::string& rgb_base_topic,
const std::string& depth_base_topic,
123 const std::string& pcl_topic,
size_t queue_size,
128 : impl(new
Impl(queue_size))
130 this->
impl->hasPcl =
true;
134 const auto rgb_topic = rgb_nh.
resolveName(rgb_base_topic);
136 const auto depth_topic = depth_nh.
resolveName(depth_base_topic);
139 impl->rgbSub.subscribe(image_it, rgb_topic, queue_size, transport_hints_rgb);
140 impl->rgbInfoSub.subscribe(rgb_nh, rgb_info_topic, queue_size, transport_hints_rgb.
getRosHints());
141 impl->depthSub.subscribe(image_it, depth_topic, queue_size, transport_hints_depth);
142 impl->depthInfoSub.subscribe(depth_nh, depth_info_topic, queue_size, transport_hints_depth.
getRosHints());
143 impl->pclSub.subscribe(pcl_nh, pcl_topic, queue_size, transport_hints_pcl);
146 impl->syncPcl.registerCallback(boost::bind(callback, _1, _2, _3, _4, _5));
150 impl->rgbInfoSub.registerCallback(boost::bind(
increment, &
impl->rgbInfoReceived));
152 impl->depthInfoSub.registerCallback(boost::bind(
increment, &
impl->depthInfoReceived));
161 if (
impl)
return impl->rgbSub.getTopic();
167 if (
impl)
return impl->rgbInfoSub.getTopic();
173 if (
impl)
return impl->depthSub.getTopic();
179 if (
impl)
return impl->depthInfoSub.getTopic();
185 if (
impl &&
impl->hasPcl)
return impl->pclSub.getTopic();
192 return std::max(std::max(
193 std::max(
impl->rgbSub.getNumPublishers(),
impl->rgbInfoSub.getSubscriber().getNumPublishers()),
194 std::max(
impl->depthSub.getNumPublishers(),
impl->depthInfoSub.getSubscriber().getNumPublishers())
195 ), (this->impl->hasPcl ?
impl->pclSub.getSubscriber().getNumPublishers() : 0));
202 if (
impl)
return impl->rgbSub.getTransport();
208 if (
impl)
return impl->depthSub.getTransport();
217 RgbdCameraSubscriber::operator
void*()
const
219 return (impl && impl->isValid()) ? (
void*)1 : (
void*)0;