grid_map icon indicating copy to clipboard operation
grid_map copied to clipboard

missmatching sizes of grid_map using rviz plugin (ROS)

Open csanrod opened this issue 2 years ago • 1 comments

Hello!

I'm developing an app using ROS Noetic, in Ubuntu 20.04 LTS, using C++. Here I provide the code where I initialize everything:

GridMap map({"elevation"});
map.setFrameId("map");    
map.setGeometry(Length(10, 10), 1);

Then I create and publish the message here:

int i = 0;
for (GridMapIterator it(map); !it.isPastEnd(); ++it) {
  Position position;
  map.getPosition(*it, position);
  map.at("elevation", *it) = data.data[i];
  i++;
}

ros::Time time = ros::Time::now();
map.setTimestamp(time.toNSec());
grid_map_msgs::GridMap message;
GridMapRosConverter::toMessage(map, message);
publisher.publish(message);

The thing is 'data' is an array of 100 elements (10x10), but when I display it in rviz, I get a 9x9 representation. I tried to change the size to 11x11, but the representation gets buggy because it has more than 100 elements, but the matrix showed in rviz is 10x10. Here are some results:

In this case, the representation of the data is correct, but it shows a 9x9 matrix instead of a 10x10 in rviz, meanwhile the data is still a 10x10 array: image

Here I paint an 11x11 map in rviz (which shows a 10x10), but data displayed is inconsistent because I'm giving 100 elements to the 11x11 map: image

Why is this happening?

csanrod avatar Apr 13 '23 15:04 csanrod

Each corner point on the black lines represent a cell center, the planes that you see are the interpolation between four corner points. So this is no bug and works as intended, as there are 10 "corner points" for the 10x10 grid example.

weidinger-c avatar May 08 '23 06:05 weidinger-c