
<h3>Question</h3>
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:
https://answers.ros.org/question/335530/what-range-of-costs-does-ros-navigation-support/
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!
<h3>Answer1:</h3>
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 LaserScan
s &/or PointCloud
s, 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)" />
<h3>Answer2:</h3>
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.
Edit:
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
来源:https://stackoverflow.com/questions/62069112/how-do-i-map-a-non-binary-occupancy-grid-with-several-values-to-a-cost-map-in-ro