ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

costmap_2d doesn't fit environment map size

asked 2019-10-20 09:15:06 -0600

davidem gravatar image

updated 2019-10-20 09:47:28 -0600

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.
image description 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.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2019-10-20 09:34:23 -0600

fergs gravatar image

There are dozens of parameters that need to be set to run move_base - I'd suggest looking at the pre-configured turtlebot_navigation package rather than trying to configure yourself. If you really want to configure yourself, see the tutorial on the wiki

edit flag offensive delete link more


Thanks for the sources, I'll give a look. I am not a copy-paste guy, so I prefer to follow instructions and read docs rather than using a pre-configured thing. Sadly, docs aren't very detailed on parameters and tweaks, while tutorials are scarse...

davidem gravatar image davidem  ( 2019-10-20 09:49:54 -0600 )edit

I would think of it less as copy and paste and more as the vendor having provided a default configuration that you can then tweak. You didn’t decide to write your own drivers for the platform for instance, no need to start entirely from scratch on the navigation config either. Setting up move_base from scratch is a very advanced topic.

fergs gravatar image fergs  ( 2019-10-20 10:30:45 -0600 )edit

Lesson learned. Thanks

davidem gravatar image davidem  ( 2019-10-20 11:18:37 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2019-10-20 09:15:06 -0600

Seen: 325 times

Last updated: Oct 20 '19