Converting pointcloud2 data to ros image
I have created a node that publishes fake pointcloud2 data. However, I am not getting an image unless I use an organised point cloud. I arbitrarily set the height and width parameters to 100 each, and also gave arbitrary rgb values to the points and I got a 100x100 image. However, I do not understand how the image is a representation of my pointcloud2 data. ie. what has happened to the x,y,z values I supplied.
//generating fake pointcloud data
for(i=0;i<100;i++)
{
for(j=0;j<100;j++)
{
cloud->at(i,j).x=1.0+j;
cloud->at(i,j).y=2.0+j;
cloud->at(i,j).z=3.0+j;
cloud->at(i,j).r=(40+j)%255;
}
}