I am unable to zero copy from a gridmap message type into the corresponding eigen matrix using the grid_map::multiArrayMessageMapToMatrixEigen() function in GridMapMessageHelpers.hpp.
Here is code to reproduce this:
// create a minimal gridmap
grid_map::GridMap map({"foo"});
map.setGeometry(grid_map::Length(1.0, 1.0), 0.2, grid_map::Position(0.0, 0.0));
// for convenience generate a valid gridmap message
grid_map_msgs::GridMap msg;
grid_map::GridMapRosConverter converter;
converter.toMessage(map, msg);
// attempt to zero copy msg into a matrix
msg.data[0].data[0] = 1.f; // mark data at this index
grid_map::Matrix mat;
if(!grid_map::multiArrayMessageMapToMatrixEigen(msg.data[0], mat))
{
return -1;
}
// verify the addresses of the data
std::cout<<"msg value:"<<msg.data[0].data[0]<<std::endl;
std::cout<<"mat value: "<<mat(0, 0)<<std::endl;
std::cout<<"msg address" <<&msg.data[0].data[0]<<std::endl;
std::cout<<"mat address" <<&mat(0, 0)<<std::endl;
The output of which was:
msg value:1
mat value: 1
msg address0x55d9e2d209b0
mat address0x55d9e2d208e0
I am unable to zero copy from a gridmap message type into the corresponding eigen matrix using the
grid_map::multiArrayMessageMapToMatrixEigen()
function in GridMapMessageHelpers.hpp.Here is code to reproduce this:
The output of which was: