fzi-forschungszentrum-informatik / vdb_mapping

Performantes 3D Kartierungs-Framework auf Basis von OpenVDB
Apache License 2.0
41 stars 10 forks source link

Handling of clouds that might have zero points (x=y=z=0) #3

Open PaulKemppi opened 2 years ago

PaulKemppi commented 2 years ago

Hi and thank you for the interesting and very useful vdb_mapping module.

This is not a bug, but a suggestion to modify the code so that it can handle gracefully input clouds that have invalid points. Some sensors / software modules may represent points with no range measurement as x=y=z=NaN or x=y=z=0 and have them in the cloud just to keep the cloud organized (= having width and height).

At least with x=y=z=0, the while loop in VDBMapping::insertPointCloud (line 110) never exists and no output is published.

To ignore zero points, one could check the length of the ray and ignore the point of the ray length is too small:

  double min_ray_length = 1e-7;
  // Raycasting of every point in the input cloud
  for (const PointT& pt : *cloud)
  {
    max_range_ray = false;
    ray_end_world = openvdb::Vec3d(pt.x, pt.y, pt.z);
    // Ignore points in the origin
    ray_length = (ray_end_world - ray_origin_world).length();
    if (ray_length < min_ray_length)
    {
        continue;
    }
    .
    .
MGBla commented 2 years ago

Hey Paul, thanks for the feedback and you are absolutely right. I think currently it might do one raycasting iteration in case of a 0,0,0 point. In the next few days(hopefully) I will make a sync with our development repo and include a sanity check for these cases while I'm at it.