ROS Map Files Explained: The .pgm Image and .yaml Metadata
A ROS map is two small files: a greyscale image and a YAML file that says how to read it. They look simple, and they are, but a few of their details decide…
A map straight out of SLAM is a record of everything the laser saw while you drove around: the walls, but also the people who walked past, the cart that has since moved, and the street outside the glass door. Navigation and localisation both work better on a map that shows only what is permanently there. This guide is a practical workflow for cleaning a map without damaging the parts the robot relies on.
Editing fixes small problems, not a bad map. Before you open an editor:
Save the result with map_saver_cli and keep that original pair of files untouched. Edit a copy.
People, doors that were open during mapping, and carts or chairs that move every day leave black blobs and streaks in open space. They make the planner route around obstacles that no longer exist and can confuse localisation when the robot sees open floor where the map shows something solid. Paint them free.
Single black or grey pixels scattered in open areas come from sensor noise and reflections. Each one becomes an inflated obstacle in the costmap, so a handful of specks can block a doorway for planning purposes. Erase them.
Lasers pass through glass, so the map may contain a fan of free space and stray obstacles outside the building, or a wall with a gap where a glass door is. Erase what lies outside, and paint the glass wall itself as occupied so the robot never plans through it. Mirrors cause the opposite problem: a phantom room reflected behind the mirror. Erase the phantom and draw the wall.
A 2D laser scans a single horizontal plane. It does not see stairs going down, a loading-dock edge, low glass tables, or overhanging shelves below or above its height. These are the places where robots fall or collide, so mark them as occupied, or better, as keep-out zones (below).
Where the robot must never pass through a gap (an emergency exit, a door to a room it must not enter), draw a line across it. A thin line is enough on the static map; the costmap's inflation layer adds the safety margin around it.
It is tempting to tidy a map until it looks like an architect's plan. Resist it.
free_thresh is 0.196 or lower, or the map server will read grey as free anyway, as explained in our guide to ROS map files..pgm and .yaml in the ROS Map Editor and zoom in.The editor paints only the exact values 0, 205 and 254. An ordinary image editor's soft brush adds in-between greys at the edge of every stroke, which the map server reads as obstacles or unknown cells, so a cleaned area ends up with a ring of speckles around it.
Painting an area occupied is permanent and absolute. If a rule only applies sometimes (a keep-out zone during opening hours) or you want the robot to slow down rather than stop (a narrow aisle), keep the map honest and put the rule in a separate mask image loaded through Nav2's costmap filters. Our guide to keep-out zones and speed limits shows how.
A ROS map is two small files: a greyscale image and a YAML file that says how to read it. They look simple, and they are, but a few of their details decide…
Every real deployment has rules the walls don't show: stay out of the kitchen, slow down near the reception desk, never enter the loading bay while forklifts…
slam_toolbox is the standard 2D SLAM package in ROS 2 and the one Nav2 recommends for building maps. This guide goes from a robot with a laser scanner to a…
Two numbers in every ROS map's YAML file have consequences far beyond the map itself. The resolution decides how much memory the costmaps use, how fast the…
If you have any query or problem
feel free to contact us
email: [email protected]
Comments 0