Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

While i don't have a fix to show i was able to determine what was causing my coloring errors from the pointcloud.


Each field of the PointCloud2 message has a datatype property that tells you how to unpack the data into its proper values. I was attempting to unpack one datatype as another which caused the mismatch.


Each point cloud message contains a property msg.fields which describes the type of data stored in the point cloud message.

For the RealSense D435i they are set up as follows

  • msg.fields[0]/name = "x"
  • msg.fields[1]/name = "y"
  • msg.fields[2]/name = "z"
  • msg.fields[3]/name = "rgb"

The RealSense camera publishes the xyz fields with a datatype 7 (float32) and the rgb field with a datatype of 6 (uint32). See the ROS PointCloud2 message description for more details.

You must first be careful when unpacking the data to make sure you unpack it assuming the correct datatype as that may change between your differing colored point cloud sources. Then you must ensure to cast/store the individual unpacked r, g, b using a datatype that displays their proper value (uint8). Only then will you get the correct 0-255 range for the data.

I know this explanation is lacking but i hope it helps some of you!