Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
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;
}

this is how i am using pcl to find out x y and z ,, int x and y are my pixel values from blob,, but i have the same problem x y and z datat from point cloud have a lot of Nan values .. please help

thanks ya all