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:
- Xavier NX Development board
- AntMicro / Capable Robot Nano Baseboard
- Two Allied Vision Alvium CSI cameras
Software-wise:
- Jetpack 4.4.1
- Allied Vision's custom Kernel for CSI cameras
- Melodic installed from debs
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/trisect_v4l_mwe
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?