Ask Your Question
1

Publishing and subscribing to a topic in different threads

asked 2012-09-08 14:17:40 -0600

Nishant gravatar image

Hi all!

I was just curious about this, before I actually sit for coding.

Suppose I have a thread in which I am publishing to a topic. Then, can I subscribe to that same topic from some different thread?

I am really sorry if this question is too trivial. I just don't want to end up writing code for nothing :)

All help is appreciated!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
4

answered 2012-09-08 16:34:37 -0600

jbohren gravatar image

Yes, you can do this.

In fact, if you're in c++, if you use the shared_ptr signatures in your code, you will even skip the serialization/deserialization step.

Do note, however, that by default roscpp only uses a single thread if you use ros::spin() or ros::spinOnce().

For more info on roscpp threading models and how to use multiple threads with roscpp, see here.

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

1 follower

Stats

Asked: 2012-09-08 14:17:40 -0600

Seen: 1,408 times

Last updated: Sep 08 '12