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

NodeHandle changing the behavior of V4L2 ioctls?

asked 2021-05-11 11:57:08 -0500

amarburg gravatar image

updated 2021-05-11 13:58:44 -0500


I'm looking for help in unravelling an unusual problem which is somewhere at the intersection of ROS and Linux4Tegra

My setup:


I am working on a custom ROS node which is derived from the V4L capture sample code -- essentially a sequence of ioctl calls to a /dev/video device. At a code level, it is very similar to usb_cam, though we're using CSI cameras.

My MWE is here:

If I remove references to ROS, it runs without complaint; I get the expected result from the camera.

If I add the ros::init and build within Catkin, it runs without complaint; I get the expected result from the camera.

If I then also add a NodeHandle, I get non-deterministic errors when initializing the cameras. About 25% of the time, it works, other times one of the ioctl calls fails with EBUSY. The failing call is not consistent and varies from run to run.

From my examination, it looks like the v4l2 code in the kernel return EBUSY if the device is actively streaming (which it's not), is open by another program (can't find any evidence with fuser or lsof), or if the video device is in "file IO emulation mode". This seems to be the case -- but why? My code isn't otherwise changing from the "working" configuration.

Sooo.... what changes when NodeHandle initializes ROS? I'm stumped. Anyone have any clue how to start to debug this problem?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2021-05-21 19:15:26 -0500

amarburg gravatar image

Answering myself. I was not able to solve this problem in userspace. A couple of sessions with strace and no luck.

My short-term solution was to actively disable the IO emulation for the V4L driver in the kernel. Since I'm using a custom kernel this was "straightforward."

edit flag offensive delete link more

Question Tools



Asked: 2021-05-11 11:57:08 -0500

Seen: 144 times

Last updated: May 21 '21