[ROS Q&A] 136 – How to edit a map generated with gmapping

Written by Alberto Ezquerro


In this video we are going to see how to edit a map (PGM file) which has been generating with the gmapping package.

This is a video based on the following post on ROS Answers:


▸ Original question: https://answers.ros.org/question/295879/how-to-edit-the-map-pbm-built-by-gmapping-pkg/
ROS Development Studio (ROSDS)
Robot Ignite Academy
ROS Navigation in 5 Days Online Course

Step 1. Create a project in ROS Development Studio(ROSDS)

ROSDS helps you follow our tutorial in a fast pace without dealing without setting up an environment locally. If you haven’t had an account yet, you can create a free account here. Let’s create a new project and call it edit_map_qa.

Step 2. Map generation

In ROS, you can generate a map with SLAM algorithm like gmapping. The map file normally has the .pgm and .yaml foramt where the .pgm is basically an image and .yaml file contains some information like origin, resolution and etc. In this tutorial, I a map is generated using the summit xl robot.

Step 3. Edit map

There are many edit tools available. As a demonstration, we use GIMP on mac to edit the .pgm image. For example, Add a wall in the map.

Step 4. Publish the new map to the map server

Now, you can launch the navigation package again, you’ll see that a new ‘wall’ appears on the map. If you do the path planning again, you should notice that the path is changed due to the wall is blocking the way now.

Want to learn more?

If you are interested in this topic and want to learn more about the navigation stack in ROS and how to use map sever, please check our ROS Navigation in 5 Days Online Course for more information.



Edit by: Tony Huang


Did you like this video? Do you have questions about what is explained? Whatever the case, please leave a comment on the comments section below, so we can interact and learn from each other.

If you want to learn about other ROS topics, please let us know on the comments area and we will do a video about it.

You May Also Like…

1 Comment

  1. Walter Pintor

    Hi Alberto.

    Thanks for showing this simple way of modifying the map.

    In the case I don’t have access to the .pgn or .pgm nor the .yaml file, and I can only subscribe to the /map topic, is it possible to subscribe to this topic, download the information, reconstruct the map and modify it?

    Looking forward to your reply/


Submit a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share This