0
$\begingroup$

Rosanswers logo

Hi there, it's my first time asking question, if there is something I missed please inform me:) So my question is like this. I have one node, with two subscriber, linked to two different topic. When I use the while+ros::spinOnce() procedure to replace spin, which subscriber's program would be called first when ros::spinOnce() is executed?


Originally posted by cangjiaxuan on ROS Answers with karma: 20 on 2015-01-21

Post score: 0

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

that does not depend on the subscriber node, but on the topics being published to it. the first topic to be published once you start your program will activate the callback of the correspondant subscriber.


Originally posted by Procópio with karma: 4402 on 2015-01-21

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$
0
$\begingroup$

Rosanswers logo

Briefly, yes, you're missing something. :)

More expansively, a node is a process; separate nodes execute independently. In your case, you have at least two nodes, one with two subscriber members (call it subNode) and (at least) one other node with publisher member(s) (call it pubNode). SubNode executes by endlessly looping -- during each loop, the 'spinOnce' checks the callback queue for messages. Unless and until pubNode publishes a message that subNode receives, nothing will happen (beyond the endless looping).

In general, there's no guarantee which message subNode will receive first, but it will handle its callbacks in the order it receives the messages.


Originally posted by kramer with karma: 1470 on 2015-01-21

This answer was NOT ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

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