34 #include <nav_msgs/Path.h> 35 #include <std_msgs/Int32MultiArray.h> 36 #include <std_msgs/Bool.h> 39 #include <pcl/io/io.h> 41 #include <visualization_msgs/MarkerArray.h> 56 #include <rtabmap/core/Version.h> 62 #ifdef WITH_OCTOMAP_MSGS 63 #ifdef RTABMAP_OCTOMAP 69 #define BAD_COVARIANCE 9999 72 #include "rtabmap_ros/Info.h" 73 #include "rtabmap_ros/MapData.h" 74 #include "rtabmap_ros/MapGraph.h" 75 #include "rtabmap_ros/GetMap.h" 76 #include "rtabmap_ros/PublishMap.h" 84 CoreWrapper::CoreWrapper() :
88 lastPoseIntermediate_(
false),
89 latestNodeWasReached_(
false),
90 frameId_(
"base_link"),
93 groundTruthFrameId_(
""),
94 groundTruthBaseFrameId_(
""),
97 odomDefaultAngVariance_(1.0),
98 odomDefaultLinVariance_(1.0),
99 waitForTransform_(
true),
100 waitForTransformDuration_(0.2),
101 useActionForGoal_(
false),
104 genScanMaxDepth_(4.0),
105 genScanMinDepth_(0.0),
106 scanCloudMaxPoints_(0),
109 tfThreadRunning_(
false),
112 stereoToDepth_(
false),
113 odomSensorSync_(
false),
114 rate_(
Parameters::defaultRtabmapDetectionRate()),
115 createIntermediateNodes_(
Parameters::defaultRtabmapCreateIntermediateNodes()),
116 maxMappingNodes_(
Parameters::defaultGridGlobalMaxNodes()),
117 time_(
ros::Time::now()),
119 mbClient_(
"move_base",
true)
131 bool publishTf =
true;
132 double tfDelay = 0.05;
133 double tfTolerance = 0.1;
146 "anymore! It is replaced by \"rgbd_cameras\" parameter " 147 "used when \"subscribe_rgbd\" is true");
150 pnh.
param(
"publish_tf", publishTf, publishTf);
151 pnh.
param(
"tf_delay", tfDelay, tfDelay);
154 ROS_ERROR(
"tf_prefix parameter has been removed, use directly map_frame_id, odom_frame_id and frame_id parameters.");
156 pnh.
param(
"tf_tolerance", tfTolerance, tfTolerance);
167 if(pnh.
hasParam(
"scan_cloud_normal_k"))
169 ROS_WARN(
"rtabmap: Parameter \"scan_cloud_normal_k\" has been removed. RTAB-Map's parameter \"%s\" should be used instead. " 170 "The value is copied. Use \"%s\" to avoid this warning.",
171 Parameters::kMemLaserScanNormalK().c_str(),
172 Parameters::kMemLaserScanNormalK().c_str());
174 pnh.
getParam(
"scan_cloud_normal_k", value);
181 NODELET_WARN(
"Parameter \"flip_scan\" doesn't exist anymore. Rtabmap now " 182 "detects automatically if the laser is upside down with /tf, then if so, it " 183 "switches scan values.");
193 NODELET_INFO(
"rtabmap: ground_truth_frame_id = %s -> ground_truth_base_frame_id = %s",
199 NODELET_INFO(
"rtabmap: tf_tolerance = %f", tfTolerance);
200 NODELET_INFO(
"rtabmap: odom_sensor_sync = %s",
odomSensorSync_?
"true":
"false");
201 bool subscribeStereo =
false;
202 pnh.
param(
"subscribe_stereo", subscribeStereo, subscribeStereo);
205 NODELET_INFO(
"rtabmap: stereo_to_depth = %s",
stereoToDepth_?
"true":
"false");
239 ParametersMap allParameters = Parameters::getDefaultParameters();
247 for(ParametersMap::iterator iter=allParameters.begin(); iter!=allParameters.end(); ++iter)
255 NODELET_INFO(
"Setting RTAB-Map parameter \"%s\"=\"%s\"", iter->first.c_str(), vStr.c_str());
257 if(iter->first.compare(Parameters::kRtabmapWorkingDirectory()) == 0)
261 else if(iter->first.compare(Parameters::kKpDictionaryPath()) == 0)
267 else if(pnh.
getParam(iter->first, vBool))
269 NODELET_INFO(
"Setting RTAB-Map parameter \"%s\"=\"%s\"", iter->first.c_str(),
uBool2Str(vBool).c_str());
272 else if(pnh.
getParam(iter->first, vDouble))
274 NODELET_INFO(
"Setting RTAB-Map parameter \"%s\"=\"%s\"", iter->first.c_str(),
uNumber2Str(vDouble).c_str());
277 else if(pnh.
getParam(iter->first, vInt))
279 NODELET_INFO(
"Setting RTAB-Map parameter \"%s\"=\"%s\"", iter->first.c_str(),
uNumber2Str(vInt).c_str());
285 std::vector<std::string> argList =
getMyArgv();
286 char * argv[argList.size()];
287 bool deleteDbOnStart =
false;
288 for(
unsigned int i=0; i<argList.size(); ++i)
290 argv[i] = &argList[i].at(0);
291 if(strcmp(argv[i],
"--delete_db_on_start") == 0 || strcmp(argv[i],
"-d") == 0)
293 deleteDbOnStart =
true;
297 for(ParametersMap::const_iterator iter=parameters.begin(); iter!=parameters.end(); ++iter)
300 NODELET_INFO(
"Update RTAB-Map parameter \"%s\"=\"%s\" from arguments", iter->first.c_str(), iter->second.c_str());
304 for(std::map<std::string, std::pair<bool, std::string> >::const_iterator iter=Parameters::getRemovedParameters().begin();
305 iter!=Parameters::getRemovedParameters().end();
312 std::string paramValue;
317 else if(pnh.
getParam(iter->first, vBool))
321 else if(pnh.
getParam(iter->first, vDouble))
325 else if(pnh.
getParam(iter->first, vInt))
329 if(!paramValue.empty())
331 if(iter->second.first)
335 NODELET_WARN(
"Rtabmap: Parameter name changed: \"%s\" -> \"%s\". Please update your launch file accordingly. Value \"%s\" is still set to the new parameter name.",
336 iter->first.c_str(), iter->second.second.c_str(), paramValue.c_str());
340 if(iter->second.second.empty())
342 NODELET_ERROR(
"Rtabmap: Parameter \"%s\" doesn't exist anymore!",
343 iter->first.c_str());
347 NODELET_ERROR(
"Rtabmap: Parameter \"%s\" doesn't exist anymore! You may look at this similar parameter: \"%s\"",
348 iter->first.c_str(), iter->second.second.c_str());
357 bool subscribeScan2d =
false;
358 bool subscribeScan3d =
false;
359 pnh.
param(
"subscribe_scan", subscribeScan2d, subscribeScan2d);
360 pnh.
param(
"subscribe_scan_cloud", subscribeScan3d, subscribeScan3d);
361 if((subscribeScan2d || subscribeScan3d) &&
parameters_.find(Parameters::kGridFromDepth()) ==
parameters_.end())
363 NODELET_WARN(
"Setting \"%s\" parameter to false (default true) as \"subscribe_scan\" or \"subscribe_scan_cloud\" is " 364 "true. The occupancy grid map will be constructed from " 365 "laser scans. To get occupancy grid map from cloud projection, set \"%s\" " 366 "to true. To suppress this warning, " 367 "add <param name=\"%s\" type=\"string\" value=\"false\"/>",
368 Parameters::kGridFromDepth().c_str(),
369 Parameters::kGridFromDepth().c_str(),
370 Parameters::kGridFromDepth().c_str());
373 if((subscribeScan2d || subscribeScan3d) &&
parameters_.find(Parameters::kGridRangeMax()) ==
parameters_.end())
375 NODELET_INFO(
"Setting \"%s\" parameter to 0 (default %f) as \"subscribe_scan\" or \"subscribe_scan_cloud\" is true.",
376 Parameters::kGridRangeMax().c_str(),
377 Parameters::defaultGridRangeMax());
380 int regStrategy = Parameters::defaultRegStrategy();
381 Parameters::parse(
parameters_, Parameters::kRegStrategy(), regStrategy);
382 if(subscribeScan2d &&
384 (regStrategy == Registration::kTypeIcp || regStrategy == Registration::kTypeVisIcp))
386 NODELET_WARN(
"Setting \"%s\" parameter to 10 (default 0) as \"subscribe_scan\" is " 387 "true and \"%s\" uses ICP. Proximity detection by space will be also done by merging close " 388 "scans. To disable, set \"%s\" to 0. To suppress this warning, " 389 "add <param name=\"%s\" type=\"string\" value=\"10\"/>",
390 Parameters::kRGBDProximityPathMaxNeighbors().c_str(),
391 Parameters::kRegStrategy().c_str(),
392 Parameters::kRGBDProximityPathMaxNeighbors().c_str(),
393 Parameters::kRGBDProximityPathMaxNeighbors().c_str());
397 int estimationType = Parameters::defaultVisEstimationType();
398 Parameters::parse(
parameters_, Parameters::kVisEstimationType(), estimationType);
400 bool subscribeRGBD =
false;
401 pnh.
param(
"rgbd_cameras", cameras, cameras);
402 pnh.
param(
"subscribe_rgbd", subscribeRGBD, subscribeRGBD);
403 if(subscribeRGBD && cameras> 1 && estimationType>0)
405 NODELET_WARN(
"Setting \"%s\" parameter to 0 (%d is not supported " 406 "for multi-cameras) as \"subscribe_rgbd\" is " 407 "true and \"rgbd_cameras\">1. Set \"%s\" to 0 to suppress this warning.",
408 Parameters::kVisEstimationType().c_str(),
410 Parameters::kVisEstimationType().c_str());
424 for(ParametersMap::iterator iter=dbParameters.begin(); iter!=dbParameters.end(); ++iter)
426 if(iter->first.compare(Parameters::kRtabmapWorkingDirectory()) == 0)
432 allParameters.find(iter->first) != allParameters.end() &&
433 allParameters.find(iter->first)->second.compare(iter->second) !=0)
435 NODELET_INFO(
"Update RTAB-Map parameter \"%s\"=\"%s\" from database", iter->first.c_str(), iter->second.c_str());
442 parameters_.insert(allParameters.begin(), allParameters.end());
448 nh.
setParam(iter->first, iter->second);
453 NODELET_INFO(
"RTAB-Map detection rate = %f Hz",
rate_);
460 NODELET_INFO(
"Create intermediate nodes");
474 NODELET_WARN(
"Node paused... don't forget to call service \"resume\" to start rtabmap.");
481 NODELET_INFO(
"rtabmap: Deleted database \"%s\" (--delete_db_on_start or -d are set).",
databasePath_.c_str());
491 NODELET_INFO(
"rtabmap: database_path parameter not set, the map will not be saved.");
501 float xMin, yMin, gridCellSize;
505 NODELET_INFO(
"rtabmap: 2D occupancy grid map loaded (%dx%d).", map.cols, map.rows);
535 #ifdef WITH_OCTOMAP_MSGS 536 #ifdef RTABMAP_OCTOMAP 537 octomapBinarySrv_ = nh.
advertiseService(
"octomap_binary", &CoreWrapper::octomapBinaryCallback,
this);
538 octomapFullSrv_ = nh.
advertiseService(
"octomap_full", &CoreWrapper::octomapFullCallback,
this);
547 int optimizeIterations = 0;
548 Parameters::parse(
parameters_, Parameters::kOptimizerIterations(), optimizeIterations);
549 if(publishTf && optimizeIterations != 0)
556 UWARN(
"Graph optimization is disabled (%s=0), the tf between frame \"%s\" and odometry frame will not be published. You can safely ignore this warning if you are using map_optimizer node.",
557 Parameters::kOptimizerIterations().c_str(),
mapFrameId_.c_str());
565 if(isRGBD && !incremental)
567 NODELET_INFO(
"\"%s\" is true and \"%s\" is false, subscribing to RGB + camera info...",
568 Parameters::kRGBDEnabled().c_str(),
569 Parameters::kMemIncrementalMemory().c_str());
577 std::string odomFrameId;
578 pnh.
getParam(
"odom_frame_id", odomFrameId);
579 if(!odomFrameId.empty())
586 rgbApproximateSync_->
registerCallback(boost::bind(&CoreWrapper::rgbCallback,
this, _1, _2));
592 rgbExactSync_->
registerCallback(boost::bind(&CoreWrapper::rgbCallback,
this, _1, _2));
594 NODELET_INFO(
"\n%s subscribed to:\n %s\n %s",
606 rgbOdomApproximateSync_->
registerCallback(boost::bind(&CoreWrapper::rgbOdomCallback,
this, _1, _2, _3));
612 rgbOdomExactSync_->
registerCallback(boost::bind(&CoreWrapper::rgbOdomCallback,
this, _1, _2, _3));
614 NODELET_INFO(
"\n%s subscribed to:\n %s\n %s\n %s",
625 NODELET_WARN(
"ROS param subscribe_depth, subscribe_stereo and subscribe_rgbd are false, but RTAB-Map " 626 "parameter \"%s\" and \"%s\" are true! Please set subscribe_depth, subscribe_stereo or subscribe_rgbd " 627 "to true to use rtabmap node for RGB-D SLAM, set \"%s\" to false for loop closure " 628 "detection on images-only or set \"%s\" to false to localize a single RGB camera against pre-built 3D map.",
629 Parameters::kRGBDEnabled().c_str(),
630 Parameters::kMemIncrementalMemory().c_str(),
631 Parameters::kRGBDEnabled().c_str(),
632 Parameters::kMemIncrementalMemory().c_str());
669 printf(
"rtabmap: Saving database/long-term memory... (located at %s)\n",
databasePath_.c_str());
673 float xMin=0.0f, yMin=0.0f, gridCellSize = 0.05f;
677 printf(
"rtabmap: 2D occupancy grid map saved.\n");
688 if(!configFile.empty())
690 NODELET_INFO(
"Loading parameters from %s", configFile.c_str());
693 NODELET_WARN(
"Config file doesn't exist! It will be generated...");
695 Parameters::readINI(configFile.c_str(), parameters);
701 if(!configFile.empty())
703 printf(
"Saving parameters to %s\n", configFile.c_str());
707 printf(
"Config file doesn't exist, a new one will be created.\n");
709 Parameters::writeINI(configFile.c_str(),
parameters_);
713 NODELET_INFO(
"Parameters are not saved! (No configuration file provided...)");
731 msg.header.stamp = tfExpiration;
758 NODELET_ERROR(
"Input type must be image=mono8,mono16,rgb8,bgr8");
779 NODELET_WARN(
"RTAB-Map could not process the data received! (ROS id = %d)", ptrImage->header.seq);
788 NODELET_WARN(
"Ignoring received image because its sequence ID=0. Please " 789 "set \"Mem/GenerateIds\"=\"true\" to ignore ros generated sequence id. " 790 "Use only \"Mem/GenerateIds\"=\"false\" for once-time run of RTAB-Map and " 791 "when you need to have IDs output of RTAB-map synchronised with the source " 792 "image sequence ID.");
794 NODELET_INFO(
"rtabmap: Update rate=%fs, Limit=%fs, Processing time = %fs (%d local nodes)",
803 void CoreWrapper::rgbCallback(
804 const sensor_msgs::ImageConstPtr& imageMsg,
805 const sensor_msgs::CameraInfoConstPtr& cameraInfoMsg)
807 rtabmap_ros::UserDataConstPtr userDataMsg;
808 nav_msgs::OdometryConstPtr odomMsg;
809 sensor_msgs::LaserScanConstPtr scanMsg;
810 sensor_msgs::PointCloud2ConstPtr scan3dMsg;
811 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
816 void CoreWrapper::rgbOdomCallback(
817 const sensor_msgs::ImageConstPtr& imageMsg,
818 const sensor_msgs::CameraInfoConstPtr& cameraInfoMsg,
819 const nav_msgs::OdometryConstPtr & odomMsg)
821 rtabmap_ros::UserDataConstPtr userDataMsg;
822 sensor_msgs::LaserScanConstPtr scanMsg;
823 sensor_msgs::PointCloud2ConstPtr scan3dMsg;
824 rtabmap_ros::OdomInfoConstPtr odomInfoMsg;
839 static bool shown =
false;
842 NODELET_WARN(
"We received odometry message, but we cannot get the " 843 "corresponding TF %s->%s at data stamp %fs (odom msg stamp is %fs). Make sure TF of odometry is " 844 "also published to get more accurate pose estimation. This " 845 "warning is only printed once.", odomMsg->header.frame_id.c_str(),
frameId_.c_str(), stamp.
toSec(), odomMsg->header.stamp.toSec());
848 stamp = odomMsg->header.stamp;
858 UWARN(
"Odometry is reset (identity pose or high variance (%f) detected). Increment map id!",
MAX(odomMsg->pose.covariance[0], odomMsg->twist.covariance[0]));
871 double variance = odomMsg->twist.covariance[0];
875 covariance = cv::Mat(6,6,CV_64FC1, (
void*)odomMsg->pose.covariance.data()).clone();
880 covariance = cv::Mat(6,6,CV_64FC1, (
void*)odomMsg->twist.covariance.data()).clone();
883 if(
uIsFinite(covariance.at<
double>(0,0)) &&
884 covariance.at<
double>(0,0) != 1.0 &&
885 covariance.at<
double>(0,0)>0.0)
896 bool ignoreFrame =
false;
916 else if(!ignoreFrame)
940 UWARN(
"Odometry is reset (identity pose detected). Increment map id!");
949 bool ignoreFrame =
false;
969 else if(!ignoreFrame)
981 const nav_msgs::OdometryConstPtr & odomMsg,
982 const rtabmap_ros::UserDataConstPtr & userDataMsg,
983 const std::vector<cv_bridge::CvImageConstPtr> & imageMsgs,
984 const std::vector<cv_bridge::CvImageConstPtr> & depthMsgs,
985 const std::vector<sensor_msgs::CameraInfo> & cameraInfoMsgs,
986 const sensor_msgs::LaserScanConstPtr& scan2dMsg,
987 const sensor_msgs::PointCloud2ConstPtr& scan3dMsg,
988 const rtabmap_ros::OdomInfoConstPtr& odomInfoMsg)
993 odomFrameId = odomMsg->header.frame_id;
996 if(!
odomUpdate(odomMsg, scan2dMsg->header.stamp))
1001 else if(scan3dMsg.get())
1003 if(!
odomUpdate(odomMsg, scan3dMsg->header.stamp))
1008 else if(imageMsgs.size() == 0 || imageMsgs[0].get() == 0 || !
odomUpdate(odomMsg, imageMsgs[0]->
header.stamp))
1013 else if(scan2dMsg.get())
1020 else if(scan3dMsg.get())
1027 else if(imageMsgs.size() == 0 || imageMsgs[0].get() == 0 || !
odomTFUpdate(imageMsgs[0]->
header.stamp))
1043 const std::string & odomFrameId,
1044 const rtabmap_ros::UserDataConstPtr & userDataMsg,
1045 const std::vector<cv_bridge::CvImageConstPtr> & imageMsgs,
1046 const std::vector<cv_bridge::CvImageConstPtr> & depthMsgs,
1047 const std::vector<sensor_msgs::CameraInfo> & cameraInfoMsgs,
1048 const sensor_msgs::LaserScanConstPtr& scan2dMsg,
1049 const sensor_msgs::PointCloud2ConstPtr& scan3dMsg,
1050 const rtabmap_ros::OdomInfoConstPtr& odomInfoMsg)
1054 std::vector<rtabmap::CameraModel> cameraModels;
1068 NODELET_ERROR(
"Could not convert rgb/depth msgs! Aborting rtabmap update...");
1073 if(!depth.empty() && depth.type() == CV_32FC1 &&
uStr2Bool(
parameters_.at(Parameters::kMemSaveDepth16Format())))
1076 static bool shown =
false;
1079 NODELET_WARN(
"Save depth data to 16 bits format: depth type detected is " 1080 "32FC1, use 16UC1 depth format to avoid this conversion " 1081 "(or set parameter \"Mem/SaveDepth16Format=false\" to use " 1082 "32bits format). This message is only printed once...");
1088 Transform scanLocalTransform = Transform::getIdentity();
1089 bool genMaxScanPts = 0;
1090 if(scan2dMsg.get() == 0 && scan3dMsg.get() == 0 && !depth.empty() &&
genScan_)
1092 pcl::PointCloud<pcl::PointXYZ>::Ptr scanCloud2d(
new pcl::PointCloud<pcl::PointXYZ>);
1093 *scanCloud2d = util3d::laserScanFromDepthImages(
1098 genMaxScanPts += depth.cols;
1101 else if(scan2dMsg.get() != 0)
1113 NODELET_ERROR(
"Could not convert laser scan msg! Aborting rtabmap update...");
1117 if((scanLocalTransform.
rotation()*zAxis).z() < 0)
1120 cv::flip(scan, flipScan, 1);
1126 scan = util3d::transformLaserScan(LaserScan::backwardCompatibility(scan), scanLocalTransform).data();
1127 scanLocalTransform = Transform::getIdentity();
1130 else if(scan3dMsg.get() != 0)
1142 NODELET_ERROR(
"Could not convert 3d laser scan msg! Aborting rtabmap update...");
1154 if(userDataMsg.get())
1160 NODELET_WARN(
"Synchronized and asynchronized user data topics cannot be used at the same time. Async user data dropped!");
1171 SensorData data(LaserScan::backwardCompatibility(scan,
1174 scanLocalTransform),
1193 if(!sensorToBase.
isNull())
1196 globalPose *= sensorToBase;
1208 globalPose *= correction;
1212 NODELET_WARN(
"Could not adjust global pose accordingly to latest odometry pose. " 1213 "If odometry is small since it received the global pose and " 1214 "covariance is large, this should not be a problem.");
1216 cv::Mat globalPoseCovariance = cv::Mat(6,6, CV_64FC1, (
void*)
globalPose_.pose.covariance.data()).clone();
1217 data.setGlobalPose(globalPose, globalPoseCovariance);
1223 if(odomInfoMsg.get())
1238 const nav_msgs::OdometryConstPtr & odomMsg,
1239 const rtabmap_ros::UserDataConstPtr & userDataMsg,
1242 const sensor_msgs::CameraInfo& leftCamInfoMsg,
1243 const sensor_msgs::CameraInfo& rightCamInfoMsg,
1244 const sensor_msgs::LaserScanConstPtr& scan2dMsg,
1245 const sensor_msgs::PointCloud2ConstPtr& scan3dMsg,
1246 const rtabmap_ros::OdomInfoConstPtr& odomInfoMsg)
1251 odomFrameId = odomMsg->header.frame_id;
1254 if(!
odomUpdate(odomMsg, scan2dMsg->header.stamp))
1259 else if(scan3dMsg.get())
1261 if(!
odomUpdate(odomMsg, scan3dMsg->header.stamp))
1266 else if(leftImageMsg.get() == 0 || !
odomUpdate(odomMsg, leftImageMsg->header.stamp))
1271 else if(scan2dMsg.get())
1278 else if(scan3dMsg.get())
1285 else if(leftImageMsg.get() == 0 || !
odomTFUpdate(leftImageMsg->header.stamp))
1307 NODELET_ERROR(
"Could not convert stereo msgs! Aborting rtabmap update...");
1318 if(disparity.empty())
1320 NODELET_ERROR(
"Could not compute disparity image (\"stereo_to_depth\" is true)!");
1330 NODELET_ERROR(
"Could not compute depth image (\"stereo_to_depth\" is true)!");
1333 UASSERT(depth.type() == CV_16UC1 || depth.type() == CV_32FC1);
1337 if(depth.type() == CV_16UC1)
1345 imgDepth->image = depth;
1346 imgDepth->header = leftImageMsg->header;
1347 std::vector<cv_bridge::CvImageConstPtr> rgbImages(1);
1348 std::vector<cv_bridge::CvImageConstPtr> depthImages(1);
1349 std::vector<sensor_msgs::CameraInfo> cameraInfos(1);
1350 rgbImages[0] = leftImageMsg;
1351 depthImages[0] = imgDepth;
1352 cameraInfos[0] = leftCamInfoMsg;
1354 commonDepthCallbackImpl(odomFrameId, rtabmap_ros::UserDataConstPtr(), rgbImages, depthImages, cameraInfos, scan2dMsg, scan3dMsg, odomInfoMsg);
1359 Transform scanLocalTransform = Transform::getIdentity();
1360 if(scan2dMsg.get() != 0)
1372 NODELET_ERROR(
"Could not convert laser scan msg! Aborting rtabmap update...");
1376 if((scanLocalTransform.
rotation()*zAxis).z() < 0)
1379 cv::flip(scan, flipScan, 1);
1385 scan = util3d::transformLaserScan(LaserScan::backwardCompatibility(scan), scanLocalTransform).data();
1386 scanLocalTransform = Transform::getIdentity();
1389 else if(scan3dMsg.get() != 0)
1401 NODELET_ERROR(
"Could not convert 3d laser scan msg! Aborting rtabmap update...");
1413 if(userDataMsg.get())
1419 NODELET_WARN(
"Synchronized and asynchronized user data topics cannot be used at the same time. Async user data dropped!");
1430 SensorData data(LaserScan::backwardCompatibility(scan,
1431 scan2dMsg.get() != 0?(int)scan2dMsg->ranges.size():scan3dMsg.get() != 0?
scanCloudMaxPoints_:0,
1432 scan2dMsg.get() != 0?scan2dMsg->range_max:0,
1433 scanLocalTransform),
1443 if(odomInfoMsg.get())
1462 const std::string & odomFrameId,
1463 const cv::Mat & odomCovariance,
1469 double timeRtabmap = 0.0;
1470 double timeUpdateMaps = 0.0;
1471 double timePublishMaps = 0.0;
1474 if(covariance.empty() || !
uIsFinite(covariance.at<
double>(0,0)) || covariance.at<
double>(0,0)<=0.0
f)
1476 covariance = cv::Mat::eye(6,6,CV_64FC1);
1491 std::map<std::string, float> externalStats;
1492 std::vector<float> odomVelocity;
1495 externalStats.insert(std::make_pair(
"Odometry/LocalBundle/ms", odomInfo.
localBundleTime*1000.0f));
1496 externalStats.insert(std::make_pair(
"Odometry/LocalBundleConstraints/", odomInfo.
localBundleConstraints));
1497 externalStats.insert(std::make_pair(
"Odometry/LocalBundleOutliers/", odomInfo.
localBundleOutliers));
1498 externalStats.insert(std::make_pair(
"Odometry/TotalTime/ms", odomInfo.
timeEstimation*1000.0f));
1499 externalStats.insert(std::make_pair(
"Odometry/Registration/ms", odomInfo.
reg.
totalTime*1000.0f));
1503 externalStats.insert(std::make_pair(
"Odometry/Speed/kph", speed));
1504 externalStats.insert(std::make_pair(
"Odometry/Inliers/", odomInfo.
reg.
inliers));
1505 externalStats.insert(std::make_pair(
"Odometry/Features/", odomInfo.
features));
1506 externalStats.insert(std::make_pair(
"Odometry/DistanceTravelled/m", odomInfo.
distanceTravelled));
1507 externalStats.insert(std::make_pair(
"Odometry/KeyFrameAdded/", odomInfo.
keyFrameAdded));
1508 externalStats.insert(std::make_pair(
"Odometry/LocalKeyFrames/", odomInfo.
localKeyFrames));
1509 externalStats.insert(std::make_pair(
"Odometry/LocalMapSize/", odomInfo.
localMapSize));
1510 externalStats.insert(std::make_pair(
"Odometry/LocalScanMapSize/", odomInfo.
localScanMapSize));
1511 externalStats.insert(std::make_pair(
"Odometry/RAM_usage/MB", odomInfo.
memoryUsage));
1515 odomVelocity.resize(6);
1518 odomVelocity[0] = x/odomInfo.
interval;
1519 odomVelocity[1] = y/odomInfo.
interval;
1520 odomVelocity[2] = z/odomInfo.
interval;
1521 odomVelocity[3] = roll/odomInfo.
interval;
1522 odomVelocity[4] = pitch/odomInfo.
interval;
1523 odomVelocity[5] = yaw/odomInfo.
interval;
1532 if(
rtabmap_.
process(data, odom, covariance, odomVelocity, externalStats))
1534 timeRtabmap = timer.
ticks();
1551 geometry_msgs::PoseWithCovarianceStamped poseMsg;
1553 poseMsg.header.stamp = stamp;
1555 poseMsg.pose.covariance;
1557 memcpy(poseMsg.pose.covariance.data(), cov.data, cov.total()*
sizeof(double));
1563 std::map<int, rtabmap::Signature> tmpSignature;
1565 filteredPoses.size() == 0 ||
1574 filteredPoses.insert(std::make_pair(-1,
mapToOdom_*odom));
1579 std::map<int, Transform> nearestPoses;
1581 for(std::vector<int>::iterator iter=nodes.begin(); iter!=nodes.end(); ++iter)
1583 std::map<int, Transform>::iterator pter = filteredPoses.find(*iter);
1584 if(pter != filteredPoses.end())
1586 nearestPoses.insert(*pter);
1590 std::set<int> onPath;
1594 onPath.insert(nextNodes.begin(), nextNodes.end());
1596 for(std::map<int, Transform>::iterator iter=filteredPoses.begin(); iter!=filteredPoses.end(); ++iter)
1598 if(iter->first < 0 || onPath.find(iter->first) != onPath.end())
1600 nearestPoses.insert(*iter);
1602 else if(onPath.empty())
1608 filteredPoses = nearestPoses;
1619 timeUpdateMaps = timer.
ticks();
1643 std_msgs::Bool result;
1678 NODELET_ERROR(
"Planning: Local map broken, current goal id=%d (the robot may have moved to far from planned nodes)",
1683 std_msgs::Bool result;
1684 result.data =
false;
1694 timePublishMaps = timer.
ticks();
1699 timeRtabmap = timer.
ticks();
1701 NODELET_INFO(
"rtabmap (%d): Rate=%.2fs, Limit=%.3fs, RTAB-Map=%.4fs, Maps update=%.4fs pub=%.4fs (local map=%d, WM=%d)",
1711 rtabmapROSStats_.insert(std::make_pair(std::string(
"RtabmapROS/TimeRtabmap/ms"), timeRtabmap*1000.0
f));
1712 rtabmapROSStats_.insert(std::make_pair(std::string(
"RtabmapROS/TimeUpdatingMaps/ms"), timeUpdateMaps*1000.0f));
1713 rtabmapROSStats_.insert(std::make_pair(std::string(
"RtabmapROS/TimePublishing/ms"), timePublishMaps*1000.0f));
1714 rtabmapROSStats_.insert(std::make_pair(std::string(
"RtabmapROS/TimeTotal/ms"), (timeRtabmap+timeUpdateMaps+timePublishMaps)*1000.0f));
1718 NODELET_WARN(
"Ignoring received image because its sequence ID=0. Please " 1719 "set \"Mem/GenerateIds\"=\"true\" to ignore ros generated sequence id. " 1720 "Use only \"Mem/GenerateIds\"=\"false\" for once-time run of RTAB-Map and " 1721 "when you need to have IDs output of RTAB-map synchronized with the source " 1722 "image sequence ID.");
1733 ROS_WARN(
"Overwriting previous user data set. Asynchronous user " 1734 "data input topic should be used with user data published at " 1735 "lower rate than map update rate (current %s=%f).",
1736 Parameters::kRtabmapDetectionRate().c_str(),
rate_);
1764 const std::string & label,
1767 double * planningTime)
1787 *planningTime = 0.0;
1790 bool success =
false;
1796 *planningTime = timer.
elapsed();
1799 const std::vector<std::pair<int, Transform> > & poses =
rtabmap_.
getPath();
1804 if(poses.size() == 0)
1806 NODELET_WARN(
"Planning: Goal already reached (RGBD/GoalReachedRadius=%fm).",
1811 std_msgs::Bool result;
1822 NODELET_INFO(
"Planning: Path successfully created (size=%d)", (
int)poses.size());
1839 std::stringstream stream;
1840 for(std::vector<std::pair<int, Transform> >::const_iterator iter=poses.begin(); iter!=poses.end(); ++iter)
1842 if(iter != poses.begin())
1846 stream << iter->first;
1848 NODELET_INFO(
"Global path: [%s]", stream.str().c_str());
1857 else if(!label.empty())
1859 NODELET_ERROR(
"Planning: Node with label \"%s\" not found!", label.c_str());
1865 NODELET_ERROR(
"Planning: Could not plan to node %d! The node is not in map's graph (look for warnings before this message for more details).",
id);
1882 std_msgs::Bool result;
1883 result.data =
false;
1899 if(
mapFrameId_.compare(msg->header.frame_id) != 0)
1904 NODELET_ERROR(
"Cannot transform goal pose from \"%s\" frame to \"%s\" frame!",
1905 msg->header.frame_id.c_str(),
mapFrameId_.c_str());
1908 targetPose = t * targetPose;
1916 if(msg->node_id <= 0 && msg->node_label.empty())
1935 NODELET_INFO(
"Setting RTAB-Map parameter \"%s\"=\"%s\"", iter->first.c_str(), vStr.c_str());
1936 iter->second = vStr;
1938 else if(nh.
getParam(iter->first, vBool))
1940 NODELET_INFO(
"Setting RTAB-Map parameter \"%s\"=\"%s\"", iter->first.c_str(),
uBool2Str(vBool).c_str());
1943 else if(nh.
getParam(iter->first, vInt))
1948 else if(nh.
getParam(iter->first, vDouble))
1995 nh.
setParam(
"is_rtabmap_paused",
true);
2011 nh.
setParam(
"is_rtabmap_paused",
false);
2045 NODELET_INFO(
"Backup: Reloading memory... done!");
2056 nh.
setParam(rtabmap::Parameters::kMemIncrementalMemory(),
"false");
2067 nh.
setParam(rtabmap::Parameters::kMemIncrementalMemory(),
"true");
2099 NODELET_INFO(
"rtabmap: Getting map (global=%s optimized=%s graphOnly=%s)...",
2100 req.global?
"true":
"false",
2101 req.optimized?
"true":
"false",
2102 req.graphOnly?
"true":
"false");
2103 std::map<int, Signature> signatures;
2104 std::map<int, Transform> poses;
2105 std::multimap<int, rtabmap::Link> constraints;
2144 NODELET_WARN(
"/get_proj_map service is deprecated! Call /get_grid_map service " 2145 "instead with <param name=\"%s\" type=\"string\" value=\"true\"/>. " 2146 "Do \"$ rosrun rtabmap_ros rtabmap --params | grep Grid\" to see " 2147 "all occupancy grid parameters.",
2148 Parameters::kGridFromDepth().c_str());
2152 NODELET_WARN(
"/get_proj_map service is deprecated! Call /get_grid_map service instead.");
2159 NODELET_WARN(
"/get_grid_map service is deprecated! Call /get_map service instead.");
2166 float xMin=0.0f, yMin=0.0f, gridCellSize = 0.05f;
2172 res.map.info.resolution = gridCellSize;
2173 res.map.info.origin.position.x = 0.0;
2174 res.map.info.origin.position.y = 0.0;
2175 res.map.info.origin.position.z = 0.0;
2176 res.map.info.origin.orientation.x = 0.0;
2177 res.map.info.origin.orientation.y = 0.0;
2178 res.map.info.origin.orientation.z = 0.0;
2179 res.map.info.origin.orientation.w = 1.0;
2181 res.map.info.width = pixels.cols;
2182 res.map.info.height = pixels.rows;
2183 res.map.info.origin.position.x = xMin;
2184 res.map.info.origin.position.y = yMin;
2185 res.map.data.resize(res.map.info.width * res.map.info.height);
2187 memcpy(res.map.data.data(), pixels.data, res.map.info.width * res.map.info.height);
2199 float xMin=0.0f, yMin=0.0f, gridCellSize = 0.05f;
2205 res.map.info.resolution = gridCellSize;
2206 res.map.info.origin.position.x = 0.0;
2207 res.map.info.origin.position.y = 0.0;
2208 res.map.info.origin.position.z = 0.0;
2209 res.map.info.origin.orientation.x = 0.0;
2210 res.map.info.origin.orientation.y = 0.0;
2211 res.map.info.origin.orientation.z = 0.0;
2212 res.map.info.origin.orientation.w = 1.0;
2214 res.map.info.width = pixels.cols;
2215 res.map.info.height = pixels.rows;
2216 res.map.info.origin.position.x = xMin;
2217 res.map.info.origin.position.y = yMin;
2218 res.map.data.resize(res.map.info.width * res.map.info.height);
2220 memcpy(res.map.data.data(), pixels.data, res.map.info.width * res.map.info.height);
2237 std::map<int, Transform> poses;
2238 std::multimap<int, rtabmap::Link> constraints;
2239 std::map<int, Signature > signatures;
2263 rtabmap_ros::MapDataPtr msg(
new rtabmap_ros::MapData);
2264 msg->header.stamp = now;
2278 rtabmap_ros::MapGraphPtr msg(
new rtabmap_ros::MapGraph);
2279 msg->header.stamp = now;
2292 std::map<int, Transform> filteredPoses = poses;
2295 std::map<int, Transform> nearestPoses;
2296 std::vector<int> nodes = graph::findNearestNodes(filteredPoses, filteredPoses.rbegin()->second,
maxMappingNodes_);
2297 for(std::vector<int>::iterator iter=nodes.begin(); iter!=nodes.end(); ++iter)
2299 std::map<int, Transform>::iterator pter = filteredPoses.find(*iter);
2300 if(pter != filteredPoses.end())
2302 nearestPoses.insert(*pter);
2306 if(signatures.size())
2324 if(pubLabels || pubPath)
2326 if(poses.size() && signatures.size())
2328 visualization_msgs::MarkerArray markers;
2329 nav_msgs::Path path;
2332 path.poses.resize(poses.size());
2335 for(std::map<int, Signature>::const_iterator iter=signatures.begin();
2336 iter!=signatures.end();
2339 std::map<int, Transform>::const_iterator poseIter= poses.find(iter->first);
2340 if(poseIter!=poses.end())
2345 if(!iter->second.getLabel().empty())
2347 visualization_msgs::Marker marker;
2349 marker.header.stamp = now;
2350 marker.ns =
"labels";
2351 marker.id = -iter->first;
2352 marker.action = visualization_msgs::Marker::ADD;
2353 marker.pose.position.x = poseIter->second.x();
2354 marker.pose.position.y = poseIter->second.y();
2355 marker.pose.position.z = poseIter->second.z();
2356 marker.pose.orientation.x = 0.0;
2357 marker.pose.orientation.y = 0.0;
2358 marker.pose.orientation.z = 0.0;
2359 marker.pose.orientation.w = 1.0;
2362 marker.scale.z = 0.5;
2363 marker.color.a = 0.7;
2364 marker.color.r = 1.0;
2365 marker.color.g = 0.0;
2366 marker.color.b = 0.0;
2368 marker.type = visualization_msgs::Marker::TEXT_VIEW_FACING;
2369 marker.text = iter->second.getLabel();
2371 markers.markers.push_back(marker);
2374 visualization_msgs::Marker marker;
2376 marker.header.stamp = now;
2378 marker.id = iter->first;
2379 marker.action = visualization_msgs::Marker::ADD;
2380 marker.pose.position.x = poseIter->second.x();
2381 marker.pose.position.y = poseIter->second.y();
2382 marker.pose.position.z = poseIter->second.z();
2383 marker.pose.orientation.x = 0.0;
2384 marker.pose.orientation.y = 0.0;
2385 marker.pose.orientation.z = 0.0;
2386 marker.pose.orientation.w = 1.0;
2389 marker.scale.z = 0.2;
2390 marker.color.a = 0.5;
2391 marker.color.r = 1.0;
2392 marker.color.g = 1.0;
2393 marker.color.b = 1.0;
2396 marker.type = visualization_msgs::Marker::TEXT_VIEW_FACING;
2399 markers.markers.push_back(marker);
2405 path.poses.at(oi).header.stamp =
ros::Time(iter->second.getStamp());
2411 if(pubLabels && markers.markers.size())
2418 path.header.stamp = now;
2419 path.poses.resize(oi);
2427 UWARN(
"No subscribers, don't need to publish!");
2440 if(
mapFrameId_.compare(req.goal.header.frame_id) != 0)
2445 NODELET_ERROR(
"Cannot transform goal pose from \"%s\" frame to \"%s\" frame!",
2446 req.goal.header.frame_id.c_str(),
mapFrameId_.c_str());
2455 const std::vector<std::pair<int, Transform> > & poses =
rtabmap_.
getPath();
2458 if(poses.size() == 0)
2460 NODELET_WARN(
"Planning: Goal already reached (RGBD/GoalReachedRadius=%fm).",
2463 res.plan.poses.resize(1);
2468 res.plan.poses.resize(poses.size());
2470 for(std::vector<std::pair<int, Transform> >::const_iterator iter=poses.begin(); iter!=poses.end(); ++iter)
2472 res.plan.poses[oi].header = res.plan.header;
2478 res.plan.poses.resize(res.plan.poses.size()+1);
2484 std::stringstream stream;
2485 for(std::vector<std::pair<int, Transform> >::const_iterator iter=poses.begin(); iter!=poses.end(); ++iter)
2487 if(iter != poses.begin())
2491 stream << iter->first;
2493 NODELET_INFO(
"Planned path: [%s]", stream.str().c_str());
2503 double planningTime = 0.0;
2505 const std::vector<std::pair<int, Transform> > & path =
rtabmap_.
getPath();
2506 res.path_ids.resize(path.size());
2507 res.path_poses.resize(path.size());
2508 res.planning_time = planningTime;
2509 for(
unsigned int i=0; i<path.size(); ++i)
2511 res.path_ids[i] = path[i].first;
2528 std_msgs::Bool result;
2529 result.data =
false;
2547 NODELET_INFO(
"Set label \"%s\" to node %d", req.node_label.c_str(), req.node_id);
2551 NODELET_INFO(
"Set label \"%s\" to last node", req.node_label.c_str());
2558 NODELET_ERROR(
"Could not set label \"%s\" to node %d", req.node_label.c_str(), req.node_id);
2562 NODELET_ERROR(
"Could not set label \"%s\" to last node", req.node_label.c_str());
2574 NODELET_INFO(
"List labels service: %d labels found.", (
int)res.labels.size());
2581 UDEBUG(
"Publishing stats...");
2587 rtabmap_ros::InfoPtr msg(
new rtabmap_ros::Info);
2588 msg->header.stamp = stamp;
2597 rtabmap_ros::MapDataPtr msg(
new rtabmap_ros::MapData);
2598 msg->header.stamp = stamp;
2613 rtabmap_ros::MapGraphPtr msg(
new rtabmap_ros::MapGraph);
2614 msg->header.stamp = stamp;
2628 if(pubLabels || pubPath)
2632 visualization_msgs::MarkerArray markers;
2633 nav_msgs::Path path;
2636 path.poses.resize(stats.
poses().size());
2639 for(std::map<int, Signature>::const_iterator iter=stats.
getSignatures().begin();
2643 std::map<int, Transform>::const_iterator poseIter= stats.
poses().find(iter->first);
2644 if(poseIter!=stats.
poses().end())
2649 if(!iter->second.getLabel().empty())
2651 visualization_msgs::Marker marker;
2653 marker.header.stamp = stamp;
2654 marker.ns =
"labels";
2655 marker.id = -iter->first;
2656 marker.action = visualization_msgs::Marker::ADD;
2657 marker.pose.position.x = poseIter->second.x();
2658 marker.pose.position.y = poseIter->second.y();
2659 marker.pose.position.z = poseIter->second.z();
2660 marker.pose.orientation.x = 0.0;
2661 marker.pose.orientation.y = 0.0;
2662 marker.pose.orientation.z = 0.0;
2663 marker.pose.orientation.w = 1.0;
2666 marker.scale.z = 0.5;
2667 marker.color.a = 0.7;
2668 marker.color.r = 1.0;
2669 marker.color.g = 0.0;
2670 marker.color.b = 0.0;
2672 marker.type = visualization_msgs::Marker::TEXT_VIEW_FACING;
2673 marker.text = iter->second.getLabel();
2675 markers.markers.push_back(marker);
2678 visualization_msgs::Marker marker;
2680 marker.header.stamp = stamp;
2682 marker.id = iter->first;
2683 marker.action = visualization_msgs::Marker::ADD;
2684 marker.pose.position.x = poseIter->second.x();
2685 marker.pose.position.y = poseIter->second.y();
2686 marker.pose.position.z = poseIter->second.z();
2687 marker.pose.orientation.x = 0.0;
2688 marker.pose.orientation.y = 0.0;
2689 marker.pose.orientation.z = 0.0;
2690 marker.pose.orientation.w = 1.0;
2693 marker.scale.z = 0.2;
2694 marker.color.a = 0.5;
2695 marker.color.r = 1.0;
2696 marker.color.g = 1.0;
2697 marker.color.b = 1.0;
2700 marker.type = visualization_msgs::Marker::TEXT_VIEW_FACING;
2703 markers.markers.push_back(marker);
2709 path.poses.at(oi).header.stamp =
ros::Time(iter->second.getStamp());
2715 if(pubLabels && markers.markers.size())
2722 path.header.stamp = stamp;
2723 path.poses.resize(oi);
2737 geometry_msgs::PoseStamped poseMsg;
2739 poseMsg.header.stamp = stamp;
2746 NODELET_INFO(
"Connecting to move_base action server...");
2751 move_base_msgs::MoveBaseGoal goal;
2752 goal.target_pose = poseMsg;
2762 NODELET_ERROR(
"Cannot connect to move_base action server!");
2778 const move_base_msgs::MoveBaseResultConstPtr& result)
2780 bool ignore =
false;
2789 NODELET_WARN(
"Planning: move_base reached current goal but it is not " 2790 "the last one planned by rtabmap. A new goal should be sent when " 2791 "rtabmap will be able to retrieve next locations on the path.");
2801 NODELET_ERROR(
"Planning: move_base failed for some reason. Aborting the plan...");
2806 std_msgs::Bool result;
2843 nav_msgs::Path path;
2845 path.header.stamp = stamp;
2846 path.poses.resize(poses.size());
2848 for(std::vector<std::pair<int, Transform> >::iterator iter=poses.begin(); iter!=poses.end(); ++iter)
2850 path.poses[oi].header = path.header;
2870 nav_msgs::Path path;
2872 path.header.stamp = stamp;
2877 path.poses[oi].header = path.header;
2883 path.poses.resize(path.poses.size()+1);
2892 #ifdef WITH_OCTOMAP_MSGS 2893 #ifdef RTABMAP_OCTOMAP 2894 bool CoreWrapper::octomapBinaryCallback(
2895 octomap_msgs::GetOctomap::Request &req,
2896 octomap_msgs::GetOctomap::Response &res)
2898 NODELET_INFO(
"Sending binary map data on service request");
2905 std::map<int, Transform> nearestPoses;
2906 std::vector<int> nodes = graph::findNearestNodes(poses, poses.rbegin()->second,
maxMappingNodes_);
2907 for(std::vector<int>::iterator iter=nodes.begin(); iter!=nodes.end(); ++iter)
2909 std::map<int, Transform>::iterator pter = poses.find(*iter);
2910 if(pter != poses.end())
2912 nearestPoses.insert(*pter);
2915 poses = nearestPoses;
2925 bool CoreWrapper::octomapFullCallback(
2926 octomap_msgs::GetOctomap::Request &req,
2927 octomap_msgs::GetOctomap::Response &res)
2929 NODELET_INFO(
"Sending full map data on service request");
2936 std::map<int, Transform> nearestPoses;
2937 std::vector<int> nodes = graph::findNearestNodes(poses, poses.rbegin()->second,
maxMappingNodes_);
2938 for(std::vector<int>::iterator iter=nodes.begin(); iter!=nodes.end(); ++iter)
2940 std::map<int, Transform>::iterator pter = poses.find(*iter);
2941 if(pter != poses.end())
2943 nearestPoses.insert(*pter);
2946 poses = nearestPoses;
geometry_msgs::PoseWithCovarianceStamped globalPose_
ros::ServiceServer setLogErrorSrv_
bool convertScanMsg(const sensor_msgs::LaserScanConstPtr &scan2dMsg, const std::string &frameId, const std::string &odomFrameId, const ros::Time &odomStamp, cv::Mat &scan, rtabmap::Transform &scanLocalTransform, tf::TransformListener &listener, double waitForTransform)
ros::ServiceServer getMapDataSrv_
Transform getMapCorrection() const
cv::Mat RTABMAP_EXP disparityFromStereoImages(const cv::Mat &leftImage, const cv::Mat &rightImage, const ParametersMap ¶meters=ParametersMap())
CvImageConstPtr toCvShare(const sensor_msgs::ImageConstPtr &source, const std::string &encoding=std::string())
static std::string homeDir()
GLM_FUNC_DECL T roll(detail::tquat< T, P > const &x)
Subscriber subscribe(const std::string &base_topic, uint32_t queue_size, const boost::function< void(const sensor_msgs::ImageConstPtr &)> &callback, const ros::VoidPtr &tracked_object=ros::VoidPtr(), const TransportHints &transport_hints=TransportHints())
const Transform & getPathTransformToGoal() const
std::string getTopic() const
bool getMapDataCallback(rtabmap_ros::GetMap::Request &req, rtabmap_ros::GetMap::Response &res)
void set2DMap(const cv::Mat &map, float xMin, float yMin, float cellSize, const std::map< int, rtabmap::Transform > &poses, const rtabmap::Memory *memory=0)
std::map< int, rtabmap::Transform > getFilteredPoses(const std::map< int, rtabmap::Transform > &poses)
void get3DMap(std::map< int, Signature > &signatures, std::map< int, Transform > &poses, std::multimap< int, Link > &constraints, bool optimized, bool global) const
ros::ServiceServer getProjMapSrv_
ros::ServiceServer pauseSrv_
const V_string & getMyArgv() const
void defaultCallback(const sensor_msgs::ImageConstPtr &imageMsg)
void setParameters(const rtabmap::ParametersMap ¶meters)
void userDataAsyncCallback(const rtabmap_ros::UserDataConstPtr &dataMsg)
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::LaserScanConstPtr &scanMsg, const sensor_msgs::PointCloud2ConstPtr &scan3dMsg, const rtabmap_ros::OdomInfoConstPtr &odomInfoMsg)
bool waitForServer(const ros::Duration &timeout=ros::Duration(0, 0)) const
#define NODELET_ERROR(...)
ros::ServiceServer setLogDebugSrv_
const cv::Mat & localizationCovariance() const
rtabmap::Transform lastPose_
void clearPath(int status)
#define NODELET_WARN(...)
void publish(const boost::shared_ptr< M > &message) const
bool convertScan3dMsg(const sensor_msgs::PointCloud2ConstPtr &scan3dMsg, const std::string &frameId, const std::string &odomFrameId, const ros::Time &odomStamp, cv::Mat &scan, rtabmap::Transform &scanLocalTransform, tf::TransformListener &listener, double waitForTransform)
bool setLogWarn(std_srvs::Empty::Request &, std_srvs::Empty::Response &)
Transform getPose(int locationId) const
ros::ServiceServer publishMapDataSrv_
void goalDoneCb(const actionlib::SimpleClientGoalState &state, const move_base_msgs::MoveBaseResultConstPtr &result)
double odomDefaultLinVariance_
ros::ServiceServer setLogWarnSrv_
std::string uReplaceChar(const std::string &str, char before, char after)
image_transport::Subscriber defaultSub_
const std::map< int, Signature > & getSignatures() const
ros::ServiceServer resetSrv_
void mapGraphToROS(const std::map< int, rtabmap::Transform > &poses, const std::multimap< int, rtabmap::Link > &links, const rtabmap::Transform &mapToOdom, rtabmap_ros::MapGraph &msg)
bool computePath(int targetNode, bool global)
bool getProbMapCallback(nav_msgs::GetMap::Request &req, nav_msgs::GetMap::Response &res)
rtabmap::ParametersMap parameters_
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
bool createIntermediateNodes_
rtabmap::OdometryInfo odomInfoFromROS(const rtabmap_ros::OdomInfo &msg)
int uStrNumCmp(const std::string &a, const std::string &b)
void publishCurrentGoal(const ros::Time &stamp)
void saveParameters(const std::string &configFile)
bool resetRtabmapCallback(std_srvs::Empty::Request &, std_srvs::Empty::Response &)
bool deleteParam(const std::string &key) const
std::pair< std::string, std::string > ParametersPair
std::string resolveName(const std::string &name, bool remap=true) const
ros::ServiceServer getMapSrv_
bool setModeMappingCallback(std_srvs::Empty::Request &, std_srvs::Empty::Response &)
ros::ServiceServer getGridMapSrv_
rtabmap::Rtabmap rtabmap_
void setInitialPose(const Transform &initialPose)
bool labelLocation(int id, const std::string &label)
static bool fullMapToMsg(const OctomapT &octomap, Octomap &msg)
void goalFeedbackCb(const move_base_msgs::MoveBaseFeedbackConstPtr &feedback)
const rtabmap::OctoMap * getOctomap() const
void transformToGeometryMsg(const rtabmap::Transform &transform, geometry_msgs::Transform &msg)
static ParametersMap parseArguments(int argc, char *argv[], bool onlyParameters=false)
cv::Mat RTABMAP_EXP depthFromDisparity(const cv::Mat &disparity, float fx, float baseline, int type=CV_32FC1)
void publishLocalPath(const ros::Time &stamp)
static int erase(const std::string &filePath)
const std::string & getName() const
ros::Publisher localizationPosePub_
bool publishMapCallback(rtabmap_ros::PublishMap::Request &, rtabmap_ros::PublishMap::Response &)
void copy(const std::string &to)
rtabmap::Transform lastPublishedMetricGoal_
bool listLabelsCallback(rtabmap_ros::ListLabels::Request &req, rtabmap_ros::ListLabels::Response &res)
std::map< std::string, std::string > ParametersMap
cv::Mat getGridProbMap(float &xMin, float &yMin, float &gridCellSize)
float gridCellSize() const
ros::ServiceServer getProbMapSrv_
bool cancelGoalCallback(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res)
bool getPlanCallback(nav_msgs::GetPlan::Request &req, nav_msgs::GetPlan::Response &res)
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
float getGoalReachedRadius() const
const LaserScan & laserScanRaw() const
GLM_FUNC_DECL T pitch(detail::tquat< T, P > const &x)
std::string getDatabaseVersion() const
bool setLabelCallback(rtabmap_ros::SetLabel::Request &req, rtabmap_ros::SetLabel::Response &res)
bool lastPoseIntermediate_
std::vector< std::pair< int, Transform > > getPathNextPoses() const
void process(const ros::Time &stamp, const rtabmap::SensorData &data, const rtabmap::Transform &odom=rtabmap::Transform(), const std::string &odomFrameId="", const cv::Mat &odomCovariance=cv::Mat::eye(6, 6, CV_64FC1), const rtabmap::OdometryInfo &odomInfo=rtabmap::OdometryInfo())
int localBundleConstraints
static void setLevel(ULogger::Level level)
void commonDepthCallbackImpl(const std::string &odomFrameId, 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::LaserScanConstPtr &scan2dMsg, const sensor_msgs::PointCloud2ConstPtr &scan3dMsg, const rtabmap_ros::OdomInfoConstPtr &odomInfoMsg)
void getGraph(std::map< int, Transform > &poses, std::multimap< int, Link > &constraints, bool optimized, bool global, std::map< int, Signature > *signatures=0)
std::string databasePath_
rtabmap::Transform getTransform(const std::string &fromFrameId, const std::string &toFrameId, const ros::Time &stamp, tf::TransformListener &listener, double waitForTransform)
bool resumeRtabmapCallback(std_srvs::Empty::Request &, std_srvs::Empty::Response &)
static bool binaryMapToMsg(const OctomapT &octomap, Octomap &msg)
bool odomUpdate(const nav_msgs::OdometryConstPtr &odomMsg, ros::Time stamp)
std::string uBool2Str(bool boolean)
bool setLogDebug(std_srvs::Empty::Request &, std_srvs::Empty::Response &)
const std::map< int, Transform > & getLocalOptimizedPoses() 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::LaserScanConstPtr &scanMsg, const sensor_msgs::PointCloud2ConstPtr &scan3dMsg, const rtabmap_ros::OdomInfoConstPtr &odomInfoMsg)
ros::Publisher nextMetricGoalPub_
bool isIDsGenerated() const
void initialPoseCallback(const geometry_msgs::PoseWithCovarianceStampedConstPtr &msg)
ros::NodeHandle & getPrivateNodeHandle() const
ros::Subscriber initialPoseSub_
bool isServerConnected() const
cv::Mat RTABMAP_EXP laserScan2dFromPointCloud(const pcl::PointCloud< pcl::PointXYZ > &cloud, const Transform &transform=Transform(), bool filterNaNs=true)
void goalCallback(const geometry_msgs::PoseStampedConstPtr &msg)
bool uIsFinite(const T &value)
bool openConnection(const std::string &url, bool overwritten=false)
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::LaserScanConstPtr &scanMsg, const sensor_msgs::PointCloud2ConstPtr &scan3dMsg, const rtabmap_ros::OdomInfoConstPtr &odomInfoMsg)
#define UASSERT(condition)
ros::Publisher mapDataPub_
void init(ros::NodeHandle &nh, ros::NodeHandle &pnh, const std::string &name, bool usePublicNamespace)
void globalPoseAsyncCallback(const geometry_msgs::PoseWithCovarianceStampedConstPtr &globalPoseMsg)
ros::Subscriber globalPoseAsyncSub_
static std::string currentDir(bool trailingSeparator=false)
bool odomTFUpdate(const ros::Time &stamp)
const CameraModel & left() const
std::string uNumber2Str(unsigned int number)
void close(bool databaseSaved=true, const std::string &ouputDatabasePath="")
Connection registerCallback(C &callback)
std::string getTopic() const
ros::ServiceServer setModeMappingSrv_
ros::Subscriber userDataAsyncSub_
void publishGlobalPath(const ros::Time &stamp)
std::map< int, rtabmap::Transform > updateMapCaches(const std::map< int, rtabmap::Transform > &poses, const rtabmap::Memory *memory, bool updateGrid, bool updateOctomap, const std::map< int, rtabmap::Signature > &signatures=std::map< int, rtabmap::Signature >())
double odomDefaultAngVariance_
ros::ServiceServer updateSrv_
unsigned int getPathCurrentGoalIndex() const
bool latestNodeWasReached_
bool pauseRtabmapCallback(std_srvs::Empty::Request &, std_srvs::Empty::Response &)
ros::ServiceServer backupDatabase_
void setupCallbacks(ros::NodeHandle &nh, ros::NodeHandle &pnh, const std::string &name)
ros::ServiceServer setLogInfoSrv_
void mapDataToROS(const std::map< int, rtabmap::Transform > &poses, const std::multimap< int, rtabmap::Link > &links, const std::map< int, rtabmap::Signature > &signatures, const rtabmap::Transform &mapToOdom, rtabmap_ros::MapData &msg)
std::map< std::string, float > rtabmapROSStats_
bool setGoalCallback(rtabmap_ros::SetGoal::Request &req, rtabmap_ros::SetGoal::Response &res)
int getSignatureIdByLabel(const std::string &label, bool lookInDatabase=true) const
int getLastLocationId() const
bool getGridMapCallback(nav_msgs::GetMap::Request &req, nav_msgs::GetMap::Response &res)
bool updateRtabmapCallback(std_srvs::Empty::Request &, std_srvs::Empty::Response &)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
const Statistics & getStatistics() const
void loadParameters(const std::string &configFile, rtabmap::ParametersMap ¶meters)
const std::string TYPE_32FC1
bool isDataSubscribed() const
bool process(const SensorData &data, Transform odomPose, const cv::Mat &odomCovariance=cv::Mat::eye(6, 6, CV_64FC1), const std::vector< float > &odomVelocity=std::vector< float >(), const std::map< std::string, float > &externalStats=std::map< std::string, float >())
const std::string TYPE_16UC1
ros::ServiceServer setLabelSrv_
const RtabmapColorOcTree * octree() const
const rtabmap::OccupancyGrid * getOccupancyGrid() const
tf2_ros::TransformBroadcaster tfBroadcaster_
bool triggerNewMapCallback(std_srvs::Empty::Request &, std_srvs::Empty::Response &)
bool isApproxSync() const
void save2DMap(const cv::Mat &map, float xMin, float yMin, float cellSize) const
QMap< QString, QVariant > ParametersMap
message_filters::Subscriber< nav_msgs::Odometry > rgbOdomSub_
float getTimeThreshold() const
boost::mutex mapToOdomMutex_
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
bool uStr2Bool(const char *str)
ros::ServiceServer cancelGoalSrv_
bool convertStereoMsg(const cv_bridge::CvImageConstPtr &leftImageMsg, const cv_bridge::CvImageConstPtr &rightImageMsg, const sensor_msgs::CameraInfo &leftCamInfoMsg, const sensor_msgs::CameraInfo &rightCamInfoMsg, const std::string &frameId, const std::string &odomFrameId, const ros::Time &odomStamp, cv::Mat &left, cv::Mat &right, rtabmap::StereoCameraModel &stereoModel, tf::TransformListener &listener, double waitForTransform)
ros::NodeHandle & getNodeHandle() const
tf::TransformListener tfListener_
bool setModeLocalizationCallback(std_srvs::Empty::Request &, std_srvs::Empty::Response &)
void init(const ParametersMap ¶meters, const std::string &databasePath="")
std::list< V > uValues(const std::multimap< K, V > &mm)
void goalNodeCallback(const rtabmap_ros::GoalConstPtr &msg)
rtabmap::Transform transformFromPoseMsg(const geometry_msgs::Pose &msg)
bool getProjMapCallback(nav_msgs::GetMap::Request &req, nav_msgs::GetMap::Response &res)
bool uContains(const std::list< V > &list, const V &value)
static DBDriver * create(const ParametersMap ¶meters=ParametersMap())
void parseParameters(const ParametersMap ¶meters)
cv::Mat userDataFromROS(const rtabmap_ros::UserData &dataMsg)
rtabmap::Transform mapToOdom_
void transformToPoseMsg(const rtabmap::Transform &transform, geometry_msgs::Pose &msg)
void subscribe(ImageTransport &it, const std::string &base_topic, uint32_t queue_size, const TransportHints &transport_hints=TransportHints())
int getLastSignatureId() const
const std::map< int, Transform > & poses() const
void publishMaps(const std::map< int, rtabmap::Transform > &poses, const ros::Time &stamp, const std::string &mapFrameId)
void sendGoal(const Goal &goal, SimpleDoneCallback done_cb=SimpleDoneCallback(), SimpleActiveCallback active_cb=SimpleActiveCallback(), SimpleFeedbackCallback feedback_cb=SimpleFeedbackCallback())
#define NODELET_INFO(...)
bool getMapCallback(nav_msgs::GetMap::Request &req, nav_msgs::GetMap::Response &res)
uint32_t getNumSubscribers() const
SensorData & sensorData()
int getPathStatus() const
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)
const std::vector< std::pair< int, Transform > > & getPath() const
const Signature * getLastWorkingSignature() const
std::map< int, std::string > getAllLabels() const
const std::multimap< int, Link > & constraints() const
bool hasSubscribers() const
bool getParam(const std::string &key, std::string &s) const
boost::thread * transformThread_
rtabmap::Transform currentMetricGoal_
message_filters::Subscriber< sensor_msgs::CameraInfo > rgbCameraInfoSub_
image_transport::SubscriberFilter rgbSub_
ParametersMap getLastParameters() const
bool setLogError(std_srvs::Empty::Request &, std_srvs::Empty::Response &)
cv::Mat load2DMap(float &xMin, float &yMin, float &cellSize) const
const Memory * getMemory() const
ros::Subscriber goalNodeSub_
ros::ServiceServer listLabelsSrv_
double timestampFromROS(const ros::Time &stamp)
GLM_FUNC_DECL T yaw(detail::tquat< T, P > const &x)
float uStr2Float(const std::string &str)
ros::Publisher labelsPub_
bool setLogInfo(std_srvs::Empty::Request &, std_srvs::Empty::Response &)
ros::Publisher mapPathPub_
PLUGINLIB_EXPORT_CLASS(rtabmap_ros::CoreWrapper, nodelet::Nodelet)
const Transform & getLastLocalizationPose() const
void setGroundTruth(const Transform &pose)
cv::Mat RTABMAP_EXP cvtDepthFromFloat(const cv::Mat &depth32F)
cv::Mat getGridMap(float &xMin, float &yMin, float &gridCellSize)
ros::Publisher localPathPub_
bool hasParam(const std::string &key) const
double waitForTransformDuration_
std::string groundTruthFrameId_
const Transform & mapCorrection() const
bool backupDatabaseCallback(std_srvs::Empty::Request &, std_srvs::Empty::Response &)
ros::ServiceServer getPlanSrv_
bool isGridFromDepth() const
void setParam(const std::string &key, const XmlRpc::XmlRpcValue &v) const
int getPathCurrentGoalId() const
void publishStats(const ros::Time &stamp)
ros::ServiceServer setGoalSrv_
void publishLoop(double tfDelay, double tfTolerance)
ros::Publisher globalPathPub_
std::string getTopic() const
std::vector< int > getPathNextNodes() const
std::string groundTruthBaseFrameId_
ros::ServiceServer setModeLocalizationSrv_
ros::Publisher goalReachedPub_
float getLocalRadius() const
bool convertRGBDMsgs(const std::vector< cv_bridge::CvImageConstPtr > &imageMsgs, const std::vector< cv_bridge::CvImageConstPtr > &depthMsgs, const std::vector< sensor_msgs::CameraInfo > &cameraInfoMsgs, const std::string &frameId, const std::string &odomFrameId, const ros::Time &odomStamp, cv::Mat &rgb, cv::Mat &depth, std::vector< rtabmap::CameraModel > &cameraModels, tf::TransformListener &listener, double waitForTransform)
V uValue(const std::map< K, V > &m, const K &key, const V &defaultValue=V())
void goalCommonCallback(int id, const std::string &label, const rtabmap::Transform &pose, const ros::Time &stamp, double *planningTime=0)
#define SYNC_INIT(PREFIX)
void infoToROS(const rtabmap::Statistics &stats, rtabmap_ros::Info &info)
ros::ServiceServer triggerNewMapSrv_
ros::Publisher mapGraphPub_
void uInsert(std::map< K, V > &map, const std::pair< K, V > &pair)
ros::ServiceServer resumeSrv_
void backwardCompatibilityParameters(ros::NodeHandle &pnh, rtabmap::ParametersMap ¶meters) const