I am trying to do a basic RRT global planner implementation in ROS Melodic. I am using a wheeled mobile robot for testing my own global planner plugin for robot navigation through move_base. I am loading the map using map server package. As you know RRT requires a point to sample from configuration space, in order to sample random points i use the map bounds obtained by following attribute from costmap_2d.

 x_rand.point.x = randomDouble(costmap_->getOriginX(), costmap_->getOriginX() + costmap_->getSizeInMetersX());
 x_rand.point.y = randomDouble(costmap_->getOriginY(), costmap_->getOriginY() + costmap_->getSizeInMetersY());

Now, the samples are taken from a bound of X-> (-100, 100), y-> (-100,100) which seem to be default values for ROS.

My actual map is only 40 * 40 in dimension. As you can guess, planner samples a lot of useless point. On top of it when i evaluate the cost of a point which lies outside the 40 * 40 map bounds(actual map bounds) the cost values evaluate to zero, i.e.

costmap_->getCost(x, y) = 0;

This makes the planner think it is a right point to extrapolate towards.

Am i missing something ? please let me know!

  • 1
    $\begingroup$ Please edit your question to provide more information: Is this a wheeled-robot, or a robot arm? Are you using move_base? What is the data source(s) for the global costmap (e.g. a map server)? $\endgroup$
    – Mike973
    Nov 11 at 13:56
  • $\begingroup$ Yes, I am using a wheeled mobile robot for navigation. i am using move base. I am loading the map using map server package . how do i proceed? $\endgroup$
    – Rahul
    Nov 13 at 5:27
  • $\begingroup$ It would be better to edit your question to add the above details, rather than just having them in the comments. Are you trying to write your own Global Planner plugin for move_base, or is your code executing external to move_base? $\endgroup$
    – Mike973
    Nov 15 at 13:39
  • $\begingroup$ Hi, I dded the details in my question again. I am writing my own global planner plugin. The only thing is a random sample is taken even outside the actual map bounds. $\endgroup$
    – Rahul
    Nov 23 at 6:13

1 Answer 1


I think you are confused about the coordinate system that is being used. Please read http://wiki.ros.org/costmap_2d, particularly sections 7 and 8.1.4.

Assuming your global costmap is initialized in the standard way, you should be choosing a cell between (0,0) and (getSizeInCellsX()-1, getSizeInCellsY()-1). Note that (0,0) is the lower left cell of the costmap.

Later, if you need it, you can convert from costmap-coordinates to map-coordinates.

If you configure a static map layer, the global costmap will pick up those dimensions, or if you load a costmap image it will use those dimensions, or finally you can set the costmap size using configuration values.

  • $\begingroup$ I will look into what you suggested, is dimensions of costmap different from map ? where do we specify the configuration values for costmap size ? $\endgroup$
    – Rahul
    Nov 25 at 12:15

Your Answer

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

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