35 #define IMAGE_CONVERSION() \ 37 std::vector<cv_bridge::CvImageConstPtr> imageMsgs(2); \ 38 std::vector<cv_bridge::CvImageConstPtr> depthMsgs(2); \ 39 rtabmap_ros::toCvShare(image1Msg, imageMsgs[0], depthMsgs[0]); \ 40 rtabmap_ros::toCvShare(image2Msg, imageMsgs[1], depthMsgs[1]); \ 41 std::vector<sensor_msgs::CameraInfo> cameraInfoMsgs; \ 42 cameraInfoMsgs.push_back(image1Msg->rgbCameraInfo); \ 43 cameraInfoMsgs.push_back(image2Msg->rgbCameraInfo); 46 void CommonDataSubscriber::rgbd2Callback(
47 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
48 const rtabmap_ros::RGBDImageConstPtr& image2Msg)
52 nav_msgs::OdometryConstPtr odomMsg;
53 rtabmap_ros::UserDataConstPtr userDataMsg;
54 sensor_msgs::LaserScanConstPtr scanMsg;
55 sensor_msgs::PointCloud2ConstPtr scan3dMsg;
56 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
57 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg);
59 void CommonDataSubscriber::rgbd2Scan2dCallback(
60 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
61 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
62 const sensor_msgs::LaserScanConstPtr& scanMsg)
66 nav_msgs::OdometryConstPtr odomMsg;
67 rtabmap_ros::UserDataConstPtr userDataMsg;
68 sensor_msgs::PointCloud2ConstPtr scan3dMsg;
69 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
70 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg);
72 void CommonDataSubscriber::rgbd2Scan3dCallback(
73 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
74 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
75 const sensor_msgs::PointCloud2ConstPtr& scan3dMsg)
79 nav_msgs::OdometryConstPtr odomMsg;
80 rtabmap_ros::UserDataConstPtr userDataMsg;
81 sensor_msgs::LaserScanConstPtr scanMsg;
82 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
83 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg);
85 void CommonDataSubscriber::rgbd2InfoCallback(
86 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
87 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
88 const rtabmap_ros::OdomInfoConstPtr& odomInfoMsg)
92 nav_msgs::OdometryConstPtr odomMsg;
93 rtabmap_ros::UserDataConstPtr userDataMsg;
94 sensor_msgs::LaserScanConstPtr scanMsg;
95 sensor_msgs::PointCloud2ConstPtr scan3dMsg;
96 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg);
98 void CommonDataSubscriber::rgbd2Scan2dInfoCallback(
99 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
100 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
101 const sensor_msgs::LaserScanConstPtr& scanMsg,
102 const rtabmap_ros::OdomInfoConstPtr& odomInfoMsg)
106 nav_msgs::OdometryConstPtr odomMsg;
107 rtabmap_ros::UserDataConstPtr userDataMsg;
108 sensor_msgs::PointCloud2ConstPtr scan3dMsg;
109 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg);
111 void CommonDataSubscriber::rgbd2Scan3dInfoCallback(
112 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
113 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
114 const sensor_msgs::PointCloud2ConstPtr& scan3dMsg,
115 const rtabmap_ros::OdomInfoConstPtr& odomInfoMsg)
119 nav_msgs::OdometryConstPtr odomMsg;
120 rtabmap_ros::UserDataConstPtr userDataMsg;
121 sensor_msgs::LaserScanConstPtr scanMsg;
122 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg);
126 void CommonDataSubscriber::rgbd2OdomCallback(
127 const nav_msgs::OdometryConstPtr & odomMsg,
128 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
129 const rtabmap_ros::RGBDImageConstPtr& image2Msg)
133 rtabmap_ros::UserDataConstPtr userDataMsg;
134 sensor_msgs::LaserScanConstPtr scanMsg;
135 sensor_msgs::PointCloud2ConstPtr scan3dMsg;
136 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
137 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg);
139 void CommonDataSubscriber::rgbd2OdomScan2dCallback(
140 const nav_msgs::OdometryConstPtr & odomMsg,
141 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
142 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
143 const sensor_msgs::LaserScanConstPtr& scanMsg)
147 rtabmap_ros::UserDataConstPtr userDataMsg;
148 sensor_msgs::PointCloud2ConstPtr scan3dMsg;
149 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
150 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg);
152 void CommonDataSubscriber::rgbd2OdomScan3dCallback(
153 const nav_msgs::OdometryConstPtr & odomMsg,
154 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
155 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
156 const sensor_msgs::PointCloud2ConstPtr& scan3dMsg)
160 rtabmap_ros::UserDataConstPtr userDataMsg;
161 sensor_msgs::LaserScanConstPtr scanMsg;
162 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
163 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg);
165 void CommonDataSubscriber::rgbd2OdomInfoCallback(
166 const nav_msgs::OdometryConstPtr & odomMsg,
167 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
168 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
169 const rtabmap_ros::OdomInfoConstPtr& odomInfoMsg)
173 rtabmap_ros::UserDataConstPtr userDataMsg;
174 sensor_msgs::LaserScanConstPtr scanMsg;
175 sensor_msgs::PointCloud2ConstPtr scan3dMsg;
176 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg);
178 void CommonDataSubscriber::rgbd2OdomScan2dInfoCallback(
179 const nav_msgs::OdometryConstPtr & odomMsg,
180 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
181 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
182 const sensor_msgs::LaserScanConstPtr& scanMsg,
183 const rtabmap_ros::OdomInfoConstPtr& odomInfoMsg)
187 rtabmap_ros::UserDataConstPtr userDataMsg;
188 sensor_msgs::PointCloud2ConstPtr scan3dMsg;
189 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg);
191 void CommonDataSubscriber::rgbd2OdomScan3dInfoCallback(
192 const nav_msgs::OdometryConstPtr & odomMsg,
193 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
194 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
195 const sensor_msgs::PointCloud2ConstPtr& scan3dMsg,
196 const rtabmap_ros::OdomInfoConstPtr& odomInfoMsg)
200 rtabmap_ros::UserDataConstPtr userDataMsg;
201 sensor_msgs::LaserScanConstPtr scanMsg;
202 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg);
206 void CommonDataSubscriber::rgbd2DataCallback(
207 const rtabmap_ros::UserDataConstPtr& userDataMsg,
208 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
209 const rtabmap_ros::RGBDImageConstPtr& image2Msg)
213 nav_msgs::OdometryConstPtr odomMsg;
214 sensor_msgs::LaserScanConstPtr scanMsg;
215 sensor_msgs::PointCloud2ConstPtr scan3dMsg;
216 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
217 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg);
219 void CommonDataSubscriber::rgbd2DataScan2dCallback(
220 const rtabmap_ros::UserDataConstPtr& userDataMsg,
221 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
222 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
223 const sensor_msgs::LaserScanConstPtr& scanMsg)
227 nav_msgs::OdometryConstPtr odomMsg;
228 sensor_msgs::PointCloud2ConstPtr scan3dMsg;
229 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
230 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg);
232 void CommonDataSubscriber::rgbd2DataScan3dCallback(
233 const rtabmap_ros::UserDataConstPtr& userDataMsg,
234 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
235 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
236 const sensor_msgs::PointCloud2ConstPtr& scan3dMsg)
240 nav_msgs::OdometryConstPtr odomMsg;
241 sensor_msgs::LaserScanConstPtr scanMsg;
242 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
243 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg);
245 void CommonDataSubscriber::rgbd2DataInfoCallback(
246 const rtabmap_ros::UserDataConstPtr& userDataMsg,
247 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
248 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
249 const rtabmap_ros::OdomInfoConstPtr& odomInfoMsg)
253 nav_msgs::OdometryConstPtr odomMsg;
254 sensor_msgs::LaserScanConstPtr scanMsg;
255 sensor_msgs::PointCloud2ConstPtr scan3dMsg;
256 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg);
258 void CommonDataSubscriber::rgbd2DataScan2dInfoCallback(
259 const rtabmap_ros::UserDataConstPtr& userDataMsg,
260 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
261 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
262 const sensor_msgs::LaserScanConstPtr& scanMsg,
263 const rtabmap_ros::OdomInfoConstPtr& odomInfoMsg)
267 nav_msgs::OdometryConstPtr odomMsg;
268 sensor_msgs::PointCloud2ConstPtr scan3dMsg;
269 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg);
271 void CommonDataSubscriber::rgbd2DataScan3dInfoCallback(
272 const rtabmap_ros::UserDataConstPtr& userDataMsg,
273 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
274 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
275 const sensor_msgs::PointCloud2ConstPtr& scan3dMsg,
276 const rtabmap_ros::OdomInfoConstPtr& odomInfoMsg)
280 nav_msgs::OdometryConstPtr odomMsg;
281 sensor_msgs::LaserScanConstPtr scanMsg;
282 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg);
286 void CommonDataSubscriber::rgbd2OdomDataCallback(
287 const nav_msgs::OdometryConstPtr& odomMsg,
288 const rtabmap_ros::UserDataConstPtr& userDataMsg,
289 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
290 const rtabmap_ros::RGBDImageConstPtr& image2Msg)
294 sensor_msgs::LaserScanConstPtr scanMsg;
295 sensor_msgs::PointCloud2ConstPtr scan3dMsg;
296 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
297 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg);
299 void CommonDataSubscriber::rgbd2OdomDataScan2dCallback(
300 const nav_msgs::OdometryConstPtr& odomMsg,
301 const rtabmap_ros::UserDataConstPtr& userDataMsg,
302 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
303 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
304 const sensor_msgs::LaserScanConstPtr& scanMsg)
308 sensor_msgs::PointCloud2ConstPtr scan3dMsg;
309 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
310 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg);
312 void CommonDataSubscriber::rgbd2OdomDataScan3dCallback(
313 const nav_msgs::OdometryConstPtr& odomMsg,
314 const rtabmap_ros::UserDataConstPtr& userDataMsg,
315 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
316 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
317 const sensor_msgs::PointCloud2ConstPtr& scan3dMsg)
321 sensor_msgs::LaserScanConstPtr scanMsg;
322 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
323 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg);
325 void CommonDataSubscriber::rgbd2OdomDataInfoCallback(
326 const nav_msgs::OdometryConstPtr& odomMsg,
327 const rtabmap_ros::UserDataConstPtr& userDataMsg,
328 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
329 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
330 const rtabmap_ros::OdomInfoConstPtr& odomInfoMsg)
334 sensor_msgs::LaserScanConstPtr scanMsg;
335 sensor_msgs::PointCloud2ConstPtr scan3dMsg;
336 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg);
338 void CommonDataSubscriber::rgbd2OdomDataScan2dInfoCallback(
339 const nav_msgs::OdometryConstPtr& odomMsg,
340 const rtabmap_ros::UserDataConstPtr& userDataMsg,
341 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
342 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
343 const sensor_msgs::LaserScanConstPtr& scanMsg,
344 const rtabmap_ros::OdomInfoConstPtr& odomInfoMsg)
348 sensor_msgs::PointCloud2ConstPtr scan3dMsg;
349 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg);
351 void CommonDataSubscriber::rgbd2OdomDataScan3dInfoCallback(
352 const nav_msgs::OdometryConstPtr& odomMsg,
353 const rtabmap_ros::UserDataConstPtr& userDataMsg,
354 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
355 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
356 const sensor_msgs::PointCloud2ConstPtr& scan3dMsg,
357 const rtabmap_ros::OdomInfoConstPtr& odomInfoMsg)
361 sensor_msgs::LaserScanConstPtr scanMsg;
362 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg);
369 bool subscribeUserData,
370 bool subscribeScan2d,
371 bool subscribeScan3d,
372 bool subscribeOdomInfo,
379 for(
int i=0; i<2; ++i)
384 if(subscribeOdom && subscribeUserData)
392 if(subscribeOdomInfo)
403 else if(subscribeScan3d)
407 if(subscribeOdomInfo)
418 else if(subscribeOdomInfo)
429 else if(subscribeOdom)
436 if(subscribeOdomInfo)
447 else if(subscribeScan3d)
451 if(subscribeOdomInfo)
462 else if(subscribeOdomInfo)
473 else if(subscribeUserData)
480 if(subscribeOdomInfo)
491 else if(subscribeScan3d)
495 if(subscribeOdomInfo)
506 else if(subscribeOdomInfo)
523 if(subscribeOdomInfo)
534 else if(subscribeScan3d)
538 if(subscribeOdomInfo)
549 else if(subscribeOdomInfo)
std::string uFormat(const char *fmt,...)
void setupRGBD2Callbacks(ros::NodeHandle &nh, ros::NodeHandle &pnh, bool subscribeOdom, bool subscribeUserData, bool subscribeScan2d, bool subscribeScan3d, bool subscribeOdomInfo, int queueSize, bool approxSync)
#define SYNC_DECL5(PREFIX, APPROX, QUEUE_SIZE, SUB0, SUB1, SUB2, SUB3, SUB4)
#define IMAGE_CONVERSION()
virtual void commonDepthCallback(const nav_msgs::OdometryConstPtr &odomMsg, const rtabmap_ros::UserDataConstPtr &userDataMsg, const std::vector< cv_bridge::CvImageConstPtr > &imageMsgs, const std::vector< cv_bridge::CvImageConstPtr > &depthMsgs, const std::vector< sensor_msgs::CameraInfo > &cameraInfoMsgs, const sensor_msgs::LaserScanConstPtr &scanMsg, const sensor_msgs::PointCloud2ConstPtr &scan3dMsg, const rtabmap_ros::OdomInfoConstPtr &odomInfoMsg)=0
#define SYNC_DECL3(PREFIX, APPROX, QUEUE_SIZE, SUB0, SUB1, SUB2)
message_filters::Subscriber< rtabmap_ros::UserData > userDataSub_
bool subscribedToOdomInfo_
#define SYNC_DECL6(PREFIX, APPROX, QUEUE_SIZE, SUB0, SUB1, SUB2, SUB3, SUB4, SUB5)
message_filters::Subscriber< rtabmap_ros::OdomInfo > odomInfoSub_
#define SYNC_DECL2(PREFIX, APPROX, QUEUE_SIZE, SUB0, SUB1)
message_filters::Subscriber< sensor_msgs::LaserScan > scanSub_
#define SYNC_DECL4(PREFIX, APPROX, QUEUE_SIZE, SUB0, SUB1, SUB2, SUB3)
message_filters::Subscriber< nav_msgs::Odometry > odomSub_
message_filters::Subscriber< sensor_msgs::PointCloud2 > scan3dSub_
void subscribe(ros::NodeHandle &nh, const std::string &topic, uint32_t queue_size, const ros::TransportHints &transport_hints=ros::TransportHints(), ros::CallbackQueueInterface *callback_queue=0)
std::vector< message_filters::Subscriber< rtabmap_ros::RGBDImage > * > rgbdSubs_