36 #define IMAGE_CONVERSION() \ 37 UASSERT(!imagesMsg->rgbd_images.empty()); \ 39 std::vector<cv_bridge::CvImageConstPtr> imageMsgs(imagesMsg->rgbd_images.size()); \ 40 std::vector<cv_bridge::CvImageConstPtr> depthMsgs(imagesMsg->rgbd_images.size()); \ 41 std::vector<sensor_msgs::CameraInfo> cameraInfoMsgs; \ 42 std::vector<sensor_msgs::CameraInfo> depthCameraInfoMsgs; \ 43 std::vector<rtabmap_ros::GlobalDescriptor> globalDescriptorMsgs; \ 44 std::vector<std::vector<rtabmap_ros::KeyPoint> > localKeyPoints; \ 45 std::vector<std::vector<rtabmap_ros::Point3f> > localPoints3d; \ 46 std::vector<cv::Mat> localDescriptors; \ 47 for(size_t i=0; i<imageMsgs.size(); ++i) \ 49 rtabmap_ros::toCvShare(imagesMsg->rgbd_images[i], imagesMsg, imageMsgs[i], depthMsgs[i]); \ 50 cameraInfoMsgs.push_back(imagesMsg->rgbd_images[i].rgb_camera_info); \ 51 depthCameraInfoMsgs.push_back(imagesMsg->rgbd_images[i].depth_camera_info); \ 52 if(!imagesMsg->rgbd_images[i].global_descriptor.data.empty()) \ 53 globalDescriptorMsgs.push_back(imagesMsg->rgbd_images[i].global_descriptor); \ 54 localKeyPoints.push_back(imagesMsg->rgbd_images[i].key_points); \ 55 localPoints3d.push_back(imagesMsg->rgbd_images[i].points); \ 56 localDescriptors.push_back(rtabmap::uncompressData(imagesMsg->rgbd_images[i].descriptors)); \ 58 if(!depthMsgs[0].get()) \ 63 const rtabmap_ros::RGBDImagesConstPtr& imagesMsg)
67 nav_msgs::OdometryConstPtr odomMsg;
68 rtabmap_ros::UserDataConstPtr userDataMsg;
69 sensor_msgs::LaserScan scanMsg;
70 sensor_msgs::PointCloud2 scan3dMsg;
71 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
72 commonMultiCameraCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, depthCameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
74 void CommonDataSubscriber::rgbdXScan2dCallback(
75 const rtabmap_ros::RGBDImagesConstPtr& imagesMsg,
76 const sensor_msgs::LaserScanConstPtr& scanMsg)
80 nav_msgs::OdometryConstPtr odomMsg;
81 rtabmap_ros::UserDataConstPtr userDataMsg;
82 sensor_msgs::PointCloud2 scan3dMsg;
83 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
84 commonMultiCameraCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, depthCameraInfoMsgs, *scanMsg, scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
86 void CommonDataSubscriber::rgbdXScan3dCallback(
87 const rtabmap_ros::RGBDImagesConstPtr& imagesMsg,
88 const sensor_msgs::PointCloud2ConstPtr& scan3dMsg)
92 nav_msgs::OdometryConstPtr odomMsg;
93 rtabmap_ros::UserDataConstPtr userDataMsg;
94 sensor_msgs::LaserScan scanMsg;
95 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
96 commonMultiCameraCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, depthCameraInfoMsgs, scanMsg, *scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
98 void CommonDataSubscriber::rgbdXScanDescCallback(
99 const rtabmap_ros::RGBDImagesConstPtr& imagesMsg,
100 const rtabmap_ros::ScanDescriptorConstPtr& scanDescMsg)
104 nav_msgs::OdometryConstPtr odomMsg;
105 rtabmap_ros::UserDataConstPtr userDataMsg;
106 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
107 if(!scanDescMsg->global_descriptor.data.empty())
109 globalDescriptorMsgs.push_back(scanDescMsg->global_descriptor);
111 commonMultiCameraCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, depthCameraInfoMsgs, scanDescMsg->scan, scanDescMsg->scan_cloud, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
113 void CommonDataSubscriber::rgbdXInfoCallback(
114 const rtabmap_ros::RGBDImagesConstPtr& imagesMsg,
115 const rtabmap_ros::OdomInfoConstPtr& odomInfoMsg)
119 nav_msgs::OdometryConstPtr odomMsg;
120 rtabmap_ros::UserDataConstPtr userDataMsg;
121 sensor_msgs::LaserScan scanMsg;
122 sensor_msgs::PointCloud2 scan3dMsg;
123 commonMultiCameraCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, depthCameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
126 void CommonDataSubscriber::rgbdXOdomCallback(
127 const nav_msgs::OdometryConstPtr & odomMsg,
128 const rtabmap_ros::RGBDImagesConstPtr& imagesMsg)
132 rtabmap_ros::UserDataConstPtr userDataMsg;
133 sensor_msgs::LaserScan scanMsg;
134 sensor_msgs::PointCloud2 scan3dMsg;
135 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
136 commonMultiCameraCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, depthCameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
138 void CommonDataSubscriber::rgbdXOdomScan2dCallback(
139 const nav_msgs::OdometryConstPtr & odomMsg,
140 const rtabmap_ros::RGBDImagesConstPtr& imagesMsg,
141 const sensor_msgs::LaserScanConstPtr& scanMsg)
145 rtabmap_ros::UserDataConstPtr userDataMsg;
146 sensor_msgs::PointCloud2 scan3dMsg;
147 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
148 commonMultiCameraCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, depthCameraInfoMsgs, *scanMsg, scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
150 void CommonDataSubscriber::rgbdXOdomScan3dCallback(
151 const nav_msgs::OdometryConstPtr & odomMsg,
152 const rtabmap_ros::RGBDImagesConstPtr& imagesMsg,
153 const sensor_msgs::PointCloud2ConstPtr& scan3dMsg)
157 rtabmap_ros::UserDataConstPtr userDataMsg;
158 sensor_msgs::LaserScan scanMsg;
159 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
160 commonMultiCameraCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, depthCameraInfoMsgs, scanMsg, *scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
162 void CommonDataSubscriber::rgbdXOdomScanDescCallback(
163 const nav_msgs::OdometryConstPtr & odomMsg,
164 const rtabmap_ros::RGBDImagesConstPtr& imagesMsg,
165 const rtabmap_ros::ScanDescriptorConstPtr& scanDescMsg)
169 rtabmap_ros::UserDataConstPtr userDataMsg;
170 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
171 if(!scanDescMsg->global_descriptor.data.empty())
173 globalDescriptorMsgs.push_back(scanDescMsg->global_descriptor);
175 commonMultiCameraCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, depthCameraInfoMsgs, scanDescMsg->scan, scanDescMsg->scan_cloud, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
177 void CommonDataSubscriber::rgbdXOdomInfoCallback(
178 const nav_msgs::OdometryConstPtr & odomMsg,
179 const rtabmap_ros::RGBDImagesConstPtr& imagesMsg,
180 const rtabmap_ros::OdomInfoConstPtr& odomInfoMsg)
184 rtabmap_ros::UserDataConstPtr userDataMsg;
185 sensor_msgs::LaserScan scanMsg;
186 sensor_msgs::PointCloud2 scan3dMsg;
187 commonMultiCameraCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, depthCameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
190 #ifdef RTABMAP_SYNC_USER_DATA 192 void CommonDataSubscriber::rgbdXDataCallback(
193 const rtabmap_ros::UserDataConstPtr& userDataMsg,
194 const rtabmap_ros::RGBDImagesConstPtr& imagesMsg)
198 nav_msgs::OdometryConstPtr odomMsg;
199 sensor_msgs::LaserScan scanMsg;
200 sensor_msgs::PointCloud2 scan3dMsg;
201 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
202 commonMultiCameraCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, depthCameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
204 void CommonDataSubscriber::rgbdXDataScan2dCallback(
205 const rtabmap_ros::UserDataConstPtr& userDataMsg,
206 const rtabmap_ros::RGBDImagesConstPtr& imagesMsg,
207 const sensor_msgs::LaserScanConstPtr& scanMsg)
211 nav_msgs::OdometryConstPtr odomMsg;
212 sensor_msgs::PointCloud2 scan3dMsg;
213 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
214 commonMultiCameraCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, depthCameraInfoMsgs, *scanMsg, scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
216 void CommonDataSubscriber::rgbdXDataScan3dCallback(
217 const rtabmap_ros::UserDataConstPtr& userDataMsg,
218 const rtabmap_ros::RGBDImagesConstPtr& imagesMsg,
219 const sensor_msgs::PointCloud2ConstPtr& scan3dMsg)
223 nav_msgs::OdometryConstPtr odomMsg;
224 sensor_msgs::LaserScan scanMsg;
225 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
226 commonMultiCameraCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, depthCameraInfoMsgs, scanMsg, *scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
228 void CommonDataSubscriber::rgbdXDataScanDescCallback(
229 const rtabmap_ros::UserDataConstPtr& userDataMsg,
230 const rtabmap_ros::RGBDImagesConstPtr& imagesMsg,
231 const rtabmap_ros::ScanDescriptorConstPtr& scanDescMsg)
235 nav_msgs::OdometryConstPtr odomMsg;
236 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
237 if(!scanDescMsg->global_descriptor.data.empty())
239 globalDescriptorMsgs.push_back(scanDescMsg->global_descriptor);
241 commonMultiCameraCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, depthCameraInfoMsgs, scanDescMsg->scan, scanDescMsg->scan_cloud, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
243 void CommonDataSubscriber::rgbdXDataInfoCallback(
244 const rtabmap_ros::UserDataConstPtr& userDataMsg,
245 const rtabmap_ros::RGBDImagesConstPtr& imagesMsg,
246 const rtabmap_ros::OdomInfoConstPtr& odomInfoMsg)
250 nav_msgs::OdometryConstPtr odomMsg;
251 sensor_msgs::LaserScan scanMsg;
252 sensor_msgs::PointCloud2 scan3dMsg;
253 commonMultiCameraCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, depthCameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
257 void CommonDataSubscriber::rgbdXOdomDataCallback(
258 const nav_msgs::OdometryConstPtr& odomMsg,
259 const rtabmap_ros::UserDataConstPtr& userDataMsg,
260 const rtabmap_ros::RGBDImagesConstPtr& imagesMsg)
264 sensor_msgs::LaserScan scanMsg;
265 sensor_msgs::PointCloud2 scan3dMsg;
266 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
267 commonMultiCameraCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, depthCameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
269 void CommonDataSubscriber::rgbdXOdomDataScan2dCallback(
270 const nav_msgs::OdometryConstPtr& odomMsg,
271 const rtabmap_ros::UserDataConstPtr& userDataMsg,
272 const rtabmap_ros::RGBDImagesConstPtr& imagesMsg,
273 const sensor_msgs::LaserScanConstPtr& scanMsg)
277 sensor_msgs::PointCloud2 scan3dMsg;
278 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
279 commonMultiCameraCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, depthCameraInfoMsgs, *scanMsg, scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
281 void CommonDataSubscriber::rgbdXOdomDataScan3dCallback(
282 const nav_msgs::OdometryConstPtr& odomMsg,
283 const rtabmap_ros::UserDataConstPtr& userDataMsg,
284 const rtabmap_ros::RGBDImagesConstPtr& imagesMsg,
285 const sensor_msgs::PointCloud2ConstPtr& scan3dMsg)
289 sensor_msgs::LaserScan scanMsg;
290 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
291 commonMultiCameraCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, depthCameraInfoMsgs, scanMsg, *scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
293 void CommonDataSubscriber::rgbdXOdomDataScanDescCallback(
294 const nav_msgs::OdometryConstPtr& odomMsg,
295 const rtabmap_ros::UserDataConstPtr& userDataMsg,
296 const rtabmap_ros::RGBDImagesConstPtr& imagesMsg,
297 const rtabmap_ros::ScanDescriptorConstPtr& scanDescMsg)
301 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
302 if(!scanDescMsg->global_descriptor.data.empty())
304 globalDescriptorMsgs.push_back(scanDescMsg->global_descriptor);
306 commonMultiCameraCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, depthCameraInfoMsgs, scanDescMsg->scan, scanDescMsg->scan_cloud, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
308 void CommonDataSubscriber::rgbdXOdomDataInfoCallback(
309 const nav_msgs::OdometryConstPtr& odomMsg,
310 const rtabmap_ros::UserDataConstPtr& userDataMsg,
311 const rtabmap_ros::RGBDImagesConstPtr& imagesMsg,
312 const rtabmap_ros::OdomInfoConstPtr& odomInfoMsg)
316 sensor_msgs::LaserScan scanMsg;
317 sensor_msgs::PointCloud2 scan3dMsg;
318 commonMultiCameraCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, depthCameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
326 bool subscribeUserData,
327 bool subscribeScan2d,
328 bool subscribeScan3d,
329 bool subscribeScanDesc,
330 bool subscribeOdomInfo,
337 #ifdef RTABMAP_SYNC_USER_DATA 338 if(subscribeOdom && subscribeUserData)
342 if(subscribeScanDesc)
346 if(subscribeOdomInfo)
349 ROS_WARN(
"subscribe_odom_info ignored...");
353 else if(subscribeScan2d)
357 if(subscribeOdomInfo)
360 ROS_WARN(
"subscribe_odom_info ignored...");
364 else if(subscribeScan3d)
368 if(subscribeOdomInfo)
371 ROS_WARN(
"subscribe_odom_info ignored...");
375 else if(subscribeOdomInfo)
391 if(subscribeScanDesc)
395 if(subscribeOdomInfo)
398 ROS_WARN(
"subscribe_odom_info ignored...");
402 else if(subscribeScan2d)
406 if(subscribeOdomInfo)
409 ROS_WARN(
"subscribe_odom_info ignored...");
413 else if(subscribeScan3d)
417 if(subscribeOdomInfo)
420 ROS_WARN(
"subscribe_odom_info ignored...");
424 else if(subscribeOdomInfo)
435 #ifdef RTABMAP_SYNC_USER_DATA 436 else if(subscribeUserData)
439 if(subscribeScanDesc)
443 if(subscribeOdomInfo)
446 ROS_WARN(
"subscribe_odom_info ignored...");
450 else if(subscribeScan2d)
454 if(subscribeOdomInfo)
457 ROS_WARN(
"subscribe_odom_info ignored...");
461 else if(subscribeScan3d)
465 if(subscribeOdomInfo)
468 ROS_WARN(
"subscribe_odom_info ignored...");
472 else if(subscribeOdomInfo)
486 if(subscribeScanDesc)
490 if(subscribeOdomInfo)
493 ROS_WARN(
"subscribe_odom_info ignored...");
497 else if(subscribeScan2d)
501 if(subscribeOdomInfo)
504 ROS_WARN(
"subscribe_odom_info ignored...");
508 else if(subscribeScan3d)
512 if(subscribeOdomInfo)
515 ROS_WARN(
"subscribe_odom_info ignored...");
519 else if(subscribeOdomInfo)
530 uFormat(
"\n%s subscribed to:\n %s",
message_filters::Subscriber< rtabmap_ros::RGBDImages > rgbdXSub_
std::string uFormat(const char *fmt,...)
std::string getTopic() const
#define IMAGE_CONVERSION()
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
#define SYNC_DECL3(CLASS, PREFIX, APPROX, QUEUE_SIZE, SUB0, SUB1, SUB2)
ROSCPP_DECL const std::string & getName()
message_filters::Subscriber< rtabmap_ros::UserData > userDataSub_
bool subscribedToOdomInfo_
message_filters::Subscriber< rtabmap_ros::OdomInfo > odomInfoSub_
bool subscribedToScanDescriptor_
message_filters::Subscriber< sensor_msgs::LaserScan > scanSub_
message_filters::Subscriber< rtabmap_ros::ScanDescriptor > scanDescSub_
ros::Subscriber rgbdXSubOnly_
virtual void commonMultiCameraCallback(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 std::vector< sensor_msgs::CameraInfo > &depthCameraInfoMsgs, 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
message_filters::Subscriber< nav_msgs::Odometry > odomSub_
void setupRGBDXCallbacks(ros::NodeHandle &nh, ros::NodeHandle &pnh, bool subscribeOdom, bool subscribeUserData, bool subscribeScan2d, bool subscribeScan3d, bool subscribeScanDesc, bool subscribeOdomInfo, int queueSize, bool approxSync)
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)
void rgbdXCallback(const rtabmap_ros::RGBDImagesConstPtr &)
std::string subscribedTopicsMsg_
#define SYNC_DECL4(CLASS, PREFIX, APPROX, QUEUE_SIZE, SUB0, SUB1, SUB2, SUB3)
#define SYNC_DECL2(CLASS, PREFIX, APPROX, QUEUE_SIZE, SUB0, SUB1)