-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Correspondence estimation with different point types #4901
Correspondence estimation with different point types #4901
Conversation
common/include/pcl/common/io.h
Outdated
@@ -319,10 +319,10 @@ namespace pcl | |||
pcl::PCLPointCloud2 &cloud_out); | |||
|
|||
/** \brief Check if two given point types are the same or not. */ | |||
template <typename Point1T, typename Point2T> inline bool | |||
template <typename Point1T, typename Point2T> inline constexpr bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this function live in common/include/pcl/type_traits.h
perhaps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can simplify this a lot more (and deprecate it) since this is just a function call instead of std::is_same_v<A, B>
. Thoughts: @mvieth ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not necessarily against deprecating isSamePointType
, but I don't really see a problem with people using pcl::isSamePointType<A, B>()
instead of std::is_same<A, B>::value
(or is_same_v
starting with C++17).
How would you simplify it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright. If we don't deprecate it, should we move it to type_traits.h
or some other file than io.h
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from this, LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem I see with moving the function to a different header file is that if someone uses the function and includes the current header file (io.h), they would get an error that the function can not be found (unless they also include the new header file by chance), without any prior warning that the function will move or similar. I agree that, if isSamePointType
was new and we had to decide where to put it, type_traits.h seems more fitting than io.h, but I honestly don't think it is worth to move this existing function
registration/include/pcl/registration/impl/correspondence_estimation.hpp
Outdated
Show resolved
Hide resolved
registration/include/pcl/registration/impl/correspondence_estimation.hpp
Outdated
Show resolved
Hide resolved
registration/include/pcl/registration/impl/correspondence_estimation.hpp
Outdated
Show resolved
Hide resolved
test/common/test_common.cpp
Outdated
constexpr const bool status0 = isSamePointType<PointXYZ, PointXYZ> (); | ||
EXPECT_TRUE (status0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts on combining into a single line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
also, only two of these tests seem like relevant, should i remove duplication, eg there's no point to test
EXPECT_TRUE (isSamePointType<PointNormal, PointNormal> ());
if there's
EXPECT_TRUE (isSamePointType<PointXYZ, PointXYZ> ());
what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH I would rather keep those tests. Yes, knowing the implementation of isSamePointType
, it is clear that they will pass, but the tests should not make any assumptions about the implementation. If, for some reason, isSamePointType
is changed in the future, we would want to test it with all these tests. Plus they cost practically nothing (compilation time/...).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
conversely, someone reading those tests would (mistakenly) assume that there is some difference in comparison logic for PointXYZ
and PointNormal
types (because we have two tests and you usually don't pay for what you don't need, especially in library code). and checking out the implementation of isSamePointType
would cause even more confusion, because std::is_same
works the same in both cases, of course.
so, if there's some need in description forisSamePointType
logic, i suggest we leave it as a comment, just quoting cppreference.com:
If T and U name the same type (taking into account const/volatile qualifications), provides the member constant value equal to true. Otherwise value is false.
Commutativity is satisfied, i.e. for any two types T and U, is_same<T, U>::value == true if and only if is_same<U, T>::value == true.
if for some reason it does not seem sufficient, i will revert removal of those extra tests, of course
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi! should i revert my changes in tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay.
someone reading those tests would (mistakenly) assume that there is some difference in comparison logic for PointXYZ and PointNormal types
I don't really agree with that thought. I think it is normal to test a function with many different parameters, also template parameters, without any implication that the function works differently for some parameters. I think the EXPECT_TRUE
and EXPECT_FALSE
also make clear what the function should do in each case. If you want to add a clarifying comment somewhere, that is of course always a good idea. I just think removing already existing tests is counter-intuitive, considering that too much code in PCL is untested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
decreasing code coverage is certainly not a good idea, that's right, so i did roll back my changes. hopefully this PR is an overall improvement and may be merged without changes in tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's also an opened question whether isSamePointType
should live in io.h
common/include/pcl/common/io.h
Outdated
@@ -319,10 +319,10 @@ namespace pcl | |||
pcl::PCLPointCloud2 &cloud_out); | |||
|
|||
/** \brief Check if two given point types are the same or not. */ | |||
template <typename Point1T, typename Point2T> inline bool | |||
template <typename Point1T, typename Point2T> inline constexpr bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can simplify this a lot more (and deprecate it) since this is just a function call instead of std::is_same_v<A, B>
. Thoughts: @mvieth ?
registration/include/pcl/registration/impl/correspondence_estimation_backprojection.hpp
Outdated
Show resolved
Hide resolved
registration/include/pcl/registration/impl/correspondence_estimation.hpp
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If CI is 🟢
common/include/pcl/common/io.h
Outdated
@@ -319,10 +319,10 @@ namespace pcl | |||
pcl::PCLPointCloud2 &cloud_out); | |||
|
|||
/** \brief Check if two given point types are the same or not. */ | |||
template <typename Point1T, typename Point2T> inline bool | |||
template <typename Point1T, typename Point2T> inline constexpr bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from this, LGTM
// Check if the correspondence is reciprocal | ||
target_idx = nn_indices[min_index]; | ||
tree_reciprocal_->nearestKSearch( | ||
(*target_)[target_idx], 1, index_reciprocal, distance_reciprocal); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I am missing something here: target_
contains points of type PointTarget
, but tree_reciprocal_
uses points of type PointSource
, so this should not work, right? I see that you did not change this line, so is this an error that existed before but was not discovered? In correspondence_estimation_backprojection.hpp, this is the same, but in correspondence_estimation.hpp, the point is copied (copyPoint before, pointCopyOrRef with your changes). Do you have an idea?
Apart from this, looks good to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suppose that you're right, it seems like only the cases when point types are the same were covered, i've added another one for completeness (though ), so it should be correct now, but that required some additional changes
PTAL, i might have messed up that source-target logic (hope not)
061ccb3
to
a206b9a
Compare
@al-tu The new test(s) don't seem to compile yet |
c53fdec
to
7e7e479
Compare
@kunaltyagi @mvieth hello! do you have any idea why one particular test on clang/macos catalina fails? may this be a flaky situation? it would be nice to be able to restart ci via bot command |
I restarted the CI. Unfortunately, there are a few tests that fail randomly (but rarely) |
thanks a lot! passes now, so yes, that was a random fail |
hello. it's actually ready now, could you please re-review? thanks! |
@al-tu Do you have time to rebase this? |
more tests for correspondence estimation to cover cases when source and target pointclouds have different point types
7e7e479
to
75bd2d1
Compare
sure, done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, and sorry that we took so long with the reviews
isSamePointType function
correspondence estimation functions forward point selection to helper template functions specializations instead of if blocks with runtime type checks