-
Notifications
You must be signed in to change notification settings - Fork 196
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
PointCloud in YARP #1597
PointCloud in YARP #1597
Conversation
template< class T1, class T2 > | ||
inline bool toPCL(yarp::sig::PointCloud< T1 > &yarpCloud, ::pcl::PointCloud< T2 > &pclCloud) | ||
{ | ||
yAssert(sizeof(T1) == sizeof(T2)); |
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.
static_assert
?
As you are directly copyng the raw memory, perhaps it is even safer to just defined the template to operate on one consistent type.
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 here is that we can't have any control on T2
because it is a pcl's type, the only thing that I can check is that the sizeof
of the yarp type and the pcl type are the same.
I used static_assert
inside the yarp PointCloud for defining which T1 are allowed and supported for now, the problem is that with the static_assert
we can add the corresponding list of pcl supported types but inside these conversion functions (toPcl
and fromPcl
) we cannot check the correspondence between the yarp type and pcl type (e.g. yarp::sig::XYZ_DATA
and pcl::PointXYZ
)
Note that it is possible that sizeof(T1)==sizeof(T2)
but the two types can be incompatible.
Example:
sizeof(yarp::sig::XYZ_DATA)
is equal to sizeof(pcl::Normal)
but they have different fields.
This check is not sufficient to be 100% safe but better than nothing 😅
I hope that the user will these functions with the correct types and not try some exotic conversions like yarp XYZ to pcl NxNyNz (Normals):sweat_smile:
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 see, T1 is something like struct vec3 { double x; double y; double z; }
and in memcpy you are relying of the memory structure of the two types to be the same, I get it.
However, I think it is is desirable to transform this in static_assert(sizeof(T1) == sizeof(T2))
.
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.
Ah ok now I get your point, yes probably is better static_assert
in this case 👍
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.
LGTM!
Just noticed some minor (picky) typos.
} | ||
|
||
/** | ||
* Convert a pcl::PointCloud to a yarp::sig::PointCloud object |
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 is an extra space before and after pcl::PointCloud
and after yarp::sig::PointCloud
.
} | ||
|
||
|
||
/** \brief Concatenate a point cloud to the current cloud. |
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.
Probably missing a newline after /**
?
return (*this); | ||
} | ||
|
||
/** \brief Concatenate a point cloud to another cloud. |
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.
Probably missing a newline after /**
?
class yarp::sig::PointCloudNetworkHeader | ||
{ | ||
public: | ||
PointCloudNetworkHeader() : width(10), |
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.
Here and the following lines the indentation seems somwhat wrong.
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.
It seems ok 🤔
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 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.
Ah ok I see, I thought was referred to the indentation of public 😅
Why |
@traversaro because they are |
1b1be65
to
be5e191
Compare
be5e191
to
62db0ce
Compare
Thanks @Nicogene and @barbalberto for this awesome integration 💖 We have the urge to merge this PR in order to start testing an online viewer of point clouds. |
All tests passed, for me the PR is ready to be merged. |
@@ -49,6 +49,7 @@ Using YARP devices: | |||
\li \subpage yarp_config_files | |||
|
|||
More software tutorials: | |||
\li \subpage yarp_pointcloud |
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 would add this page also on the Interoperability and advanced use section in the main page of YARP.
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.
Is it possible to do it without restarting all the 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.
@Nicogene let's be flexible and add this change after the merge 😉 (if you like to have the green lights within the PR)
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.
Please fix this as suggested by @traversaro in next iteration
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.
src/libYARP_pcl/CMakeLists.txt
Outdated
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/yarp) | ||
|
||
set_property(GLOBAL APPEND PROPERTY YARP_LIBS YARP_pcl) | ||
#set_property(TARGET YARP_pcl PROPERTY FOLDER "Libraries") |
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.
This line can be removed?
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.
Yes it is a copy-paste from the CMakeLists.txt of libYARP_eigen
.
(If you uncomment this line the CMake complaints, so I think it is better to remove it 🤔)
|
||
/** | ||
* Convert a yarp::sig::PointCloud to a pcl::PointCloud object | ||
* @param yarpCloud yarp::sig::PointCloud input |
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.
@param[in] ?
* @return a pcl PointCloud filled with data contained in the yarp cloud. | ||
*/ | ||
template< class T1, class T2 > | ||
inline bool toPCL(yarp::sig::PointCloud< T1 > &yarpCloud, ::pcl::PointCloud< T2 > &pclCloud) |
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 yarpCloud
is just an input argument, perhaps we can have const yarp::sig::PointCloud< T1 > &yarpCloud
?
|
||
/** | ||
* Convert a pcl::PointCloud to a yarp::sig::PointCloud object | ||
* @param pclCloud pcl::PointCloud input |
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.
@param[in]
/** | ||
* Convert a pcl::PointCloud to a yarp::sig::PointCloud object | ||
* @param pclCloud pcl::PointCloud input | ||
* @return a yarp cloud filled with data contained in the pcl cloud. |
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.
Missing yarpCloud docs.
inline PointCloud<T>& | ||
operator+=(const PointCloud<T>& rhs) | ||
{ | ||
//TODO: take the newest timestamp |
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 this is an actual TODO, can you open a issue in the YARP issue tracker?
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 think that I can remove it, in PCL the operator+=
takes the newest timestamp because the timestamp is in the pointcloud header, but in YARP
is handled on another level.
{ | ||
//TODO: take the newest timestamp | ||
|
||
yAssert(getPointType() == rhs.getPointType()); |
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.
Some gentler error, or perhaps document this behavior in the docs?
} | ||
|
||
inline void push_back (const T& pt) | ||
{ |
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 indentation of this method is different.
*/ | ||
virtual void fromExternalPC(const char* source, int type, size_t width, size_t height, bool isDense = true) | ||
{ | ||
yAssert(source); |
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.
As before, are you sure that crashing is a sensible behavior (especially if not documented) for wrong parameters?
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.
yarp::sig::Image*
classes are plenty of these yAssert
😅
I think that the assert is necessary in these cases, but probably it is better to document 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.
I see, then it is a discussion worth having on another place.
// yarp::sig::Vector orientation; // orientation wrt origin -- could be an Eigen::Quaternion for better PCL compatibility if yarp can afford to depend from it | ||
|
||
// YARPish fileds | ||
// char *data; // actual pointCloud data. |
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 all this commented line are not necessary, can we remove them?
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 think that it is better to keep it for the future improvements
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 you leave them here with no comment at all, just commented out, nobody will never know what are those lines and why they are here. Hence I agree with @traversaro
Added some comments but:
|
I can do the changes requested by @traversaro, and I think that tomorrow should be ready. |
352bc27
to
8b7fe66
Compare
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.
👍
8b7fe66
to
a4a3e97
Compare
Rebased over last |
Tests are ok, the only one failing is P.R. looks ok, but I see it introduces a lot of warnings |
I have to check on a windows machine, the lines pointed by appveyor seems wrong |
The refactoring of `PointCloudBase` has been done for the future `PointCloudMap`.
The more important change is the input cloud passed to `toPcl` and `fromPcl` made const.
- remove useless return - make isOrganized const - in toString function use char[128] instead of char[100] - use snprintf instead of sprintf - remove inline if() return
ee94aa7
to
6673c6f
Compare
Fixed copyright headers, renamed structures to "DataXxx" in order to have some kind of "namespacing", and cleanup... Now LGTM |
Merged, thanks. |
This PR introduces the
PointCloud
type in YARP 🎉A nice documentation page has been added under "YARP tutorials"
Probably the most important feature is the total compatibility with the PCL PointCloud.
In this sense in the documentation has been added a section where is explained how to convert a yarp cloud in a pcl cloud and viceversa.
Please review code.