Ask Your Question

sensor_msgs pointcloud2 color value ?

asked 2018-12-01 06:10:21 -0600

dinesh gravatar image

Does sensor_msgs/PointCloud2 data type also contains the rgb value of the image? Currentely i'm using below code, and when i publish the converted pcl type, it also shows rgb values, how is that possible?

cloud_cb (const sensor_msgs::PointCloud2ConstPtr& input)
    pcl::PointCloud<pcl::PointXYZRGB> output;


    main (int argc, char** argv)
  // Initialize ROS
  ros::init (argc, argv, "training");
  ros::NodeHandle nh;

  ros::Subscriber sub = nh.subscribe<sensor_msgs::PointCloud2> ("input", 1, cloud_cb);
  marker_pub = nh.advertise<visualization_msgs::Marker> ("visualization_marker",1);

  // Spin
  ros::spin ();

as i can see in the sensor_msgs/pointcloud2 documentations it shows below values:

std_msgs/Header header
uint32 height
uint32 width
sensor_msgs/PointField[] fields
bool is_bigendian
uint32 point_step
uint32 row_step
uint8[] data
bool is_dense

where data should be representing only the depth of the voxels. how is it returning rgb values when converted to pcl<xyzrgb> data type? i'm little confused, cas i didn't used this code for year.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-12-01 08:59:23 -0600

Yes the PointCloud2 message can represent color point clouds.

The sensor_msgs/PointCloud2 message type can represent an unlimited range of different point cloud types, simple XYZ points, XYZ intenstiy, XYZ color, XYZ with normals. There is no limit since each message uses the sensor_msgs/PointField[] fields declaraion to define the point data structure structure it uses.

The actual data of the point cloud is stored as a raw data buffer in the data element, this needs to be decoded by the receiver using the point structure defined. This is the why the message definition doesn't explicitly include the the XYZ, RGB or any other representation of point data.

Hope this clears this up.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2018-12-01 06:10:21 -0600

Seen: 1,550 times

Last updated: Dec 01 '18