Rosbank is not updated

I wrote a ROS subscriber for one of the image themes, and I set my buffer to 1 using:

subscriber =rospy.Subscriber("/camera/rgb/image_mono/compressed",CompressedImage, callback, queue_size=1) 

However, my subscriber is still behind. Any idea what could be causing this? Do I set the queue size correctly?

+4
source share
4 answers

The queue is for the incoming message queue. This means that if your callback takes longer than when receiving new messages, only the queue size saved, the rest are not processed by your node.

I would suggest printing a message in the node publisher before publishing and a message at the top of your callback method. Then you can pinpoint the time it takes to process your messages. All other synchronization problems may be caused by your callback method.

+3
source

I had the same problem (it was not the exact frame rate, which was the problem, it was the actual lag). When I kill all image sources (rosbag, camera driver, etc.), My node will process ~ 5-10 frames even after the source was killed (and I was sure that I had queue_size=1 )

Here is the github issue I made and it was resolved. It turns out that several queues are involved (and not just the one you set queue_size to 1). In my case, the default buff_size was less than my images, so my node did not process them fast enough, and there was always a backup of the images in some queue.

TL DR increase buff_size for your subscriber, as I did here . It worked for me :)

+7
source

addition to why buff_size matters.
Also, an official document can help explain another reason that causes a lag in terms of pub.publish.

publish () in rospy is synchronous by default (for the opposite reason for compatibility), which means the call blocks until:

messages were serialized to a buffer, and this buffer was written to transport each current subscriber

0
source

The reason behind the apparent lag is most likely due to the fact that your callback function is time consuming. If at all possible, try to fix it. Setting the queue size to 1 essentially means that ROS processes any frames it can hold on.

Set the queue size to a larger number, say 5 or 10. Thus (I hope if the processing delay is not too big), all your frames will be processed, but they will be behind in time, that is, the video processing will be performed several steps behind but without any β€œjerks” and missing frames between them.

-1
source

Source: https://habr.com/ru/post/1235335/


All Articles