36 #define IMAGE_CONVERSION() \ 38 std::vector<cv_bridge::CvImageConstPtr> imageMsgs(6); \ 39 std::vector<cv_bridge::CvImageConstPtr> depthMsgs(6); \ 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 rtabmap_ros::toCvShare(image4Msg, imageMsgs[3], depthMsgs[3]); \ 44 rtabmap_ros::toCvShare(image5Msg, imageMsgs[4], depthMsgs[4]); \ 45 rtabmap_ros::toCvShare(image6Msg, imageMsgs[5], depthMsgs[5]); \ 46 if(!depthMsgs[0].get()) \ 48 std::vector<sensor_msgs::CameraInfo> cameraInfoMsgs; \ 49 cameraInfoMsgs.push_back(image1Msg->rgb_camera_info); \ 50 cameraInfoMsgs.push_back(image2Msg->rgb_camera_info); \ 51 cameraInfoMsgs.push_back(image3Msg->rgb_camera_info); \ 52 cameraInfoMsgs.push_back(image4Msg->rgb_camera_info); \ 53 cameraInfoMsgs.push_back(image5Msg->rgb_camera_info); \ 54 cameraInfoMsgs.push_back(image6Msg->rgb_camera_info); \ 55 std::vector<rtabmap_ros::GlobalDescriptor> globalDescriptorMsgs; \ 56 std::vector<std::vector<rtabmap_ros::KeyPoint> > localKeyPoints; \ 57 std::vector<std::vector<rtabmap_ros::Point3f> > localPoints3d; \ 58 std::vector<cv::Mat> localDescriptors; \ 59 if(!image1Msg->global_descriptor.data.empty()) \ 60 globalDescriptorMsgs.push_back(image1Msg->global_descriptor); \ 61 if(!image2Msg->global_descriptor.data.empty()) \ 62 globalDescriptorMsgs.push_back(image2Msg->global_descriptor); \ 63 if(!image3Msg->global_descriptor.data.empty()) \ 64 globalDescriptorMsgs.push_back(image3Msg->global_descriptor); \ 65 if(!image4Msg->global_descriptor.data.empty()) \ 66 globalDescriptorMsgs.push_back(image4Msg->global_descriptor); \ 67 if(!image5Msg->global_descriptor.data.empty()) \ 68 globalDescriptorMsgs.push_back(image5Msg->global_descriptor); \ 69 if(!image6Msg->global_descriptor.data.empty()) \ 70 globalDescriptorMsgs.push_back(image6Msg->global_descriptor); \ 71 localKeyPoints.push_back(image1Msg->key_points); \ 72 localKeyPoints.push_back(image2Msg->key_points); \ 73 localKeyPoints.push_back(image3Msg->key_points); \ 74 localKeyPoints.push_back(image4Msg->key_points); \ 75 localKeyPoints.push_back(image5Msg->key_points); \ 76 localKeyPoints.push_back(image6Msg->key_points); \ 77 localPoints3d.push_back(image1Msg->points); \ 78 localPoints3d.push_back(image2Msg->points); \ 79 localPoints3d.push_back(image3Msg->points); \ 80 localPoints3d.push_back(image4Msg->points); \ 81 localPoints3d.push_back(image5Msg->points); \ 82 localPoints3d.push_back(image6Msg->points); \ 83 localDescriptors.push_back(rtabmap::uncompressData(image1Msg->descriptors)); \ 84 localDescriptors.push_back(rtabmap::uncompressData(image2Msg->descriptors)); \ 85 localDescriptors.push_back(rtabmap::uncompressData(image3Msg->descriptors)); \ 86 localDescriptors.push_back(rtabmap::uncompressData(image4Msg->descriptors)); \ 87 localDescriptors.push_back(rtabmap::uncompressData(image5Msg->descriptors)); \ 88 localDescriptors.push_back(rtabmap::uncompressData(image6Msg->descriptors)); 91 void CommonDataSubscriber::rgbd6Callback(
92 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
93 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
94 const rtabmap_ros::RGBDImageConstPtr& image3Msg,
95 const rtabmap_ros::RGBDImageConstPtr& image4Msg,
96 const rtabmap_ros::RGBDImageConstPtr& image5Msg,
97 const rtabmap_ros::RGBDImageConstPtr& image6Msg)
101 nav_msgs::OdometryConstPtr odomMsg;
102 rtabmap_ros::UserDataConstPtr userDataMsg;
103 sensor_msgs::LaserScan scanMsg;
104 sensor_msgs::PointCloud2 scan3dMsg;
105 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
106 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
108 void CommonDataSubscriber::rgbd6Scan2dCallback(
109 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
110 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
111 const rtabmap_ros::RGBDImageConstPtr& image3Msg,
112 const rtabmap_ros::RGBDImageConstPtr& image4Msg,
113 const rtabmap_ros::RGBDImageConstPtr& image5Msg,
114 const rtabmap_ros::RGBDImageConstPtr& image6Msg,
115 const sensor_msgs::LaserScanConstPtr& scanMsg)
119 nav_msgs::OdometryConstPtr odomMsg;
120 rtabmap_ros::UserDataConstPtr userDataMsg;
121 sensor_msgs::PointCloud2 scan3dMsg;
122 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
123 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, *scanMsg, scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
125 void CommonDataSubscriber::rgbd6Scan3dCallback(
126 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
127 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
128 const rtabmap_ros::RGBDImageConstPtr& image3Msg,
129 const rtabmap_ros::RGBDImageConstPtr& image4Msg,
130 const rtabmap_ros::RGBDImageConstPtr& image5Msg,
131 const rtabmap_ros::RGBDImageConstPtr& image6Msg,
132 const sensor_msgs::PointCloud2ConstPtr& scan3dMsg)
136 nav_msgs::OdometryConstPtr odomMsg;
137 rtabmap_ros::UserDataConstPtr userDataMsg;
138 sensor_msgs::LaserScan scanMsg;
139 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
140 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, *scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
142 void CommonDataSubscriber::rgbd6ScanDescCallback(
143 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
144 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
145 const rtabmap_ros::RGBDImageConstPtr& image3Msg,
146 const rtabmap_ros::RGBDImageConstPtr& image4Msg,
147 const rtabmap_ros::RGBDImageConstPtr& image5Msg,
148 const rtabmap_ros::RGBDImageConstPtr& image6Msg,
149 const rtabmap_ros::ScanDescriptorConstPtr& scanDescMsg)
153 nav_msgs::OdometryConstPtr odomMsg;
154 rtabmap_ros::UserDataConstPtr userDataMsg;
155 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
156 if(!scanDescMsg->global_descriptor.data.empty())
158 globalDescriptorMsgs.push_back(scanDescMsg->global_descriptor);
160 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanDescMsg->scan, scanDescMsg->scan_cloud, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
162 void CommonDataSubscriber::rgbd6InfoCallback(
163 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
164 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
165 const rtabmap_ros::RGBDImageConstPtr& image3Msg,
166 const rtabmap_ros::RGBDImageConstPtr& image4Msg,
167 const rtabmap_ros::RGBDImageConstPtr& image5Msg,
168 const rtabmap_ros::RGBDImageConstPtr& image6Msg,
169 const rtabmap_ros::OdomInfoConstPtr& odomInfoMsg)
173 nav_msgs::OdometryConstPtr odomMsg;
174 rtabmap_ros::UserDataConstPtr userDataMsg;
175 sensor_msgs::LaserScan scanMsg;
176 sensor_msgs::PointCloud2 scan3dMsg;
177 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
181 void CommonDataSubscriber::rgbd6OdomCallback(
182 const nav_msgs::OdometryConstPtr & odomMsg,
183 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
184 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
185 const rtabmap_ros::RGBDImageConstPtr& image3Msg,
186 const rtabmap_ros::RGBDImageConstPtr& image4Msg,
187 const rtabmap_ros::RGBDImageConstPtr& image5Msg,
188 const rtabmap_ros::RGBDImageConstPtr& image6Msg)
192 rtabmap_ros::UserDataConstPtr userDataMsg;
193 sensor_msgs::LaserScan scanMsg;
194 sensor_msgs::PointCloud2 scan3dMsg;
195 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
196 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
198 void CommonDataSubscriber::rgbd6OdomScan2dCallback(
199 const nav_msgs::OdometryConstPtr & odomMsg,
200 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
201 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
202 const rtabmap_ros::RGBDImageConstPtr& image3Msg,
203 const rtabmap_ros::RGBDImageConstPtr& image4Msg,
204 const rtabmap_ros::RGBDImageConstPtr& image5Msg,
205 const rtabmap_ros::RGBDImageConstPtr& image6Msg,
206 const sensor_msgs::LaserScanConstPtr& scanMsg)
210 rtabmap_ros::UserDataConstPtr userDataMsg;
211 sensor_msgs::PointCloud2 scan3dMsg;
212 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
213 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, *scanMsg, scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
215 void CommonDataSubscriber::rgbd6OdomScan3dCallback(
216 const nav_msgs::OdometryConstPtr & odomMsg,
217 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
218 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
219 const rtabmap_ros::RGBDImageConstPtr& image3Msg,
220 const rtabmap_ros::RGBDImageConstPtr& image4Msg,
221 const rtabmap_ros::RGBDImageConstPtr& image5Msg,
222 const rtabmap_ros::RGBDImageConstPtr& image6Msg,
223 const sensor_msgs::PointCloud2ConstPtr& scan3dMsg)
227 rtabmap_ros::UserDataConstPtr userDataMsg;
228 sensor_msgs::LaserScan scanMsg;
229 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
230 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, *scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
232 void CommonDataSubscriber::rgbd6OdomScanDescCallback(
233 const nav_msgs::OdometryConstPtr & odomMsg,
234 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
235 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
236 const rtabmap_ros::RGBDImageConstPtr& image3Msg,
237 const rtabmap_ros::RGBDImageConstPtr& image4Msg,
238 const rtabmap_ros::RGBDImageConstPtr& image5Msg,
239 const rtabmap_ros::RGBDImageConstPtr& image6Msg,
240 const rtabmap_ros::ScanDescriptorConstPtr& scanDescMsg)
244 rtabmap_ros::UserDataConstPtr userDataMsg;
245 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
246 if(!scanDescMsg->global_descriptor.data.empty())
248 globalDescriptorMsgs.push_back(scanDescMsg->global_descriptor);
250 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanDescMsg->scan, scanDescMsg->scan_cloud, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
252 void CommonDataSubscriber::rgbd6OdomInfoCallback(
253 const nav_msgs::OdometryConstPtr & odomMsg,
254 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
255 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
256 const rtabmap_ros::RGBDImageConstPtr& image3Msg,
257 const rtabmap_ros::RGBDImageConstPtr& image4Msg,
258 const rtabmap_ros::RGBDImageConstPtr& image5Msg,
259 const rtabmap_ros::RGBDImageConstPtr& image6Msg,
260 const rtabmap_ros::OdomInfoConstPtr& odomInfoMsg)
264 rtabmap_ros::UserDataConstPtr userDataMsg;
265 sensor_msgs::LaserScan scanMsg;
266 sensor_msgs::PointCloud2 scan3dMsg;
267 commonDepthCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
270 void CommonDataSubscriber::setupRGBD6Callbacks(
274 bool subscribeUserData,
275 bool subscribeScan2d,
276 bool subscribeScan3d,
277 bool subscribeScanDesc,
278 bool subscribeOdomInfo,
285 for(
int i=0; i<6; ++i)
293 if(subscribeScanDesc)
297 if(subscribeOdomInfo)
300 ROS_WARN(
"subscribe_odom_info ignored...");
302 SYNC_DECL8(rgbd6OdomScanDesc, approxSync, queueSize,
odomSub_, (*
rgbdSubs_[0]), (*
rgbdSubs_[1]), (*
rgbdSubs_[2]), (*
rgbdSubs_[3]), (*
rgbdSubs_[4]), (*
rgbdSubs_[5]),
scanDescSub_);
304 else if(subscribeScan2d)
308 if(subscribeOdomInfo)
311 ROS_WARN(
"subscribe_odom_info ignored...");
313 SYNC_DECL8(rgbd6OdomScan2d, approxSync, queueSize,
odomSub_, (*
rgbdSubs_[0]), (*
rgbdSubs_[1]), (*
rgbdSubs_[2]), (*
rgbdSubs_[3]), (*
rgbdSubs_[4]), (*
rgbdSubs_[5]),
scanSub_);
315 else if(subscribeScan3d)
319 if(subscribeOdomInfo)
322 ROS_WARN(
"subscribe_odom_info ignored...");
324 SYNC_DECL8(rgbd6OdomScan3d, approxSync, queueSize,
odomSub_, (*
rgbdSubs_[0]), (*
rgbdSubs_[1]), (*
rgbdSubs_[2]), (*
rgbdSubs_[3]), (*
rgbdSubs_[4]), (*
rgbdSubs_[5]),
scan3dSub_);
326 else if(subscribeOdomInfo)
330 SYNC_DECL8(rgbd6OdomInfo, approxSync, queueSize,
odomSub_, (*
rgbdSubs_[0]), (*
rgbdSubs_[1]), (*
rgbdSubs_[2]), (*
rgbdSubs_[3]), (*
rgbdSubs_[4]), (*
rgbdSubs_[5]),
odomInfoSub_);
339 if(subscribeScanDesc)
343 if(subscribeOdomInfo)
346 ROS_WARN(
"subscribe_odom_info ignored...");
350 else if(subscribeScan2d)
354 if(subscribeOdomInfo)
357 ROS_WARN(
"subscribe_odom_info ignored...");
361 else if(subscribeScan3d)
365 if(subscribeOdomInfo)
368 ROS_WARN(
"subscribe_odom_info ignored...");
372 else if(subscribeOdomInfo)
std::string uFormat(const char *fmt,...)
#define SYNC_DECL7(PREFIX, APPROX, QUEUE_SIZE, SUB0, SUB1, SUB2, SUB3, SUB4, SUB5, SUB6)
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
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_
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)
#define SYNC_DECL8(PREFIX, APPROX, QUEUE_SIZE, SUB0, SUB1, SUB2, SUB3, SUB4, SUB5, SUB6, SUB7)
std::vector< message_filters::Subscriber< rtabmap_ros::RGBDImage > * > rgbdSubs_