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

Add check for invalid plane coefficients in MovingLeastSquares #2805

Merged
merged 2 commits into from
Feb 6, 2019

Conversation

ThorstenHarter
Copy link
Contributor

Observation:
If the input cloud is non-dense or if the points in the neighborhood are linearly dependent, the algorithm creates invalid output points.

Proposal:
Check the values of the computed eigen vector for NaN (line 740 ff.) and keep the input point in this case instead (53af42f).

@ThorstenHarter
Copy link
Contributor Author

@Levi-Armstrong: Would you please review, since you authored the original code.

I made this change already six months ago in our local repository and have been using it since.

@@ -738,9 +738,20 @@ pcl::MLSResult::computeMLSSurface (const pcl::PointCloud<PointT> &cloud,
model_coefficients.head<3> ().matrix () = eigen_vector;
model_coefficients[3] = -1 * model_coefficients.dot (xyz_centroid);

query_point = cloud.points[index].getVector3fMap ().template cast<double> ();

if (!pcl_isfinite (eigen_vector[0]) || !pcl_isfinite (eigen_vector[1]) || !pcl_isfinite (eigen_vector[2]))
Copy link
Member

Choose a reason for hiding this comment

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

We have a pending PR that removes pcl_isfinite macro (#2798). Please use eigen_vector.isFinite() instead.

@taketwo
Copy link
Member

taketwo commented Jan 24, 2019

Sorry if I was not clear enough. I only meant that you should not add new code using pcl_isfinite, not correct existing. The referenced PR will take care of existing code. As it is now, these two are in conflict.

@ThorstenHarter
Copy link
Contributor Author

I have corrected my last commit, so that the pcl_isfinite is only replaced in the new if-clause.

Copy link
Member

@taketwo taketwo left a comment

Choose a reason for hiding this comment

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

Thanks! Let's wait for @Levi-Armstrong final word.

@taketwo
Copy link
Member

taketwo commented Feb 5, 2019

@SergioRAgostinho should we squash on merge?

@SergioRAgostinho
Copy link
Member

In the optimal case, I would squash the 1st, 3rd and 4th commits while keeping the 2nd (code inspection one) separated.

@taketwo
Copy link
Member

taketwo commented Feb 6, 2019

@ThorstenHarter would you mind doing this?

Thorsten Harter added 2 commits February 6, 2019 10:29
If the input cloud is non-dense, the algorithm creates invalid output points.
Keep the input point in this case instead.
- Add const wherever possible
- Join local variable declaration and assignment
- Initialize structs
@ThorstenHarter
Copy link
Contributor Author

@taketwo Done.

@taketwo
Copy link
Member

taketwo commented Feb 6, 2019

Thanks!

@taketwo taketwo merged commit b535651 into PointCloudLibrary:master Feb 6, 2019
@taketwo taketwo changed the title Add check for invalid plane coefficients in pcl::MovingLeastSquares Add check for invalid plane coefficients in MovingLeastSquares Jan 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants