Hi perception engineers!
if you use PCL with ROS, you are certainly using the function pcl::fromROSMsg
to converts sensor_msgs::PointCloud2
to pcl::PointCloud<PointT>
.
This function consumes a considerable amount of CPU and we haven’t started processing the PointCloud yet!
Luckily, you can make this function almost 2 times faster.
The implementation is available here: Drop in replacement for pcl::fromROSMsg · GitHub
You can easily convert this to ROS2, simply renaming the namespace of the sensors_msgs
.
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.