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

How to update the occupancy grid of the rviz map with another map?

asked 2022-01-20 04:57:51 -0500

ymag gravatar image


I am using local_costmap (not the raw laser scan data) as an input to a model, from which I receive another map, let's call it mapX. Now, I want that the robot navigates using the information from the new mapX (I have it both as a local and global map), instead of per default from the local_costmap. The problem is, that I do not want to update the local_costmap itself, that the global planner is using, because then moving forward the robot will collect local_costmap data that the model can not deal with. So I want that the local_costmap stays untouched, but at the same time, the robot plans according to the new mapX. I am using move_base and a standard global planner.

So I guess there should be a config file somewhere in the navigation stack, where I can just change the name of the topic? Or maybe I can work with a multiple-layer local_costmap, where I have the initial map as a first layer and the new mapX as a second (not sure how it works and should be implemented either), but even for that I guess I have to change something in the move_base package to say which layer from the local_costmap should be used?

I am still new to ros (melodic), so I will appreciate any help, giving me some direction in which I should read more and research. Thank you in advance!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2022-01-22 09:28:28 -0500

Mike Scheutzow gravatar image

The standard ros move_base navigation stack already supports what you want to do if you create the proper configuration. First, in move_base, the global_costmap and the local_costmap are completely independent. Second, the global planner never looks at the local_costmap, so changes you make to local_costmap will not affect global planning. Third, you need to research more about costmap_2d and its layered costmap design. Start here:

You can add your own layer and intelligently merge it with the other layers (Obstacle Cost Layer), or you can update the base layer (Static Map Layer). I generally find the former works better.

edit flag offensive delete link more


Hi, thank you for the answer. Working with a layered costmap did the trick. I still have one understanding question. Is it possible from inside of a script to subscribe to only a specific layer of the local_costmap? So let's say my local_costmap detects changes from laser_scan, from camera etc., everything on a different layer. But I want internally to have the information from the local_costmap once from all layers (which I do) and once from only a specific layer. I do not want to choose from those two ways, I want to have both. Is that possible? What I am doing right now is using for this purpose once the local_costmap and once the global_costmap (making the global_costmap have only one of the layers of the local_costmap), but I am afraid in the future I would need to use the global_costmap for other purposes. Do you have any ...(more)

ymag gravatar image ymag  ( 2022-01-25 05:09:45 -0500 )edit

As far as I know, that is not possible with the standard costmap_2d. But nothing stops you from creating a node that subscribes to whatever topic the costmap-layer is using as a data source.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2022-01-25 06:17:33 -0500 )edit

That is indeed true. I do have a problem though visualizing the data from a laser scan (my data source) as a global map, which of course updates itself (that is something I need for training). That is why I decided to get the local_costmap instead since it is easier to visualize and use to get a global map from it. But now that I have to change the local_costmap, I can not use it anymore like before, because it has unwanted additional information. So going back to trying to visualize laser scan could be the answer indeed, but I have problems with that. With the laser scan, I think I have to consider much more factors, for example not only the position but also the orientation of the robot, etc. Do you maybe have any advice on how to visualize the laser scan on a global map (as an ...(more)

ymag gravatar image ymag  ( 2022-01-25 06:34:47 -0500 )edit

This site is structured with a Question/Answer format, so discussions which go too far off topic from the original question are discouraged. That said, I'll point out that rviz is already capable of rendering a laser scan onto the map, assuming you have a valid TF Tree.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2022-01-25 09:53:30 -0500 )edit

I know, I am sorry, I just took a shot. Thank you tough!

ymag gravatar image ymag  ( 2022-01-25 10:07:34 -0500 )edit

Question Tools

1 follower


Asked: 2022-01-20 04:57:51 -0500

Seen: 642 times

Last updated: Jan 22 '22