11 if (pnh.hasParam(
"rate"))
22 if (pnh.hasParam(
"fix_rgb_frame_id"))
24 if (this->
rgbFrameId.has_value() && this->rgbFrameId.value().empty())
29 if (pnh.hasParam(
"fix_depth_frame_id"))
31 if (this->
depthFrameId.has_value() && this->depthFrameId.value().empty())
72 void RgbdCameraThrottleNodelet::cb(
const sensor_msgs::ImageConstPtr& rgbImg,
const sensor_msgs::CameraInfoConstPtr& rgbInfo,
const sensor_msgs::ImageConstPtr& depthImg,
const sensor_msgs::CameraInfoConstPtr& depthInfo)
85 if (!this->
rgbFrameId.has_value() && !this->depthFrameId.has_value())
87 this->
pub.
publish(rgbImg, rgbInfo, depthImg, depthInfo);
89 sensor_msgs::ImageConstPtr pubRgbImg = rgbImg;
90 sensor_msgs::CameraInfoConstPtr pubRgbInfo = rgbInfo;
91 sensor_msgs::ImageConstPtr pubDepthImg = depthImg;
92 sensor_msgs::CameraInfoConstPtr pubDepthInfo = depthInfo;
96 sensor_msgs::ImagePtr newRgbImg(
new sensor_msgs::Image);
97 sensor_msgs::CameraInfoPtr newRgbInfo(
new sensor_msgs::CameraInfo);
99 *newRgbInfo = *rgbInfo;
100 newRgbImg->header.frame_id = this->
rgbFrameId.value();
101 newRgbInfo->header.frame_id = this->
rgbFrameId.value();
103 pubRgbImg = newRgbImg;
104 pubRgbInfo = newRgbInfo;
109 sensor_msgs::ImagePtr newDepthImg(
new sensor_msgs::Image);
110 sensor_msgs::CameraInfoPtr newDepthInfo(
new sensor_msgs::CameraInfo);
111 *newDepthImg = *depthImg;
112 *newDepthInfo = *depthInfo;
113 newDepthImg->header.frame_id = this->
depthFrameId.value();
114 newDepthInfo->header.frame_id = this->
depthFrameId.value();
116 pubDepthImg = newDepthImg;
117 pubDepthInfo = newDepthInfo;
120 this->
pub.
publish(pubRgbImg, pubRgbInfo, pubDepthImg, pubDepthInfo);
124 void RgbdCameraThrottleNodelet::cbPcl(
const sensor_msgs::ImageConstPtr& rgbImg,
const sensor_msgs::CameraInfoConstPtr& rgbInfo,
const sensor_msgs::ImageConstPtr& depthImg,
const sensor_msgs::CameraInfoConstPtr& depthInfo,
const sensor_msgs::PointCloud2ConstPtr& pcl)
137 if (!this->
rgbFrameId.has_value() && !this->depthFrameId.has_value())
139 this->
pub.
publish(rgbImg, rgbInfo, depthImg, depthInfo, pcl);
141 sensor_msgs::ImageConstPtr pubRgbImg = rgbImg;
142 sensor_msgs::CameraInfoConstPtr pubRgbInfo = rgbInfo;
143 sensor_msgs::ImageConstPtr pubDepthImg = depthImg;
144 sensor_msgs::CameraInfoConstPtr pubDepthInfo = depthInfo;
148 sensor_msgs::ImagePtr newRgbImg(
new sensor_msgs::Image);
149 sensor_msgs::CameraInfoPtr newRgbInfo(
new sensor_msgs::CameraInfo);
150 *newRgbImg = *rgbImg;
151 *newRgbInfo = *rgbInfo;
152 newRgbImg->header.frame_id = this->
rgbFrameId.value();
153 newRgbInfo->header.frame_id = this->
rgbFrameId.value();
155 pubRgbImg = newRgbImg;
156 pubRgbInfo = newRgbInfo;
161 sensor_msgs::ImagePtr newDepthImg(
new sensor_msgs::Image);
162 sensor_msgs::CameraInfoPtr newDepthInfo(
new sensor_msgs::CameraInfo);
163 *newDepthImg = *depthImg;
164 *newDepthInfo = *depthInfo;
165 newDepthImg->header.frame_id = this->
depthFrameId.value();
166 newDepthInfo->header.frame_id = this->
depthFrameId.value();
168 pubDepthImg = newDepthImg;
169 pubDepthInfo = newDepthInfo;
172 this->
pub.
publish(pubRgbImg, pubRgbInfo, pubDepthImg, pubDepthInfo, pcl);
212 this->subDepthNh.resolveName(this->subDepthBaseName).c_str(),
213 this->subPclNh.resolveName(
"points_in").c_str());
218 this->subDepthNh.resolveName(this->subDepthBaseName).c_str());
226 NODELET_DEBUG(
"Stopped lazy-subscription to %s, %s and %s", this->
sub.value().getRGBTopic().c_str(), this->sub.value().getDepthTopic().c_str(), this->sub.value().getPclTopic().c_str());
228 NODELET_DEBUG(
"Stopped lazy-subscription to %s and %s", this->
sub.value().getRGBTopic().c_str(), this->sub.value().getDepthTopic().c_str());
229 this->
sub.value().shutdown();