Trouble with YAML example file
gjf2a opened this issue · 9 comments
I am using ROS2 Humble.
I installed the ros2-humble-usb-cam. I'm trying to set it up with a Logitech CV270 webcam.
I first tried using the usb_cam.yml example. It gave me the following error message:
[ERROR] [1687449780.122892676] [rcl]: Failed to parse global arguments
terminate called after throwing an instance of 'rclcpp::exceptions::RCLInvalidROSArgsError'
what(): failed to initialize rcl: Couldn't parse params file: '--params-file usb_cam.yml'. Error: Cannot have a value before ros__parameters at line 1, at ./src/parse.c:793, at ./src/rcl/arguments.c:406
[ros2run]: Aborted
After some searching online, I modified it as follows (FYI, my webcam is /dev/video1):
usb_cam:
ros__parameters:
start_service_name: "start_capture"
stop_service_name: "stop_capture"
video_device: /dev/video1
io_method: mmap
pixel_format: yuyv
color_format: yuv422p
create_suspended: false
full_ffmpeg_log: false
camera_name: head_camera
camera_frame_id: head_camera
camera_transport_suffix: image_raw
camera_info_url: ""
image_width: 640
image_height: 480
framerate: 30
intrinsic_controls:
focus_auto: true
exposure_auto_priority: true
exposure_auto: 3
white_balance_temperature_auto: true
power_line_frequency: 1
ignore: [
brightness,
contrast,
saturation,
gain,
sharpness,
backlight_compensation,
white_balance_temperature,
exposure_absolute,
pan_absolute,
tilt_absolute,
focus_absolute,
zoom_absolute
]
That variation yields the following error:
terminate called after throwing an instance of 'rclcpp::exceptions::InvalidParameterTypeException'
what(): parameter 'framerate' has invalid type: Wrong parameter type, parameter {framerate} is of type {double}, setting it to {integer} is not allowed.
[ros2run]: Aborted
I next changed the framerate
parameter to 30.0. That yielded this error:
[INFO] [1687450137.021337933] [usb_cam]: camera_name value: head_camera
[WARN] [1687450137.021771694] [usb_cam]: framerate: 30.000000
[INFO] [1687450137.035924330] [usb_cam]: using default calibration URL
[INFO] [1687450137.036119211] [usb_cam]: camera calibration URL: file:///home/ferrer/.ros/camera_info/head_camera.yaml
[ERROR] [1687450137.036437053] [camera_calibration_parsers]: Unable to open camera calibration file [/home/ferrer/.ros/camera_info/head_camera.yaml]
[WARN] [1687450137.036536514] [usb_cam]: Camera calibration file /home/ferrer/.ros/camera_info/head_camera.yaml not found
[INFO] [1687450137.036704185] [usb_cam]: Starting 'head_camera' (/dev/video1) at 640x480 via mmap (yuyv) at 30 FPS
terminate called after throwing an instance of 'char*'
[ros2run]: Aborted
I am completely at a loss. Any suggestions would be most welcome!
Did you copy the sample YAML from the ROS1 version? If yes, merging between current ROS1 and ROS2 code is in progress, so you should not use YAML file from ROS1 to set up ROS2 version
It looks like that I did indeed mistakenly use the ROS1 version.
So I went back to the usb_cam site and found what I think is the correct params.yaml
example.
It still doesn't seem to recognize my camera. Here is my camera information:
sudo v4l2-ctl --list-devices
[sudo] password for ferrer:
Amlogic Video Decoder (platform:meson-vdec):
/dev/video0
UVC Camera (046d:0825) (usb-xhci-hcd.0.auto-1.2):
/dev/video1
/dev/video2
/dev/media0
But no matter what video device I try (I tried /dev/video1
, /dev/video2
, and even /dev/video0
just for comparison), I get the following error message:
ferrer@ferrer-aml-s905x-cc:~$ ros2 run usb_cam usb_cam_node_exe --ros-args --params-file params.yaml
[INFO] [1687450766.510501487] [usb_cam]: camera_name value: test_camera
[WARN] [1687450766.510939914] [usb_cam]: framerate: 30.000000
[INFO] [1687450766.525389172] [usb_cam]: camera calibration URL: package://usb_cam/config/camera_info.yaml
[INFO] [1687450766.528417785] [usb_cam]: Starting 'test_camera' (/dev/video1) at 640x480 via mmap (mjpeg2rgb) at 30 FPS
terminate called after throwing an instance of 'char*'
[ros2run]: Aborted
I tried a couple of other pixel formats (rgb8
, yuyv
) and it is always this same error.
Any suggestions again most welcome. Thanks for the fast reply earlier!
mmap
, userptr
, read
. Refer to your camera's documentation and datasheets
mmap
,userptr
,read
. Refer to your camera's documentation and datasheets
Gotcha. I tried all three of those for the io_method
field, and I still get the same error message every time. I'm not sure what else to look for on the data sheet.
Check if you have permission to /dev/video*
@gjf2a I am going to go ahead and close this issue as inactive / not exactly sure what the issue really is.
Feel free to debug some more and open a new issue outlining exactly whats wrong and we can help you out! 👍🏼
I've got the very same error as @gjf2a, with a Logitech C270 too and using ros2 humble on ubuntu 22.04
I would like to help with diagnostics and solution. I lowered the framerate to 10 fps and got this error:
[INFO] [1715365395.749175594] [usb_cam]: Timer triggering every 100 ms
Select timeout, exiting...
terminate called after throwing an instance of 'char const*'
[ros2run]: Aborted
I can see camera image with vlc, so permissions are ok.