ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Rewriting the first piece of code like this may help with understanding.
int index;
for (unsigned int y = 0; y < size_y; ++i)
{
for (unsigned int x = 0; x < size_x; ++j)
{
index = toIndex(x, y);
char value = new_map->data[index];
costmap_[index] = interpretValue(value);
}
}
Not sure if this will even compile, but the point is the two things are equivalent. toIndex function projects 2d coordinates into an index in 1d array, and the value of x and y start from 0. Since the code tries to copy all the value into costmap_, it doesn't really care about the index of each value as long as all the cells are looped through. Therefore it didn't bother to use toIndex.