Rosanswers logo

I'd like to add values to the costmap used by move_base (and the PR2). However I don't want to add obstacles from sensor data. Instead, I'd like to just be able to arbitrarily raise the cost of going through particular locations. For instance, our lab has a kitchen, and we'd rather the robots don't go into that area unless they absolutely have to. Seems like you could do that by making the value of the costmap in that area less than 127 (as per the costmap documentation).

It seems like there might be three approaches to this problem.

  1. Formulate the restrictions as artificial sensor data. Seems tricky and hacky.
  2. Dynamically edit the global map.
  3. Enhance move_base to subscribe to some additional information source.

It seems like 3 is the most straightforward solution, but I'm wondering if there's a better way.

tl;dr; How do I add "I'd really rather you didn't go there" areas to the costmap?

Originally posted by David Lu on ROS Answers with karma: 10932 on 2012-01-09

Post score: 4


2 Answers 2


Rosanswers logo

I'd say that if you just wanted to avoid that area completely, you could simply mark those areas as obstacles in a static map and load that map into the global map using map_server.

If you want to preserve the ability to traverse it, the above are the best options in my opinion.

I'll add a fourth option, just in case:

Carry two static maps loaded from image files. One with the areas in question marked as obstacles, and one with them as free. Then, you can use actionlib to watch for a path-planning failure due to no route. If this error is received, you could then load the emptier map and retry. This is also a fairly hacky solution, but it eliminates the need for marking the areas as obstacles dynamically.

Originally posted by DimitriProsser with karma: 11163 on 2012-01-09

This answer was ACCEPTED on the original site

Post score: 3


Rosanswers logo

What I actually ended up doing was what I listed as option 1, which was easier than expected. I created a PointCloud designating where I didn't want the robot to go. Then I fed that in as one of the observation sources.

I had initially tried to send the PointCloud with the frame_id /map but move_base didn't like that, so I transformed it to /base_laser_link instead.

I'm still interested if anyone has hacked up option 3 so that you don't have to mark things as obstacles necessarily, but just increase the cost a little bit.

Originally posted by David Lu with karma: 10932 on 2012-02-08

This answer was NOT ACCEPTED on the original site

Post score: 1

Original comments

Comment by fmarques on 2012-02-20:
I'm also interested in adding custom values to the costmap, so I can raise the cost of a certain cells. My idea is to add a pointcloud as an observation source with the intensity off a given point as the cost to be added to the costmap.

Comment by David Lu on 2012-02-20:
What application are you considering? I'm currently developing a patch to costmap that can take in cost map adjustments and trying to decide what sort of values you might want to feed in.

Comment by fmarques on 2012-02-22:
I'm trying to make a generic way to fuse multiple sensors, so that some of then increase cost and some decrease cost.

Comment by oswinium on 2014-03-18:
David, are there any tutorials or step-by-step guides for how to actually go about doing this i.e. manually creating a PointCloud; positioning it in a certain location in a costmap; and feeding it in as an observation source?

Comment by David Lu on 2014-03-19:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.