39 #include <rtabmap/core/Version.h>
41 #include <pcl/search/kdtree.h>
43 #include <nav_msgs/OccupancyGrid.h>
49 #if defined(WITH_OCTOMAP_MSGS) and defined(RTABMAP_OCTOMAP)
51 #include <octomap/ColorOcTree.h>
55 #if defined(WITH_GRID_MAP_ROS) and defined(RTABMAP_GRIDMAP)
56 #include <grid_map_ros/GridMapRosConverter.hpp>
64 MapsManager::MapsManager() :
65 cloudOutputVoxelized_(
true),
66 cloudSubtractFiltering_(
false),
67 cloudSubtractFilteringMinNeighbors_(2),
68 mapFilterRadius_(0.0),
69 mapFilterAngle_(30.0),
70 mapCacheCleanup_(
true),
71 alwaysUpdateMap_(
false),
72 scanEmptyRayTracing_(
true),
78 #
if defined(WITH_OCTOMAP_MSGS) and defined(RTABMAP_OCTOMAP)
79 octomap_(new
OctoMap(&localMaps_)),
83 octomapTreeDepth_(16),
84 octomapUpdated_(
true),
85 #
if defined(WITH_GRID_MAP_ROS) and defined(RTABMAP_GRIDMAP)
86 elevationMap_(new
GridMap(&localMaps_)),
90 elevationMapUpdated_(
true),
102 if(pnh.
hasParam(
"map_negative_poses_ignored"))
104 ROS_WARN(
"Parameter \"map_negative_poses_ignored\" has been "
105 "removed. Use \"map_always_update\" instead.");
106 if(!pnh.
hasParam(
"map_always_update"))
108 bool negPosesIgnored;
109 pnh.
getParam(
"map_negative_poses_ignored", negPosesIgnored);
115 if(pnh.
hasParam(
"map_negative_scan_empty_ray_tracing"))
117 ROS_WARN(
"Parameter \"map_negative_scan_empty_ray_tracing\" has been "
118 "removed. Use \"map_empty_ray_tracing\" instead.");
119 if(!pnh.
hasParam(
"map_empty_ray_tracing"))
126 if(pnh.
hasParam(
"scan_output_voxelized"))
128 ROS_WARN(
"Parameter \"scan_output_voxelized\" has been "
129 "removed. Use \"cloud_output_voxelized\" instead.");
130 if(!pnh.
hasParam(
"cloud_output_voxelized"))
148 #if defined(WITH_OCTOMAP_MSGS) and defined(RTABMAP_OCTOMAP)
152 ROS_WARN(
"octomap_tree_depth maximum is 16");
157 ROS_WARN(
"octomap_tree_depth cannot be negative, set to 16 instead");
170 if(usePublicNamespace)
196 #if defined(WITH_OCTOMAP_MSGS) and defined(RTABMAP_OCTOMAP)
215 #if defined(WITH_GRID_MAP_ROS) and defined(RTABMAP_GRIDMAP)
227 #if defined(WITH_OCTOMAP_MSGS) and defined(RTABMAP_OCTOMAP)
231 #if defined(WITH_GRID_MAP_ROS) and defined(RTABMAP_GRIDMAP)
238 const std::string & rosName,
239 const std::string & parameterName,
244 ParametersMap::const_iterator
iter = Parameters::getDefaultParameters().find(parameterName);
245 if(
iter != Parameters::getDefaultParameters().
end())
247 ROS_WARN(
"Parameter \"%s\" has moved from "
248 "rtabmap_ros to rtabmap library. Use "
249 "parameter \"%s\" instead. The value is still "
250 "copied to new parameter name.",
252 parameterName.c_str());
253 std::string
type = Parameters::getType(parameterName);
254 if(
type.compare(
"float") ||
type.compare(
"double"))
260 else if(
type.compare(
"int") ||
type.compare(
"unsigned int"))
266 else if(
type.compare(
"bool"))
270 if(rosName.compare(
"grid_incremental") == 0)
279 ROS_ERROR(
"Not handled type \"%s\" for parameter \"%s\"",
type.c_str(), parameterName.c_str());
284 ROS_ERROR(
"Parameter \"%s\" not found in default parameters.", parameterName.c_str());
292 if(pnh.
hasParam(
"cloud_frustum_culling"))
294 ROS_WARN(
"Parameter \"cloud_frustum_culling\" has been removed. OctoMap topics "
295 "already do it. You can remove it from your launch file.");
299 parameterMoved(pnh,
"cloud_decimation", Parameters::kGridDepthDecimation(), parameters);
300 parameterMoved(pnh,
"cloud_max_depth", Parameters::kGridRangeMax(), parameters);
301 parameterMoved(pnh,
"cloud_min_depth", Parameters::kGridRangeMin(), parameters);
302 parameterMoved(pnh,
"cloud_voxel_size", Parameters::kGridCellSize(), parameters);
303 parameterMoved(pnh,
"cloud_floor_culling_height", Parameters::kGridMaxGroundHeight(), parameters);
304 parameterMoved(pnh,
"cloud_ceiling_culling_height", Parameters::kGridMaxObstacleHeight(), parameters);
305 parameterMoved(pnh,
"cloud_noise_filtering_radius", Parameters::kGridNoiseFilteringRadius(), parameters);
306 parameterMoved(pnh,
"cloud_noise_filtering_min_neighbors", Parameters::kGridNoiseFilteringMinNeighbors(), parameters);
307 parameterMoved(pnh,
"scan_decimation", Parameters::kGridScanDecimation(), parameters);
308 parameterMoved(pnh,
"scan_voxel_size", Parameters::kGridCellSize(), parameters);
309 parameterMoved(pnh,
"proj_max_ground_angle", Parameters::kGridMaxGroundAngle(), parameters);
310 parameterMoved(pnh,
"proj_min_cluster_size", Parameters::kGridMinClusterSize(), parameters);
311 parameterMoved(pnh,
"proj_max_height", Parameters::kGridMaxObstacleHeight(), parameters);
312 parameterMoved(pnh,
"proj_max_obstacles_height", Parameters::kGridMaxObstacleHeight(), parameters);
313 parameterMoved(pnh,
"proj_max_ground_height", Parameters::kGridMaxGroundHeight(), parameters);
315 parameterMoved(pnh,
"proj_detect_flat_obstacles", Parameters::kGridFlatObstacleDetected(), parameters);
316 parameterMoved(pnh,
"proj_map_frame", Parameters::kGridMapFrameProjection(), parameters);
317 parameterMoved(pnh,
"grid_unknown_space_filled", Parameters::kGridScan2dUnknownSpaceFilled(), parameters);
318 parameterMoved(pnh,
"grid_cell_size", Parameters::kGridCellSize(), parameters);
319 parameterMoved(pnh,
"grid_size", Parameters::kGridGlobalMinSize(), parameters);
320 parameterMoved(pnh,
"grid_eroded", Parameters::kGridGlobalEroded(), parameters);
321 parameterMoved(pnh,
"grid_footprint_radius", Parameters::kGridGlobalFootprintRadius(), parameters);
323 #if defined(WITH_OCTOMAP_MSGS) and defined(RTABMAP_OCTOMAP)
324 parameterMoved(pnh,
"octomap_ground_is_obstacle", Parameters::kGridGroundIsObstacle(), parameters);
325 parameterMoved(pnh,
"octomap_occupancy_thr", Parameters::kGridGlobalOccupancyThr(), parameters);
337 #if defined(WITH_OCTOMAP_MSGS) and defined(RTABMAP_OCTOMAP)
342 #if defined(WITH_GRID_MAP_ROS) and defined(RTABMAP_GRIDMAP)
353 const std::map<int, rtabmap::Transform> & poses,
360 for(std::map<int, rtabmap::Transform>::const_iterator
iter=poses.lower_bound(1);
iter!=poses.end(); ++
iter)
367 if(
data.gridCellSize() == 0.0f)
369 ROS_WARN(
"Local occupancy grid doesn't exist for node %d",
iter->first);
373 cv::Mat ground, obstacles, emptyCells;
402 #if defined(WITH_OCTOMAP_MSGS) and defined(RTABMAP_OCTOMAP)
405 #if defined(WITH_GRID_MAP_ROS) and defined(RTABMAP_GRIDMAP)
410 iter->second =
false;
454 return std::map<int, Transform>();
458 const std::map<int, rtabmap::Transform> & posesIn,
462 const std::map<int, rtabmap::Signature> & signatures)
464 bool updateGridCache = updateGrid || updateOctomap;
465 bool updateElevation =
false;
466 if(!updateGrid && !updateOctomap && !updateOctomap)
485 updateGridCache = updateOctomap || updateGrid || updateElevation ||
492 #if not (defined(WITH_OCTOMAP_MSGS) and defined(RTABMAP_OCTOMAP))
493 updateOctomap =
false;
495 #if not (defined(WITH_GRID_MAP_ROS) and defined(RTABMAP_GRIDMAP))
496 updateElevation =
false;
504 UDEBUG(
"Updating map caches...");
506 if(!memory && signatures.size() == 0)
508 ROS_ERROR(
"Memory and signatures should not be both null!?");
509 return std::map<int, rtabmap::Transform>();
513 std::map<int, rtabmap::Transform> poses;
514 if(posesIn.begin()->first < 0)
516 poses.insert(posesIn.lower_bound(0), posesIn.end());
522 std::map<int, rtabmap::Transform> filteredPoses;
530 UDEBUG(
"Filter nodes...");
533 if(poses.find(0) != poses.end())
536 filteredPoses.insert(*poses.find(0));
541 filteredPoses = poses;
546 filteredPoses.erase(0);
549 bool longUpdate =
false;
551 if(filteredPoses.size() > 20)
555 ROS_WARN(
"Many occupancy grids should be loaded (~%d), this may take a while to update the map(s)...",
int(filteredPoses.size()-
localMaps_.
size()));
558 #if defined(WITH_OCTOMAP_MSGS) and defined(RTABMAP_OCTOMAP)
561 ROS_WARN(
"Many clouds should be added to octomap (~%d), this may take a while to update the map(s)...",
int(filteredPoses.size()-
octomap_->
addedNodes().size()));
569 for(std::map<int, rtabmap::Transform>::iterator
iter=filteredPoses.begin();
iter!=filteredPoses.end(); ++
iter)
571 if(!
iter->second.isNull())
577 std::map<int, rtabmap::Signature>::const_iterator findIter = signatures.find(
iter->first);
578 if(findIter != signatures.end())
580 data = findIter->second.sensorData();
588 cv::Point3f viewPoint;
589 cv::Mat ground, obstacles, emptyCells;
594 bool generateGrid =
data.gridCellSize() == 0.0f;
595 static bool warningShown =
false;
596 if(occupancySavedInDB && generateGrid && !warningShown)
599 UWARN(
"Occupancy grid for location %d should be added to global map (e..g, a ROS node is subscribed to "
600 "any occupancy grid output) but it cannot be found "
601 "in memory. For convenience, the occupancy "
602 "grid is regenerated. Make sure parameter \"%s\" is true to "
603 "avoid this warning for the next locations added to map. For older "
604 "locations already in database without an occupancy grid map, you can use the "
605 "\"rtabmap-databaseViewer\" to regenerate the missing occupancy grid maps and "
606 "save them back in the database for next sessions. This warning is only shown once.",
607 data.id(), Parameters::kRGBDCreateOccupancyGrid().c_str());
609 if(memory && occupancySavedInDB && generateGrid)
620 generateGrid?0:&ground,
621 generateGrid?0:&obstacles,
622 generateGrid?0:&emptyCells);
640 bool unknownSpaceFilled = Parameters::defaultGridScan2dUnknownSpaceFilled();
641 Parameters::parse(
parameters_, Parameters::kGridScan2dUnknownSpaceFilled(), unknownSpaceFilled);
658 generateGrid?0:&ground,
659 generateGrid?0:&obstacles,
660 generateGrid?0:&emptyCells);
695 #if defined(WITH_OCTOMAP_MSGS) and defined(RTABMAP_OCTOMAP)
704 #if defined(WITH_GRID_MAP_ROS) and defined(RTABMAP_GRIDMAP)
709 ROS_INFO(
"GridMap (elevation map) update time = %fs",
time.ticks());
747 return filteredPoses;
751 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
754 int minNeighborsInRadius)
756 UASSERT(minNeighborsInRadius > 0);
759 pcl::PointCloud<pcl::PointXYZRGB>::Ptr output(
new pcl::PointCloud<pcl::PointXYZRGB>);
760 output->resize(cloud->size());
762 for(
unsigned int i=0;
i<cloud->size(); ++
i)
764 std::vector<std::vector<size_t> > kIndices;
765 std::vector<std::vector<float> > kDistances;
766 cv::Mat pt = (cv::Mat_<float>(1, 3) << cloud->at(
i).x, cloud->at(
i).y, cloud->at(
i).z);
767 substractCloudIndex.
radiusSearch(pt, kIndices, kDistances, radiusSearch, minNeighborsInRadius, 32, 0,
false);
768 if(kIndices.size() == 1 && kIndices[0].size() < minNeighborsInRadius)
770 output->at(oi++) = cloud->at(
i);
778 const std::map<int, rtabmap::Transform> & poses,
780 const std::string & mapFrameId)
782 ROS_DEBUG(
"Publishing maps... poses=%d", (
int)poses.size());
798 ROS_WARN(
"/scan_map topic is deprecated! Subscribe to /cloud_map topic "
799 "instead with <param name=\"%s\" type=\"string\" value=\"0\"/>. "
800 "Do \"$ rosrun rtabmap_ros rtabmap --params | grep Grid\" to see "
801 "all occupancy grid parameters.",
802 Parameters::kGridSensor().
c_str());
806 ROS_WARN(
"/scan_map topic is deprecated! Subscribe to /cloud_map topic instead.");
811 bool graphGroundOptimized =
false;
812 bool graphObstacleOptimized =
false;
819 bool graphGroundChanged = updateGround;
820 bool graphObstacleChanged = updateObstacles;
822 for(std::map<int, Transform>::const_iterator
iter=poses.lower_bound(1);
iter!=poses.end(); ++
iter)
824 std::map<int, Transform>::const_iterator jter;
830 graphGroundChanged =
false;
831 UASSERT(!
iter->second.isNull() && !jter->second.isNull());
832 if(
iter->second.getDistanceSquared(jter->second) > updateErrorSqr)
834 graphGroundOptimized =
true;
843 graphObstacleChanged =
false;
844 UASSERT(!
iter->second.isNull() && !jter->second.isNull());
845 if(
iter->second.getDistanceSquared(jter->second) > updateErrorSqr)
847 graphObstacleOptimized =
true;
852 int countObstacles = 0;
853 int countGrounds = 0;
856 if(graphGroundOptimized || graphGroundChanged)
864 if(graphObstacleOptimized || graphObstacleChanged )
873 if(graphGroundOptimized || graphObstacleOptimized)
875 ROS_INFO(
"Graph has changed, updating clouds...");
877 cv::Mat tmpGroundPts;
878 cv::Mat tmpObstaclePts;
879 for(std::map<int, Transform>::const_iterator
iter = poses.lower_bound(1);
iter!=poses.end(); ++
iter)
888 pcl::PointCloud<pcl::PointXYZRGB>::Ptr transformed = util3d::transformPointCloud(kter->second,
iter->second);
892 for(
unsigned int i=0;
i<transformed->size(); ++
i)
894 if(tmpGroundPts.empty())
896 tmpGroundPts = (cv::Mat_<float>(1, 3) << transformed->at(
i).x, transformed->at(
i).y, transformed->at(
i).z);
897 tmpGroundPts.reserve(previousIndexedGroundSize>0?previousIndexedGroundSize:100);
901 cv::Mat pt = (cv::Mat_<float>(1, 3) << transformed->at(
i).x, transformed->at(
i).y, transformed->at(
i).z);
902 tmpGroundPts.push_back(pt);
909 if(updateObstacles &&
916 pcl::PointCloud<pcl::PointXYZRGB>::Ptr transformed = util3d::transformPointCloud(kter->second,
iter->second);
920 for(
unsigned int i=0;
i<transformed->size(); ++
i)
922 if(tmpObstaclePts.empty())
924 tmpObstaclePts = (cv::Mat_<float>(1, 3) << transformed->at(
i).x, transformed->at(
i).y, transformed->at(
i).z);
925 tmpObstaclePts.reserve(previousIndexedObstacleSize>0?previousIndexedObstacleSize:100);
929 cv::Mat pt = (cv::Mat_<float>(1, 3) << transformed->at(
i).x, transformed->at(
i).y, transformed->at(
i).z);
930 tmpObstaclePts.push_back(pt);
938 double addingPointsTime =
t.ticks();
940 if(graphGroundOptimized && !tmpGroundPts.empty())
944 if(graphObstacleOptimized && !tmpObstaclePts.empty())
948 double indexingTime =
t.ticks();
949 ROS_INFO(
"Graph optimized! Time recreating clouds (%d ground, %d obstacles) = %f s (indexing %fs)", countGrounds, countObstacles, addingPointsTime+indexingTime, indexingTime);
951 else if(graphGroundChanged || graphObstacleChanged)
953 ROS_WARN(
"Graph has changed! The whole cloud is regenerated.");
956 for(std::map<int, Transform>::const_iterator
iter = poses.begin();
iter!=poses.end(); ++
iter)
967 pcl::PointCloud<pcl::PointXYZRGB>::Ptr transformed = util3d::laserScanToPointCloudRGB(LaserScan::backwardCompatibility(jter->second.groundCells),
iter->second, 0, 255, 0);
968 pcl::PointCloud<pcl::PointXYZRGB>::Ptr subtractedCloud = transformed;
975 if(subtractedCloud->size())
978 cv::Mat pts(subtractedCloud->size(), 3, CV_32FC1);
979 for(
unsigned int i=0;
i<subtractedCloud->size(); ++
i)
981 pts.at<
float>(
i, 0) = subtractedCloud->at(
i).x;
982 pts.at<
float>(
i, 1) = subtractedCloud->at(
i).y;
983 pts.at<
float>(
i, 2) = subtractedCloud->at(
i).z;
997 groundClouds_.insert(std::make_pair(
iter->first, util3d::transformPointCloud(subtractedCloud,
iter->second.inverse())));
999 if(subtractedCloud->size())
1012 if(jter!=
localMaps_.
end() && jter->second.obstacleCells.cols)
1014 pcl::PointCloud<pcl::PointXYZRGB>::Ptr transformed = util3d::laserScanToPointCloudRGB(LaserScan::backwardCompatibility(jter->second.obstacleCells),
iter->second, 255, 0, 0);
1015 pcl::PointCloud<pcl::PointXYZRGB>::Ptr subtractedCloud = transformed;
1022 if(subtractedCloud->size())
1025 cv::Mat pts(subtractedCloud->size(), 3, CV_32FC1);
1026 for(
unsigned int i=0;
i<subtractedCloud->size(); ++
i)
1028 pts.at<
float>(
i, 0) = subtractedCloud->at(
i).x;
1029 pts.at<
float>(
i, 1) = subtractedCloud->at(
i).y;
1030 pts.at<
float>(
i, 2) = subtractedCloud->at(
i).z;
1044 obstacleClouds_.insert(std::make_pair(
iter->first, util3d::transformPointCloud(subtractedCloud,
iter->second.inverse())));
1046 if(subtractedCloud->size())
1068 ROS_INFO(
"Assembled %d obstacle and %d ground clouds (%d points, %fs)",
1071 if( countGrounds > 0 ||
1072 countObstacles > 0 ||
1082 sensor_msgs::PointCloud2::Ptr cloudMsg(
new sensor_msgs::PointCloud2);
1084 cloudMsg->header.stamp = stamp;
1085 cloudMsg->header.frame_id = mapFrameId;
1091 sensor_msgs::PointCloud2::Ptr cloudMsg(
new sensor_msgs::PointCloud2);
1093 cloudMsg->header.stamp = stamp;
1094 cloudMsg->header.frame_id = mapFrameId;
1101 sensor_msgs::PointCloud2::Ptr cloudMsg(
new sensor_msgs::PointCloud2);
1103 cloudMsg->header.stamp = stamp;
1104 cloudMsg->header.frame_id = mapFrameId;
1123 size_t totalBytes = 0;
1126 totalBytes +=
sizeof(
int) +
iter->second->points.size()*
sizeof(pcl::PointXYZRGB);
1130 totalBytes +=
sizeof(
int) +
iter->second->points.size()*
sizeof(pcl::PointXYZRGB);
1136 ROS_INFO(
"MapsManager: cleanup point clouds (%ld points, %ld cached clouds, ~%ld MB)...",
1139 totalBytes/1048576);
1167 #if defined(WITH_OCTOMAP_MSGS) and defined(RTABMAP_OCTOMAP)
1181 octomap_msgs::Octomap
msg;
1183 msg.header.frame_id = mapFrameId;
1184 msg.header.stamp = stamp;
1190 octomap_msgs::Octomap
msg;
1192 msg.header.frame_id = mapFrameId;
1193 msg.header.stamp = stamp;
1203 sensor_msgs::PointCloud2
msg;
1204 pcl::IndicesPtr obstacleIndices(
new std::vector<int>);
1205 pcl::IndicesPtr frontierIndices(
new std::vector<int>);
1206 pcl::IndicesPtr emptyIndices(
new std::vector<int>);
1207 pcl::IndicesPtr groundIndices(
new std::vector<int>);
1208 pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud =
octomap_->
createCloud(
octomapTreeDepth_, obstacleIndices.get(), emptyIndices.get(), groundIndices.get(),
true, frontierIndices.get(),0);
1212 pcl::PointCloud<pcl::PointXYZRGB> cloudOccupiedSpace;
1213 pcl::IndicesPtr
indices = util3d::concatenate(obstacleIndices, groundIndices);
1214 pcl::copyPointCloud(*cloud, *
indices, cloudOccupiedSpace);
1216 msg.header.frame_id = mapFrameId;
1217 msg.header.stamp = stamp;
1223 pcl::PointCloud<pcl::PointXYZRGB> cloudFrontier;
1224 pcl::copyPointCloud(*cloud, *frontierIndices, cloudFrontier);
1226 msg.header.frame_id = mapFrameId;
1227 msg.header.stamp = stamp;
1233 pcl::PointCloud<pcl::PointXYZRGB> cloudObstacles;
1234 pcl::copyPointCloud(*cloud, *obstacleIndices, cloudObstacles);
1236 msg.header.frame_id = mapFrameId;
1237 msg.header.stamp = stamp;
1243 pcl::PointCloud<pcl::PointXYZRGB> cloudGround;
1244 pcl::copyPointCloud(*cloud, *groundIndices, cloudGround);
1246 msg.header.frame_id = mapFrameId;
1247 msg.header.stamp = stamp;
1253 pcl::PointCloud<pcl::PointXYZRGB> cloudEmptySpace;
1254 pcl::copyPointCloud(*cloud, *emptyIndices, cloudEmptySpace);
1256 msg.header.frame_id = mapFrameId;
1257 msg.header.stamp = stamp;
1265 float xMin=0.0f, yMin=0.0f, gridCellSize = 0.05f;
1271 nav_msgs::OccupancyGrid map;
1272 map.info.resolution = gridCellSize;
1273 map.info.origin.position.x = 0.0;
1274 map.info.origin.position.y = 0.0;
1275 map.info.origin.position.z = 0.0;
1276 map.info.origin.orientation.x = 0.0;
1277 map.info.origin.orientation.y = 0.0;
1278 map.info.origin.orientation.z = 0.0;
1279 map.info.origin.orientation.w = 1.0;
1281 map.info.width = pixels.cols;
1282 map.info.height = pixels.rows;
1283 map.info.origin.position.x = xMin;
1284 map.info.origin.position.y = yMin;
1285 map.data.resize(map.info.width * map.info.height);
1287 memcpy(map.data.data(), pixels.data, map.info.width * map.info.height);
1289 map.header.frame_id = mapFrameId;
1290 map.header.stamp = stamp;
1295 else if(poses.size())
1297 ROS_WARN(
"Octomap projection map is empty! (poses=%d octomap nodes=%d). "
1298 "Make sure you enabled \"%s\" and set \"%s\"=1. "
1299 "See \"$ rosrun rtabmap_ros rtabmap --params | grep Grid\" for more info.",
1301 Parameters::kGrid3D().c_str(), Parameters::kGridSensor().c_str());
1318 ROS_INFO(
"MapsManager: cleanup octomap (%ld leaf nodes, ~%ld MB)...",
1370 ROS_WARN(
"/proj_map topic is deprecated! Subscribe to /grid_map topic "
1371 "instead with <param name=\"%s\" type=\"string\" value=\"1\"/>. "
1372 "Do \"$ rosrun rtabmap_ros rtabmap --params | grep Grid\" to see "
1373 "all occupancy grid parameters.",
1374 Parameters::kGridSensor().
c_str());
1378 ROS_WARN(
"/proj_map topic is deprecated! Subscribe to /grid_map topic instead.");
1385 float xMin=0.0f, yMin=0.0f, gridCellSize = 0.05f;
1390 nav_msgs::OccupancyGrid map;
1391 map.info.resolution = gridCellSize;
1392 map.info.origin.position.x = 0.0;
1393 map.info.origin.position.y = 0.0;
1394 map.info.origin.position.z = 0.0;
1395 map.info.origin.orientation.x = 0.0;
1396 map.info.origin.orientation.y = 0.0;
1397 map.info.origin.orientation.z = 0.0;
1398 map.info.origin.orientation.w = 1.0;
1400 map.info.width = pixels.cols;
1401 map.info.height = pixels.rows;
1402 map.info.origin.position.x = xMin;
1403 map.info.origin.position.y = yMin;
1404 map.data.resize(map.info.width * map.info.height);
1406 memcpy(map.data.data(), pixels.data, map.info.width * map.info.height);
1408 map.header.frame_id = mapFrameId;
1409 map.header.stamp = stamp;
1417 else if(poses.size())
1425 float xMin=0.0f, yMin=0.0f, gridCellSize = 0.05f;
1426 cv::Mat pixels = this->
getGridMap(xMin, yMin, gridCellSize);
1431 nav_msgs::OccupancyGrid map;
1432 map.info.resolution = gridCellSize;
1433 map.info.origin.position.x = 0.0;
1434 map.info.origin.position.y = 0.0;
1435 map.info.origin.position.z = 0.0;
1436 map.info.origin.orientation.x = 0.0;
1437 map.info.origin.orientation.y = 0.0;
1438 map.info.origin.orientation.z = 0.0;
1439 map.info.origin.orientation.w = 1.0;
1441 map.info.width = pixels.cols;
1442 map.info.height = pixels.rows;
1443 map.info.origin.position.x = xMin;
1444 map.info.origin.position.y = yMin;
1445 map.data.resize(map.info.width * map.info.height);
1447 memcpy(map.data.data(), pixels.data, map.info.width * map.info.height);
1449 map.header.frame_id = mapFrameId;
1450 map.header.stamp = stamp;
1463 else if(poses.size())
1482 #if defined(WITH_GRID_MAP_ROS) and defined(RTABMAP_GRIDMAP)
1487 grid_map_msgs::GridMap
msg;
1488 #if RTABMAP_VERSION_MAJOR>0 || (RTABMAP_VERSION_MAJOR==0 && RTABMAP_VERSION_MINOR>21) || (RTABMAP_VERSION_MAJOR==0 && RTABMAP_VERSION_MINOR==21 && RTABMAP_VERSION_PATCH>=8)
1493 msg.info.header.frame_id = mapFrameId;
1494 msg.info.header.stamp = stamp;
1521 float & gridCellSize)
1530 float & gridCellSize)