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

Subscriber gets older timestamped messages

asked 2011-11-01 13:31:40 -0500

130s gravatar image

updated 2011-11-02 04:07:57 -0500

2 different nodes are listening to a msg with the same topic. 1 node (written in C++) gets the msg and print its content in an expected, minimum delay. But the other (python) node shows the older content and I have no idea why this delay occurs. I'd appreciate any ideas.

Codes (partial, they show where I compare the values):

Coincident or not, the difference is the language (C++ vs Python), and extension (Codes in python is separated into parent and sub class). But I don't know if these factors matter (and hopefully they do not).

All nodes run on the same machine (Ubuntu 11.04, electric, Intel i7 quad).

Update 11/2/11) I'm now comparing timestamp and approx. 30 seconds after starting program, the difference of timestamps from both nodes are 8 ROS seconds.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2011-11-02 06:19:34 -0500

130s gravatar image

updated 2011-11-02 06:31:47 -0500

Solved by myself - changing subscriber's queue_size works out for me. Using the code example on my environment I described in the question, I increased it from 1 to 5 in the problematic code (the one in python). Btw the queue_size in the publisher is not showing influence here.

PS. However I still don't get why...I've read documents including this QA though. Is my understanding below correct...? I'll give a vote if someone corrects it.

Increasing queue_size means the number of msgs processed in one callback increases, and that number could be greater than calling callback during exactly same length of period.

edit flag offensive delete link more


All messages being received are put into a queue. When this queue has data in it, your callbacks will be called. However if data comes in faster than your callback executes, the queue will fill up. It looks like you had your queue length set to 1000. Meaning you could be 1000 messages behind.
tfoote gravatar image tfoote  ( 2011-11-02 08:05:03 -0500 )edit
@tfoote thank you, that makes perfect sense to me. Now I feel this queuing architecture might not be ROS specific but instead more common in general distributed system, and also suppose that could be because the documents out there don't explain detail.
130s gravatar image 130s  ( 2011-11-02 08:31:44 -0500 )edit

Question Tools


Asked: 2011-11-01 13:31:40 -0500

Seen: 2,125 times

Last updated: Nov 02 '11