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

Loading 2D raw data

asked 2011-03-31 01:03:45 -0500

szokei gravatar image

Hello, I've obtained a 2D map from another development environment, how could I load/display/manipulate (in gazebo/rviz) this set of 2D points. Thank you.

edit retag flag offensive close merge delete


What format is your map in ?
Guido gravatar image Guido  ( 2011-03-31 01:17:40 -0500 )edit
I've the 2D coordinate points in a .txt file.
szokei gravatar image szokei  ( 2011-03-31 19:41:44 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2011-03-31 20:54:15 -0500

Guido gravatar image

I think the simplest way is to write your map to a .pgm file. I guess a simple program can do it. It has to map the occupied points to black pixels (value=0), the free points to white pixels (254) and unknown points to gray pixels (205).

Then you can use the map_server package to publish it to rviz with the command: rosrun map_server map_server mymap.pgm

If you set the fixed frame as "/map" in rviz, you should see your map.

Hope this helps,


edit flag offensive delete link more


I've plot my map in Matlab, saved it in .tif and convert it into .pgm. The map is successfully loaded into RViz . Thank you!
szokei gravatar image szokei  ( 2011-04-01 23:39:46 -0500 )edit

I know this is an old thread, but I cant get this method to work. I have the pgm file on my desktop, and I run rosrun map_server map_server mymap.pgm, but it cant open the file. Any help would be appreciated. Thanks!

kost9 gravatar image kost9  ( 2015-01-28 23:55:56 -0500 )edit

I used rosrun map_server map_serverrospack find <my_map_package>/mymap.yaml.

Be sure you have the correct file_path within the argument for your mymap.yaml

sealguy77 gravatar image sealguy77  ( 2015-06-11 19:10:06 -0500 )edit

The command is rosrun map_server map_server mymap.yaml not rosrun map_server map_server mymap.pgm

JackB gravatar image JackB  ( 2020-10-06 17:05:59 -0500 )edit

Question Tools


Asked: 2011-03-31 01:03:45 -0500

Seen: 2,871 times

Last updated: Mar 31 '11