ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

Losing intensity data when converting between sensor_msgs::PointCloud2 and pcl::PointCloud<T>

asked 2014-06-11 07:08:21 -0600

samudra gravatar image


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::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 ( {
            sensor_msgs::PointCloud2 framecloud =; //I still have intensity
            CloudXYZI framecloud_pcl;
            pcl::fromROSMsg(framecloud, framecloud_pcl); //Failed to find match for field 'intensity'
            t_last_assemble = ros::Time::now();

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2014-10-22 05:48:58 -0600

Raitalaama gravatar image

Had the same problem too. Found out that It is caused by pcl calling the intensity field 'intensity' and ros calling it 'intensities'.

I guess the real fix would be pcl and ros to use same naming convention or to have fromROSMsg to handle the difference. Luckily, the problem is easy to circumvent by just changing the field name of the sensor_msgs::PointCloud2 from intensities to intensity.

sensor_msgs::PointCloud2 response =;
response.fields[3].name = "intensity";
pcl::PointCloud<pcl::PointXYZI> response_pcl;

I'm not sure if the intensity field index is always 3 so you might want to check the names of all of the fields in the message first to be sure.

edit flag offensive delete link more


This fixed it, thanks!

nbanyk gravatar image nbanyk  ( 2015-04-29 15:03:48 -0600 )edit

answered 2014-09-02 00:47:48 -0600

Same here! Have you come up with any solution yet?

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



Asked: 2014-06-11 07:08:21 -0600

Seen: 4,357 times

Last updated: Jun 11 '14