Ask Your Question

How to have no-copy publishing over multiple cores?

asked 2015-05-07 14:58:13 -0500

sergiom gravatar image

I have 2 ROS Nodes each running on its own CPU core.

Is there a way I can publish a message in one node and have it be received by the other, without any copying occurring?

My ROS messages are larges images, so any copying of data would cause a large hit to performance.

As I understand it, the Publisher/Subscriber system only allows no-copy messages in a singe node process. A nodelet is the usual workaround since that runs both the nodes in a single process. Unfortunately, I need each of my ROS Nodes running on their own CPU, so I don't think I can do that as a solution.

I know I could create shared memory manually (either via a POSIX API or Boost) but would prefer if there was a solution using only the ROS APIs.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2015-05-07 23:29:17 -0500

Dirk Thomas gravatar image

Multiple threads within a single process do run on different cores of the CPU ( ). So nodelets are solving exactly your use case. That's why most of the image processing code is ROS package use nodelerts to implement the pipeline.

edit flag offensive delete link more


So the first sentence in my question is more of a requirement than a detail. I would like each node to only be executed in one core.

Does nodelet have a mechanism for specifying where it's executing threads will be run? Something like an OS-neutral set_affinity?

sergiom gravatar image sergiom  ( 2015-05-08 10:12:51 -0500 )edit

No, they don't have that feature atm. Also the worker threads in the nodelet manager have no fixed association to the callback of the nodelets which would also be required in order to handle all callback from a specific nodelet on a specific core.

Dirk Thomas gravatar image Dirk Thomas  ( 2015-05-08 10:39:20 -0500 )edit

answered 2015-05-07 20:10:44 -0500

ahendrix gravatar image

ROS doesn't provide intra-process, zero-copy publishing.

Nodelets can be run multi-threaded, so it is possible to have zero-copy between different nodelets within a single nodelet manager.

I also believe that there is some research into shared-memory image transports at ETH: , but it looks like these haven't been worked on in a while.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2015-05-07 14:58:13 -0500

Seen: 629 times

Last updated: May 07 '15