Ask Your Question
1

create an occupancy grid map from octomap

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

sai gravatar image

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

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 -0600

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 imagesai ( 2014-01-20 04:52:38 -0600 )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 imagesai ( 2014-01-20 04:52:44 -0600 )edit

I searched for map.pgm but cannot find it.

sai gravatar imagesai ( 2014-01-20 04:53:34 -0600 )edit

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

AHornung gravatar imageAHornung ( 2014-01-20 05:19:16 -0600 )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 imagesai ( 2014-01-20 05:24:12 -0600 )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 imagesai ( 2014-01-20 05:47:47 -0600 )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 imagesai ( 2014-01-20 06:31:02 -0600 )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 imagemaxj_ros ( 2019-03-24 21:56:21 -0600 )edit
0

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

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 imagesai ( 2014-01-17 16:45:51 -0600 )edit
2

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

Stefan Kohlbrecher gravatar imageStefan Kohlbrecher ( 2014-01-17 21:30:39 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

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

Seen: 2,451 times

Last updated: Jan 20 '14