PointCloud2 and PointField
The documentation on the PointCloud2 and PointField messages is a bit sparse and I'm having some difficulty understanding it. I've found the following documentation for these messages PointCloud2 PointField.
If we want to send a 2d image (320x240 pixels) with depth & intensity data that are both floats, I imagine we the object should be populated like this (note this is only pseudo code so there are syntax errors) but its not clear to me if this is completely correct.
PointCloud2 msg;
msg.height = 240;
msg.width = 320;
msg.point_step = 8;
msg.row_step = msg.width*msg.point_step;
msg.is_bigendian = false;
bool is_dense = true;
msg.fields[0].name = "depth";
msg.fields[0].offset = 0;
msg.fields[0].datatype = FLOAT32;
msg.fields[0].count = ???;
msg.fields[1].name = "intensity";
msg.fields[1].offset = 0;
msg.fields[1].datatype = FLOAT32;
msg.fields[1].count = ???;
int byteIdx = 0
for(i = 0; i < depth.size();i++)
{
msg.data[byteIdx++].count = (uint8_t)(depth[i] >>0);
msg.data[byteIdx++].count = (uint8_t)(depth[i] >>8);
msg.data[byteIdx++].count = (uint8_t)(depth[i] >>16);
msg.data[byteIdx++].count = (uint8_t)(depth[i] >>24);
msg.data[byteIdx++].count = (uint8_t)(intensity[i] >>0);
msg.data[byteIdx++].count = (uint8_t)(intensity[i] >>8);
msg.data[byteIdx++].count = (uint8_t)(intensity[i] >>16);
msg.data[byteIdx++].count = (uint8_t)(intensity[i] >>24);
}
So my primary questions are ...
- What is the count value for a field ? Seems to me that this should always be set to 1, when would this not be set to 1?
- What is the purpose of the is_dense field? Does it change how the bytes should be formatted in the msg.data property?
- Are there any examples of populating this message or additional documentation that people could point me to?
Thanks