0
$\begingroup$

I have ROS2 Humble installed on Ubuntu 22.04 Server (64-bit) on a Raspberry Pi4.

When I run the v4l2_camera node it finds my Pi Camera (v1.3) but then complains:

Failed stream start: Invalid argument (22)

$ ros2 run v4l2_camera v4l2_camera_node -ros-args --params-file /home/ubuntu/ros2ws/v4l2_camera_params.yaml
[INFO] [1667398998.222438071] [v4l2_camera]: Driver: unicam
[INFO] [1667398998.223092209] [v4l2_camera]: Version: 331580
[INFO] [1667398998.223198373] [v4l2_camera]: Device: unicam
[INFO] [1667398998.223268817] [v4l2_camera]: Location: platform:fe801000.csi
[INFO] [1667398998.223331871] [v4l2_camera]: Capabilities:
[INFO] [1667398998.223396278] [v4l2_camera]:   Read/write: YES
[INFO] [1667398998.223460721] [v4l2_camera]:   Streaming: YES
[INFO] [1667398998.223542720] [v4l2_camera]: Current pixel format: pgAA @ 2592x1944
[INFO] [1667398998.223637940] [v4l2_camera]: Available pixel formats: 
[INFO] [1667398998.223709587] [v4l2_camera]: Available controls: 
[INFO] [1667398998.225908478] [v4l2_camera]: Requesting format: 2592x1944 YUYV
[INFO] [1667398998.226086845] [v4l2_camera]: Success
[INFO] [1667398998.226256139] [v4l2_camera]: Requesting format: 640x480 YUYV
[INFO] [1667398998.226385618] [v4l2_camera]: Success
[INFO] [1667398998.226483839] [v4l2_camera]: Starting camera
[ERROR] [1667398998.245779840] [v4l2_camera]: Failed stream start: Invalid argument (22)

This is my params file:

/**:
  ros__parameters:
    video_device: /dev/video0
    pixel_format: YUYV
    output_encoding: rgb8
    image_size: [640, 480]
    time_per_frame: [1, 30]
    camera_frame_id: camera_optical_frame

I noticed that the startup does not list any "Available pixel formats" but do not know if that could be contributing.

How do I find out what is the "Invalid argument (22)" in the error message?

$\endgroup$

2 Answers 2

1
$\begingroup$

This is a known issue, which is discussed here: https://gitlab.com/boldhearts/ros2_v4l2_camera/-/issues/45

The underlying cause is that Raspberry Pi has moved to the new 'unicam' driver. Seemingly as part of their effort to move to libcamera to power their camera stack. Although this new driver is a V4L2 driver as well, unfortunately it proofs tricky to get YUV or RGB frames out of it.

Based on this comment in the v4l2_camera issue, you can comment out camera_auto_detect=1 in /boot/firmware/config.txt to have the old driver loaded instead. The v4l2_camera package then works as normal with that. This may affect other, libcamera based, utilities if you want to use any.

$\endgroup$
1
$\begingroup$

Have you tried leaving off the parameters file? It looks to me like you're specifying the default values, but you're also specifying items I'm not seeing as available for selection, like time_per_frame and camera_frame_id. This is in a look at the README here. The Invalid Argument (22) is coming from cerrno, where error 22 is Invalid argument.

As far as determining which argument is bad, if using the defaults doesn't work for you then you would need to attach a debugger and watch what's being evaluated when the error is thrown.

Lastly, when I search for time_per_frame the only result I'm seeing is in the changelog, and that from August 6th of this year. I can't tell how it's processed or what the appropriate values should be, but it looks like a pretty recent change so if your project is out of date then you might be trying to use functionality that doesn't yet exist in your project.

$\endgroup$
1
  • $\begingroup$ > Have you tried leaving off the parameters file? Yes, I tried leaving off the parameters file. > if your project is out of date? All updated. I think the package was not updated for humble distro, but I'm not smart enough to debug this. $\endgroup$ Commented Nov 9, 2022 at 22:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.