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 precompiled computeApproximateCovariances; fix compilation error for the same #3711

Merged
merged 2 commits into from
Mar 15, 2020

Conversation

Morwenn
Copy link
Contributor

@Morwenn Morwenn commented Mar 4, 2020

A colleague told me that computeApproximateCovariances failed to compile: it seems that the automatic change from old for loops to foreach loops introduced that bug.

This this an obvious albeit untested fix since I don't have a test case. I guess that it could ship in 1.10.2 considering how simple and breaking it is.

This bug was most likely introduced when for loops were changed into foreach ones.
@kunaltyagi kunaltyagi added this to the pcl-1.10.1 milestone Mar 4, 2020
@kunaltyagi
Copy link
Member

The green CI implies that there is no cpp file (no test, no lib) including this at all. Is there any way to fix the lack of compilation?

@kunaltyagi kunaltyagi added changelog: fix Meta-information for changelog generation module: features needs: author reply Specify why not closed/merged yet labels Mar 4, 2020
@Morwenn
Copy link
Contributor Author

Morwenn commented Mar 4, 2020

If I actually knew what the function did, how to use it, etc. I'd gladly contribute a test but I'm not the user myself so I unfortunately don't have a ready-made test :/

@kunaltyagi
Copy link
Member

To clarify, I don't think a test is needed, just some way we can compile this header. A test is good, but for 1.10.1, simply compiling it on CI would be great

@Morwenn
Copy link
Contributor Author

Morwenn commented Mar 4, 2020

Hum, then maybe it would be worth creating .cpp in the test suite files with explicit instantiations of function templates and class templates with some template parameters? Something along these lines:

template void pcl::features::computeApproximateCovariances<pcl::PointXYZ, pcl::PointXYZ>(const pcl::PointCloud<pcl::PointXYZ>&, const pcl::PointCloud<pcl::PointXYZ>&, std::vector<Eigen::Matrix3d, Eigen::aligned_allocator<Eigen::Matrix3d>>&, double);

It would take care of the instantiation and compilation without having to find valid use cases or how to call it correctly. Such a file would also be a good list of functions that lack tests - which can be added later.

@kunaltyagi
Copy link
Member

What about an cpp file with template instantiation instead of a test?

@Morwenn
Copy link
Contributor Author

Morwenn commented Mar 5, 2020

Well, that's what I was proposing :p

@kunaltyagi
Copy link
Member

Oops. My bad again. I meant a cpp file "not in the test suite". There are such template instantiations in a lot of places in PCL

@Morwenn
Copy link
Contributor Author

Morwenn commented Mar 5, 2020

Oh, Ill try to find an example of what you already have then.

@Morwenn
Copy link
Contributor Author

Morwenn commented Mar 7, 2020

So basically I need to add PCL_INSTANTIATE_computeApproximateCovariances at the end of from_meshes.h and I need to create a from_meshes.cpp where I call PCL_INSTANTIATE(computeApproximateCovariances, /* foo */); depending on the precompilation options, where foo corresponds to the types of points I need to instantiate the template with? From what I'm gathering I will probably need a product instantiation but I'm not sure which kind of points I'm supposed to handle.

Concerning the type of points: the function takes normals from which we use normal_x, normal_y and normal_z so I guess that we should pass it all point types that support those variables, but cloud is only passed to check its size against that of normals so I'm not sure for which kind of cloud points the function should be instantiated.

@kunaltyagi
Copy link
Member

So basically ...?

Yes. That's the right track. The cpp file will need 2 modes: core_points_only and all points.

From what I'm gathering I will probably need a product instantiation but I'm not sure which kind of points I'm supposed to handle

The first template argument are points that have xyz, and the second are those that have normal. There are macros for both in PCL, which might help here. This will be the non-core-points mode. For core points mode, I know it's a handpicked selection, but I'm not sure which ones. @taketwo or @SergioRAgostinho might know better

@kunaltyagi kunaltyagi added changelog: enhancement Meta-information for changelog generation needs: feedback Specify why not closed/merged yet needs: more work Specify why not closed/merged yet and removed needs: author reply Specify why not closed/merged yet labels Mar 8, 2020
@kunaltyagi kunaltyagi changed the title Fix undeclared variable bug in computeApproximateCovariances Add precompiled computeApproximateCovariances; fix compilation error for the same Mar 8, 2020
@SergioRAgostinho
Copy link
Member

@taketwo or @SergioRAgostinho might know better

No big intuition, I would replicate what I've seen in other classes of the same module, related to this one.

// Instantiations of specific point types
#ifdef PCL_ONLY_CORE_POINT_TYPES
  PCL_INSTANTIATE_PRODUCT(PrincipalCurvaturesEstimation, ((pcl::PointXYZ)(pcl::PointXYZI)(pcl::PointXYZRGBA))((pcl::Normal))((pcl::PrincipalCurvatures)))
#else
  PCL_INSTANTIATE_PRODUCT(PrincipalCurvaturesEstimation, (PCL_XYZ_POINT_TYPES)(PCL_NORMAL_POINT_TYPES)((pcl::PrincipalCurvatures)))
#endif

In your case you're only interest the first two operands of the product. This seems to be the common instantiation in other classes of this module which need covariance information.

@kunaltyagi kunaltyagi removed the needs: feedback Specify why not closed/merged yet label Mar 10, 2020
@taketwo taketwo removed the needs: more work Specify why not closed/merged yet label Mar 13, 2020
@kunaltyagi kunaltyagi added the needs: pr merge Specify why not closed/merged yet label Mar 15, 2020
@kunaltyagi kunaltyagi merged commit e6e7377 into PointCloudLibrary:master Mar 15, 2020
@kunaltyagi kunaltyagi removed the needs: pr merge Specify why not closed/merged yet label Mar 15, 2020
@Morwenn Morwenn deleted the patch-1 branch March 15, 2020 13:57
@taketwo taketwo changed the title Add precompiled computeApproximateCovariances; fix compilation error for the same Add precompiled computeApproximateCovariances; fix compilation error for the same Mar 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: enhancement Meta-information for changelog generation changelog: fix Meta-information for changelog generation module: features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants