Why does costmap_2d::Costmap2D Class Reference use integers and not float?
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
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.
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.
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?