sensor_msgs pointcloud2 color value ?
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?
void
cloud_cb (const sensor_msgs::PointCloud2ConstPtr& input)
{
pcl::PointCloud<pcl::PointXYZRGB> output;
pcl::fromROSMsg(*input,output);
cout<<output.at(100,100).x<<""<<output.at(100,100).r<<endl;
}
int
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.