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

pcl contains x y and z values as nan !!

asked 2017-04-27 03:22:37 -0600

zubair gravatar image

updated 2017-04-27 04:35:20 -0600

hi guys, i am doing blob detection and for my x y and z values i am using point cloud, but most of the time the values of x y and z in point cloud is Nan ! though the pixel values of x and y which i am getting from my blob is never Nan (obviously), so these pixel values of x and y i am feeding to point cloud to calculate x y and z resp. can anyone tell me how can i retrieve continuous x y and z values from my point cloud !!! below is my code .

void getXYZ(int x, int y)
int arrayPosition = y * my_pcl.row_step + x * my_pcl.point_step;
int arrayPosX = arrayPosition + my_pcl.fields[0].offset; // X has an offset of 0
int arrayPosY = arrayPosition + my_pcl.fields[1].offset; // Y has an offset of 4
int arrayPosZ = arrayPosition + my_pcl.fields[2].offset; // Z has an offset of 8

float X;
float Y;
float Z;

memcpy(&X, &[arrayPosX], sizeof(float));
memcpy(&Y, &[arrayPosY], sizeof(float));
memcpy(&Z, &[arrayPosZ], sizeof(float));

geometry_msgs::Point p;
// put data into the point p
p.x = X;
p.y = Y;
p.z = Z;
std::cout << "x :" << p.x << "y :" << p.y << "z :" << p.z << std::endl;

where int x and int y are my pixel values i am giving in my main programme from blob..

thanks guys

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-05-09 03:32:33 -0600

saikishor gravatar image

Hiii there, I just came across your issue. if your point from the point cloud returns nan, that it means that the point doesn't exist in the point cloud. The program you shared should work, but your pixel query is in the some region of point cloud where the point cloud is not registered. Better query at the object and you will see that it works

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2017-04-27 03:22:37 -0600

Seen: 675 times

Last updated: May 09 '18