ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Two subscriber topics in rclpy.spin() not working properly and losing frames. [closed]

asked 2021-08-18 11:02:23 -0600

NiranjanRavi gravatar image

Hi,

I am working with ROS2 - foxy distribution. I have two usb cams, generate frames at 30 fps.
USB cam packages are from this git: https://github.com/ros-drivers/usb_ca... . When i run the publishers, i could see the topic listed as, /usb_cam_0/camera_info , /usb_cam_0/image_raw , /usb_cam_1/camera_info, /usb_cam_1/image_raw .

I want to subscribe a frame from camera 1 and concat it with frame from camera 2 and save in a directory. Then the cycle repeats as long as code runs. I wanted t code in python. For some reason, message filters/time synchronizer library in python was throwing error which i wasn't able to fix. (https://answers.ros.org/question/3843...)

So the approach which I tried:

rclpy.spin() which has below functions:

self.subscription_1 = self.create_subscription(Image, '/usb_cam_0/image_raw', self.camera_0_callback, 1) self.subscription_2 = self.create_subscription(Image, '/usb_cam_1/image_raw', self.camera_1_callback, 1)

camera_0_callback is not getting called always. Almost half of times when the code runs, it skips camera_0_callback. I tried variable delays, increasing queue sizes but it doesn't seem to work.

All the while, ros2 topic list shows the topics; Could it be an issue with camera? Or am i not performing the queue logic incorrectly? Any inputs will be helpful.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by NiranjanRavi
close date 2021-09-20 17:01:49.827827

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-08-19 20:22:43 -0600

Pepis gravatar image

Are you using a single threaded or a multi threaded executor? If its the case try a multi threaded executor. Could you share your code to see how are you handling the node spin?

edit flag offensive delete link more

Comments

Hi, I had to do a work around. Saving individually and concat later. It reduces the frame loss considerably.

NiranjanRavi gravatar image NiranjanRavi  ( 2021-09-20 16:57:49 -0600 )edit

Question Tools

3 followers

Stats

Asked: 2021-08-18 11:02:23 -0600

Seen: 478 times

Last updated: Aug 19 '21