0
$\begingroup$

Rosanswers logo

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!


Originally posted by Nishant on ROS Answers with karma: 143 on 2012-09-08

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by jbohren with karma: 5809 on 2012-09-08

This answer was ACCEPTED on the original site

Post score: 4

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.