Ask Your Question
0

Why does costmap_2d::Costmap2D Class Reference use integers and not float?

asked 2019-03-29 09:32:44 -0500

JackB gravatar image

updated 2019-04-01 02:02:08 -0500

mgruhler gravatar image

Looking through the documentation of costmap_2d::Costmap2D Class Reference I am seeing that a lot of the functionality for querying specific values about cells uses unsigned ints. For example;

getCost (unsigned int mx, unsigned int my) const Get the cost of a cell in the costmap.

getIndex (unsigned int mx, unsigned int my) const Given two map coordinates... compute the associated index.

indexToCells (unsigned int index, unsigned int &mx, unsigned int &my) const Given an index... compute the associated map coordinates."

My question is why does it not use floats instead of unsigned ints? Because if I want to get the cost of a cell at map coordinate (25.25, 13.75), and the resolution is small, then the integer value (25, 14) will not be able to query the value of the true cell I want.

This may be a pretty bad question cause I am so new to this, but it has really been frustrating my understating and use of the ROS costmap2D.

Thanks ahead of time!

JJB

edit retag flag offensive close merge delete

Comments

3

I would say because a costmap is a discretised representation of a 2d area, and that discretisation was done at a certain resolution.

Given a certain resolution, it doesn't make sense to ask for a value at .25 and .75 of a cell, as there can be no more accurate data than the resolution allows.

If you're asking why you can't use "real coordinates" (ie: meters from the origin" or something similar") that would be something else.

gvdhoorn gravatar imagegvdhoorn ( 2019-03-29 10:02:28 -0500 )edit

I think that might be what I am really trying to understand, why can you not use meters from origin to work with the costmap.

JackB gravatar imageJackB ( 2019-03-29 10:45:14 -0500 )edit
2

The Costmap2D::worldToMap function converts world coordinates (in meters, as doubles) to map coordinates that you can use with the other functions. Perhaps that's what you're looking for?

ahendrix gravatar imageahendrix ( 2019-04-01 02:21:15 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-04-01 02:25:08 -0500

mgruhler gravatar image

The costmap is internally stored as a one-dimensional array. Thus, for looking up data, you use the array index or the cell coordinates mx and my.

If you want to use metric coordinates, you need to first retrieve the respective cell coordinates using one of the worldToMap functions (inverse is mapToWorld). Those functions take care of converting metric to cell (or map) coordinates (and vice versa) observing the respective sizes in x and y as well as the resolution.

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: 2019-03-29 09:32:44 -0500

Seen: 29 times

Last updated: Apr 01