How do I map a non-binary Occupancy Grid with several values to a cost map in ROS?


I'm looking for a way to map a non-binary occupancy grid to a global cost map. The occupancy grid has the values -1 for undefined, 0 for non-collision and 1-100 for collision areas. There is a similar question here for which the given answer doesn't offer a concrete solution:


For a better overview:

I'm using ROS Melodic.

My occupancy grid looks like this: Image of Occupancy grid

My global_costmap_params.yaml looks like this:

global_costmap: plugins: - {name: static_layer, type: "costmap_2d::StaticLayer"} - {name: inflation_layer, type: "costmap_2d::InflationLayer"} global_frame: base_link map_topic: "prediction_occ_grid" update_frequency: 10.0 publish_frequency: 10.0 rolling_window: true always_send_full_costmap: true height: 26.9 width: 36.4

Note that I'm a pure beginner in costmaps, so it might be that this doesn't make sense at all!

Using the given global_costmap_params.yaml deliveres the following costmap: Image of the resulting global costmap

As you can see the costmap "ignores" the collision-areas and maps them in the same costs as the non-collision-path-area. Is there any way to modify the costmap_params in order for it to map the occupancy grid properly?

Thanks in advance!


Most specifically, I'd look at the costmap params for the plugins, chiefly the static_map and obstacles plugins. Perhaps you want the staticmap parameter trinary_costmap to be true, to have the full scale of values in the costmap. The ones in obstacles are likely to change what you expect to see, with multiple layers or input data.

I would also look at Clearpath's Husky husky_navigation package for a good example, ex. move_base.launch file. All the parameters are written in the config/ dir, and loaded by rosparam within the move_base node. Some details: if you're doing a local costmap that moves with the robot, you don't want to track the empty space, you'd want a rolling window, and to use the Obstacle layer instead of the static layer; for the global, you would track all the space, but not move the window with respect to the robot, and you'd use a static map.

I think one issue you have is in data flow. How Ros (& most people, because of it) leans is to have an initial/static map loaded from the beginning (map_server) for both amcl and move_base, update both with either LaserScans &/or PointClouds, and then you're just left with the amcl output of frame tfs & local position estimation, and feeding that into the move_base node, you only need the goal. To use an occ_grid map msg to update amcl, for example, you have to change the use_map_topic param.

Edit: In case map_server was what you really needed, here's an example usage I pulled from husky_nav's amcl_demo.launch:

<pre class="lang-xml prettyprint-override"><!-- Run the map server --> <arg name="map_file" default="$(find husky_navigation)/maps/playpen_map.yaml"/> <node name="map_server" pkg="map_server" type="map_server" args="$(arg map_file)" />

Turned out the plugin somehow isn't able to read the given params from the global_costmap_params.yaml (any ideas about what the reason could be or how to fix that?).

I solved the issue by cloning the navigation-repo into my catkin_ws/src folder (instead of installing navigation via sudo apt-get install ros-melodic-navigation) and change the default-value for the trinary_costmap-param inside costmap_2d/plugins/static_layer.cpp to 'false'.

It's now able to map all intermediate values of the occupancy grid correctly.


I figured out that this is due to a namespace issue. Since the <em>trinary_costmap</em> is a plugin-internal parameter for the static_layer-plugin, it appears that the namespace must be specified explicitly.

Therefore, setting the param in <em>global_costmap_params.yaml</em> like this works:

/move_base/global_costmap/static_layer/trinary_costmap: false



  • How do I map a non-binary Occupancy Grid with several values to a cost map in ROS?
  • Jquery get id or class from dynamic element
  • JMESPath descend in tree for filter
  • cheap stereo vision camera + opencv [closed]
  • How to add dynamic filter drop down using Jqgrid?
  • How to optimise bootstrap to avoid rendering unused css code
  • How can I create DOM object from a HTML file in php language?
  • Get UIImage from function
  • Azure Container Group IP Address disappeared
  • Unable to replicate an encryption format from Java to PHP
  • Using Sybase ASE BCP to a Remote Server
  • Is Xss protection in Spring security enabled by default?
  • Unable to select a space or join an organization on run.pivotal.io
  • Inno Setup event that is generated when folder is browsed on TInputDirWizardPage?
  • EF: one-to-one relationship
  • Firebase Cloud Messaging: how to send data message to all users? [duplicate]
  • c# selenium chrome-webdrive clicking button using class and title
  • Optimization of Neural Network input data
  • Reveal Icon Button - Bootstrap 3
  • Javapackager tool from command-line on OSX?
  • React Native - FlatList with dynamic height children
  • How do I set context and followup event in one intent?
  • ClearCase can I use clearexport_ccase/clearimport to copy VOB data to a VOB on a different machine
  • Hiding prices based on visitor location backend bug in Woocommerce
  • Android NDK refer to external libraries in JNI
  • VS2010: Ctrl-PgUp / -PgDown like in browsers
  • Protractor Page objects - TypeError: Object # has no method 'methodName'
  • Excel Reverse Match
  • I need a PHP mySQL Login script that directs user to specific URL based on username and password
  • Javascript inside HTML import not affecting imported HTML
  • C# code can't “see” the methods in my C++ dll
  • Copy and paste data from multiple workbooks to a worksheet in another Workbook
  • Magento-Change Attribute of All Products
  • Creating 2d platforms using JavaScript
  • Create an average of multiple excel chart without the data source
  • PHPMailer return to AJAX
  • Cloud Code: Creating a Parse.File from URL
  • jQuery scrollTop if URL has hash
  • How do I add a mouse over tooltip to an Image using .DrawImage()
  • Create/delete users from text file using Bash script