Ros loses messages

Let’s take the simplest example (eg, Python’s) and update it slightly to our needs:

pub = rospy.Publisher('hello', String, queue_size=10)
rate = rospy.Rate(250) # 250hz
for i in range(10):
    pub.publish("hello world"+str(i))

And it seems to be clear what to expect in the subscriber (lets just output to the console that what came), but we can see:

But we do not see anything. What? How? Why? We check a hundred times the name of the topic – there is nowhere else to suspect a fake. Damn it, we increase range(10) to range(500) and start seeing the long-awaited hello world X, but X starts only somewhere with 200 (and up to 500 as it should). Ok, it’s getting better but where are the previous 200 messages gone? Trying to mess with queue_size, but it’s clear that this is not it. Okay, let us put another experiment – rate down to 10hz. And yes, we see literally starting with the 2nd. But where is the first?

Finally – everything is simple. In the second line the publisher has not been created yet and when the implementation reaches step “publish” – it publishes in nowhere. If you simply insert time.sleep(0.1) between the creation of the publisher and its use, the subscriber will see all the messages starting with the first (in this case from zero of course).

P.S. In the C++ – exactly the same thing, maybe even more is lost, since it is more speedy. But why on the rate (10) it loses only 1-2 messages, and on the rate (250) up to 200 – I think it’s not difficult to guess.

Add comment

5 Comment threads
0 Thread replies
Most reacted comment
Hottest comment thread
4 Comment authors
RonbalAndreWitWilltoureKennethdem Recent comment authors
newest oldest most voted

алкоголь интернет магазин санкт петербург 4. Для розничной продажи алкогольной продукции, включая пиво, необходимо иметь контрольно-кассовый аппарат. Это относится и к организациям и к индивидуальным предпринимателям. Исключение составляют организации общественного питания, в отношении пива: они могут реализовывать пиво без применения ККТ, так же не применять ККТ могут плательщики ЕНВД, вместо кассового чека они могут выдавать бланки строгой отчетности. Штрафы за торговлю пивом без ККТ, либо за реализацию в неположенном месте и в неположенное время составляют: алкоголь с доставкой – для организаций – 30-50 тыс. руб., – для индивидуальных предпринимателей – 3-4 тыс. руб. водка в канистрах 5 литров в санкт… Read more »