-
Notifications
You must be signed in to change notification settings - Fork 337
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
fromROSMsg optimized (almost 2X speed) #368
Conversation
Avoid the intermediate conversion to pcl::PCLPointCloud2. This makes the execution of more or less twice as fast for large clouds.
Please note that I am applying this to foxy, but it can be ported to all the other branches, including ROS1 |
I couldn’t agree more, I’ll take a look at this on Monday |
The speedup is obviously very nice, but as you said, duplicating the code of |
|
@mvieth I'm more than happy to have the fix be internal to PCL if you like, that would seem to be the best solution to reduce code duplication. |
@facontidavide Would you like to open a pull request at https://github.com/PointCloudLibrary/pcl with a first draft? Then we can discuss everything further there and decide whether that's the way we want to go 🙂 |
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.
Hello,
Did you intentionally skip the assignment of is_bigendian
member? Nevertheless I wanted to point out.
Just so I can keep up to date -- is there any movement on this? is there a pcl pr that we should link to this one? no worries if not. |
Agreed! This would be great to get in |
So I tested my idea from above a bit (creating a new templated function pcl::PCLPointCloud2 pcl_pc2;
pcl_conversions::copyPointCloud2MetaData(cloud, pcl_pc2); // Like pcl_conversions::toPCL, but does not copy the binary data
pcl::MsgFieldMap field_map;
pcl::createMapping<T> (pcl_pc2.fields, field_map);
pcl::fromPCLPointCloud2(pcl_pc2, pcl_cloud, field_map, &cloud.data[0]); This would mean no copying of code from PCL to perception_pcl, and still only copying the binary point data once. We could add the new function to PCL with release 1.13.1, and then everyone who uses PCL >= 1.13.1 and an up-to-date perception_pcl would automatically have the speedup. |
Looks good to me! |
This is especially interesting for perception_pcl (see ros-perception/perception_pcl#368)
Other PR supersedes |
Hi,
I can not count the number of times some colleague complained about
pcl::fromROSMsg
consuming large amont of CPU!After looking at the implementation, I realized that we are copying the data twice, using the
pcl::PCLPointCloud2 pcl_pc2
as intermediate data structure.First of all, let me tell you that I HATE copy and pasting and that I absolutely agree that code readability come first.
BUT, this function is the bread and butter of every ROS + PCL application, and the amount of CPU improvement is really too much to be ignored!
Please see my benchmark comparison here:
Cheers!