1

I am trying to convert a point cloud (x, y, z) data acquired from a Kinect V2 using libfreenect2, into a virtual 2D laser scan (e.g., a horizontal angle/distance vector).

I am currently assigning per pixel column, the PCL distance value, as shown below:

std::vector<float> scan(512, 0);
for (unsigned int row = 0; row < 424; ++row) {
    for (unsigned int col = 0; col < 512; ++col) {
        float x, y, z;
        registration->getPointXYZ(depth, row, col, x, y, z);
        if (std::isnan(x) || std::isnan(y) || std::isnan(z)) {
            continue;
        }
        Eigen::Vector3f values = rotate_translate((-1 * x), y - 1.186, z);
        if (scan[col] == 0) {
            scan[col] = values[1];
        }
        if (values[1] < scan[col]) {
            scan[col] = values[1];
        }
    }
}

You may ignore the rotate_translate method, it simply changes the local to global coordinates using the sensor pose.

The problem is best shown using the pictures below:

Whereas the LIDAR range sensor produces the following pointsmap:

lidar Map

the kinect 2D range scan is curved, and of course narrower, since the horizontal FOV is 70.6 degrees compared to the 270 degree range of the LIDAR.

kinect map

It is this curvature that I am trying to fix; the SLAM/ICP library I'm using is mrpt and the actual data scan is inserted into an mrpt::obs::CObservation2DRangeScan observation:

auto obs = mrpt::obs::CObservation2DRangeScan();
obs.loadFromVectors(scan.size(), scan.data(), (char*)scan.data());
obs.aperture = mrpt::utils::DEG2RAD(70.6f);
obs.maxRange = 6.0;
obs.rightToLeft = true;
obs.timestamp = mrpt::system::now();
obs.setSensorPose(sensor);

I've searched around google and SO, and the only answers which seem to address this question, are this one and that one. So whereas I understand that the curvature is the result of me assigning each pixel column the PCL value, I am uncertain as to how I can use that to remove the curvature.

Each reply seems to take a different approach, and from what I understand the task is a linear interpolation of the angle per pixel ratio, and the current pixel coordinates?

Community
  • 1
  • 1
Ælex
  • 14,432
  • 20
  • 88
  • 129

0 Answers0