Point cloud density in RTAB-map vs. published over ROS

classic Classic list List threaded Threaded
7 messages Options
ibd
Reply | Threaded
Open this post in threaded view
|

Point cloud density in RTAB-map vs. published over ROS

ibd
I just noticed that the point cloud published over ROS (visualized with RVIZ) is a lot less dense than the point cloud (PC) that is shown in RTAB-map's own visualizer.

1. Are there parameters to control in-app point cloud density and PC density published over ROS?

I also noticed that the input point cloud (from camera) is denser than the published ROS topic, so there definitely seems to be some PC simplification going on.

If you like, I can share some comparison screenshots.

I tried changing the number of features detected in the image (1000 -> 4000 -> "inf"), but it does not seem to increase the overall point cloud density, and also not the one in RVIZ.

Cheers!
- ibd
Reply | Threaded
Open this post in threaded view
|

Re: Point cloud density in RTAB-map vs. published over ROS

simon.xm.lee
Hi,

Excuse me. How do you change the number of features detected in the image from 1000 to 4000? Can you share the information?

Regard.
Reply | Threaded
Open this post in threaded view
|

Re: Point cloud density in RTAB-map vs. published over ROS

matlabbe
Administrator
Hi,

Number of features used for odometry (rgbd_odometry node): Vis/MaxFeatures (default 1000)
Number of features used for loop closure detection (rtabmap node): Kp/MaxFeatures (default 400)

For the point cloud density, /rtabmap/cloud_map is voxelized at 5 cm by default, for performance purpose. The parameter Grid/VoxelSize can be decreased if more dense map cloud is required:
<node pkg="rtabmap_ros" type="rtabmap" name="rtabmap">
   ...
  <param name="Grid/CellSize" type="string" value="0.01"/> <!-- 1 cm voxel -->
  <param name="grid_cell_size" type="double" value="0.01"/> <!-- if rtabmap is not latest from source -->
</node>

Note that if you just want to reconstruct the 3D map at high resolution, I recommend to open the database (~/.ros/rtabmap.db) in rtabmap standalone app after mapping and do File->Export 3D clouds. You will then have all options to regenerate the 3D map at which density you want.

cheers,
Mathieu
ibd
Reply | Threaded
Open this post in threaded view
|

Re: Point cloud density in RTAB-map vs. published over ROS

ibd
Thank you Mathieu, it works perfectly!
ibd
Reply | Threaded
Open this post in threaded view
|

Re: Point cloud density in RTAB-map vs. published over ROS

ibd
In reply to this post by matlabbe
I have another related question.

I noticed that the "Grid/CellSize" parameter controls both the resolution of rtabmap/cloud_map, as well as the generated /map!

For my application, I would like to generate a 2D /map with a coarser resolution (0.07) than the voxel map (0.02). Is it possible to set these resolutions independently?


I tried adding both Grid/CellSize and Grid/VoxelSize (in that order). Regarding Grid/VoxelSize I get the error:
Parameter "cloud_voxel_size" has moved from rtabmap_ros to rtabmap library. Use parameter "Grid/CellSize" instead. The value is still copied to new parameter name.
I notice that the Grid/CellSize parameter is dominant, and both the 2D map and the 3D map "listen" to this parameter to set their resolution. Hence my question above.
Reply | Threaded
Open this post in threaded view
|

Re: Point cloud density in RTAB-map vs. published over ROS

matlabbe
Administrator
Hi,

Since the occupancy grid refactoring (at the end of last year), there is only one parameter setting the density of the cloud (voxel size) or the cell size, which is Grid/CellSize, unifying all output topics parametrization.

What could be done is to set Grid/CellSize to smallest resolution (0.02), then republish the grid map at corser resolution like 0.06 or 0.08 (multiple of 0.02) to be easily converted. To convert to 0.06 cell size, iterate occupancy grid message and convert 3x3 cells to 1x1 cells.

Another way is to modify MapsManager::generateGridMap() by something like this (not tested):
cv::Mat MapsManager::generateGridMap(
		const std::map<int, rtabmap::Transform> & poses,
		float & xMin,
		float & yMin,
		float & gridCellSize)
{
    std::map<int, Transform> poses;
    poses.insert(std::make_pair(1, Transform::getIdentity()));

    cv::Mat ground = util3d::laserScanFromPointCloud(assembledGround_);
    cv::Mat obstacles = util3d::laserScanFromPointCloud(assembledObstacles_);

    std::map<int, std::pair<cv::Mat, cv::Mat> > occupancy;
    occupancy.insert(std::make_pair(1, std::make_pair(ground, obstacles)));

    gridCellSize = 0.07;
    return util3d::create2DMapFromOccupancyLocalMaps(poses, occupancy, gridCellSize, xMin, yMin);
}

cheers,
Mathieu
ibd
Reply | Threaded
Open this post in threaded view
|

Re: Point cloud density in RTAB-map vs. published over ROS

ibd
Hi Mathieu

I tested your hack. It works! With slight modifications. Here's the final hacked function:

cv::Mat MapsManager::generateGridMap(
		const std::map<int, rtabmap::Transform> & poses,
		float & xMin,
		float & yMin,
		float & gridCellSize)
{
	// gridCellSize = occupancyGrid_->getCellSize();
	// occupancyGrid_->update(poses);
	// return occupancyGrid_->getMap(xMin, yMin);

	std::map<int, rtabmap::Transform> poses2;
  poses2.insert(std::make_pair(1, Transform::getIdentity()));

  cv::Mat ground = util3d::laserScanFromPointCloud(*assembledGround_, poses2[1]);
  cv::Mat obstacles = util3d::laserScanFromPointCloud(*assembledObstacles_, poses2[1]);

  std::map<int, std::pair<cv::Mat, cv::Mat> > occupancy;
  occupancy.insert(std::make_pair(1, std::make_pair(ground, obstacles)));

  gridCellSize = 0.08;
  return util3d::create2DMapFromOccupancyLocalMaps(poses2, occupancy, gridCellSize, xMin, yMin);
}

Thank you very much.

Best
ibd