Losing intensity data when converting between sensor_msgs::PointCloud2 and pcl::PointCloud<T>
Hello,
Am I supposed to lose intensity data when converting between sensor_msgs::PointCloud2 and pcl::PointCloud<t>? Specifically, I am getting an accumulated laser data from laser_assembler in sensor_msgs::PointCloud2 form. I want to work with the individual points, so I converted it to pcl::PointCloud<pcl::pointxyzi> using pcl::fromROSMsg. However, during runtime I get the warning "Failed to find match for field 'intensity'", and the resulting pcl PointCloud has the value 1 for the intensity of each point.
Here is the part where I periodically assemble laser scan and convert it into a pcl PointCloud:
ros::service::waitForService("assemble_scans");
ros::ServiceClient assembler_client = nh.serviceClient<laser_assembler::AssembleScans2>("assemble_scans2");
laser_assembler::AssembleScans2 assembler_srv;
frame_pub = nh.advertise<CloudXYZI>("assembled_laser", 1);
while (ros::ok()) {
if (ros::Time::now() - t_last_assemble > ros::Duration(t_skip)) {
assembler_srv.request.begin = ros::Time::now() - ros::Duration(t_frame);
assembler_srv.request.end = ros::Time::now();
if (assembler_client.call(assembler_srv)) {
sensor_msgs::PointCloud2 framecloud = assembler_srv.response.cloud; //I still have intensity
CloudXYZI framecloud_pcl;
pcl::fromROSMsg(framecloud, framecloud_pcl); //Failed to find match for field 'intensity'
frame_pub.publish(framecloud);
t_last_assemble = ros::Time::now();
}
}
ros::spinOnce();
}