Robotics StackExchange | Archived questions

NodeHandle changing the behavior of V4L2 ioctls?

All,

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

My setup:

Software-wise:

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: https://gitlab.com/amarburg/trisectv4lmwe

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?

Asked by amarburg on 2021-05-11 11:57:08 UTC

Comments

Answers

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."

Asked by amarburg on 2021-05-21 19:15:26 UTC

Comments