# 2D map from Octomap

I would like to use an octomap generated from RGBDSLAM to produce a 2d map that I can use with the navigation stack. The advantage of this approach vs a fake (or real) laser scanner is that it would not require separate odometry information or for the sensor to remain level. It seems that Octomap already produces a 2D map but this includes features at every height "pancaked" onto the map. Is there a way to simply take a slice through the 3d map at a particular z value?

Many thanks,

James

edit retag close merge delete

Sort by » oldest newest most voted

Thanks Felix,

Found another way around it in the end, though possibly less efficient than your approach. The first thing I found out was that octomap server accepts min and max z values just as parameters so by adding

param name="occupancy_min_z" value="-0.5"

param name="occupancy_max_z" value="0.5"

to the launch file I got a cut down octomap, which then gave a sensible 2d map. Quite nice having the 3D map as well though, for visualisation if nothing else and I'd rather not run 2 octomap_servers, so I had a look through OctomapServer.cpp and edited the 2d map stuff so that it only adds to the occupancy grid if the point is within a certain z range:

void OctomapServer::handleOccupiedNode(const OcTreeROS::OcTreeType::iterator& it){
// update 2D map (occupied always overrides):
if (m_publish2DMap){
...........
octomap::point3d curpoint;
m_octoMap->octree.genCoords(nKey, m_treeDepth, curpoint);
if (curpoint.z() > -0.5 && curpoint.z() < 0.5){
m_gridmap.data[m_gridmap.info.width*j + i] = 100;
}
} else{ ..........///same thing here

more

From the code, I think that if you want to cut down on the amount of world octomap models you can use pointcloud_min_z.

( 2016-11-29 05:10:38 -0500 )edit

If you want to code something up, I'd recommend to write a node listening to rgbdslam's output topic, pass-through-filtering it to exclude floor and ceiling and otherwise just omit the z coordinate and render the 2D points to an image.

Would be an efficient way to go and should be coded in a day or two.

Things to keep in mind: rgbdslam has no notion of up and down, its Z axis is the up vector of the kinect in the first frame, because by default it takes the /openni_camera frame of the first image as the origin.

Regards, Felix

more

In this case, do we need to write the subscriber and the publisher in the same node?

( 2012-09-17 03:18:18 -0500 )edit

Not sure if I understand. The node could subscribe to rgbdslam's batch_cloud, possibly transform it to another frame, then filter and downproject it. Depending on how you want to use it, you could publish it, but I guess the general use case is to save the image and a .yaml as a map

( 2012-09-23 06:38:56 -0500 )edit

Now I have a dense pointcloud and octomap, But I don't know how to navigate with them, Do you know how to transfer octomap to 2D map so that it can be used to navigate in ros?

( 2018-07-17 03:32:54 -0500 )edit

OctoMap has iterators for traversing the tree; I suggest using one of those, and ignoring those voxels that have the wrong z-value.

more