36 #define IMAGE_CONVERSION() \ 38 std::vector<cv_bridge::CvImageConstPtr> imageMsgs(2); \ 39 std::vector<cv_bridge::CvImageConstPtr> depthMsgs(2); \ 40 rtabmap_ros::toCvShare(image1Msg, imageMsgs[0], depthMsgs[0]); \ 41 rtabmap_ros::toCvShare(image2Msg, imageMsgs[1], depthMsgs[1]); \ 42 if(!depthMsgs[0].get()) \ 44 std::vector<sensor_msgs::CameraInfo> cameraInfoMsgs; \ 45 cameraInfoMsgs.push_back(image1Msg->rgb_camera_info); \ 46 cameraInfoMsgs.push_back(image2Msg->rgb_camera_info); \ 47 std::vector<rtabmap_ros::GlobalDescriptor> globalDescriptorMsgs; \ 48 std::vector<std::vector<rtabmap_ros::KeyPoint> > localKeyPoints; \ 49 std::vector<std::vector<rtabmap_ros::Point3f> > localPoints3d; \ 50 std::vector<cv::Mat> localDescriptors; \ 51 if(!image1Msg->global_descriptor.data.empty()) \ 52 globalDescriptorMsgs.push_back(image1Msg->global_descriptor); \ 53 if(!image2Msg->global_descriptor.data.empty()) \ 54 globalDescriptorMsgs.push_back(image2Msg->global_descriptor); \ 55 localKeyPoints.push_back(image1Msg->key_points); \ 56 localKeyPoints.push_back(image2Msg->key_points); \ 57 localPoints3d.push_back(image1Msg->points); \ 58 localPoints3d.push_back(image2Msg->points); \ 59 localDescriptors.push_back(rtabmap::uncompressData(image1Msg->descriptors)); \ 60 localDescriptors.push_back(rtabmap::uncompressData(image2Msg->descriptors)); 63 void CommonDataSubscriber::rgbd2Callback(
64 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
65 const rtabmap_ros::RGBDImageConstPtr& image2Msg)
69 nav_msgs::OdometryConstPtr odomMsg;
70 rtabmap_ros::UserDataConstPtr userDataMsg;
71 sensor_msgs::LaserScan scanMsg;
72 sensor_msgs::PointCloud2 scan3dMsg;
73 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
74 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
76 void CommonDataSubscriber::rgbd2Scan2dCallback(
77 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
78 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
79 const sensor_msgs::LaserScanConstPtr& scanMsg)
83 nav_msgs::OdometryConstPtr odomMsg;
84 rtabmap_ros::UserDataConstPtr userDataMsg;
85 sensor_msgs::PointCloud2 scan3dMsg;
86 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
87 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, *scanMsg, scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
89 void CommonDataSubscriber::rgbd2Scan3dCallback(
90 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
91 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
92 const sensor_msgs::PointCloud2ConstPtr& scan3dMsg)
96 nav_msgs::OdometryConstPtr odomMsg;
97 rtabmap_ros::UserDataConstPtr userDataMsg;
98 sensor_msgs::LaserScan scanMsg;
99 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
100 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, *scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
102 void CommonDataSubscriber::rgbd2ScanDescCallback(
103 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
104 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
105 const rtabmap_ros::ScanDescriptorConstPtr& scanDescMsg)
109 nav_msgs::OdometryConstPtr odomMsg;
110 rtabmap_ros::UserDataConstPtr userDataMsg;
111 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
112 if(!scanDescMsg->global_descriptor.data.empty())
114 globalDescriptorMsgs.push_back(scanDescMsg->global_descriptor);
116 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanDescMsg->scan, scanDescMsg->scan_cloud, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
118 void CommonDataSubscriber::rgbd2InfoCallback(
119 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
120 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
121 const rtabmap_ros::OdomInfoConstPtr& odomInfoMsg)
125 nav_msgs::OdometryConstPtr odomMsg;
126 rtabmap_ros::UserDataConstPtr userDataMsg;
127 sensor_msgs::LaserScan scanMsg;
128 sensor_msgs::PointCloud2 scan3dMsg;
129 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
132 void CommonDataSubscriber::rgbd2OdomCallback(
133 const nav_msgs::OdometryConstPtr & odomMsg,
134 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
135 const rtabmap_ros::RGBDImageConstPtr& image2Msg)
139 rtabmap_ros::UserDataConstPtr userDataMsg;
140 sensor_msgs::LaserScan scanMsg;
141 sensor_msgs::PointCloud2 scan3dMsg;
142 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
143 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
145 void CommonDataSubscriber::rgbd2OdomScan2dCallback(
146 const nav_msgs::OdometryConstPtr & odomMsg,
147 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
148 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
149 const sensor_msgs::LaserScanConstPtr& scanMsg)
153 rtabmap_ros::UserDataConstPtr userDataMsg;
154 sensor_msgs::PointCloud2 scan3dMsg;
155 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
156 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, *scanMsg, scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
158 void CommonDataSubscriber::rgbd2OdomScan3dCallback(
159 const nav_msgs::OdometryConstPtr & odomMsg,
160 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
161 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
162 const sensor_msgs::PointCloud2ConstPtr& scan3dMsg)
166 rtabmap_ros::UserDataConstPtr userDataMsg;
167 sensor_msgs::LaserScan scanMsg;
168 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
169 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, *scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
171 void CommonDataSubscriber::rgbd2OdomScanDescCallback(
172 const nav_msgs::OdometryConstPtr & odomMsg,
173 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
174 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
175 const rtabmap_ros::ScanDescriptorConstPtr& scanDescMsg)
179 rtabmap_ros::UserDataConstPtr userDataMsg;
180 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
181 if(!scanDescMsg->global_descriptor.data.empty())
183 globalDescriptorMsgs.push_back(scanDescMsg->global_descriptor);
185 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanDescMsg->scan, scanDescMsg->scan_cloud, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
187 void CommonDataSubscriber::rgbd2OdomInfoCallback(
188 const nav_msgs::OdometryConstPtr & odomMsg,
189 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
190 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
191 const rtabmap_ros::OdomInfoConstPtr& odomInfoMsg)
195 rtabmap_ros::UserDataConstPtr userDataMsg;
196 sensor_msgs::LaserScan scanMsg;
197 sensor_msgs::PointCloud2 scan3dMsg;
198 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
201 #ifdef RTABMAP_SYNC_USER_DATA 203 void CommonDataSubscriber::rgbd2DataCallback(
204 const rtabmap_ros::UserDataConstPtr& userDataMsg,
205 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
206 const rtabmap_ros::RGBDImageConstPtr& image2Msg)
210 nav_msgs::OdometryConstPtr odomMsg;
211 sensor_msgs::LaserScan scanMsg;
212 sensor_msgs::PointCloud2 scan3dMsg;
213 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
214 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
216 void CommonDataSubscriber::rgbd2DataScan2dCallback(
217 const rtabmap_ros::UserDataConstPtr& userDataMsg,
218 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
219 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
220 const sensor_msgs::LaserScanConstPtr& scanMsg)
224 nav_msgs::OdometryConstPtr odomMsg;
225 sensor_msgs::PointCloud2 scan3dMsg;
226 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
227 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, *scanMsg, scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
229 void CommonDataSubscriber::rgbd2DataScan3dCallback(
230 const rtabmap_ros::UserDataConstPtr& userDataMsg,
231 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
232 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
233 const sensor_msgs::PointCloud2ConstPtr& scan3dMsg)
237 nav_msgs::OdometryConstPtr odomMsg;
238 sensor_msgs::LaserScan scanMsg;
239 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
240 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, *scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
242 void CommonDataSubscriber::rgbd2DataScanDescCallback(
243 const rtabmap_ros::UserDataConstPtr& userDataMsg,
244 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
245 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
246 const rtabmap_ros::ScanDescriptorConstPtr& scanDescMsg)
250 nav_msgs::OdometryConstPtr odomMsg;
251 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
252 if(!scanDescMsg->global_descriptor.data.empty())
254 globalDescriptorMsgs.push_back(scanDescMsg->global_descriptor);
256 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanDescMsg->scan, scanDescMsg->scan_cloud, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
258 void CommonDataSubscriber::rgbd2DataInfoCallback(
259 const rtabmap_ros::UserDataConstPtr& userDataMsg,
260 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
261 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
262 const rtabmap_ros::OdomInfoConstPtr& odomInfoMsg)
266 nav_msgs::OdometryConstPtr odomMsg;
267 sensor_msgs::LaserScan scanMsg;
268 sensor_msgs::PointCloud2 scan3dMsg;
269 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
273 void CommonDataSubscriber::rgbd2OdomDataCallback(
274 const nav_msgs::OdometryConstPtr& odomMsg,
275 const rtabmap_ros::UserDataConstPtr& userDataMsg,
276 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
277 const rtabmap_ros::RGBDImageConstPtr& image2Msg)
281 sensor_msgs::LaserScan scanMsg;
282 sensor_msgs::PointCloud2 scan3dMsg;
283 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
284 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
286 void CommonDataSubscriber::rgbd2OdomDataScan2dCallback(
287 const nav_msgs::OdometryConstPtr& odomMsg,
288 const rtabmap_ros::UserDataConstPtr& userDataMsg,
289 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
290 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
291 const sensor_msgs::LaserScanConstPtr& scanMsg)
295 sensor_msgs::PointCloud2 scan3dMsg;
296 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
297 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, *scanMsg, scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
299 void CommonDataSubscriber::rgbd2OdomDataScan3dCallback(
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::PointCloud2ConstPtr& scan3dMsg)
308 sensor_msgs::LaserScan scanMsg;
309 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
310 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, *scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
312 void CommonDataSubscriber::rgbd2OdomDataScanDescCallback(
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 rtabmap_ros::ScanDescriptorConstPtr& scanDescMsg)
321 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
322 if(!scanDescMsg->global_descriptor.data.empty())
324 globalDescriptorMsgs.push_back(scanDescMsg->global_descriptor);
326 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanDescMsg->scan, scanDescMsg->scan_cloud, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
328 void CommonDataSubscriber::rgbd2OdomDataInfoCallback(
329 const nav_msgs::OdometryConstPtr& odomMsg,
330 const rtabmap_ros::UserDataConstPtr& userDataMsg,
331 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
332 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
333 const rtabmap_ros::OdomInfoConstPtr& odomInfoMsg)
337 sensor_msgs::LaserScan scanMsg;
338 sensor_msgs::PointCloud2 scan3dMsg;
339 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
343 void CommonDataSubscriber::setupRGBD2Callbacks(
347 bool subscribeUserData,
348 bool subscribeScan2d,
349 bool subscribeScan3d,
350 bool subscribeScanDesc,
351 bool subscribeOdomInfo,
358 for(
int i=0; i<2; ++i)
363 #ifdef RTABMAP_SYNC_USER_DATA 364 if(subscribeOdom && subscribeUserData)
368 if(subscribeScanDesc)
372 if(subscribeOdomInfo)
375 ROS_WARN(
"subscribe_odom_info ignored...");
379 else if(subscribeScan2d)
383 if(subscribeOdomInfo)
386 ROS_WARN(
"subscribe_odom_info ignored...");
390 else if(subscribeScan3d)
394 if(subscribeOdomInfo)
397 ROS_WARN(
"subscribe_odom_info ignored...");
401 else if(subscribeOdomInfo)
417 if(subscribeScanDesc)
421 if(subscribeOdomInfo)
424 ROS_WARN(
"subscribe_odom_info ignored...");
428 else if(subscribeScan2d)
432 if(subscribeOdomInfo)
435 ROS_WARN(
"subscribe_odom_info ignored...");
439 else if(subscribeScan3d)
443 if(subscribeOdomInfo)
446 ROS_WARN(
"subscribe_odom_info ignored...");
450 else if(subscribeOdomInfo)
461 #ifdef RTABMAP_SYNC_USER_DATA 462 else if(subscribeUserData)
465 if(subscribeScanDesc)
469 if(subscribeOdomInfo)
472 ROS_WARN(
"subscribe_odom_info ignored...");
476 else if(subscribeScan2d)
480 if(subscribeOdomInfo)
483 ROS_WARN(
"subscribe_odom_info ignored...");
487 else if(subscribeScan3d)
491 if(subscribeOdomInfo)
494 ROS_WARN(
"subscribe_odom_info ignored...");
498 else if(subscribeOdomInfo)
512 if(subscribeScanDesc)
516 if(subscribeOdomInfo)
519 ROS_WARN(
"subscribe_odom_info ignored...");
523 else if(subscribeScan2d)
527 if(subscribeOdomInfo)
530 ROS_WARN(
"subscribe_odom_info ignored...");
534 else if(subscribeScan3d)
538 if(subscribeOdomInfo)
541 ROS_WARN(
"subscribe_odom_info ignored...");
545 else if(subscribeOdomInfo)
std::string uFormat(const char *fmt,...)
#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::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_
message_filters::Subscriber< rtabmap_ros::OdomInfo > odomInfoSub_
bool subscribedToScanDescriptor_
#define SYNC_DECL2(PREFIX, APPROX, QUEUE_SIZE, SUB0, SUB1)
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_