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
Asked by zubair on 2017-04-27 03:22:37 UTC
Answers
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
Asked by saikishor on 2018-05-09 03:32:33 UTC
Comments