Grid layer in costmap2d tutorials, out of map bounds, matchSize().
After closely following the Costmap2D tutorial on creating new layers, simple layer worked as intended, grid layer didn't.
After some poking around, I noticed that the costmap it created was always empty because if(worldToMap(mark_x, mark_y, mx, my))
always returned false as the point exceeded the local costmap's bounds. I then noticed that matchSize();
in void GridLayer::onInitialize()
had no impact on execution, I think it gets called by the base class anyway. I then moved matchSize()
into the updateBounds
method and the point now falls inside the costmap's bounds, making it work like simple layer.
My question is the following: Is this a problem with the tutorial or is this a problem with my particular configuration?
I'm using it as a local_costmap layer and my configuration file looks like this:
local_costmap:
global_frame: /map
robot_base_frame: /base_link
update_frequency: 8.0
publish_frequency: 4.0
rolling_window: true
static_map: false
width: 6.0
height: 6.0
resolution: 0.05
plugins:
- {name: obstacle_layer, type: "costmap_2d::ObstacleLayer", output: "screen"}
#- {name: simple_layer, type: "simple_layer_namespace::SimpleLayer", output: "screen"}
- {name: grid_layer, type: "simple_layer_namespace::GridLayer", output: "screen"}
- {name: inflation_layer, type: "costmap_2d::InflationLayer", output: "screen"}
The layer works with and without modification as a global costmap layer.
Asked by SleepyTurtle on 2019-02-22 05:13:15 UTC
Answers
I gave this a try and could not replicate the error. It partially will depend on what your /map->/base_link
transform is.
I would modify your origin to be -3, -3 so that the local costmap is centered around the origin. Then while publishing the above transform as the identity, I found that the worldToMap(1.0, 0.0)
resulted in 80 60
.
Here is my test setup:
<launch>
<node name="costmap_node" pkg="costmap_2d" type="costmap_2d_node" output="screen">
<rosparam ns="costmap">
global_frame: /map
robot_base_frame: /base_link
update_frequency: 8.0
publish_frequency: 4.0
rolling_window: true
static_map: false
width: 6.0
height: 6.0
origin_x: -3
origin_y: -3
resolution: 0.05
plugins:
- {name: obstacle_layer, type: "costmap_2d::ObstacleLayer", output: "screen"}
#- {name: simple_layer, type: "simple_layer_namespace::SimpleLayer", output: "screen"}
- {name: grid_layer, type: "simple_layer_namespace::GridLayer", output: "screen"}
- {name: inflation_layer, type: "costmap_2d::InflationLayer", output: "screen"}
</rosparam>
</node>
<node name="static_tf0" pkg="tf" type="static_transform_publisher" args="0 0 0 0 0 0 /map /base_link 100" />
</launch>
Asked by David Lu on 2019-02-25 15:55:48 UTC
Comments
My /map -> /base_link transform is provided by AMCL. Changing the origin didn't fix the issue. I tried out your test setup and it works, it must be something to do with particularities of the navigation's stack's local map, I'll continue to work on it. Thanks a lot for looking into my problem!
Asked by SleepyTurtle on 2019-02-27 03:33:32 UTC
Comments