# Using gmapping generated map on Stage

Hi, I searched for a guide on how to use a map generated with gmapping on Stage but couldn't find anything (weird). I generated a map with a real robot using gmapping and as result I got a pgm file and a yaml file. Here's the output of the yaml

image: basketRX.pgm

resolution: 0.050000

origin: [-39.400000, -36.200000, 0.000000]

negate: 0

occupied_thresh: 0.65

free_thresh: 0.196


And this is the generated 1632x1216 map (i converted it to png)

I want to use this map with stage so I modified it a bit (to include just the centre of the map and I repassed the obstacles with GIMP) and wrote a .world file. Unfortunately it seems that the robot cannot localize and navigate badly. Using the same navigation and amcl config file with a different map everything works as it should. So it must be something wrong in the world file I wrote.

The modified map is the following:

While the world file I wrote is this:

include "../Common/Erratic.inc"
include "../Common/Landmarks.inc"
include "../Common/Urg.inc"

# set the resolution of the underlying raytrace model in meters
resolution 0.02

# simulation timestep in milliseconds
interval_sim 100

define landfinder fiducial
(
range_min 1.0
range_max 30.0
range_max_id 30.0
fov 270.0
ignore_zloc 0

# model properties
size [ 0.010 0.010 0.010 ]
)

define floorplan model
(
# sombre, sensible, artistic
color "black"

# most maps will need a bounding box
boundary 1

gui_nose 0
gui_grid 0

gui_outline 0
gripper_return 0
fiducial_return 0
range_return 1
)

window
(
size [ 1120 818 ]
center [ -0.652 2.391 ]
rotate [ 0.000 0.000 ]
scale 21.734
#show_grid 1
#show_trailfast 1
)

floorplan
(
name "map"
bitmap "map.png"
size [78.800 58.713 0.500]
pose [0 0 0 0]
)

define box model
(
size [0.400 0.400 0.500]
gui_nose 0
)

# ROBOTs
erratic(pose [5.000  4.000 0.000 0.000] name "robot_0" color "blue")
erratic(pose [5.000  0.000 0.000 0.000] name "robot_1" color "orange")
erratic(pose [5.000  -4.000 0.000 0.000] name "robot_2" color "green")


Do you see anything wrong?

edit retag close merge delete

Sort by » oldest newest most voted

"Unfortunately it seems that the robot cannot localize and navigate badly."

In the .world file, you should have the exactly same objects those exist in your .pgm file, so the robot can localize itself using the objects. For example, if you have a black square object in the .pgm file, when you create your .world file, you should put a same size object there. In the gazebo simulation, when the robot gets close to the object, the robot will know "oh there is an object ahead of me in the real world, and there is also one object like this in the .pgm map you gave me. I must be at the front of this object. Yes, I know where I am."

more