Skip to content

Commit 29feb18

Browse files
authored
Added unit test for points almost on a line, that previously resulted in NAN values. (#6426)
* Added unit test for points almost on a line, that previously resulted in NAN values. * Update per review.
1 parent 63f25ce commit 29feb18

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

test/surface/test_moving_least_squares.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,36 @@ PointCloud<PointNormal>::Ptr cloud_with_normals1 (new PointCloud<PointNormal>);
6161
search::KdTree<PointXYZ>::Ptr tree3;
6262
search::KdTree<PointNormal>::Ptr tree4;
6363

64+
TEST(PCL, MovingLeastSquares_almost_on_line)
65+
{
66+
PointCloud<PointXYZ>::Ptr cloud_almost_on_line (new PointCloud<PointXYZ>);
67+
cloud_almost_on_line->push_back(pcl::PointXYZ(-89.546, 4.03964, 450.883));
68+
cloud_almost_on_line->push_back(pcl::PointXYZ(-88.8728, 4.03964, 450.883));
69+
cloud_almost_on_line->push_back(pcl::PointXYZ(-86.8529, 4.03964, 450.883));
70+
cloud_almost_on_line->push_back(pcl::PointXYZ(-85.5064, 4.03964, 450.883));
71+
72+
// Init objects
73+
PointCloud<PointXYZ> mls_points;
74+
MovingLeastSquares<PointXYZ, PointXYZ> mls;
75+
76+
// Set parameters
77+
mls.setInputCloud(cloud_almost_on_line);
78+
mls.setSearchRadius(4.65032);
79+
mls.setUpsamplingMethod(MovingLeastSquares<PointXYZ, PointXYZ>::SAMPLE_LOCAL_PLANE);
80+
mls.setUpsamplingRadius(0.8);
81+
mls.setUpsamplingStepSize(0.4);
82+
83+
// Reconstruct
84+
mls.process(mls_points);
85+
ASSERT_FALSE(mls_points.empty());
86+
87+
for (const auto& mls_point : mls_points)
88+
{
89+
// Check for NaNs in output
90+
EXPECT_TRUE(pcl::isFinite(mls_point));
91+
}
92+
}
93+
6494
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6595
TEST (PCL, MovingLeastSquares)
6696
{

0 commit comments

Comments
 (0)