36 callbackCalled_(
false),
37 subscribedToDepth_(!gui),
38 subscribedToStereo_(
false),
39 subscribedToRGB_(!gui),
40 subscribedToOdom_(
false),
41 subscribedToRGBD_(
false),
42 subscribedToScan2d_(
false),
43 subscribedToScan3d_(
false),
44 subscribedToScanDescriptor_(
false),
45 subscribedToOdomInfo_(
false),
67 #ifdef RTABMAP_SYNC_USER_DATA
117 #ifdef RTABMAP_SYNC_USER_DATA
151 #ifdef RTABMAP_SYNC_USER_DATA
167 #ifdef RTABMAP_SYNC_MULTI_RGBD
182 #ifdef RTABMAP_SYNC_USER_DATA
212 #ifdef RTABMAP_SYNC_USER_DATA
242 #ifdef RTABMAP_SYNC_USER_DATA
299 #ifdef RTABMAP_SYNC_USER_DATA
319 #ifdef RTABMAP_SYNC_USER_DATA
332 const std::string &
name)
334 bool subscribeScan2d =
false;
335 bool subscribeScan3d =
false;
336 bool subscribeScanDesc =
false;
337 bool subscribeOdomInfo =
false;
338 bool subscribeUserData =
false;
339 bool subscribeOdom =
true;
345 if(pnh.
getParam(
"subscribe_laserScan", subscribeScan2d) && subscribeScan2d)
347 ROS_WARN(
"rtabmap: \"subscribe_laserScan\" parameter is deprecated, use \"subscribe_scan\" instead. The scan topic is still subscribed.");
350 pnh.
param(
"subscribe_scan", subscribeScan2d, subscribeScan2d);
351 pnh.
param(
"subscribe_scan_cloud", subscribeScan3d, subscribeScan3d);
352 pnh.
param(
"subscribe_scan_descriptor", subscribeScanDesc, subscribeScanDesc);
355 pnh.
param(
"subscribe_odom_info", subscribeOdomInfo, subscribeOdomInfo);
356 pnh.
param(
"subscribe_user_data", subscribeUserData, subscribeUserData);
357 pnh.
param(
"subscribe_odom", subscribeOdom, subscribeOdom);
359 #ifdef RTABMAP_SYNC_USER_DATA 360 if(subscribeUserData)
362 ROS_ERROR(
"subscribe_user_data is true, but rtabmap_ros has been built with RTABMAP_SYNC_USER_DATA. Setting back to false.");
363 subscribeUserData =
false;
369 ROS_WARN(
"rtabmap: Parameters subscribe_depth and subscribe_stereo cannot be true at the same time. Parameter subscribe_depth is set to false.");
375 ROS_WARN(
"rtabmap: Parameters subscribe_stereo and subscribe_rgb cannot be true at the same time. Parameter subscribe_rgb is set to false.");
380 ROS_WARN(
"rtabmap: Parameters subscribe_depth and subscribe_rgbd cannot be true at the same time. Parameter subscribe_depth is set to false.");
386 ROS_WARN(
"rtabmap: Parameters subscribe_rgb and subscribe_rgbd cannot be true at the same time. Parameter subscribe_rgb is set to false.");
391 ROS_WARN(
"rtabmap: Parameters subscribe_stereo and subscribe_rgbd cannot be true at the same time. Parameter subscribe_stereo is set to false.");
394 if(subscribeScan2d && subscribeScan3d)
396 ROS_WARN(
"rtabmap: Parameters subscribe_scan and subscribe_scan_cloud cannot be true at the same time. Parameter subscribe_scan_cloud is set to false.");
397 subscribeScan3d =
false;
399 if(subscribeScan2d && subscribeScanDesc)
401 ROS_WARN(
"rtabmap: Parameters subscribe_scan and subscribe_scan_descriptor cannot be true at the same time. Parameter subscribe_scan is set to false.");
402 subscribeScan2d =
false;
404 if(subscribeScan3d && subscribeScanDesc)
406 ROS_WARN(
"rtabmap: Parameters subscribe_scan_cloud and subscribe_scan_descriptor cannot be true at the same time. Parameter subscribe_scan_cloud is set to false.");
407 subscribeScan3d =
false;
409 if(subscribeScan2d || subscribeScan3d || subscribeScanDesc)
421 std::string odomFrameId;
422 pnh.
getParam(
"odom_frame_id", odomFrameId);
423 pnh.
param(
"rgbd_cameras", rgbdCameras, rgbdCameras);
426 ROS_ERROR(
"\"depth_cameras\" parameter doesn't exist anymore. It is replaced by \"rgbd_cameras\" used when \"subscribe_rgbd\" is true.");
431 ROS_WARN(
"Parameter \"stereo_approx_sync\" has been renamed " 432 "to \"approx_sync\"! Your value is still copied to " 433 "corresponding parameter.");
450 ROS_INFO(
"%s: subscribe_odom_info = %s", name.c_str(), subscribeOdomInfo?
"true":
"false");
451 ROS_INFO(
"%s: subscribe_user_data = %s", name.c_str(), subscribeUserData?
"true":
"false");
452 ROS_INFO(
"%s: subscribe_scan = %s", name.c_str(), subscribeScan2d?
"true":
"false");
453 ROS_INFO(
"%s: subscribe_scan_cloud = %s", name.c_str(), subscribeScan3d?
"true":
"false");
454 ROS_INFO(
"%s: subscribe_scan_descriptor = %s", name.c_str(), subscribeScanDesc?
"true":
"false");
499 #ifdef RTABMAP_SYNC_MULTI_RGBD 514 else if(rgbdCameras == 5)
528 else if(rgbdCameras == 4)
542 else if(rgbdCameras == 3)
556 else if(rgbdCameras == 2)
573 ROS_FATAL(
"Cannot synchronize more than 1 rgbd topic (rtabmap_ros has been built without RTABMAP_SYNC_MULTI_RGBD option)");
591 else if(subscribeScan2d || subscribeScan3d || subscribeScanDesc)
604 else if(subscribedToOdom_)
651 #ifdef RTABMAP_SYNC_USER_DATA 670 SYNC_DEL(depthOdomDataScanDescInfo);
701 #ifdef RTABMAP_SYNC_USER_DATA 736 #ifdef RTABMAP_SYNC_USER_DATA 752 #ifdef RTABMAP_SYNC_MULTI_RGBD 767 #ifdef RTABMAP_SYNC_USER_DATA 797 #ifdef RTABMAP_SYNC_USER_DATA 827 #ifdef RTABMAP_SYNC_USER_DATA 869 #endif //RTABMAP_SYNC_MULTI_RGBD 883 #ifdef RTABMAP_SYNC_USER_DATA 903 #ifdef RTABMAP_SYNC_USER_DATA 910 for(
unsigned int i=0; i<
rgbdSubs_.size(); ++i)
943 ROS_WARN(
"%s: Did not receive data since 5 seconds! Make sure the input topics are " 944 "published (\"$ rostopic hz my_topic\") and the timestamps in their " 945 "header are set. If topics are coming from different computers, make sure " 946 "the clocks of the computers are synchronized (\"ntpdate\"). %s%s",
949 uFormat(
"If topics are not published at the same rate, you could increase \"queue_size\" parameter (current=%d).",
queueSize_).c_str():
950 "Parameter \"approx_sync\" is false, which means that input topics should have all the exact timestamp for the callback to be called.",
957 const nav_msgs::OdometryConstPtr & odomMsg,
958 const rtabmap_ros::UserDataConstPtr & userDataMsg,
961 const sensor_msgs::CameraInfo & rgbCameraInfoMsg,
962 const sensor_msgs::CameraInfo & depthCameraInfoMsg,
963 const sensor_msgs::LaserScan& scanMsg,
964 const sensor_msgs::PointCloud2& scan3dMsg,
965 const rtabmap_ros::OdomInfoConstPtr& odomInfoMsg,
966 const std::vector<rtabmap_ros::GlobalDescriptor> & globalDescriptorMsgs,
967 const std::vector<rtabmap_ros::KeyPoint> & localKeyPoints,
968 const std::vector<rtabmap_ros::Point3f> & localPoints3d,
969 const cv::Mat & localDescriptors)
973 std::vector<std::vector<rtabmap_ros::KeyPoint> > localKeyPointsMsgs;
974 localKeyPointsMsgs.push_back(localKeyPoints);
975 std::vector<std::vector<rtabmap_ros::Point3f> > localPoints3dMsgs;
976 localPoints3dMsgs.push_back(localPoints3d);
977 std::vector<cv::Mat> localDescriptorsMsgs;
978 localDescriptorsMsgs.push_back(localDescriptors);
980 if(depthMsg.get() == 0 ||
985 std::vector<cv_bridge::CvImageConstPtr> imageMsgs;
986 std::vector<cv_bridge::CvImageConstPtr> depthMsgs;
987 std::vector<sensor_msgs::CameraInfo> cameraInfoMsgs;
990 imageMsgs.push_back(imageMsg);
994 depthMsgs.push_back(depthMsg);
996 cameraInfoMsgs.push_back(rgbCameraInfoMsg);
1006 globalDescriptorMsgs,
1009 localDescriptorsMsgs);
1023 globalDescriptorMsgs,
CommonDataSubscriber(bool gui)
std::string uFormat(const char *fmt,...)
virtual ~CommonDataSubscriber()
bool deleteParam(const std::string &key) const
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
void setupRGBCallbacks(ros::NodeHandle &nh, ros::NodeHandle &pnh, bool subscribeOdom, bool subscribeUserData, bool subscribeScan2d, bool subscribeScan3d, bool subscribeScanDesc, bool subscribeOdomInfo, int queueSize, bool approxSync)
void setupScanCallbacks(ros::NodeHandle &nh, ros::NodeHandle &pnh, bool subscribeScan2d, bool subscribeScanDesc, bool subscribeOdom, bool subscribeUserData, bool subscribeOdomInfo, int queueSize, bool approxSync)
void commonSingleDepthCallback(const nav_msgs::OdometryConstPtr &odomMsg, const rtabmap_ros::UserDataConstPtr &userDataMsg, const cv_bridge::CvImageConstPtr &imageMsg, const cv_bridge::CvImageConstPtr &depthMsg, const sensor_msgs::CameraInfo &rgbCameraInfoMsg, const sensor_msgs::CameraInfo &depthCameraInfoMsg, 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< rtabmap_ros::KeyPoint > &localKeyPoints=std::vector< rtabmap_ros::KeyPoint >(), const std::vector< rtabmap_ros::Point3f > &localPoints3d=std::vector< rtabmap_ros::Point3f >(), const cv::Mat &localDescriptors=cv::Mat())
void setupOdomCallbacks(ros::NodeHandle &nh, ros::NodeHandle &pnh, bool subscribeUserData, bool subscribeOdomInfo, int queueSize, bool approxSync)
void setupCallbacks(ros::NodeHandle &nh, ros::NodeHandle &pnh, const std::string &name)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
const std::string TYPE_32FC1
bool subscribedToScanDescriptor_
virtual void commonStereoCallback(const nav_msgs::OdometryConstPtr &odomMsg, const rtabmap_ros::UserDataConstPtr &userDataMsg, const cv_bridge::CvImageConstPtr &leftImageMsg, const cv_bridge::CvImageConstPtr &rightImageMsg, const sensor_msgs::CameraInfo &leftCamInfoMsg, const sensor_msgs::CameraInfo &rightCamInfoMsg, 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< rtabmap_ros::KeyPoint > &localKeyPoints=std::vector< rtabmap_ros::KeyPoint >(), const std::vector< rtabmap_ros::Point3f > &localPoints3d=std::vector< rtabmap_ros::Point3f >(), const cv::Mat &localDescriptors=cv::Mat())=0
const std::string TYPE_16UC1
boost::thread * warningThread_
const std::string & name() const
bool getParam(const std::string &key, std::string &s) const
void setupRGBDCallbacks(ros::NodeHandle &nh, ros::NodeHandle &pnh, bool subscribeOdom, bool subscribeUserData, bool subscribeScan2d, bool subscribeScan3d, bool subscribeScanDesc, bool subscribeOdomInfo, int queueSize, bool approxSync)
bool hasParam(const std::string &key) const
std::string subscribedTopicsMsg_
void setupStereoCallbacks(ros::NodeHandle &nh, ros::NodeHandle &pnh, bool subscribeOdom, bool subscribeOdomInfo, int queueSize, bool approxSync)
std::vector< message_filters::Subscriber< rtabmap_ros::RGBDImage > * > rgbdSubs_
#define SYNC_INIT(PREFIX)
void setupDepthCallbacks(ros::NodeHandle &nh, ros::NodeHandle &pnh, bool subscribeOdom, bool subscribeUserData, bool subscribeScan2d, bool subscribeScan3d, bool subscribeScanDesc, bool subscribeOdomInfo, int queueSize, bool approxSync)