Efficient way to send a new large pointcloud (100.000+ Points)
Hi,
I have pointers to arrays for x, y, z and intensity data. Now I want to create a Pointcloud message from it but I'm missing the correct idea to this efficiently. I have ~100.000 Points @~30Hz+ that need to be sent in an appropriate time. Right now I'm creating a point with x,y,z data and push it into my point cloud in each iteration (100.000+...) which is quite time-consuming. I would be really happy if you could point me in the right direction on how to do this with the least amount of computation time. Is there a way to handle it without copying any data?
Thanks for your help! :)
Here is a simplified version of the code I'm using:
typedef pcl::PointCloud<pcl::PointXYZ> PointCloud;
PointCloud::Ptr cloud(new PointCloud);
for(int i = 0; i < (size = 100000) ; i++)
{
pcl::PointXYZ point;
basic_points.x = x[i];
basic_points.y = y[i];
basic_points.z = z[i];
new_pointcloud->points.push_back(point);
}
cloud->points = new_pointcloud->points;
My solution was to do it this way: