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<sensor_msgs::CameraInfo> depthCameraInfoMsgs; \ 56 depthCameraInfoMsgs.push_back(image1Msg->depth_camera_info); \ 57 depthCameraInfoMsgs.push_back(image2Msg->depth_camera_info); \ 58 depthCameraInfoMsgs.push_back(image3Msg->depth_camera_info); \ 59 depthCameraInfoMsgs.push_back(image4Msg->depth_camera_info); \ 60 depthCameraInfoMsgs.push_back(image5Msg->depth_camera_info); \ 61 depthCameraInfoMsgs.push_back(image6Msg->depth_camera_info); \ 62 std::vector<rtabmap_ros::GlobalDescriptor> globalDescriptorMsgs; \ 63 std::vector<std::vector<rtabmap_ros::KeyPoint> > localKeyPoints; \ 64 std::vector<std::vector<rtabmap_ros::Point3f> > localPoints3d; \ 65 std::vector<cv::Mat> localDescriptors; \ 66 if(!image1Msg->global_descriptor.data.empty()) \ 67 globalDescriptorMsgs.push_back(image1Msg->global_descriptor); \ 68 if(!image2Msg->global_descriptor.data.empty()) \ 69 globalDescriptorMsgs.push_back(image2Msg->global_descriptor); \ 70 if(!image3Msg->global_descriptor.data.empty()) \ 71 globalDescriptorMsgs.push_back(image3Msg->global_descriptor); \ 72 if(!image4Msg->global_descriptor.data.empty()) \ 73 globalDescriptorMsgs.push_back(image4Msg->global_descriptor); \ 74 if(!image5Msg->global_descriptor.data.empty()) \ 75 globalDescriptorMsgs.push_back(image5Msg->global_descriptor); \ 76 if(!image6Msg->global_descriptor.data.empty()) \ 77 globalDescriptorMsgs.push_back(image6Msg->global_descriptor); \ 78 localKeyPoints.push_back(image1Msg->key_points); \ 79 localKeyPoints.push_back(image2Msg->key_points); \ 80 localKeyPoints.push_back(image3Msg->key_points); \ 81 localKeyPoints.push_back(image4Msg->key_points); \ 82 localKeyPoints.push_back(image5Msg->key_points); \ 83 localKeyPoints.push_back(image6Msg->key_points); \ 84 localPoints3d.push_back(image1Msg->points); \ 85 localPoints3d.push_back(image2Msg->points); \ 86 localPoints3d.push_back(image3Msg->points); \ 87 localPoints3d.push_back(image4Msg->points); \ 88 localPoints3d.push_back(image5Msg->points); \ 89 localPoints3d.push_back(image6Msg->points); \ 90 localDescriptors.push_back(rtabmap::uncompressData(image1Msg->descriptors)); \ 91 localDescriptors.push_back(rtabmap::uncompressData(image2Msg->descriptors)); \ 92 localDescriptors.push_back(rtabmap::uncompressData(image3Msg->descriptors)); \ 93 localDescriptors.push_back(rtabmap::uncompressData(image4Msg->descriptors)); \ 94 localDescriptors.push_back(rtabmap::uncompressData(image5Msg->descriptors)); \ 95 localDescriptors.push_back(rtabmap::uncompressData(image6Msg->descriptors)); 98 void CommonDataSubscriber::rgbd6Callback(
99 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
100 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
101 const rtabmap_ros::RGBDImageConstPtr& image3Msg,
102 const rtabmap_ros::RGBDImageConstPtr& image4Msg,
103 const rtabmap_ros::RGBDImageConstPtr& image5Msg,
104 const rtabmap_ros::RGBDImageConstPtr& image6Msg)
108 nav_msgs::OdometryConstPtr odomMsg;
109 rtabmap_ros::UserDataConstPtr userDataMsg;
110 sensor_msgs::LaserScan scanMsg;
111 sensor_msgs::PointCloud2 scan3dMsg;
112 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
113 commonMultiCameraCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, depthCameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
115 void CommonDataSubscriber::rgbd6Scan2dCallback(
116 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
117 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
118 const rtabmap_ros::RGBDImageConstPtr& image3Msg,
119 const rtabmap_ros::RGBDImageConstPtr& image4Msg,
120 const rtabmap_ros::RGBDImageConstPtr& image5Msg,
121 const rtabmap_ros::RGBDImageConstPtr& image6Msg,
122 const sensor_msgs::LaserScanConstPtr& scanMsg)
126 nav_msgs::OdometryConstPtr odomMsg;
127 rtabmap_ros::UserDataConstPtr userDataMsg;
128 sensor_msgs::PointCloud2 scan3dMsg;
129 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
130 commonMultiCameraCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, depthCameraInfoMsgs, *scanMsg, scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
132 void CommonDataSubscriber::rgbd6Scan3dCallback(
133 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
134 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
135 const rtabmap_ros::RGBDImageConstPtr& image3Msg,
136 const rtabmap_ros::RGBDImageConstPtr& image4Msg,
137 const rtabmap_ros::RGBDImageConstPtr& image5Msg,
138 const rtabmap_ros::RGBDImageConstPtr& image6Msg,
139 const sensor_msgs::PointCloud2ConstPtr& scan3dMsg)
143 nav_msgs::OdometryConstPtr odomMsg;
144 rtabmap_ros::UserDataConstPtr userDataMsg;
145 sensor_msgs::LaserScan scanMsg;
146 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
147 commonMultiCameraCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, depthCameraInfoMsgs, scanMsg, *scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
149 void CommonDataSubscriber::rgbd6ScanDescCallback(
150 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
151 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
152 const rtabmap_ros::RGBDImageConstPtr& image3Msg,
153 const rtabmap_ros::RGBDImageConstPtr& image4Msg,
154 const rtabmap_ros::RGBDImageConstPtr& image5Msg,
155 const rtabmap_ros::RGBDImageConstPtr& image6Msg,
156 const rtabmap_ros::ScanDescriptorConstPtr& scanDescMsg)
160 nav_msgs::OdometryConstPtr odomMsg;
161 rtabmap_ros::UserDataConstPtr userDataMsg;
162 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
163 if(!scanDescMsg->global_descriptor.data.empty())
165 globalDescriptorMsgs.push_back(scanDescMsg->global_descriptor);
167 commonMultiCameraCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, depthCameraInfoMsgs, scanDescMsg->scan, scanDescMsg->scan_cloud, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
169 void CommonDataSubscriber::rgbd6InfoCallback(
170 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
171 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
172 const rtabmap_ros::RGBDImageConstPtr& image3Msg,
173 const rtabmap_ros::RGBDImageConstPtr& image4Msg,
174 const rtabmap_ros::RGBDImageConstPtr& image5Msg,
175 const rtabmap_ros::RGBDImageConstPtr& image6Msg,
176 const rtabmap_ros::OdomInfoConstPtr& odomInfoMsg)
180 nav_msgs::OdometryConstPtr odomMsg;
181 rtabmap_ros::UserDataConstPtr userDataMsg;
182 sensor_msgs::LaserScan scanMsg;
183 sensor_msgs::PointCloud2 scan3dMsg;
184 commonMultiCameraCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, depthCameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
188 void CommonDataSubscriber::rgbd6OdomCallback(
189 const nav_msgs::OdometryConstPtr & odomMsg,
190 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
191 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
192 const rtabmap_ros::RGBDImageConstPtr& image3Msg,
193 const rtabmap_ros::RGBDImageConstPtr& image4Msg,
194 const rtabmap_ros::RGBDImageConstPtr& image5Msg,
195 const rtabmap_ros::RGBDImageConstPtr& image6Msg)
199 rtabmap_ros::UserDataConstPtr userDataMsg;
200 sensor_msgs::LaserScan scanMsg;
201 sensor_msgs::PointCloud2 scan3dMsg;
202 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
203 commonMultiCameraCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, depthCameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
205 void CommonDataSubscriber::rgbd6OdomScan2dCallback(
206 const nav_msgs::OdometryConstPtr & odomMsg,
207 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
208 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
209 const rtabmap_ros::RGBDImageConstPtr& image3Msg,
210 const rtabmap_ros::RGBDImageConstPtr& image4Msg,
211 const rtabmap_ros::RGBDImageConstPtr& image5Msg,
212 const rtabmap_ros::RGBDImageConstPtr& image6Msg,
213 const sensor_msgs::LaserScanConstPtr& scanMsg)
217 rtabmap_ros::UserDataConstPtr userDataMsg;
218 sensor_msgs::PointCloud2 scan3dMsg;
219 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
220 commonMultiCameraCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, depthCameraInfoMsgs, *scanMsg, scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
222 void CommonDataSubscriber::rgbd6OdomScan3dCallback(
223 const nav_msgs::OdometryConstPtr & odomMsg,
224 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
225 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
226 const rtabmap_ros::RGBDImageConstPtr& image3Msg,
227 const rtabmap_ros::RGBDImageConstPtr& image4Msg,
228 const rtabmap_ros::RGBDImageConstPtr& image5Msg,
229 const rtabmap_ros::RGBDImageConstPtr& image6Msg,
230 const sensor_msgs::PointCloud2ConstPtr& scan3dMsg)
234 rtabmap_ros::UserDataConstPtr userDataMsg;
235 sensor_msgs::LaserScan scanMsg;
236 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
237 commonMultiCameraCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, depthCameraInfoMsgs, scanMsg, *scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
239 void CommonDataSubscriber::rgbd6OdomScanDescCallback(
240 const nav_msgs::OdometryConstPtr & odomMsg,
241 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
242 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
243 const rtabmap_ros::RGBDImageConstPtr& image3Msg,
244 const rtabmap_ros::RGBDImageConstPtr& image4Msg,
245 const rtabmap_ros::RGBDImageConstPtr& image5Msg,
246 const rtabmap_ros::RGBDImageConstPtr& image6Msg,
247 const rtabmap_ros::ScanDescriptorConstPtr& scanDescMsg)
251 rtabmap_ros::UserDataConstPtr userDataMsg;
252 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
253 if(!scanDescMsg->global_descriptor.data.empty())
255 globalDescriptorMsgs.push_back(scanDescMsg->global_descriptor);
257 commonMultiCameraCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, depthCameraInfoMsgs, scanDescMsg->scan, scanDescMsg->scan_cloud, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
259 void CommonDataSubscriber::rgbd6OdomInfoCallback(
260 const nav_msgs::OdometryConstPtr & odomMsg,
261 const rtabmap_ros::RGBDImageConstPtr& image1Msg,
262 const rtabmap_ros::RGBDImageConstPtr& image2Msg,
263 const rtabmap_ros::RGBDImageConstPtr& image3Msg,
264 const rtabmap_ros::RGBDImageConstPtr& image4Msg,
265 const rtabmap_ros::RGBDImageConstPtr& image5Msg,
266 const rtabmap_ros::RGBDImageConstPtr& image6Msg,
267 const rtabmap_ros::OdomInfoConstPtr& odomInfoMsg)
271 rtabmap_ros::UserDataConstPtr userDataMsg;
272 sensor_msgs::LaserScan scanMsg;
273 sensor_msgs::PointCloud2 scan3dMsg;
274 commonMultiCameraCallback(odomMsg, userDataMsg, imageMsgs, depthMsgs, cameraInfoMsgs, depthCameraInfoMsgs, scanMsg, scan3dMsg, odomInfoMsg, globalDescriptorMsgs, localKeyPoints, localPoints3d, localDescriptors);
277 void CommonDataSubscriber::setupRGBD6Callbacks(
281 bool subscribeUserData,
282 bool subscribeScan2d,
283 bool subscribeScan3d,
284 bool subscribeScanDesc,
285 bool subscribeOdomInfo,
292 for(
int i=0; i<6; ++i)
300 if(subscribeScanDesc)
304 if(subscribeOdomInfo)
307 ROS_WARN(
"subscribe_odom_info ignored...");
309 SYNC_DECL8(
CommonDataSubscriber, rgbd6OdomScanDesc, approxSync, queueSize,
odomSub_, (*
rgbdSubs_[0]), (*
rgbdSubs_[1]), (*
rgbdSubs_[2]), (*
rgbdSubs_[3]), (*
rgbdSubs_[4]), (*
rgbdSubs_[5]),
scanDescSub_);
311 else if(subscribeScan2d)
315 if(subscribeOdomInfo)
318 ROS_WARN(
"subscribe_odom_info ignored...");
320 SYNC_DECL8(
CommonDataSubscriber, rgbd6OdomScan2d, approxSync, queueSize,
odomSub_, (*
rgbdSubs_[0]), (*
rgbdSubs_[1]), (*
rgbdSubs_[2]), (*
rgbdSubs_[3]), (*
rgbdSubs_[4]), (*
rgbdSubs_[5]),
scanSub_);
322 else if(subscribeScan3d)
326 if(subscribeOdomInfo)
329 ROS_WARN(
"subscribe_odom_info ignored...");
331 SYNC_DECL8(
CommonDataSubscriber, rgbd6OdomScan3d, approxSync, queueSize,
odomSub_, (*
rgbdSubs_[0]), (*
rgbdSubs_[1]), (*
rgbdSubs_[2]), (*
rgbdSubs_[3]), (*
rgbdSubs_[4]), (*
rgbdSubs_[5]),
scan3dSub_);
333 else if(subscribeOdomInfo)
337 SYNC_DECL8(
CommonDataSubscriber, rgbd6OdomInfo, approxSync, queueSize,
odomSub_, (*
rgbdSubs_[0]), (*
rgbdSubs_[1]), (*
rgbdSubs_[2]), (*
rgbdSubs_[3]), (*
rgbdSubs_[4]), (*
rgbdSubs_[5]),
odomInfoSub_);
341 SYNC_DECL7(
CommonDataSubscriber, rgbd6Odom, approxSync, queueSize,
odomSub_, (*
rgbdSubs_[0]), (*
rgbdSubs_[1]), (*
rgbdSubs_[2]), (*
rgbdSubs_[3]), (*
rgbdSubs_[4]), (*
rgbdSubs_[5]));
346 if(subscribeScanDesc)
350 if(subscribeOdomInfo)
353 ROS_WARN(
"subscribe_odom_info ignored...");
355 SYNC_DECL7(
CommonDataSubscriber, rgbd6ScanDesc, approxSync, queueSize, (*
rgbdSubs_[0]), (*
rgbdSubs_[1]), (*
rgbdSubs_[2]), (*
rgbdSubs_[3]), (*
rgbdSubs_[4]), (*
rgbdSubs_[5]),
scanDescSub_);
357 else if(subscribeScan2d)
361 if(subscribeOdomInfo)
364 ROS_WARN(
"subscribe_odom_info ignored...");
366 SYNC_DECL7(
CommonDataSubscriber, rgbd6Scan2d, approxSync, queueSize, (*
rgbdSubs_[0]), (*
rgbdSubs_[1]), (*
rgbdSubs_[2]), (*
rgbdSubs_[3]), (*
rgbdSubs_[4]), (*
rgbdSubs_[5]),
scanSub_);
368 else if(subscribeScan3d)
372 if(subscribeOdomInfo)
375 ROS_WARN(
"subscribe_odom_info ignored...");
377 SYNC_DECL7(
CommonDataSubscriber, rgbd6Scan3d, approxSync, queueSize, (*
rgbdSubs_[0]), (*
rgbdSubs_[1]), (*
rgbdSubs_[2]), (*
rgbdSubs_[3]), (*
rgbdSubs_[4]), (*
rgbdSubs_[5]),
scan3dSub_);
379 else if(subscribeOdomInfo)
383 SYNC_DECL7(
CommonDataSubscriber, rgbd6Info, approxSync, queueSize, (*
rgbdSubs_[0]), (*
rgbdSubs_[1]), (*
rgbdSubs_[2]), (*
rgbdSubs_[3]), (*
rgbdSubs_[4]), (*
rgbdSubs_[5]),
odomInfoSub_);
CommonDataSubscriber(bool gui)
std::string uFormat(const char *fmt,...)
#define SYNC_DECL8(CLASS, PREFIX, APPROX, QUEUE_SIZE, SUB0, SUB1, SUB2, SUB3, SUB4, SUB5, SUB6, SUB7)
bool subscribedToOdomInfo_
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_
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_
#define SYNC_DECL6(CLASS, PREFIX, APPROX, QUEUE_SIZE, SUB0, SUB1, SUB2, SUB3, SUB4, SUB5)
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_DECL7(CLASS, PREFIX, APPROX, QUEUE_SIZE, SUB0, SUB1, SUB2, SUB3, SUB4, SUB5, SUB6)
std::vector< message_filters::Subscriber< rtabmap_ros::RGBDImage > * > rgbdSubs_