rtabmap icon indicating copy to clipboard operation
rtabmap copied to clipboard

How to use OctoMap integration with RTabMap

Open hashFactory opened this issue 9 months ago • 1 comments

Hello! I've starting integrating RTabMap into my iOS app and was wondering how feasible / how to go about using OctoMap from within the iOS part of RTabMap. My goal is simply to have a voxelized version of RTabMap's representation of the scene as it's mapping in real-time instead of having the current textured mesh representation.

I managed to build the iOS app with OctoMap included (so I can use #include <rtabmap/core/global_map/OctoMap.h>) but I'm a little bit confused about using Octomap.h since it doesn't seem to be used anywhere else in the code.

Any insight would be really appreciated! Thank you!

hashFactory avatar Mar 29 '25 01:03 hashFactory

We use primarily OctoMap in ROS. The standalone app can still show the OctoMap, so you can look how it updates it in MainWindow, basically:

// init:
rtabmap::LocalGridCache cache;
OctoMap octomap(&cache, parameters);

// update cache when receiving a new signature
cv::Mat ground;
cv::Mat obstacles;
cv::Mat empty;
signature->sensorData().uncompressDataConst(0, 0, 0, 0, &ground, &obstacles, &empty);
cache.add(signature->id(), ground, obstacles, empty, resolution, signature->sensorData().gridViewPoint());

// update octomap with latest poses
octomap.update(poses);

// generate point cloud from OctoMap (or iterate directly the OctoMap when rendering)
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud = octomap.createCloud(16);

Make sure RGBD/CreateOccupancyGrid is true (it is disabled by default in iOS app).

matlabbe avatar Mar 31 '25 02:03 matlabbe