30 #include <opencv2/highgui/highgui.hpp> 64 Eigen::Affine3d eigenTf;
76 long double recipNorm = 1.0 /
sqrt(msg.rotation.x * msg.rotation.x + msg.rotation.y * msg.rotation.y + msg.rotation.z * msg.rotation.z + msg.rotation.w * msg.rotation.w);
77 msg.rotation.x *= recipNorm;
78 msg.rotation.y *= recipNorm;
79 msg.rotation.z *= recipNorm;
80 msg.rotation.w *= recipNorm;
84 msg = geometry_msgs::Transform();
91 if(msg.rotation.w == 0 &&
92 msg.rotation.x == 0 &&
93 msg.rotation.y == 0 &&
99 Eigen::Affine3d tfTransform;
112 msg = geometry_msgs::Pose();
118 if(msg.orientation.w == 0 &&
119 msg.orientation.x == 0 &&
120 msg.orientation.y == 0 &&
121 msg.orientation.z == 0)
123 if(ignoreRotationIfNotSet)
129 Eigen::Affine3d tfPose;
136 if(!image.rgb.data.empty())
140 else if(!image.rgb_compressed.data.empty())
142 #ifdef CV_BRIDGE_HYDRO 143 ROS_ERROR(
"Unsupported compressed image copy, please upgrade at least to ROS Indigo to use this.");
149 if(!image.depth.data.empty())
153 else if(!image.depth_compressed.data.empty())
156 ptr->header = image.depth_compressed.header;
158 ROS_ASSERT(ptr->image.empty() || ptr->image.type() == CV_32FC1 || ptr->image.type() == CV_16UC1);
166 if(!image->rgb.data.empty())
170 else if(!image->rgb_compressed.data.empty())
172 #ifdef CV_BRIDGE_HYDRO 173 ROS_ERROR(
"Unsupported compressed image copy, please upgrade at least to ROS Indigo to use this.");
179 if(!image->depth.data.empty())
183 else if(!image->depth_compressed.data.empty())
185 if(image->depth_compressed.format.compare(
"jpg")==0)
187 #ifdef CV_BRIDGE_HYDRO 188 ROS_ERROR(
"Unsupported compressed image copy, please upgrade at least to ROS Indigo to use this.");
196 ptr->header = image->depth_compressed.header;
198 ROS_ASSERT(ptr->image.empty() || ptr->image.type() == CV_32FC1 || ptr->image.type() == CV_16UC1);
207 std_msgs::Header header;
208 header.frame_id = sensorFrameId;
213 UERROR(
"Cannot convert multi-camera data to rgbd image");
220 msg.rgb_camera_info.header = header;
221 localTransform = data.
cameraModels().front().localTransform();
228 msg.rgb_camera_info.header = header;
229 msg.depth_camera_info.header = header;
244 ROS_ERROR(
"Conversion of compressed SensorData to RGBDImage is not implemented...");
258 ROS_ERROR(
"Conversion of compressed SensorData to RGBDImage is not implemented...");
277 msg.global_descriptor.header = header;
303 ROS_ERROR(
"Input type must be image=mono8,mono16,rgb8,bgr8 (mono8 recommended), received types are %s (left) and %s (right)",
304 imageRectLeft->encoding.c_str(), imageRectRight->encoding.c_str());
308 if(!imageRectLeft->image.empty() && !imageRectRight->image.empty())
312 static bool shown =
false;
315 ROS_WARN(
"Detected baseline (%f m) is quite large! Is your " 316 "right camera_info P(0,3) correctly set? Note that " 317 "baseline=-P(0,3)/P(0,0). This warning is printed only once.",
346 ROS_WARN(
"Odom: input images empty?!?");
352 int imageWidth = imageMsg->image.cols;
353 int imageHeight = imageMsg->image.rows;
354 int depthWidth = depthMsg->image.cols;
355 int depthHeight = depthMsg->image.rows;
358 imageWidth % depthWidth == 0 && imageHeight % depthHeight == 0 &&
359 imageWidth/depthWidth == imageHeight/depthHeight,
360 uFormat(
"rgb=%dx%d depth=%dx%d", imageWidth, imageHeight, depthWidth, depthHeight).c_str());
378 ROS_ERROR(
"Input type must be image=mono8,mono16,rgb8,bgr8,bgra8,rgba8 and " 379 "image_depth=32FC1,16UC1,mono16. Current rgb=%s and depth=%s",
380 imageMsg->encoding.c_str(),
381 depthMsg->encoding.c_str());
415 UASSERT(compressed.empty() || compressed.type() == CV_8UC1);
417 if(!compressed.empty())
419 bytes.resize(compressed.cols * compressed.rows);
420 memcpy(bytes.data(), compressed.data, bytes.size());
429 out = cv::Mat(1, bytes.size(), CV_8UC1, (
void*)bytes.data());
446 stat.
setStamp(info.header.stamp.toSec());
454 std::map<int, float> mapIntFloat;
455 for(
unsigned int i=0; i<info.posteriorKeys.size() && i<info.posteriorValues.size(); ++i)
457 mapIntFloat.insert(std::pair<int, float>(info.posteriorKeys.at(i), info.posteriorValues.at(i)));
462 for(
unsigned int i=0; i<info.likelihoodKeys.size() && i<info.likelihoodValues.size(); ++i)
464 mapIntFloat.insert(std::pair<int, float>(info.likelihoodKeys.at(i), info.likelihoodValues.at(i)));
469 for(
unsigned int i=0; i<info.rawLikelihoodKeys.size() && i<info.rawLikelihoodValues.size(); ++i)
471 mapIntFloat.insert(std::pair<int, float>(info.rawLikelihoodKeys.at(i), info.rawLikelihoodValues.at(i)));
475 std::map<int, int> mapIntInt;
476 for(
unsigned int i=0; i<info.weightsKeys.size() && i<info.weightsValues.size(); ++i)
478 mapIntInt.insert(std::pair<int, int>(info.weightsKeys.at(i), info.weightsValues.at(i)));
482 std::map<int, std::string> mapIntStr;
483 for(
unsigned int i=0; i<info.labelsKeys.size() && i<info.labelsValues.size(); ++i)
485 mapIntStr.insert(std::pair<int, std::string>(info.labelsKeys.at(i), info.labelsValues.at(i)));
493 for(
unsigned int i=0; i<info.statsKeys.size() && i<info.statsValues.size(); i++)
495 stat.
addStatistic(info.statsKeys.at(i), info.statsValues.at(i));
504 info.landmarkId =
static_cast<int>(
uValue(stats.
data(), rtabmap::Statistics::kLoopLandmark_detected(), 0.0f));
512 info.wmState = stats.
wmState();
536 cv::Mat information = cv::Mat(6,6,CV_64FC1, (
void*)msg.information.data()).clone();
542 msg.fromId = link.
from();
543 msg.toId = link.
to();
544 msg.type = link.
type();
547 memcpy(msg.information.data(), link.
infMatrix().data, 36*
sizeof(double));
554 return cv::KeyPoint(msg.pt.x, msg.pt.y, msg.size, msg.angle, msg.response, msg.octave, msg.class_id);
559 msg.angle = kpt.angle;
560 msg.class_id = kpt.class_id;
561 msg.octave = kpt.octave;
564 msg.response = kpt.response;
570 std::vector<cv::KeyPoint> v(msg.size());
571 for(
unsigned int i=0; i<msg.size(); ++i)
578 void keypointsFromROS(
const std::vector<rtabmap_ros::KeyPoint> & msg, std::vector<cv::KeyPoint> & kpts,
int xShift)
580 size_t outCurrentIndex = kpts.size();
581 kpts.resize(kpts.size()+msg.size());
582 for(
unsigned int i=0; i<msg.size(); ++i)
585 kpts[outCurrentIndex+i].pt.x += xShift;
589 void keypointsToROS(
const std::vector<cv::KeyPoint> & kpts, std::vector<rtabmap_ros::KeyPoint> & msg)
591 msg.resize(kpts.size());
592 for(
unsigned int i=0; i<msg.size(); ++i)
605 msg.type = desc.
type();
614 std::vector<rtabmap::GlobalDescriptor> v(msg.size());
615 for(
unsigned int i=0; i<msg.size(); ++i)
621 return std::vector<rtabmap::GlobalDescriptor>();
624 void globalDescriptorsToROS(
const std::vector<rtabmap::GlobalDescriptor> & desc, std::vector<rtabmap_ros::GlobalDescriptor> & msg)
629 msg.resize(desc.size());
630 for(
unsigned int i=0; i<msg.size(); ++i)
644 msg.type = sensor.
type();
645 msg.value = sensor.
value();
654 for(
unsigned int i=0; i<msg.size(); ++i)
668 msg.resize(sensors.size());
670 for(rtabmap::EnvSensors::const_iterator iter=sensors.begin(); iter!=sensors.end(); ++iter)
679 return cv::Point2f(msg.x, msg.y);
688 std::vector<cv::Point2f>
points2fFromROS(
const std::vector<rtabmap_ros::Point2f> & msg)
690 std::vector<cv::Point2f> v(msg.size());
691 for(
unsigned int i=0; i<msg.size(); ++i)
698 void points2fToROS(
const std::vector<cv::Point2f> & kpts, std::vector<rtabmap_ros::Point2f> & msg)
700 msg.resize(kpts.size());
701 for(
unsigned int i=0; i<msg.size(); ++i)
709 return cv::Point3f(msg.x, msg.y, msg.z);
722 std::vector<cv::Point3f> v(msg.size());
723 for(
unsigned int i=0; i<msg.size(); ++i)
737 points3.resize(points3.size()+msg.size());
739 for(
unsigned int i=0; i<msg.size(); ++i)
751 msg.resize(pts.size());
753 for(
unsigned int i=0; i<msg.size(); ++i)
768 const sensor_msgs::CameraInfo & camInfo,
772 UASSERT(camInfo.K.empty() || camInfo.K.size() == 9);
773 if(!camInfo.K.empty())
775 K = cv::Mat(3, 3, CV_64FC1);
776 memcpy(K.data, camInfo.K.elems, 9*
sizeof(
double));
782 if(camInfo.D.size()>=4 &&
786 D = cv::Mat::zeros(1, 6, CV_64FC1);
787 D.at<
double>(0,0) = camInfo.D[0];
788 D.at<
double>(0,1) = camInfo.D[1];
789 D.at<
double>(0,4) = camInfo.D[2];
790 D.at<
double>(0,5) = camInfo.D[3];
794 D = cv::Mat(1, camInfo.D.size(), CV_64FC1);
795 memcpy(D.data, camInfo.D.data(), D.cols*
sizeof(double));
800 UASSERT(camInfo.R.empty() || camInfo.R.size() == 9);
801 if(!camInfo.R.empty())
803 R = cv::Mat(3, 3, CV_64FC1);
804 memcpy(R.data, camInfo.R.elems, 9*
sizeof(
double));
808 UASSERT(camInfo.P.empty() || camInfo.P.size() == 12);
809 if(!camInfo.P.empty())
811 P = cv::Mat(3, 4, CV_64FC1);
812 memcpy(P.data, camInfo.P.elems, 12*
sizeof(
double));
817 cv::Size(camInfo.width, camInfo.height),
823 sensor_msgs::CameraInfo & camInfo)
826 if(model.
K_raw().empty())
828 memset(camInfo.K.elems, 0.0, 9*
sizeof(
double));
832 memcpy(camInfo.K.elems, model.
K_raw().data, 9*
sizeof(double));
835 if(camInfo.D.size() == 6)
837 camInfo.D = std::vector<double>(4);
838 camInfo.D[0] = model.
D_raw().at<
double>(0,0);
839 camInfo.D[1] = model.
D_raw().at<
double>(0,1);
840 camInfo.D[2] = model.
D_raw().at<
double>(0,4);
841 camInfo.D[3] = model.
D_raw().at<
double>(0,5);
842 camInfo.distortion_model =
"equidistant";
846 camInfo.D = std::vector<double>(model.
D_raw().cols);
847 memcpy(camInfo.D.data(), model.
D_raw().data, model.
D_raw().cols*
sizeof(double));
848 if(camInfo.D.size() > 5)
850 camInfo.distortion_model =
"rational_polynomial";
854 camInfo.distortion_model =
"plumb_bob";
858 UASSERT(model.
R().empty() || model.
R().total() == 9);
859 if(model.
R().empty())
861 memset(camInfo.R.elems, 0.0, 9*
sizeof(
double));
865 memcpy(camInfo.R.elems, model.
R().data, 9*
sizeof(double));
868 UASSERT(model.
P().empty() || model.
P().total() == 12);
869 if(model.
P().empty())
871 memset(camInfo.P.elems, 0.0, 12*
sizeof(
double));
875 memcpy(camInfo.P.elems, model.
P().data, 12*
sizeof(double));
878 camInfo.binning_x = 1;
879 camInfo.binning_y = 1;
887 const sensor_msgs::CameraInfo & leftCamInfo,
888 const sensor_msgs::CameraInfo & rightCamInfo,
899 const sensor_msgs::CameraInfo & leftCamInfo,
900 const sensor_msgs::CameraInfo & rightCamInfo,
903 double waitForTransform)
907 leftCamInfo.header.frame_id,
908 leftCamInfo.header.stamp,
911 if(localTransform.
isNull())
917 leftCamInfo.header.frame_id,
918 rightCamInfo.header.frame_id,
919 leftCamInfo.header.stamp,
922 if(stereoTransform.
isNull())
930 const rtabmap_ros::MapData & msg,
931 std::map<int, rtabmap::Transform> & poses,
932 std::multimap<int, rtabmap::Link> & links,
933 std::map<int, rtabmap::Signature> & signatures,
940 for(
unsigned int i=0; i<msg.nodes.size(); ++i)
942 signatures.insert(std::make_pair(msg.nodes[i].id,
nodeDataFromROS(msg.nodes[i])));
946 const std::map<int, rtabmap::Transform> & poses,
947 const std::multimap<int, rtabmap::Link> & links,
948 const std::map<int, rtabmap::Signature> & signatures,
950 rtabmap_ros::MapData & msg)
956 msg.nodes.resize(signatures.size());
958 for(std::multimap<int, rtabmap::Signature>::const_iterator iter = signatures.begin();
959 iter!=signatures.end();
967 const rtabmap_ros::MapGraph & msg,
968 std::map<int, rtabmap::Transform> & poses,
969 std::multimap<int, rtabmap::Link> & links,
973 UASSERT(msg.posesId.size() == msg.poses.size());
974 for(
unsigned int i=0; i<msg.posesId.size(); ++i)
978 for(
unsigned int i=0; i<msg.links.size(); ++i)
981 links.insert(std::make_pair(msg.links[i].fromId,
linkFromROS(msg.links[i])));
986 const std::map<int, rtabmap::Transform> & poses,
987 const std::multimap<int, rtabmap::Link> & links,
989 rtabmap_ros::MapGraph & msg)
992 msg.posesId.resize(poses.size());
993 msg.poses.resize(poses.size());
995 for(std::map<int, rtabmap::Transform>::const_iterator iter = poses.begin();
999 msg.posesId[index] = iter->first;
1004 msg.links.resize(links.size());
1006 for(std::multimap<int, rtabmap::Link>::const_iterator iter = links.begin();
1010 linkToROS(iter->second, msg.links[index++]);
1019 std::multimap<int, int> words;
1020 std::vector<cv::KeyPoint> wordsKpts;
1021 std::vector<cv::Point3f> words3D;
1024 if(!msg.wordKpts.empty() && msg.wordKpts.size() != msg.wordIds.size())
1026 ROS_ERROR(
"Word IDs and 2D keypoints should be the same size (%d, %d)!", (
int)msg.wordIds.size(), (int)msg.wordKpts.size());
1028 if(!msg.wordPts.empty() && msg.wordPts.size() != msg.wordIds.size())
1030 ROS_ERROR(
"Word IDs and 3D points should be the same size (%d, %d)!", (
int)msg.wordIds.size(), (int)msg.wordPts.size());
1032 if(wordsDescriptors.rows != (
int)msg.wordIds.size())
1034 ROS_ERROR(
"Word IDs and descriptors should be the same size (%d, %d)!", (
int)msg.wordIds.size(), wordsDescriptors.rows);
1035 wordsDescriptors = cv::Mat();
1038 for(
unsigned int i=0; i<msg.wordIds.size(); ++i)
1040 words.insert(std::make_pair(msg.wordIds.at(i), words.size()));
1041 if(msg.wordIds.size() == msg.wordKpts.size())
1044 wordsKpts.push_back(pt);
1046 if(msg.wordIds.size() == msg.wordPts.size())
1053 std::vector<rtabmap::CameraModel> models;
1054 if(msg.baseline > 0.0f)
1057 if(msg.fx.size() == 1 &&
1058 msg.fy.size() == 1 &&
1059 msg.cx.size() == 1 &&
1060 msg.cy.size() == 1 &&
1061 msg.width.size() == 1 &&
1062 msg.height.size() == 1 &&
1063 msg.localTransform.size() == 1)
1072 cv::Size(msg.width[0], msg.height[0]));
1079 msg.fx.size() == msg.fy.size() &&
1080 msg.fx.size() == msg.cx.size() &&
1081 msg.fx.size() == msg.cy.size() &&
1082 msg.fx.size() == msg.localTransform.size())
1084 for(
unsigned int i=0; i<msg.fx.size(); ++i)
1099 cv::Size(msg.width[i], msg.height[i])));
1116 msg.laserScanMaxPts,
1117 msg.laserScanMaxRange,
1128 msg.laserScanMaxPts,
1129 msg.laserScanMaxRange,
1138 s.setWords(words, wordsKpts, words3D, wordsDescriptors);
1141 s.sensorData().setOccupancyGrid(
1147 s.sensorData().setGPS(
rtabmap::GPS(msg.gps.stamp, msg.gps.longitude, msg.gps.latitude, msg.gps.altitude, msg.gps.error, msg.gps.bearing));
1153 msg.id = signature.
id();
1154 msg.mapId = signature.
mapId();
1209 msg.localTransform.resize(1);
1217 if(msg.wordIds.size() == signature.
getWordsKpts().size())
1223 ROS_ERROR(
"Word IDs and 2D keypoints must have the same size (%d vs %d)!",
1231 if(msg.wordIds.size() == signature.
getWords3().size())
1233 msg.wordPts.resize(signature.
getWords3().size());
1237 ROS_ERROR(
"Word IDs and 3D points must have the same size (%d vs %d)!",
1242 if(!msg.wordKpts.empty() || !msg.wordPts.empty())
1244 for(
size_t i=0; i<msg.wordIds.size(); ++i)
1246 if(!msg.wordKpts.empty())
1248 if(!msg.wordPts.empty())
1261 ROS_ERROR(
"Word IDs and descriptors must have the same size (%d vs %d)!",
1286 msg.id = signature.
id();
1287 msg.mapId = signature.
mapId();
1297 std::map<std::string, float> stats;
1299 stats.insert(std::make_pair(
"Odometry/TimeRegistration/ms", info.
reg.
totalTime*1000.0f));
1300 stats.insert(std::make_pair(
"Odometry/RAM_usage/MB", info.
memoryUsage));
1303 stats.insert(std::make_pair(
"Odometry/Features/", info.
features));
1304 stats.insert(std::make_pair(
"Odometry/Matches/", info.
reg.
matches));
1306 stats.insert(std::make_pair(
"Odometry/Inliers/", info.
reg.
inliers));
1309 stats.insert(std::make_pair(
"Odometry/InliersRatio/", info.
reg.
inliers));
1311 stats.insert(std::make_pair(
"Odometry/ICPRotation/rad", info.
reg.
icpRotation));
1312 stats.insert(std::make_pair(
"Odometry/ICPTranslation/m", info.
reg.
icpTranslation));
1316 stats.insert(std::make_pair(
"Odometry/StdDevLin/",
sqrt((
float)info.
reg.
covariance.at<
double>(0,0))));
1317 stats.insert(std::make_pair(
"Odometry/StdDevAng/",
sqrt((
float)info.
reg.
covariance.at<
double>(5,5))));
1318 stats.insert(std::make_pair(
"Odometry/VarianceLin/", (
float)info.
reg.
covariance.at<
double>(0,0)));
1319 stats.insert(std::make_pair(
"Odometry/VarianceAng/", (
float)info.
reg.
covariance.at<
double>(5,5)));
1320 stats.insert(std::make_pair(
"Odometry/TimeEstimation/ms", info.
timeEstimation*1000.0f));
1322 stats.insert(std::make_pair(
"Odometry/LocalMapSize/", info.
localMapSize));
1323 stats.insert(std::make_pair(
"Odometry/LocalScanMapSize/", info.
localScanMapSize));
1324 stats.insert(std::make_pair(
"Odometry/LocalKeyFrames/", info.
localKeyFrames));
1327 stats.insert(std::make_pair(
"Odometry/LocalBundleTime/ms", info.
localBundleTime*1000.0f));
1328 stats.insert(std::make_pair(
"Odometry/KeyFrameAdded/", info.
keyFrameAdded?1.0f:0.0f));
1329 stats.insert(std::make_pair(
"Odometry/Interval/ms", (
float)info.
interval));
1333 float dist = 0.0f, speed=0.0f;
1338 stats.insert(std::make_pair(
"Odometry/T/m", dist));
1339 stats.insert(std::make_pair(
"Odometry/Tx/m", x));
1340 stats.insert(std::make_pair(
"Odometry/Ty/m", y));
1341 stats.insert(std::make_pair(
"Odometry/Tz/m", z));
1342 stats.insert(std::make_pair(
"Odometry/Troll/deg", roll*180.0/CV_PI));
1343 stats.insert(std::make_pair(
"Odometry/Tpitch/deg", pitch*180.0/CV_PI));
1344 stats.insert(std::make_pair(
"Odometry/Tyaw/deg", yaw*180.0/CV_PI));
1349 stats.insert(std::make_pair(
"Odometry/Speed/kph", speed*3.6));
1350 stats.insert(std::make_pair(
"Odometry/Speed/mph", speed*2.237));
1351 stats.insert(std::make_pair(
"Odometry/Speed/mps", speed));
1359 stats.insert(std::make_pair(
"Odometry/TG_error_lin/m", diff.
getNorm()));
1360 stats.insert(std::make_pair(
"Odometry/TG_error_ang/deg", diff.
getAngle()*180.0/CV_PI));
1365 stats.insert(std::make_pair(
"Odometry/TG/m", dist));
1366 stats.insert(std::make_pair(
"Odometry/TGx/m", x));
1367 stats.insert(std::make_pair(
"Odometry/TGy/m", y));
1368 stats.insert(std::make_pair(
"Odometry/TGz/m", z));
1369 stats.insert(std::make_pair(
"Odometry/TGroll/deg", roll*180.0/CV_PI));
1370 stats.insert(std::make_pair(
"Odometry/TGpitch/deg", pitch*180.0/CV_PI));
1371 stats.insert(std::make_pair(
"Odometry/TGyaw/deg", yaw*180.0/CV_PI));
1376 stats.insert(std::make_pair(
"Odometry/SpeedG/kph", speed*3.6));
1377 stats.insert(std::make_pair(
"Odometry/SpeedG/mph", speed*2.237));
1378 stats.insert(std::make_pair(
"Odometry/SpeedG/mps", speed));
1387 info.
lost = msg.lost;
1396 info.
reg.
covariance = cv::Mat(6,6,CV_64FC1, (
void*)msg.covariance.data()).clone();
1407 info.
stamp = msg.stamp;
1414 info.
type = msg.type;
1416 UASSERT(msg.wordsKeys.size() == msg.wordsValues.size());
1417 for(
unsigned int i=0; i<msg.wordsKeys.size(); ++i)
1434 UASSERT(msg.localMapKeys.size() == msg.localMapValues.size());
1435 for(
unsigned int i=0; i<msg.localMapKeys.size(); ++i)
1446 msg.lost = info.
lost;
1457 memcpy(msg.covariance.data(), info.
reg.
covariance.data, 36*
sizeof(double));
1469 msg.stamp = info.
stamp;
1476 msg.type = info.
type;
1503 if(!dataMsg.data.empty())
1505 if(dataMsg.cols > 0 && dataMsg.rows > 0 && dataMsg.type >= 0)
1507 data = cv::Mat(dataMsg.rows, dataMsg.cols, dataMsg.type, (
void*)dataMsg.data.data()).clone();
1511 if(dataMsg.cols != (
int)dataMsg.data.size() || dataMsg.rows != 1 || dataMsg.type != CV_8UC1)
1513 ROS_ERROR(
"cols, rows and type fields of the UserData msg " 1514 "are not correctly set (cols=%d, rows=%d, type=%d)! We assume that the data " 1515 "is compressed (cols=%d, rows=1, type=%d(CV_8UC1)).",
1516 dataMsg.cols, dataMsg.rows, dataMsg.type, (
int)dataMsg.data.size(), CV_8UC1);
1519 data = cv::Mat(1, dataMsg.data.size(), CV_8UC1, (
void*)dataMsg.data.data()).clone();
1524 void userDataToROS(
const cv::Mat & data, rtabmap_ros::UserData & dataMsg,
bool compress)
1532 dataMsg.cols = dataMsg.data.size();
1533 dataMsg.type = CV_8UC1;
1537 dataMsg.data.resize(data.step[0] * data.rows);
1538 memcpy(dataMsg.data.data(), data.data, dataMsg.data.size());
1539 dataMsg.rows = data.rows;
1540 dataMsg.cols = data.cols;
1541 dataMsg.type = data.type();
1547 const std::map<int, geometry_msgs::PoseWithCovarianceStamped> & tags,
1549 const std::string & odomFrameId,
1552 double waitForTransform,
1553 double defaultLinVariance,
1554 double defaultAngVariance)
1558 for(std::map<int, geometry_msgs::PoseWithCovarianceStamped>::const_iterator iter=tags.begin(); iter!=tags.end(); ++iter)
1562 ROS_ERROR(
"Invalid landmark received! IDs should be > 0 (it is %d). Ignoring this landmark.", iter->first);
1567 iter->second.header.frame_id,
1568 iter->second.header.stamp,
1572 if(baseToCamera.
isNull())
1574 ROS_ERROR(
"Cannot transform tag pose from \"%s\" frame to \"%s\" frame!",
1575 iter->second.header.frame_id.c_str(), frameId.c_str());
1587 iter->second.header.stamp,
1593 baseToTag = correction * baseToTag;
1597 ROS_WARN(
"Could not adjust tag pose accordingly to latest odometry pose. " 1598 "If odometry is small since it received the tag pose and " 1599 "covariance is large, this should not be a problem.");
1601 cv::Mat
covariance = cv::Mat(6,6, CV_64FC1, (
void*)iter->second.pose.covariance.data()).clone();
1602 if(covariance.empty() || !
uIsFinite(covariance.at<
double>(0,0)) || covariance.at<
double>(0,0)<=0.0
f)
1604 covariance = cv::Mat::eye(6,6,CV_64FC1);
1605 covariance(cv::Range(0,3), cv::Range(0,3)) *= defaultLinVariance;
1606 covariance(cv::Range(3,6), cv::Range(3,6)) *= defaultAngVariance;
1608 landmarks.insert(std::make_pair(iter->first,
rtabmap::Landmark(iter->first, baseToTag, covariance)));
1615 const std::string & fromFrameId,
1616 const std::string & toFrameId,
1619 double waitForTransform)
1625 if(waitForTransform > 0.0 && !stamp.
isZero())
1628 std::string errorMsg;
1631 ROS_WARN(
"Could not get transform from %s to %s after %f seconds (for stamp=%f)! Error=\"%s\".",
1632 fromFrameId.c_str(), toFrameId.c_str(), waitForTransform, stamp.
toSec(), errorMsg.c_str());
1643 ROS_WARN(
"(getting transform %s -> %s) %s", fromFrameId.c_str(), toFrameId.c_str(), ex.what());
1651 const std::string & sourceTargetFrame,
1656 double waitForTransform)
1662 ros::Time stamp = stampSource>stampTarget?stampSource:stampTarget;
1663 if(waitForTransform > 0.0 && !stamp.
isZero())
1665 std::string errorMsg;
1668 ROS_WARN(
"Could not get transform from %s to %s accordingly to %s after %f seconds (for stamps=%f -> %f)! Error=\"%s\".",
1669 sourceTargetFrame.c_str(), sourceTargetFrame.c_str(), fixedFrame.c_str(), waitForTransform, stampSource.
toSec(), stampTarget.
toSec(), errorMsg.c_str());
1675 listener.
lookupTransform(sourceTargetFrame, stampTarget, sourceTargetFrame, stampSource, fixedFrame, tmp);
1680 ROS_WARN(
"(getting transform movement of %s according to fixed %s) %s", sourceTargetFrame.c_str(), fixedFrame.c_str(), ex.what());
1686 const std::vector<cv_bridge::CvImageConstPtr> & imageMsgs,
1687 const std::vector<cv_bridge::CvImageConstPtr> & depthMsgs,
1688 const std::vector<sensor_msgs::CameraInfo> & cameraInfoMsgs,
1690 const std::string & odomFrameId,
1694 std::vector<rtabmap::CameraModel> & cameraModels,
1696 double waitForTransform,
1697 const std::vector<std::vector<rtabmap_ros::KeyPoint> > & localKeyPointsMsgs,
1698 const std::vector<std::vector<rtabmap_ros::Point3f> > & localPoints3dMsgs,
1699 const std::vector<cv::Mat> & localDescriptorsMsgs,
1700 std::vector<cv::KeyPoint> * localKeyPoints,
1701 std::vector<cv::Point3f> * localPoints3d,
1702 cv::Mat * localDescriptors)
1705 (imageMsgs.size() == depthMsgs.size() || depthMsgs.empty()) &&
1706 imageMsgs.size() == cameraInfoMsgs.size());
1708 int imageWidth = imageMsgs[0]->image.cols;
1709 int imageHeight = imageMsgs[0]->image.rows;
1710 int depthWidth = depthMsgs.size()?depthMsgs[0]->image.cols:0;
1711 int depthHeight = depthMsgs.size()?depthMsgs[0]->image.rows:0;
1713 if(depthMsgs.size())
1716 imageWidth % depthWidth == 0 && imageHeight % depthHeight == 0 &&
1717 imageWidth/depthWidth == imageHeight/depthHeight,
1718 uFormat(
"rgb=%dx%d depth=%dx%d", imageWidth, imageHeight, depthWidth, depthHeight).c_str());
1721 int cameraCount = imageMsgs.size();
1722 for(
unsigned int i=0; i<imageMsgs.size(); ++i)
1735 ROS_ERROR(
"Input rgb type must be image=mono8,mono16,rgb8,bgr8,bgra8,rgba8. Current rgb=%s",
1736 imageMsgs[i]->encoding.c_str());
1739 if(depthMsgs.size() &&
1744 ROS_ERROR(
"Input depth type must be image_depth=32FC1,16UC1,mono16. Current depth=%s",
1745 depthMsgs[i]->encoding.c_str());
1749 UASSERT_MSG(imageMsgs[i]->image.cols == imageWidth && imageMsgs[i]->image.rows == imageHeight,
1750 uFormat(
"imageWidth=%d vs %d imageHeight=%d vs %d",
1752 imageMsgs[i]->image.cols,
1754 imageMsgs[i]->image.rows).c_str());
1756 if(depthMsgs.size())
1758 UASSERT_MSG(depthMsgs[i]->image.cols == depthWidth && depthMsgs[i]->image.rows == depthHeight,
1759 uFormat(
"depthWidth=%d vs %d imageHeight=%d vs %d",
1761 depthMsgs[i]->image.cols,
1763 depthMsgs[i]->image.rows).c_str());
1764 stamp = depthMsgs[i]->header.stamp;
1768 stamp = imageMsgs[i]->header.stamp;
1773 if(localTransform.
isNull())
1775 ROS_ERROR(
"TF of received image %d at time %fs is not set!", i, stamp.toSec());
1779 if(!odomFrameId.empty() && odomStamp !=
stamp)
1790 ROS_WARN(
"Could not get odometry value for depth image stamp (%fs). Latest odometry " 1791 "stamp is %fs. The depth image pose will not be synchronized with odometry.", stamp.toSec(), odomStamp.
toSec());
1796 localTransform = sensorT * localTransform;
1819 rgb = cv::Mat(imageHeight, imageWidth*cameraCount, ptrImage->image.type());
1821 if(ptrImage->image.type() == rgb.type())
1823 ptrImage->image.copyTo(cv::Mat(rgb, cv::Rect(i*imageWidth, 0, imageWidth, imageHeight)));
1827 ROS_ERROR(
"Some RGB images are not the same type!");
1831 if(depthMsgs.size())
1834 cv::Mat subDepth = ptrDepth->image;
1838 depth = cv::Mat(depthHeight, depthWidth*cameraCount, subDepth.type());
1841 if(subDepth.type() == depth.type())
1843 subDepth.copyTo(cv::Mat(depth, cv::Rect(i*depthWidth, 0, depthWidth, depthHeight)));
1847 ROS_ERROR(
"Some Depth images are not the same type!");
1854 if(localKeyPoints && localKeyPointsMsgs.size() == imageMsgs.size())
1858 if(localPoints3d && localPoints3dMsgs.size() == imageMsgs.size())
1863 if(localDescriptors && localDescriptorsMsgs.size() == imageMsgs.size())
1865 localDescriptors->push_back(localDescriptorsMsgs[i]);
1874 const sensor_msgs::CameraInfo& leftCamInfoMsg,
1875 const sensor_msgs::CameraInfo& rightCamInfoMsg,
1877 const std::string & odomFrameId,
1883 double waitForTransform,
1884 bool alreadyRectified)
1886 UASSERT(leftImageMsg.get() && rightImageMsg.get());
1901 ROS_ERROR(
"Input type must be image=mono8,mono16,rgb8,bgr8,bgra8,rgba8");
1902 ROS_ERROR(
"Input type must be image=mono8,mono16,rgb8,bgr8,bgra8,rgba8 Current left=%s and right=%s",
1903 leftImageMsg->encoding.c_str(),
1904 rightImageMsg->encoding.c_str());
1919 rtabmap::Transform localTransform =
getTransform(frameId, leftImageMsg->header.frame_id, leftImageMsg->header.stamp, listener, waitForTransform);
1920 if(localTransform.
isNull())
1925 if(!odomFrameId.empty() && odomStamp != leftImageMsg->header.stamp)
1931 leftImageMsg->header.stamp,
1936 ROS_WARN(
"Could not get odometry value for stereo msg stamp (%fs). Latest odometry " 1937 "stamp is %fs. The stereo image pose will not be synchronized with odometry.", leftImageMsg->header.stamp.toSec(), odomStamp.
toSec());
1941 localTransform = sensorT * localTransform;
1949 static bool shown =
false;
1952 ROS_WARN(
"Detected baseline (%f m) is quite large! Is your " 1953 "right camera_info P(0,3) correctly set? Note that " 1954 "baseline=-P(0,3)/P(0,0). You may need to calibrate your camera. " 1955 "This warning is printed only once.",
1960 else if(stereoModel.
baseline() == 0 && alreadyRectified)
1963 leftCamInfoMsg.header.frame_id,
1964 rightCamInfoMsg.header.frame_id,
1965 leftCamInfoMsg.header.stamp,
1968 if(stereoTransform.
isNull() || stereoTransform.
x()<=0)
1970 ROS_WARN(
"We cannot estimated the baseline of the rectified images with tf! (%s->%s = %s)",
1971 rightCamInfoMsg.header.frame_id.c_str(), leftCamInfoMsg.header.frame_id.c_str(), stereoTransform.
prettyPrint().c_str());
1975 static bool warned =
false;
1978 ROS_WARN(
"Right camera info doesn't have Tx set but we are assuming that stereo images are already rectified (see %s parameter). While not " 1979 "recommended, we used TF to get the baseline (%s->%s = %fm) for convenience (e.g., D400 ir stereo issue). It is preferred to feed " 1980 "a valid right camera info if stereo images are already rectified. This message is only printed once...",
1981 rtabmap::Parameters::kRtabmapImagesAlreadyRectified().c_str(),
1982 rightCamInfoMsg.header.frame_id.c_str(), leftCamInfoMsg.header.frame_id.c_str(), stereoTransform.
x());
1990 stereoTransform.
x(),
1999 const sensor_msgs::LaserScan & scan2dMsg,
2001 const std::string & odomFrameId,
2005 double waitForTransform,
2006 bool outputInFrameId)
2010 odomFrameId.empty()?frameId:odomFrameId,
2011 scan2dMsg.header.frame_id,
2012 scan2dMsg.header.stamp +
ros::Duration().
fromSec(scan2dMsg.ranges.size()*scan2dMsg.time_increment),
2022 scan2dMsg.header.frame_id,
2023 scan2dMsg.header.stamp,
2026 if(scanLocalTransform.
isNull())
2032 sensor_msgs::PointCloud2 scanOut;
2038 scan2dMsg.header.frame_id,
2039 odomFrameId.empty()?frameId:odomFrameId,
2040 scan2dMsg.header.stamp,
2049 if(!odomFrameId.empty() && odomStamp != scan2dMsg.header.stamp)
2055 scan2dMsg.header.stamp,
2060 ROS_WARN(
"Could not get odometry value for laser scan stamp (%fs). Latest odometry " 2061 "stamp is %fs. The laser scan pose will not be synchronized with odometry.", scan2dMsg.header.stamp.toSec(), odomStamp.
toSec());
2066 scanLocalTransform = sensorT * scanLocalTransform;
2072 laserToOdom *= scanLocalTransform;
2075 bool hasIntensity =
false;
2076 for(
unsigned int i=0; i<scanOut.fields.size(); ++i)
2078 if(scanOut.fields[i].name.compare(
"intensity") == 0)
2080 if(scanOut.fields[i].datatype == sensor_msgs::PointField::FLOAT32)
2082 hasIntensity =
true;
2086 static bool warningShown =
false;
2089 ROS_WARN(
"The input scan cloud has an \"intensity\" field " 2090 "but the datatype (%d) is not supported. Intensity will be ignored. " 2091 "This message is only shown once.", scanOut.fields[i].datatype);
2092 warningShown =
true;
2102 pcl::PointCloud<pcl::PointXYZI>::Ptr pclScan(
new pcl::PointCloud<pcl::PointXYZI>);
2104 pclScan->is_dense =
true;
2110 pcl::PointCloud<pcl::PointXYZ>::Ptr pclScan(
new pcl::PointCloud<pcl::PointXYZ>);
2112 pclScan->is_dense =
true;
2118 if((scanLocalTransform.
rotation()*zAxis).z() < 0)
2121 cv::flip(data, flipScan, 1);
2128 scan2dMsg.range_min,
2129 scan2dMsg.range_max,
2130 scan2dMsg.angle_min,
2131 scan2dMsg.angle_max,
2132 scan2dMsg.angle_increment,
2139 const sensor_msgs::PointCloud2 & scan3dMsg,
2141 const std::string & odomFrameId,
2145 double waitForTransform,
2149 bool hasNormals =
false;
2150 bool hasColors =
false;
2151 bool hasIntensity =
false;
2152 for(
unsigned int i=0; i<scan3dMsg.fields.size(); ++i)
2154 if(scan3dMsg.fields[i].name.compare(
"normal_x") == 0)
2158 if(scan3dMsg.fields[i].name.compare(
"rgb") == 0 || scan3dMsg.fields[i].name.compare(
"rgba") == 0)
2162 if(scan3dMsg.fields[i].name.compare(
"intensity") == 0)
2164 if(scan3dMsg.fields[i].datatype == sensor_msgs::PointField::FLOAT32)
2166 hasIntensity =
true;
2170 static bool warningShown =
false;
2173 ROS_WARN(
"The input scan cloud has an \"intensity\" field " 2174 "but the datatype (%d) is not supported. Intensity will be ignored. " 2175 "This message is only shown once.", scan3dMsg.fields[i].datatype);
2176 warningShown =
true;
2183 if(scanLocalTransform.
isNull())
2185 ROS_ERROR(
"TF of received scan cloud at time %fs is not set, aborting rtabmap update.", scan3dMsg.header.stamp.toSec());
2190 if(!odomFrameId.empty() && odomStamp != scan3dMsg.header.stamp)
2196 scan3dMsg.header.stamp,
2201 ROS_WARN(
"Could not get odometry value for laser scan stamp (%fs). Latest odometry " 2202 "stamp is %fs. The 3d laser scan pose will not be synchronized with odometry.", scan3dMsg.header.stamp.toSec(), odomStamp.
toSec());
2206 scanLocalTransform = sensorT * scanLocalTransform;
2214 pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr pclScan(
new pcl::PointCloud<pcl::PointXYZRGBNormal>);
2216 if(!pclScan->is_dense)
2222 else if(hasIntensity)
2224 pcl::PointCloud<pcl::PointXYZINormal>::Ptr pclScan(
new pcl::PointCloud<pcl::PointXYZINormal>);
2226 if(!pclScan->is_dense)
2234 pcl::PointCloud<pcl::PointNormal>::Ptr pclScan(
new pcl::PointCloud<pcl::PointNormal>);
2236 if(!pclScan->is_dense)
2247 pcl::PointCloud<pcl::PointXYZRGB>::Ptr pclScan(
new pcl::PointCloud<pcl::PointXYZRGB>);
2249 if(!pclScan->is_dense)
2255 else if(hasIntensity)
2257 pcl::PointCloud<pcl::PointXYZI>::Ptr pclScan(
new pcl::PointCloud<pcl::PointXYZI>);
2259 if(!pclScan->is_dense)
2267 pcl::PointCloud<pcl::PointXYZ>::Ptr pclScan(
new pcl::PointCloud<pcl::PointXYZ>);
2269 if(!pclScan->is_dense)
CvImageConstPtr toCvShare(const sensor_msgs::ImageConstPtr &source, const std::string &encoding=std::string())
void globalDescriptorsToROS(const std::vector< rtabmap::GlobalDescriptor > &desc, std::vector< rtabmap_ros::GlobalDescriptor > &msg)
const std::string BAYER_GRBG8
GLM_FUNC_DECL T roll(detail::tquat< T, P > const &x)
void keypointsToROS(const std::vector< cv::KeyPoint > &kpts, std::vector< rtabmap_ros::KeyPoint > &msg)
void transformEigenToTF(const Eigen::Affine3d &e, tf::Transform &t)
std::vector< cv::Point2f > refCorners
rtabmap::Landmarks landmarksFromROS(const std::map< int, geometry_msgs::PoseWithCovarianceStamped > &tags, const std::string &frameId, const std::string &odomFrameId, const ros::Time &odomStamp, tf::TransformListener &listener, double waitForTransform, double defaultLinVariance, double defaultAngVariance)
void transformToTF(const rtabmap::Transform &transform, tf::Transform &tfTransform)
cv::Mat RTABMAP_EXP uncompressData(const cv::Mat &bytes)
std::string uFormat(const char *fmt,...)
const cv::Mat data() const
const std::map< int, std::string > & labels() const
Transform transformGroundTruth
const cv::Size & imageSize() const
bool convertScan3dMsg(const sensor_msgs::PointCloud2 &scan3dMsg, const std::string &frameId, const std::string &odomFrameId, const ros::Time &odomStamp, rtabmap::LaserScan &scan, tf::TransformListener &listener, double waitForTransform, int maxPoints=0, float maxRange=0.0f)
cv::Point3f RTABMAP_EXP transformPoint(const cv::Point3f &pt, const Transform &transform)
const cv::Mat & data() const
rtabmap::Signature nodeDataFromROS(const rtabmap_ros::NodeData &msg)
const LaserScan & laserScanCompressed() const
const Transform & getGroundTruthPose() const
void odomInfoToROS(const rtabmap::OdometryInfo &info, rtabmap_ros::OdomInfo &msg)
void transformTFToEigen(const tf::Transform &t, Eigen::Affine3d &e)
rtabmap::EnvSensor envSensorFromROS(const rtabmap_ros::EnvSensor &msg)
void points2fToROS(const std::vector< cv::Point2f > &kpts, std::vector< rtabmap_ros::Point2f > &msg)
rtabmap::SensorData rgbdImageFromROS(const rtabmap_ros::RGBDImageConstPtr &image)
Transform transformFiltered
void mapGraphToROS(const std::map< int, rtabmap::Transform > &poses, const std::multimap< int, rtabmap::Link > &links, const rtabmap::Transform &mapToOdom, rtabmap_ros::MapGraph &msg)
void poseEigenToMsg(const Eigen::Affine3d &e, geometry_msgs::Pose &m)
GLM_FUNC_DECL vecType< T, P > sqrt(vecType< T, P > const &x)
rtabmap::OdometryInfo odomInfoFromROS(const rtabmap_ros::OdomInfo &msg)
const std::map< int, float > & likelihood() const
std::vector< rtabmap::GlobalDescriptor > globalDescriptorsFromROS(const std::vector< rtabmap_ros::GlobalDescriptor > &msg)
void setLoopClosureId(int id)
const double & value() const
std::map< int, cv::Point3f > localMap
void setLabels(const std::map< int, std::string > &labels)
void setPosterior(const std::map< int, float > &posterior)
int proximityDetectionId() const
void poseMsgToEigen(const geometry_msgs::Pose &m, Eigen::Affine3d &e)
void setRawLikelihood(const std::map< int, float > &rawLikelihood)
const std::map< int, float > & posterior() const
void setRefImageId(int id)
float inliersMeanDistance
void setProximityDetectionId(int id)
pcl::PointCloud< pcl::PointXYZ >::Ptr RTABMAP_EXP removeNaNFromPointCloud(const pcl::PointCloud< pcl::PointXYZ >::Ptr &cloud)
void transformEigenToMsg(const Eigen::Affine3d &e, geometry_msgs::Transform &m)
void transformToGeometryMsg(const rtabmap::Transform &transform, geometry_msgs::Transform &msg)
IMETHOD Vector diff(const Vector &p_w_a, const Vector &p_w_b, double dt=1)
std::map< int, Landmark > Landmarks
const cv::Mat & descriptors() const
rtabmap::Signature nodeInfoFromROS(const rtabmap_ros::NodeData &msg)
rtabmap::Transform transformFromPoseMsg(const geometry_msgs::Pose &msg, bool ignoreRotationIfNotSet=false)
const std::string TYPE_8UC1
void fromROSMsg(const sensor_msgs::PointCloud2 &cloud, pcl::PointCloud< T > &pcl_cloud)
float gridCellSize() const
float timeParticleFiltering
const std::vector< cv::KeyPoint > & keypoints() const
void setCurrentGoalId(int goal)
std::vector< int > inliersIDs
const cv::Mat & gridObstacleCellsCompressed() const
void nodeInfoToROS(const rtabmap::Signature &signature, rtabmap_ros::NodeData &msg)
const cv::Mat & gridGroundCellsCompressed() const
GLM_FUNC_DECL T pitch(detail::tquat< T, P > const &x)
const cv::Mat & gridEmptyCellsCompressed() const
const EnvSensors & envSensors() const
const cv::Mat & imageRaw() const
int localBundleConstraints
void points3fToROS(const std::vector< cv::Point3f > &pts, std::vector< rtabmap_ros::Point3f > &msg, const rtabmap::Transform &transform=rtabmap::Transform())
geometry_msgs::TransformStamped t
const std::map< int, int > & weights() const
bool uStrContains(const std::string &string, const std::string &substring)
rtabmap::Transform getTransform(const std::string &fromFrameId, const std::string &toFrameId, const ros::Time &stamp, tf::TransformListener &listener, double waitForTransform)
const Transform & transform() const
const std::vector< cv::KeyPoint > & getWordsKpts() const
cv::Mat RTABMAP_EXP laserScan2dFromPointCloud(const pcl::PointCloud< pcl::PointXYZ > &cloud, const Transform &transform=Transform(), bool filterNaNs=true)
const std::string & getLabel() const
void point2fToROS(const cv::Point2f &kpt, rtabmap_ros::Point2f &msg)
bool uIsFinite(const T &value)
#define UASSERT(condition)
cv::KeyPoint keypointFromROS(const rtabmap_ros::KeyPoint &msg)
const std::map< std::string, float > & data() const
void setLocalPath(const std::vector< int > &localPath)
bool isValidForProjection() const
const CameraModel & left() const
std::map< std::string, float > odomInfoToStatistics(const rtabmap::OdometryInfo &info)
const cv::Mat & depthOrRightCompressed() const
void mapDataFromROS(const rtabmap_ros::MapData &msg, std::map< int, rtabmap::Transform > &poses, std::multimap< int, rtabmap::Link > &links, std::map< int, rtabmap::Signature > &signatures, rtabmap::Transform &mapToOdom)
const std::multimap< int, int > & getWords() const
std::vector< int > cornerInliers
void setExtended(bool extended)
void linkToROS(const rtabmap::Link &link, rtabmap_ros::Link &msg)
rtabmap::Link linkFromROS(const rtabmap_ros::Link &msg)
#define UASSERT_MSG(condition, msg_str)
CvImagePtr cvtColor(const CvImageConstPtr &source, const std::string &encoding)
void rgbdImageToROS(const rtabmap::SensorData &data, rtabmap_ros::RGBDImage &msg, const std::string &sensorFrameId)
LaserScan RTABMAP_EXP transformLaserScan(const LaserScan &laserScan, const Transform &transform)
Duration & fromSec(double t)
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)
const double & error() const
std::vector< unsigned char > RTABMAP_EXP compressData(const cv::Mat &data)
void envSensorsToROS(const rtabmap::EnvSensors &sensors, std::vector< rtabmap_ros::EnvSensor > &msg)
std::vector< cv::Point3f > points3fFromROS(const std::vector< rtabmap_ros::Point3f > &msg, const rtabmap::Transform &transform=rtabmap::Transform())
cv::Point3f point3fFromROS(const rtabmap_ros::Point3f &msg)
void infoFromROS(const rtabmap_ros::Info &info, rtabmap::Statistics &stat)
const std::string TYPE_32FC1
void mapGraphFromROS(const rtabmap_ros::MapGraph &msg, std::map< int, rtabmap::Transform > &poses, std::multimap< int, rtabmap::Link > &links, rtabmap::Transform &mapToOdom)
cv::Mat compressedMatFromBytes(const std::vector< unsigned char > &bytes, bool copy=true)
rtabmap::CameraModel cameraModelFromROS(const sensor_msgs::CameraInfo &camInfo, const rtabmap::Transform &localTransform=rtabmap::Transform::getIdentity())
std::vector< cv::KeyPoint > keypointsFromROS(const std::vector< rtabmap_ros::KeyPoint > &msg)
CvImagePtr toCvCopy(const sensor_msgs::ImageConstPtr &source, const std::string &encoding=std::string())
const std::string TYPE_16UC1
rtabmap::EnvSensors envSensorsFromROS(const std::vector< rtabmap_ros::EnvSensor > &msg)
const cv::Mat & getWordsDescriptors() const
const Type & type() const
Transform localTransform() const
const cv::Mat & infMatrix() const
float icpStructuralDistribution
void cameraModelToROS(const rtabmap::CameraModel &model, sensor_msgs::CameraInfo &camInfo)
const cv::Mat & depthOrRightRaw() const
int loopClosureId() const
std::list< V > uValues(const std::multimap< K, V > &mm)
float inliersDistribution
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, const std::vector< std::vector< rtabmap_ros::KeyPoint > > &localKeyPointsMsgs=std::vector< std::vector< rtabmap_ros::KeyPoint > >(), const std::vector< std::vector< rtabmap_ros::Point3f > > &localPoints3dMsgs=std::vector< std::vector< rtabmap_ros::Point3f > >(), const std::vector< cv::Mat > &localDescriptorsMsgs=std::vector< cv::Mat >(), std::vector< cv::KeyPoint > *localKeyPoints=0, std::vector< cv::Point3f > *localPoints3d=0, cv::Mat *localDescriptors=0)
const Transform & loopClosureTransform() const
cv::Mat userDataFromROS(const rtabmap_ros::UserData &dataMsg)
const std::vector< GlobalDescriptor > & globalDescriptors() const
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, bool alreadyRectified)
const cv::Mat info() const
void setLikelihood(const std::map< int, float > &likelihood)
void transformToPoseMsg(const rtabmap::Transform &transform, geometry_msgs::Pose &msg)
const cv::Mat & userDataCompressed() const
void keypointToROS(const cv::KeyPoint &kpt, rtabmap_ros::KeyPoint &msg)
const double & longitude() const
bool convertScanMsg(const sensor_msgs::LaserScan &scan2dMsg, const std::string &frameId, const std::string &odomFrameId, const ros::Time &odomStamp, rtabmap::LaserScan &scan, tf::TransformListener &listener, double waitForTransform, bool outputInFrameId=false)
const std::vector< CameraModel > & cameraModels() const
void setWmState(const std::vector< int > &state)
const Transform & getPose() const
void transformMsgToEigen(const geometry_msgs::Transform &m, Eigen::Affine3d &e)
const double & altitude() const
rtabmap::GlobalDescriptor globalDescriptorFromROS(const rtabmap_ros::GlobalDescriptor &msg)
void setStamp(double stamp)
const std::vector< cv::Point3f > & getWords3() const
std::multimap< int, cv::KeyPoint > words
SensorData & sensorData()
float icpStructuralComplexity
const CameraModel & right() const
const std::vector< int > & wmState() const
std::list< K > uKeys(const std::multimap< K, V > &mm)
void toCvShare(const rtabmap_ros::RGBDImageConstPtr &image, cv_bridge::CvImageConstPtr &rgb, cv_bridge::CvImageConstPtr &depth)
void setWeights(const std::map< int, int > &weights)
std::vector< cv::Point2f > points2fFromROS(const std::vector< rtabmap_ros::Point2f > &msg)
void globalDescriptorToROS(const rtabmap::GlobalDescriptor &desc, rtabmap_ros::GlobalDescriptor &msg)
rtabmap::StereoCameraModel stereoCameraModelFromROS(const sensor_msgs::CameraInfo &leftCamInfo, const sensor_msgs::CameraInfo &rightCamInfo, const rtabmap::Transform &localTransform=rtabmap::Transform::getIdentity(), const rtabmap::Transform &stereoTransform=rtabmap::Transform())
const StereoCameraModel & stereoCameraModel() const
void envSensorToROS(const rtabmap::EnvSensor &sensor, rtabmap_ros::EnvSensor &msg)
int currentGoalId() const
double timestampFromROS(const ros::Time &stamp)
GLM_FUNC_DECL T yaw(detail::tquat< T, P > const &x)
std::vector< int > matchesIDs
const cv::Mat & imageCompressed() const
std::vector< cv::Point2f > newCorners
const std::string BAYER_RGGB8
void setLoopClosureTransform(const Transform &loopClosureTransform)
void toCvCopy(const rtabmap_ros::RGBDImage &image, cv_bridge::CvImagePtr &rgb, cv_bridge::CvImagePtr &depth)
void userDataToROS(const cv::Mat &data, rtabmap_ros::UserData &dataMsg, bool compress)
void compressedMatToBytes(const cv::Mat &compressed, std::vector< unsigned char > &bytes)
pcl::PointCloud< pcl::PointNormal >::Ptr RTABMAP_EXP removeNaNNormalsFromPointCloud(const pcl::PointCloud< pcl::PointNormal >::Ptr &cloud)
void transformLaserScanToPointCloud(const std::string &target_frame, const sensor_msgs::LaserScan &scan_in, sensor_msgs::PointCloud &cloud_out, tf::Transformer &tf, double range_cutoff, int channel_options=channel_option::Default)
std::map< EnvSensor::Type, EnvSensor > EnvSensors
rtabmap::Transform transformFromGeometryMsg(const geometry_msgs::Transform &msg)
const std::vector< int > & localPath() const
const double & latitude() const
const Transform & localTransform() const
const double & bearing() const
void nodeDataToROS(const rtabmap::Signature &signature, rtabmap_ros::NodeData &msg)
rtabmap::Transform transformFromTF(const tf::Transform &transform)
sensor_msgs::ImagePtr toImageMsg() const
void point3fToROS(const cv::Point3f &pt, rtabmap_ros::Point3f &msg)
const cv::Point3f & gridViewPoint() const
V uValue(const std::map< K, V > &m, const K &key, const V &defaultValue=V())
cv::Point2f point2fFromROS(const rtabmap_ros::Point2f &msg)
const std::vector< cv::Point3f > & keypoints3D() const
void infoToROS(const rtabmap::Statistics &stats, rtabmap_ros::Info &info)
const double & stamp() const
cv::Mat RTABMAP_EXP uncompressImage(const cv::Mat &bytes)
void addStatistic(const std::string &name, float value)
const Transform & localTransform() const
const std::map< int, float > & rawLikelihood() const
LaserScan RTABMAP_EXP laserScanFromPointCloud(const pcl::PCLPointCloud2 &cloud, bool filterNaNs=true, bool is2D=false, const Transform &transform=Transform())
const double & stamp() const