ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hi Lorenz, Thanks for trying this yourself. I am sure that all the nodelets are running from the same manager

I basically need a mechanism for sharing memory among nodelets. I am using lots of images, point clouds and such (a there are real-time navigation requirements for the code) and therefore copying this data all around would be very slow. I was reading threads and it seems that this is the only way that one can somehow "share" data among nodelets.

What I am basically doing is sending an object that is allocated in the heap by one nodelet and passing it as a boost::shared_ptr. Then in the other nodelets I push this onto a vector of boost::shread_ptrs . Afterwards, I pass the ID of the object to the nodelets so they can start working (they look for the object on their vector of pointers)

The messages received by the nodelets are const boost::share_ptr but they are not necessarily const boost::shared_ptr const so the data can be modified... again this works pretty well with only 2 nodelets...the moment the third nodelet is started and subscribes, the zero-copy transport stops working. The second nodelet receives only a coy of the object.

There is a sort of locking mechanism because the nodelets will not start working on the data unless the IDs are received and this is how I am controlling what nodelet uses the specific data.

I will try printing the pointers to see what is actually happening. I will also try sending the object back as opposed to the ID as this might be causing copies.

Thanks