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

One Global callbackqueue for each node?

asked 2016-08-31 22:12:33 -0600

alienmon gravatar image

updated 2016-09-01 00:42:06 -0600

From what I know:

1) If we do not specify, by default the subscribe is going to global callbackqueue on that node.

2) I assume that each node has 1 global callbackqueue

3) However I read question&ans from answer.ros.org (I lost the link already)--->if we have mulitple subscribers for a node, let's say subA and subB in the same node1. We can assign different queueSize for each :

 ros::Subscriber sub1A = n.subscribe("topicA", 1, callbackMon);
 ros::Subscriber sub1B = n.subscribe("topicB", 1000, callbackMon);

I tried to implement this, and yes it's true. But I don't know why.

I want explanation on this. I thought by default sub1A and sub1B are assigned to the SAME global callbackqueue (see my point 2) , so how come I can assign different sizes for the SAME queue?

To support my question, from callback and spinning overview , I read that the implementation for spinOnce is basically :

ros::getGlobalCallbackQueue()->callAvailable(ros::WallDuration(0));

So I see that spinOnce only call from ONE QUEUE, that is the globalcallbackqueue, so I can't see that this only queue can be assign to different sizes?

------------------------------------------------------------EDIT--------------------------------------------------------------------

Please confirm/correct the following statements:

  1. When we do n.subscribe, the queue size refers to incoming message queue

  2. Each subscriber has one incoming message queue

  3. When we do advertise, the queue size refers to outgoing message queue

  4. Each publisher has one outgoing message queue

  5. Each node (by default) has one global callback queue.

Questions:

What about the callback queue size? Where do we set it?What is its default size? What happen if the incoming message queue size is small that the message has been thrown away but the callback for handling that message still in the callback queue?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-08-31 23:13:24 -0600

ahendrix gravatar image

The callback queue and the message queue are different things.

There is one callback queue that tracks which callbacks need to be processed, but there is a separate message queue for each topic.

edit flag offensive delete link more

Comments

  1. When we do n.subscribe, the queue size refers to the message queue?
  2. Each subscriber has one message queue, and each node has one global callback queue?
  3. What if the message queue size is small that the message has been thrown away but the callback for that message still in the callback q?
alienmon gravatar image alienmon  ( 2016-09-01 00:11:20 -0600 )edit

@ahendrix Please answer my additional questions , I edited my question.

alienmon gravatar image alienmon  ( 2016-09-01 00:19:08 -0600 )edit

I don't know the answers to your additional questions offhand. I suspect the only people who know are the ones who actually wrote the callback logic. I know callback dispatch works and drops messages correctly; if you really care about the finer details I'd suggest you read the code.

ahendrix gravatar image ahendrix  ( 2016-09-01 05:12:11 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2016-08-31 22:12:33 -0600

Seen: 615 times

Last updated: Sep 01 '16