By resetting the costmap origin, you are telling the costmap that its position in the world frame has changed. The costmap_2d object uses the origin that you specify when calling the mapToWorld()
method (among others) to determine the translation from world coordinates to individual costmap cells. You can set the origin in whatever frame you want.
So, if you set (10, 10) as the origin, and you sent a goal of (15, 15), when you look up the costmap grid space corresponding to your goal, the grid space would be ( (15-10) / resolution, (15-10) / resolution) ). So if your resolution was 0.1 meters/pixel, your costmap index for that goal would be (50, 50).
Additionally, the costmap grid spaces can never have a negative index (they're all unsigned int
). You can find the API here if you're interested.