Image subscriber lag (despite queue = 1) not resolved by big buff_size
Hello all,
I have a very similar problem as described here, however setting a very high value for buff_size
does not solve it. Also, in my case, instead of doing the task with a high computational cost, I just want to wait a second. If I don't wait this second, I don't have a problem, but this is necessary in my case. My code looks something like this:
class ImageCallback:
def __init__(self):
self.bridge = CvBridge()
def callback_image(self, data):
image = self.bridge.imgmsg_to_cv2(data)
print "Delay:%6.3f" % (rospy.Time.now() - data.header.stamp).to_sec()
cv2.imshow("Window", image)
cv2.waitKey(1)
rospy.sleep(1)
def main():
rospy.init_node('video')
callback_class = ImageCallback()
rospy.Subscriber("cam_vo/image_raw", Image, callback_class.callback_image, queue_size=1,
buff_size=2 ** 31 - 1)
rospy.spin()
When I run this, images are displayed to me every second as desired, but the delay initially increases to six seconds and stabilizes there. And when I pause the bag the images are coming from, the display of the images continues for some time, with the delay increasing further. The images are about 2 MB in size and were taken at 25 Hz, so the buff_size
should definitely be enough. I also tried using 2^21 as buff_size
, but that doesn't change anything.
I'm using ROS melodic with Python 2.7 on a machine running Ubuntu 18.04, as well as opencv-python in version 4.2.0.32. I appreciate any support, especially the increase of the delay to six seconds is what bothers me the most, as this causes the displayed image to not be live.