costmap_2d doesn't fit environment map size
I am using ROS Melodic on Ubuntu 18.04
I have generated a map of an environment with gmapping and now I'm trying to make my Turtlebot3 navigate it autonomously via the move_base package. This is my .yaml file of the map:
image: house.pgm
resolution: 0.050000
origin: [-10.000000, -10.000000, 0.000000]
negate: 0
occupied_thresh: 0.65
free_thresh: 0.196
then I added a line in my .launch
file to run the move_base node, this is it:
<node pkg="move_base" type="move_base" name="move_base" / >
Sadly this wasn't enough, because the costmap I was getting wasn't transformed correctly "above" the environment map, it was offset at the top-left-most corner. Moreover, it wasn't scaled properly. Fairly easy to fix, I thought, because I didn't specify the origin and the width/height of the map. Just a matter of parameters:
<param name="global_costmap/origin_x" value="-10" />
<param name="global_costmap/origin_y" value="-10" />
<param name="global_costmap/height" value="19" />
<param name="global_costmap/width" value="19" />
The origin_x
and origin_y
were copied from the .yaml
file, but then I had to do some tweaks in order to scale the costmap correctly, because it was 20x bigger than the map (why this, I don't know and hope someone can help me through.)
Via Rviz, I found out that my map was 384x384, dividing by 20 gave 19.2, which rounded down is the value you can see above as global_costmap/height
and global_costmap/width
. This way, at least, they overlap for the most part, but the result is as expected: the environment map is larger by a small amount.
Light gray: costmap, dark gray: environment map, black: background
Moreover, the costmap doesn't get rendered on Rviz, meaning I cannot see darker areas along the obstacles, like this, and the footprint of the Turtlebot3 is way larger than expected.
Edit no.1
the footprint of the Turtlebot3 is way larger than expected
Simply because I forgot to add this parameter to the move_base node:
<rosparam file="$(find turtlebot3_navigation)/param/costmap_common_params_$(arg model).yaml" command="load" />
This way, I can retrieve the correct footprint of whatever model of Turtlebot I'm deploying.