ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

2D map from Octomap

asked 2012-02-11 19:58:15 -0500

jwrobbo gravatar image

updated 2014-01-28 17:11:20 -0500

ngrennan gravatar image

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 flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
4

answered 2012-03-26 06:53:42 -0500

jwrobbo gravatar image

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
edit flag offensive delete link more

Comments

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.

kotoko gravatar image kotoko  ( 2016-11-29 05:10:38 -0500 )edit
1

answered 2012-03-26 02:41:57 -0500

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

edit flag offensive delete link more

Comments

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

Sudhan gravatar image Sudhan  ( 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

Felix Endres gravatar image Felix Endres  ( 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?

qinyingying gravatar image qinyingying  ( 2018-07-17 03:32:54 -0500 )edit
1

answered 2012-03-22 06:21:54 -0500

Mac gravatar image

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

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2012-02-11 19:58:15 -0500

Seen: 5,854 times

Last updated: Mar 26 '12