A PR has already been submitted, but if you want to take advantage of this improvement right now, you may try the stand-alone file I shared.
Cheers
PS: I also take the opportunity that friends don’t let friends allocate memory. Remember that you should try to reuse existing pointclouds in each loop, instead of allocating new ones.
Very easy! The new function is as efficient as pcl::moveFromROSwould be, if I could use it.
Unfortunately, we can not move the sensor_msg, because it is a ConstReference.
This obliges the original implementation to copy data from sensor_msgs::PointCloud2 to pcl::PointCloud2.
I skip that part, modifying the pcl::PointCloud2 to pclPintCloud<T> function, to make it able to accept the data from sensor_msgs.
Apart from that, I am not doing anything that PCL isn’t doing.