36 #define IMAGE_CONVERSION() \ 38 std::vector<cv_bridge::CvImageConstPtr> imageMsgs(3); \ 39 std::vector<cv_bridge::CvImageConstPtr> depthMsgs(3); \ 40 rtabmap_ros::toCvShare(image1Msg, imageMsgs[0], depthMsgs[0]); \ 41 rtabmap_ros::toCvShare(image2Msg, imageMsgs[1], depthMsgs[1]); \ 42 rtabmap_ros::toCvShare(image3Msg, imageMsgs[2], depthMsgs[2]); \ 43 if(!depthMsgs[0].get()) \ 45 std::vector<sensor_msgs::CameraInfo> cameraInfoMsgs; \ 46 cameraInfoMsgs.push_back(image1Msg->rgb_camera_info); \ 47 cameraInfoMsgs.push_back(image2Msg->rgb_camera_info); \ 48 cameraInfoMsgs.push_back(image3Msg->rgb_camera_info); \ 49 std::vector<rtabmap_ros::GlobalDescriptor> globalDescriptorMsgs; \ 50 std::vector<std::vector<rtabmap_ros::KeyPoint> > localKeyPoints; \ 51 std::vector<std::vector<rtabmap_ros::Point3f> > localPoints3d; \ 52 std::vector<cv::Mat> localDescriptors; \ 53 if(!image1Msg->global_descriptor.data.empty()) \ 54 globalDescriptorMsgs.push_back(image1Msg->global_descriptor); \ 55 if(!image2Msg->global_descriptor.data.empty()) \ 56 globalDescriptorMsgs.push_back(image2Msg->global_descriptor); \ 57 if(!image3Msg->global_descriptor.data.empty()) \ 58 globalDescriptorMsgs.push_back(image3Msg->global_descriptor); \ 59 localKeyPoints.push_back(image1Msg->key_points); \ 60 localKeyPoints.push_back(image2Msg->key_points); \ 61 localKeyPoints.push_back(image3Msg->key_points); \ 62 localPoints3d.push_back(image1Msg->points); \ 63 localPoints3d.push_back(image2Msg->points); \ 64 localPoints3d.push_back(image3Msg->points); \ 65 localDescriptors.push_back(rtabmap::uncompressData(image1Msg->descriptors)); \ 66 localDescriptors.push_back(rtabmap::uncompressData(image2Msg->descriptors)); \ 67 localDescriptors.push_back(rtabmap::uncompressData(image3Msg->descriptors)); 70 void CommonDataSubscriber::rgbd3Callback(
71 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
72 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
73 const rtabmap_ros::RGBDImageConstPtr& image3Msg)
77 nav_msgs::OdometryConstPtr odomMsg;
78 rtabmap_ros::UserDataConstPtr userDataMsg;
79 sensor_msgs::LaserScan scanMsg;
80 sensor_msgs::PointCloud2 scan3dMsg;
81 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
83 depthMsgs, cameraInfoMsgs, scanMsg,
84 scan3dMsg, odomInfoMsg, globalDescriptorMsgs,
85 localKeyPoints, localPoints3d, localDescriptors);
87 void CommonDataSubscriber::rgbd3Scan2dCallback(
88 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
89 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
90 const rtabmap_ros::RGBDImageConstPtr& image3Msg,
91 const sensor_msgs::LaserScanConstPtr& scanMsg)
95 nav_msgs::OdometryConstPtr odomMsg;
96 rtabmap_ros::UserDataConstPtr userDataMsg;
97 sensor_msgs::PointCloud2 scan3dMsg;
98 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
100 depthMsgs, cameraInfoMsgs, *scanMsg,
101 scan3dMsg, odomInfoMsg, globalDescriptorMsgs,
102 localKeyPoints, localPoints3d, localDescriptors);
104 void CommonDataSubscriber::rgbd3Scan3dCallback(
105 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
106 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
107 const rtabmap_ros::RGBDImageConstPtr& image3Msg,
108 const sensor_msgs::PointCloud2ConstPtr& scan3dMsg)
112 nav_msgs::OdometryConstPtr odomMsg;
113 rtabmap_ros::UserDataConstPtr userDataMsg;
114 sensor_msgs::LaserScan scanMsg;
115 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
117 depthMsgs, cameraInfoMsgs, scanMsg,
118 *scan3dMsg, odomInfoMsg, globalDescriptorMsgs,
119 localKeyPoints, localPoints3d, localDescriptors);
121 void CommonDataSubscriber::rgbd3ScanDescCallback(
122 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
123 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
124 const rtabmap_ros::RGBDImageConstPtr& image3Msg,
125 const rtabmap_ros::ScanDescriptorConstPtr& scanDescMsg)
129 nav_msgs::OdometryConstPtr odomMsg;
130 rtabmap_ros::UserDataConstPtr userDataMsg;
131 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
132 if(!scanDescMsg->global_descriptor.data.empty())
134 globalDescriptorMsgs.push_back(scanDescMsg->global_descriptor);
137 depthMsgs, cameraInfoMsgs, scanDescMsg->scan,
138 scanDescMsg->scan_cloud, odomInfoMsg, globalDescriptorMsgs,
139 localKeyPoints, localPoints3d, localDescriptors);
141 void CommonDataSubscriber::rgbd3InfoCallback(
142 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
143 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
144 const rtabmap_ros::RGBDImageConstPtr& image3Msg,
145 const rtabmap_ros::OdomInfoConstPtr& odomInfoMsg)
149 nav_msgs::OdometryConstPtr odomMsg;
150 rtabmap_ros::UserDataConstPtr userDataMsg;
151 sensor_msgs::LaserScan scanMsg;
152 sensor_msgs::PointCloud2 scan3dMsg;
154 depthMsgs, cameraInfoMsgs, scanMsg,
155 scan3dMsg, odomInfoMsg, globalDescriptorMsgs,
156 localKeyPoints, localPoints3d, localDescriptors);
160 void CommonDataSubscriber::rgbd3OdomCallback(
161 const nav_msgs::OdometryConstPtr & odomMsg,
162 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
163 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
164 const rtabmap_ros::RGBDImageConstPtr& image3Msg)
168 rtabmap_ros::UserDataConstPtr userDataMsg;
169 sensor_msgs::LaserScan scanMsg;
170 sensor_msgs::PointCloud2 scan3dMsg;
171 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
173 depthMsgs, cameraInfoMsgs, scanMsg,
174 scan3dMsg, odomInfoMsg, globalDescriptorMsgs,
175 localKeyPoints, localPoints3d, localDescriptors);
177 void CommonDataSubscriber::rgbd3OdomScan2dCallback(
178 const nav_msgs::OdometryConstPtr & odomMsg,
179 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
180 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
181 const rtabmap_ros::RGBDImageConstPtr& image3Msg,
182 const sensor_msgs::LaserScanConstPtr& scanMsg)
186 rtabmap_ros::UserDataConstPtr userDataMsg;
187 sensor_msgs::PointCloud2 scan3dMsg;
188 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
190 depthMsgs, cameraInfoMsgs, *scanMsg,
191 scan3dMsg, odomInfoMsg, globalDescriptorMsgs,
192 localKeyPoints, localPoints3d, localDescriptors);
194 void CommonDataSubscriber::rgbd3OdomScan3dCallback(
195 const nav_msgs::OdometryConstPtr & odomMsg,
196 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
197 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
198 const rtabmap_ros::RGBDImageConstPtr& image3Msg,
199 const sensor_msgs::PointCloud2ConstPtr& scan3dMsg)
203 rtabmap_ros::UserDataConstPtr userDataMsg;
204 sensor_msgs::LaserScan scanMsg;
205 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
207 depthMsgs, cameraInfoMsgs, scanMsg,
208 *scan3dMsg, odomInfoMsg, globalDescriptorMsgs,
209 localKeyPoints, localPoints3d, localDescriptors);
211 void CommonDataSubscriber::rgbd3OdomScanDescCallback(
212 const nav_msgs::OdometryConstPtr & odomMsg,
213 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
214 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
215 const rtabmap_ros::RGBDImageConstPtr& image3Msg,
216 const rtabmap_ros::ScanDescriptorConstPtr& scanDescMsg)
220 rtabmap_ros::UserDataConstPtr userDataMsg;
221 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
222 if(!scanDescMsg->global_descriptor.data.empty())
224 globalDescriptorMsgs.push_back(scanDescMsg->global_descriptor);
227 depthMsgs, cameraInfoMsgs, scanDescMsg->scan,
228 scanDescMsg->scan_cloud, odomInfoMsg, globalDescriptorMsgs,
229 localKeyPoints, localPoints3d, localDescriptors);
231 void CommonDataSubscriber::rgbd3OdomInfoCallback(
232 const nav_msgs::OdometryConstPtr & odomMsg,
233 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
234 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
235 const rtabmap_ros::RGBDImageConstPtr& image3Msg,
236 const rtabmap_ros::OdomInfoConstPtr& odomInfoMsg)
240 rtabmap_ros::UserDataConstPtr userDataMsg;
241 sensor_msgs::LaserScan scanMsg;
242 sensor_msgs::PointCloud2 scan3dMsg;
244 depthMsgs, cameraInfoMsgs, scanMsg,
245 scan3dMsg, odomInfoMsg, globalDescriptorMsgs,
246 localKeyPoints, localPoints3d, localDescriptors);
249 #ifdef RTABMAP_SYNC_USER_DATA 251 void CommonDataSubscriber::rgbd3DataCallback(
252 const rtabmap_ros::UserDataConstPtr& userDataMsg,
253 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
254 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
255 const rtabmap_ros::RGBDImageConstPtr& image3Msg)
259 nav_msgs::OdometryConstPtr odomMsg;
260 sensor_msgs::LaserScan scanMsg;
261 sensor_msgs::PointCloud2 scan3dMsg;
262 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
264 depthMsgs, cameraInfoMsgs, scanMsg,
265 scan3dMsg, odomInfoMsg, globalDescriptorMsgs,
266 localKeyPoints, localPoints3d, localDescriptors);
268 void CommonDataSubscriber::rgbd3DataScan2dCallback(
269 const rtabmap_ros::UserDataConstPtr& userDataMsg,
270 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
271 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
272 const rtabmap_ros::RGBDImageConstPtr& image3Msg,
273 const sensor_msgs::LaserScanConstPtr& scanMsg)
277 nav_msgs::OdometryConstPtr odomMsg;
278 sensor_msgs::PointCloud2 scan3dMsg;
279 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
281 depthMsgs, cameraInfoMsgs, *scanMsg,
282 scan3dMsg, odomInfoMsg, globalDescriptorMsgs,
283 localKeyPoints, localPoints3d, localDescriptors);
285 void CommonDataSubscriber::rgbd3DataScan3dCallback(
286 const rtabmap_ros::UserDataConstPtr& userDataMsg,
287 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
288 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
289 const rtabmap_ros::RGBDImageConstPtr& image3Msg,
290 const sensor_msgs::PointCloud2ConstPtr& scan3dMsg)
294 nav_msgs::OdometryConstPtr odomMsg;
295 sensor_msgs::LaserScan scanMsg;
296 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
298 depthMsgs, cameraInfoMsgs, scanMsg,
299 *scan3dMsg, odomInfoMsg, globalDescriptorMsgs,
300 localKeyPoints, localPoints3d, localDescriptors);
302 void CommonDataSubscriber::rgbd3DataScanDescCallback(
303 const rtabmap_ros::UserDataConstPtr& userDataMsg,
304 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
305 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
306 const rtabmap_ros::RGBDImageConstPtr& image3Msg,
307 const rtabmap_ros::ScanDescriptorConstPtr& scanDescMsg)
311 nav_msgs::OdometryConstPtr odomMsg;
312 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
313 if(!scanDescMsg->global_descriptor.data.empty())
315 globalDescriptorMsgs.push_back(scanDescMsg->global_descriptor);
318 depthMsgs, cameraInfoMsgs, scanDescMsg->scan,
319 scanDescMsg->scan_cloud, odomInfoMsg, globalDescriptorMsgs,
320 localKeyPoints, localPoints3d, localDescriptors);
322 void CommonDataSubscriber::rgbd3DataInfoCallback(
323 const rtabmap_ros::UserDataConstPtr& userDataMsg,
324 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
325 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
326 const rtabmap_ros::RGBDImageConstPtr& image3Msg,
327 const rtabmap_ros::OdomInfoConstPtr& odomInfoMsg)
331 nav_msgs::OdometryConstPtr odomMsg;
332 sensor_msgs::LaserScan scanMsg;
333 sensor_msgs::PointCloud2 scan3dMsg;
335 depthMsgs, cameraInfoMsgs, scanMsg,
336 scan3dMsg, odomInfoMsg, globalDescriptorMsgs,
337 localKeyPoints, localPoints3d, localDescriptors);
340 void CommonDataSubscriber::rgbd3OdomDataCallback(
341 const nav_msgs::OdometryConstPtr& odomMsg,
342 const rtabmap_ros::UserDataConstPtr& userDataMsg,
343 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
344 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
345 const rtabmap_ros::RGBDImageConstPtr& image3Msg)
349 sensor_msgs::LaserScan scanMsg;
350 sensor_msgs::PointCloud2 scan3dMsg;
351 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
353 depthMsgs, cameraInfoMsgs, scanMsg,
354 scan3dMsg, odomInfoMsg, globalDescriptorMsgs,
355 localKeyPoints, localPoints3d, localDescriptors);
357 void CommonDataSubscriber::rgbd3OdomDataScan2dCallback(
358 const nav_msgs::OdometryConstPtr& odomMsg,
359 const rtabmap_ros::UserDataConstPtr& userDataMsg,
360 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
361 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
362 const rtabmap_ros::RGBDImageConstPtr& image3Msg,
363 const sensor_msgs::LaserScanConstPtr& scanMsg)
367 sensor_msgs::PointCloud2 scan3dMsg;
368 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
370 depthMsgs, cameraInfoMsgs, *scanMsg,
371 scan3dMsg, odomInfoMsg, globalDescriptorMsgs,
372 localKeyPoints, localPoints3d, localDescriptors);
374 void CommonDataSubscriber::rgbd3OdomDataScan3dCallback(
375 const nav_msgs::OdometryConstPtr& odomMsg,
376 const rtabmap_ros::UserDataConstPtr& userDataMsg,
377 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
378 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
379 const rtabmap_ros::RGBDImageConstPtr& image3Msg,
380 const sensor_msgs::PointCloud2ConstPtr& scan3dMsg)
384 sensor_msgs::LaserScan scanMsg;
385 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
387 depthMsgs, cameraInfoMsgs, scanMsg,
388 *scan3dMsg, odomInfoMsg, globalDescriptorMsgs,
389 localKeyPoints, localPoints3d, localDescriptors);
391 void CommonDataSubscriber::rgbd3OdomDataScanDescCallback(
392 const nav_msgs::OdometryConstPtr& odomMsg,
393 const rtabmap_ros::UserDataConstPtr& userDataMsg,
394 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
395 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
396 const rtabmap_ros::RGBDImageConstPtr& image3Msg,
397 const rtabmap_ros::ScanDescriptorConstPtr& scanDescMsg)
401 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
402 if(!scanDescMsg->global_descriptor.data.empty())
404 globalDescriptorMsgs.push_back(scanDescMsg->global_descriptor);
407 depthMsgs, cameraInfoMsgs, scanDescMsg->scan,
408 scanDescMsg->scan_cloud, odomInfoMsg, globalDescriptorMsgs,
409 localKeyPoints, localPoints3d, localDescriptors);
411 void CommonDataSubscriber::rgbd3OdomDataInfoCallback(
412 const nav_msgs::OdometryConstPtr& odomMsg,
413 const rtabmap_ros::UserDataConstPtr& userDataMsg,
414 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
415 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
416 const rtabmap_ros::RGBDImageConstPtr& image3Msg,
417 const rtabmap_ros::OdomInfoConstPtr& odomInfoMsg)
421 sensor_msgs::LaserScan scanMsg;
422 sensor_msgs::PointCloud2 scan3dMsg;
424 depthMsgs, cameraInfoMsgs, scanMsg,
425 scan3dMsg, odomInfoMsg, globalDescriptorMsgs,
426 localKeyPoints, localPoints3d, localDescriptors);
430 void CommonDataSubscriber::setupRGBD3Callbacks(
434 bool subscribeUserData,
435 bool subscribeScan2d,
436 bool subscribeScan3d,
437 bool subscribeScanDescriptor,
438 bool subscribeOdomInfo,
445 for(
int i=0; i<3; ++i)
450 #ifdef RTABMAP_SYNC_USER_DATA 451 if(subscribeOdom && subscribeUserData)
455 if(subscribeScanDescriptor)
459 if(subscribeOdomInfo)
462 ROS_WARN(
"subscribe_odom_info ignored...");
466 else if(subscribeScan2d)
470 if(subscribeOdomInfo)
473 ROS_WARN(
"subscribe_odom_info ignored...");
477 else if(subscribeScan3d)
481 if(subscribeOdomInfo)
484 ROS_WARN(
"subscribe_odom_info ignored...");
488 else if(subscribeOdomInfo)
504 if(subscribeScanDescriptor)
508 if(subscribeOdomInfo)
511 ROS_WARN(
"subscribe_odom_info ignored...");
515 else if(subscribeScan2d)
519 if(subscribeOdomInfo)
522 ROS_WARN(
"subscribe_odom_info ignored...");
526 else if(subscribeScan3d)
530 if(subscribeOdomInfo)
533 ROS_WARN(
"subscribe_odom_info ignored...");
537 else if(subscribeOdomInfo)
548 #ifdef RTABMAP_SYNC_USER_DATA 549 else if(subscribeUserData)
552 if(subscribeScanDescriptor)
556 if(subscribeOdomInfo)
559 ROS_WARN(
"subscribe_odom_info ignored...");
562 else if(subscribeScan2d)
566 if(subscribeOdomInfo)
569 ROS_WARN(
"subscribe_odom_info ignored...");
573 else if(subscribeScan3d)
577 if(subscribeOdomInfo)
580 ROS_WARN(
"subscribe_odom_info ignored...");
584 else if(subscribeOdomInfo)
598 if(subscribeScanDescriptor)
602 if(subscribeOdomInfo)
605 ROS_WARN(
"subscribe_odom_info ignored...");
609 else if(subscribeScan2d)
613 if(subscribeOdomInfo)
616 ROS_WARN(
"subscribe_odom_info ignored...");
620 else if(subscribeScan3d)
624 if(subscribeOdomInfo)
627 ROS_WARN(
"subscribe_odom_info ignored...");
631 else if(subscribeOdomInfo)
std::string uFormat(const char *fmt,...)
#define SYNC_DECL5(PREFIX, APPROX, QUEUE_SIZE, SUB0, SUB1, SUB2, SUB3, SUB4)
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::LaserScan &scanMsg, const sensor_msgs::PointCloud2 &scan3dMsg, const rtabmap_ros::OdomInfoConstPtr &odomInfoMsg, const std::vector< rtabmap_ros::GlobalDescriptor > &globalDescriptorMsgs=std::vector< rtabmap_ros::GlobalDescriptor >(), const std::vector< std::vector< rtabmap_ros::KeyPoint > > &localKeyPoints=std::vector< std::vector< rtabmap_ros::KeyPoint > >(), const std::vector< std::vector< rtabmap_ros::Point3f > > &localPoints3d=std::vector< std::vector< rtabmap_ros::Point3f > >(), const std::vector< cv::Mat > &localDescriptors=std::vector< cv::Mat >())=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 IMAGE_CONVERSION()
bool subscribedToScanDescriptor_
message_filters::Subscriber< sensor_msgs::LaserScan > scanSub_
message_filters::Subscriber< rtabmap_ros::ScanDescriptor > scanDescSub_
#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_