ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

showtime's profile - activity

2022-10-17 06:18:01 -0500 received badge  Good Question (source)
2013-10-30 01:22:12 -0500 received badge  Nice Question (source)
2012-10-22 07:41:43 -0500 received badge  Famous Question (source)
2012-05-11 08:17:49 -0500 received badge  Notable Question (source)
2012-02-18 10:32:17 -0500 received badge  Popular Question (source)
2012-02-16 02:56:26 -0500 received badge  Student (source)
2011-10-31 20:51:10 -0500 received badge  Editor (source)
2011-10-31 20:50:09 -0500 asked a question Problems of NaN positions when converting PointCloud2 to pcl::PointCloud PointXYZRGB

Hello

I have tried to convert PointCloud2 message from openni_kinect to pcl::PointCloud<pcl::pointxyzrgb>. And I have some critical problem when I check position information of PointXYZRGB. All position data is written as 'nan'.

OS: Ubuntu Linux 10.04
ROS version: Electric
Sensor: Primesensor

The procedure of my code is like bellow:

A. get sensor_msg(camera/depth_registered/points) from openni_launch

B. convert sensor_msgs::PointCloud2 data (=pc2) to pcl::PointCloud<pcl::pointxyzrgb> data (=pcl_pc) as

 pcl::fromROSMsg(pc2, pcl_pc);

at this time, I check the data of pcl_pc data like bellow

cout << pcl_pc.points[0].x << endl;

the result is 'nan'

C. I convert inversely from pcl::PointCloud<pcl::pointxyzrgb> data (=pcl_pc) to convert sensor_msgs::PointCloud2 data (=pc2) for publishing to rviz a

 pcl::toROSMsg(pcl_pc, pc2);
 pub_pc_rgb.publish(pc2);

and I can make certain that point clouds data displayed correctly on rviz.

D. Moreover Moreover I saved pcl::PointCloud<pcl::pointxyzrgb> into pcd format. the values of position in this case also 'nan' like below:

# .PCD v.7 - Point Cloud Data file format
VERSION .7
FIELDS x y z rgb
SIZE 4 4 4 4
TYPE F F F F
COUNT 1 1 1 1
WIDTH 640
HEIGHT 480
VIEWPOINT 0 0 0 1 0 0 0
POINTS 307200
DATA ascii
nan nan nan 7.1023033e-39
nan nan nan 7.1023033e-39
nan nan nan 6.8275213e-39
nan nan nan 6.9197169e-39
nan nan nan 6.8278744e-39
nan nan nan 6.7356788e-39
nan nan nan 6.367262e-39
...
...

I guess this problem is associated with conversion of data format. Because the type of PointCloud2.data is unsigned char and the type of PointXYZRGB.points is float. Inside of function pcl::fromROSMsg, they copy data between these two data structure using memcpy. That's the reason that it displays correctly on rviz when I convert inversely because the function toROSMsg also use memcpy between float data(pcl::PointCloud.points) and corresponding 4 unsigned char data (PointCloud2.data).

Is there any idea about this problem?? or this only happen to me ??