I'm looking for a way to share a pcl::PointCloud between two processes without using files on the disk. In particular, I'm interested in using boost shared memory libraries to achieve my scope.
I've just tried the following instruction for the sender:
void * pSharedMemory = ... ; // from wherever
pcl::PointCloud<pcl::PointXYZ>::Ptr ptr = ... ; // from wherever
memcpy ( pSharedMemory , static_cast<void const*>(ptr.get()) , sizeof(pcl::PointCloud<pcl::PointXYZ>) ) ;
and the following for the receiver:
template <typename T> nothing ( T* ) { }
void * pSharedMemory = ... ; // from wherever
pcl::PointCloud<pcl::PointXYZ>::Ptr ptr ( static_cast<pcl::PointCloud<pcl::PointXYZ>*>(pSharedMemory) , ¬hing<pcl::PointCloud<pcl::PointXYZ> > ) ; // sets the destructor to do nothing
The sender seems to work because I'm able to visualize the PointCloud from the memory, but on the client side the object is correctly created and populated, but I get a segmentation fault when I try to access the points attribute that should contain the points of the clouds. All the other properties (like width, height, ...) are filled with the correct value.
How can I fix this problem and access the points structure? Or is there another way to achieve my scope??