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

Revision history [back]

It's perfectly acceptable to subscribe to multiple topics and/or publish to multiple topics from within the same ROS node. Each topic publisher or subscriber will have its own ros::Publisher or ros::Subscriber object, and each subscriber will probably have its own callback function (though this is not strictly required).

See here for a mroe detailed description of publishers/subscribers in C++.

Note that subscriber callbacks are generally called by background ROS threads. If you use the default node setup shown in most examples (using ros::spin), all callbacks are called from a single thread. See here for a more detailed explanation of multi-threaded usage of roscpp, if that's important for your application.

It's perfectly acceptable to subscribe to multiple topics and/or publish to multiple topics from within the same ROS node. Each topic publisher or subscriber will have its own ros::Publisher or ros::Subscriber object, and each subscriber will probably have its own callback function (though this is not strictly required).

See here for a mroe detailed description of publishers/subscribers in C++.

Note that subscriber callbacks are generally called by background ROS threads. If you use the default node setup shown in most examples (using ros::spin), all callbacks are called from a single thread. See here for a more detailed explanation of multi-threaded usage of roscpp, if that's important for your application.

Edit:
Whoops! Sorry for the double-answer. I'll leave this here, in case any of this info is helpful.