Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ROS multiple subscriber video delay

Tags:

python

ros

I'm getting a delay when having several nodes subscribe to the same video topic.

I'm using the approximate time synchronizer, to collect several images from different cameras and then publish at once. While timing between cameras can be an issue, it's not here, there isn't a delay when I only have a single node subscribing.

camtop_sub = message_filters.Subscriber('cam1/usb_cam1/image_raw', Image)
camfront_sub = message_filters.Subscriber('cam2/usb_cam1/image_raw', Image)
ts_log = message_filters.ApproximateTimeSynchronizer([cam1_sub, cam2_sub], 10, 1)
ts_log.registerCallback(self.log_callback)

The way my project is structured, I need to be able to have multiple nodes retrieving the latest image file.

Any suggestions on how to accomplish this without the delay? It's about 500ms right now.

I've noticed others suggest increasing the buffer size of the queue via the buff_size parameter in rospy.Subscriber class, but there isn't this parameter for the ApproximateTimeSynchronizer

like image 865
scriptdiddy Avatar asked Feb 14 '18 04:02

scriptdiddy


1 Answers

I don't use ROS much, but here is my take.

Can you specify which camera you are using? Could it be some implementation glitch in the camera driver? Is it possible that you have a single subscriber that interface / cache /manage the image feed from device than let other nodes who need actual image feed to subscribe to that node? Essentially a Pub/Sub broadcaster.

A project I worked on was on-prem IoT camera feed video analytics. Normally camera drivers and OS Kernels stuff does not handle broadcast well. There is normally a cache/broadcast component implemented outside of driver, like a Wowza Media streamer in my case. For your use, you could implement some simple stream buffer and make it safe concurrent access.

like image 83
ZhijieWang Avatar answered Oct 09 '22 06:10

ZhijieWang