Delay when subscribing to usb_cam/image_raw
I'm having latency issues when using message_filters
After inspection, it was found that it was caused by the delay of the subscribed usb_cam/image_raw
.
I used rostopic delay /usb_cam/image_raw
to check the delay, the average delay is 0.036s, not sure if this is too long.
Wrote a test program that only subscribes to usb_cam/image_raw
, queue_size=1
.
class listener:
def __init__(self):
self.sub = rospy.Subscriber("usb_cam/image_raw", ImageMsg, self.callback, queue_size=1)
def callback(self, Cam_img):
print('---sub---')
print(Cam_img.header)
print("================")
rospy.sleep(3.0)
def main(args):
rospy.init_node('message_test', anonymous=True)
ls = listener()
try:
rospy.spin()
except KeyboardInterrupt:
print("Shutting down")
if __name__ == '__main__':
main(sys.argv)
The message header is printed every 3 seconds, but the timestamp does not have an interval of 3 seconds after execution.
Here is the output:
---sub---
seq: 47809
stamp:
secs: 1666068526
nsecs: 467627916
frame_id: "c920_camera"
================
---sub---
seq: 47810
stamp:
secs: 1666068526
nsecs: 503613919
frame_id: "c920_camera"
================
---sub---
seq: 47811
stamp:
secs: 1666068526
nsecs: 535569917
frame_id: "c920_camera"
================
---sub---
seq: 47812
stamp:
secs: 1666068526
nsecs: 567602916
frame_id: "c920_camera"
================
How can I reduce the delay?
Thanks in advance.