Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[icp] pcl::IterativeClosestPoint crash when encountering an invalid point in debug mode #6042

Closed
QiuYilin opened this issue May 16, 2024 · 5 comments · Fixed by #6054
Closed

Comments

@QiuYilin
Copy link
Contributor

pcl::IterativeClosestPoint will crash when encountering an invalid point in debug mode, but not in release mode.

Assertion failed: point_representation_->isValid (point) && "Invalid (NaN, Inf) point coordinates given to nearestKSearch!", file C:\src\vcpkg\buildtrees\pcl\src\head\f84d767a5c-61de3f9c1f.clean\kdtree\include\pcl/kdtree/impl/kdtree_flann.hpp, line 239

code:

#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/registration/icp.h>

#include <iostream>

int main() {
  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_in(
      new pcl::PointCloud<pcl::PointXYZ>(5, 1));
  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_out(
      new pcl::PointCloud<pcl::PointXYZ>);

  pcl::io::loadPCDFile<pcl::PointXYZ>("../../source/croped.pcd", *cloud_in);

  pcl::io::loadPCDFile<pcl::PointXYZ>("../../source/croped.pcd", *cloud_out);

  std::cout << "Transformed " << cloud_in->size()
            << " data points:" << std::endl;

  pcl::IterativeClosestPoint<pcl::PointXYZ, pcl::PointXYZ> icp;
  icp.setInputSource(cloud_in);
  icp.setInputTarget(cloud_out);

  pcl::PointCloud<pcl::PointXYZ> Final;
  icp.align(Final);

  std::cout << "has converged:" << icp.hasConverged()
            << " score: " << icp.getFitnessScore() << std::endl;
  std::cout << icp.getFinalTransformation() << std::endl;

  return (0);
}

pcd file : https://github.com/QiuYilin/test/blob/main/pcl_test/source/croped.pcd

Your Environment (please complete the following information):

  • OS: [Windows 10]
  • Compiler: [MSVC 2022]
  • PCL Version: 8e844ea
@QiuYilin QiuYilin added kind: bug Type of issue status: triage Labels incomplete labels May 16, 2024
@QiuYilin QiuYilin changed the title [icp] [icp] pcl::IterativeClosestPoint crash when encountering an invalid point in debug mode May 16, 2024
@mvieth mvieth added module: registration and removed status: triage Labels incomplete labels May 16, 2024
@mvieth
Copy link
Member

mvieth commented May 16, 2024

So in release mode, how are the results (the aligned cloud and the final transformation)? Do they make sense?

Most users probably use some kind of filter (e.g. PassThrough or VoxelGrid) before ICP, so ICP currently does not check for invalid points.

@QiuYilin
Copy link
Contributor Author

The result in Release mode are meaningless. The pcd file is result of filter cropbox.

@mvieth
Copy link
Member

mvieth commented May 17, 2024

The result in Release mode are meaningless. The pcd file is result of filter cropbox.

Could you describe the crop-box filtering a bit more, perhaps post some code? Did you use a pcl::CropBox<pcl::PointXYZI> or a pcl::CropBox<pcl::PCLPointCloud2> or something else?

@QiuYilin
Copy link
Contributor Author

Yes,I used pcl::CropBoxpcl::PointXYZI with "keep organized" on.

Part of the point cloud in ascii format:

# .PCD v0.7 - Point Cloud Data file format
VERSION 0.7
FIELDS x y z intensity
SIZE 4 4 4 4
TYPE F F F F
COUNT 1 1 1 1
WIDTH 3200
HEIGHT 400
VIEWPOINT 0 0 0 1 0 0 0
POINTS 1280000
DATA ascii
nan nan nan 0
nan nan nan 0
nan nan nan 0
nan nan nan 0
nan nan nan 0
nan nan nan 0
nan nan nan 0
nan nan nan 0
nan nan nan 0
nan nan nan 0

@QiuYilin
Copy link
Contributor Author

There is still something wrong in icp.getFitnessScore(). Fix in #6056

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants