ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Grid layer in costmap2d tutorials, out of map bounds, matchSize().

asked 2019-02-22 04:13:15 -0500

SleepyTurtle gravatar image

updated 2019-02-22 04:14:34 -0500

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.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-02-25 14:55:48 -0500

David Lu gravatar image

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>
edit flag offensive delete link more

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!

SleepyTurtle gravatar image SleepyTurtle  ( 2019-02-27 02:33:32 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2019-02-22 04:13:15 -0500

Seen: 313 times

Last updated: Feb 25 '19