pcl contains x y and z values as nan !!
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, &my_pcl.data[arrayPosX], sizeof(float));
memcpy(&Y, &my_pcl.data[arrayPosY], sizeof(float));
memcpy(&Z, &my_pcl.data[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