Skip to content

Added unit test for points almost on a line, that previously resulted in NAN values.#6426

Open
larshg wants to merge 1 commit intoPointCloudLibrary:masterfrom
larshg:addunittestmls
Open

Added unit test for points almost on a line, that previously resulted in NAN values.#6426
larshg wants to merge 1 commit intoPointCloudLibrary:masterfrom
larshg:addunittestmls

Conversation

@larshg
Copy link
Copy Markdown
Contributor

@larshg larshg commented Apr 15, 2026

Adapted unit test from #788
Closes #787 as it verifies that it is already fixed.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a regression unit test to ensure MovingLeastSquares with SAMPLE_LOCAL_PLANE upsampling does not emit NaN coordinates for an (almost) collinear input set, addressing the scenario described in #787 (adapted from #788).

Changes:

  • Introduces a new TEST(PCL, MovingLeastSquares_almost_on_line) case with a small, nearly collinear PointXYZ input.
  • Runs MLS with SAMPLE_LOCAL_PLANE upsampling and asserts output points are finite.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +64 to +71
PointCloud<PointXYZ>::Ptr cloud_almost_on_line(new PointCloud<PointXYZ>);

TEST(PCL, MovingLeastSquares_almost_on_line)
{
cloud_almost_on_line->push_back(pcl::PointXYZ(-89.546, 4.03964, 450.883));
cloud_almost_on_line->push_back(pcl::PointXYZ(-88.8728, 4.03964, 450.883));
cloud_almost_on_line->push_back(pcl::PointXYZ(-86.8529, 4.03964, 450.883));
cloud_almost_on_line->push_back(pcl::PointXYZ(-85.5064, 4.03964, 450.883));
Comment on lines +84 to +90
// Reconstruct
mls.process(mls_points);

for (size_t i = 0; i < mls_points.size(); ++i) {
// Check for NaNs in output
EXPECT_TRUE(pcl::isFinite(mls_points[i]));
}
search::KdTree<PointXYZ>::Ptr tree3;
search::KdTree<PointNormal>::Ptr tree4;

PointCloud<PointXYZ>::Ptr cloud_almost_on_line(new PointCloud<PointXYZ>);
Comment on lines +87 to +89
for (size_t i = 0; i < mls_points.size(); ++i) {
// Check for NaNs in output
EXPECT_TRUE(pcl::isFinite(mls_points[i]));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (size_t i = 0; i < mls_points.size(); ++i) {
// Check for NaNs in output
EXPECT_TRUE(pcl::isFinite(mls_points[i]));
for (const auto& mls_point : mls_points) {
// Check for NaNs in output
EXPECT_TRUE(pcl::isFinite(mls_point));

Suggested by clang-tidy

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Moving Least Squares produces NaN outputs

3 participants