Ask Your Question
0

Using two static layered costmaps to make restricted areas

asked 2021-03-02 15:55:57 -0500

FFelizpe gravatar image

Hi there!

I have a small question, that seems to be simple, but it's been bothering me a lot for weeks on end. I've been working trying to make a robot capable of navigating autonomously, and it's been working fine. However, I'd like to restrict some parts of the map, even if the robot theorically should be able to navigate through them, for the sake of making a better navigation and creating restricted spaces.

I've struggled a lot with that recently, until I stumbled into that the solution might be using layered costmaps. I've been using layered costmaps (VoxelLayer for dynamic obstacles, StaticLayer for the map, Inflation, etc), but not for this purpose. I'd like to make a map for dynamic obstacles, that won't be detected by the LIDAR but they will still be restricted. And, for this, I've read that I can make a second costmap with my restricted map.

However, how do I do this? As far as I understand, I'd need to call the map from another topic that's not /map, but how do I publish the second map in this new topic? I've been using the map_server in the launch for the /map to run, and I don't know how to make that work to another topic in a new map. Besides, is this really the right approach? Will the use of two layered static costmaps help my case?

Thanks in advance!

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2021-03-04 08:36:45 -0500

Maybe a different and more flexible approach is to write your own costmap layer and give it a geometry_message::polygon as input for the restricted areas. Like this you don't have to define the areas before the navigation starts, but you can change the restricted areas during navigation.

Take a look at the create a new layer tutorial in the wiki. Even though i must admit, that it is very low level. For more information i recommend the costmap layer package from David Lu as a reference.

I did something similar for road navigation to prevent the robot from entering the left lane when the right one is free.

edit flag offensive delete link more
1

answered 2021-03-04 07:44:29 -0500

I think this is a good way to add obstacle information.

To make a second map public with a topic other than "map", use the map_topic parameter.

map_topic (string, default: "map") This parameter is useful when you have multiple costmap instances within a single node that you want to use different static maps. New in navigation 1.3.1

Stacking cost maps can be achieved by using the use_maximum parameter.

use_maximum (bool, default: false) Only matters if the static layer is not the bottom layer. If true, only the maximum value will be written to the master costmap.

The above is taken from the documentation at http://wiki.ros.org/costmap_2d/hydro/....

For example, you can use the following

global_costmap configuration yaml file

global_costmap:
  plugins: 
    - {name: static_layer1, type: "costmap_2d::StaticLayer"}
    - {name: static_layer2, type: "costmap_2d::StaticLayer"}

  static_layer1:
    map_topic: "map" 

  static_layer2:
    map_topic: "map2"
    use_maximum: true

Excerpt from launch file

<node name="static_layer1" pkg="map_server" type="map_server" args="$(find XXX)/maps/YYY.yaml"/>
<node name="static_layer2" pkg="map_server" type="map_server" args="$(find XXX)/maps/ZZZ.yaml">
    <remap from="map" to="map2"/>
</node>
edit flag offensive delete link more

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

Stats

Asked: 2021-03-02 15:55:57 -0500

Seen: 154 times

Last updated: Mar 04