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

create an occupancy grid map from octomap

asked 2014-01-16 20:24:10 -0500

sai gravatar image

updated 2014-01-20 00:20:31 -0500

ubuntu 12.04 , Fuerte and rosbuild

I have an octomap in *.ot format which can be downloaded from https://dl.dropboxusercontent.com/u/95042389/level8_extended.ot.zip

I want to create an occupancy grid map from this. Does any one have a straight forward solution for this ?

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
3

answered 2014-01-20 01:58:37 -0500

AHornung gravatar image

You can use octomap_server with your .ot file as an argument, that will load the map from file and publish it not only as an octomap but also as occupancy grid in ROS. As mentioned in the Wiki documentation, you just have to listen to the projected_map topic and there are various parameters you can set to your liking (such as minimum and maximum height of the map to consider for the projection).

Otherwise you can follow Stefan's advice and write your own map projection. Create an Octree-Iterator (as described in the OctoMap documentation, check for each node if it's occupied, and then set the corresponding coordinate in your map to occupied or free.

edit flag offensive delete link more

Comments

I gave octomap as an argument and could display the 2d map in rviz. TO save the map, in the launch file I added these to a launch file <remap from="map" to="projected_map"/> <node pkg="map_server" type="map_saver" name="map_saver1" output="screen"/> it says that map is saved but i cannot find it

sai gravatar image sai  ( 2014-01-20 04:52:38 -0500 )edit

[ INFO] [1390236546.850389657]: Waiting for the map [ INFO] [1390236547.108151857]: Received a 873 X 994 map @ 0.050 m/pix [ INFO] [1390236547.108205638]: Writing map occupancy data to map.pgm [ INFO] [1390236547.131166233]: Writing map occupancy data to map.yaml [ INFO] [1390236547.131295422]: Done

sai gravatar image sai  ( 2014-01-20 04:52:44 -0500 )edit

I searched for map.pgm but cannot find it.

sai gravatar image sai  ( 2014-01-20 04:53:34 -0500 )edit

You can run map_saver from a different terminal and it will save the map in the current directory.

AHornung gravatar image AHornung  ( 2014-01-20 05:19:16 -0500 )edit

I did the same thing but i cannot find map.pgm in the current directory or at any other place too. Any suggestions

sai gravatar image sai  ( 2014-01-20 05:24:12 -0500 )edit

Could you tell me how i can add "rosrun map_saver map_saver -f /home/sai/my_map" into roslaunch file. I dont know how to add the base directory where the file should be saved into a roslaunch file.

sai gravatar image sai  ( 2014-01-20 05:47:47 -0500 )edit

Adding this line to the launch file solved the issue <node pkg="map_server" type="map_saver" name="map_saver1" args=" -f /home/sai/Desktop/my_map" output="screen"/> I was finally able to save the map and view it. Thanks @AHornung

sai gravatar image sai  ( 2014-01-20 06:31:02 -0500 )edit

@sai I also want to convert an exiting octomap to 2d map, I saw your comment and try to get the launch file as following: <launch> <remap from="map" to="projected_map"/> <node pkg="map_server" type="map_saver" name="map_saver1" args=" -f /home/maxj/my_map" output="screen"/> </launch>

there is a octomap map naming result.ot in /home/maxj, issue occur when I run this launch file

I am a newer for ROS, Is there anything wrong? what is the correct step?

correct step as following in one terminal : rosrun octomap_server octomap_server_node result.bt you can see the projected_map through rostop list

in another terminal : roslaunch xxx.launch

it works fine for me

maxj_ros gravatar image maxj_ros  ( 2019-03-24 21:56:21 -0500 )edit
0

answered 2014-01-17 00:29:56 -0500

Code for doing that is available in the OctomapServer.cpp (see documentation http://docs.ros.org/fuerte/api/octomap_server/html/OctomapServer_8cpp_source.html">here). The functionality is spread throughout the code there however, so if you want a standalone version, you´ll have to pick out the parts you need yourself. I´m not aware of another implementation (but maybe someone else will answer with another option).

edit flag offensive delete link more

Comments

if you can make this as a comment, then others who might know will answer it.

sai gravatar image sai  ( 2014-01-17 16:45:51 -0500 )edit
2

There can be multiple answers, so if anyone has a better idea, they can just post another one.

Stefan Kohlbrecher gravatar image Stefan Kohlbrecher  ( 2014-01-17 21:30:39 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2014-01-16 20:24:10 -0500

Seen: 4,455 times

Last updated: Jan 20 '14