ROS2 v4l2_camera_node on Raspberry Pi CSI Camera Error (on Foxy Botvac Project)

1,528 views
Skip to first unread message

Ross Lunan

unread,
Oct 24, 2021, 3:28:18 PM10/24/21
to HomeBrew Robotics Club
Deployed v4l2 Package on Raspberry Pi4/4GB Foxy  https://gitlab.com/boldhearts/ros2_v4l2_camera.

Modified SD card /boot/firmware/user/cfg.txt adding start_x=1 gpu_mem

Camera appears to show up on /dev/video0, 1, 2, 3, 4, 5, 6, 7. Unsure why so many?

:~ ros2 run v4l2_camera v4l2_camera_node remap /dev/video0 /dev/video10 or
:~ ros2 run v4l2_camera v4l2_camera_node remap /dev/video10 /dev/video0, has error "Failed to open /dev/video0". Seems to ignore remapping

camp .

unread,
Oct 24, 2021, 4:04:38 PM10/24/21
to HomeBrew Robotics Club
Have you tried it without the remap? Also, is gpu_mem supposed to be "gpu_mem=128" be aware of a warning here: * https://raspberrypi.stackexchange.com/questions/14229/how-can-i-enable-the-camera-without-using-raspi-config
 
I do believe I added this to my setup but it's not here to double-check. Here's another link that may be of some use: https://chuckmails.medium.com/enable-pi-camera-with-raspberry-pi4-ubuntu-20-10-327208312f6e
 
- Camp

* Adding start_x=1 and gpu_mem=128 to the /boot/config.txt file on a Ubuntu 20.10 arm64 for Raspberry Pi 4 leads to an unfixable boot failure where it hangs on the splash screen indefinitely.

--
You received this message because you are subscribed to the Google Groups "HomeBrew Robotics Club" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hbrobotics+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hbrobotics/7cf5cfa2-1daf-4e15-834c-a149861965c3n%40googlegroups.com.

Alan Federman

unread,
Oct 24, 2021, 4:16:15 PM10/24/21
to hbrob...@googlegroups.com
are you using a Raspberry Pi camera? 

Can you view the camera with some non ROS application like raspistill?

Also check permissions on /dev/video0.  The group should be video and the user should have group privilege.

In the boot config.txt. start_x=1, gpu_mem=128

I have got the Raspicam working on Jetson with the v2l4 driver for ROS1, and also on Raspberry Pi Noetic both V2l4 and raspicam_node.  

I think camp has it working ROS2.

Ross Lunan

unread,
Oct 24, 2021, 4:43:25 PM10/24/21
to HomeBrew Robotics Club
Tnx for really fast response! 
I believe permissions and groups are OK
ubuntu@hale:~$ ls -l /dev/video*

crw-rw---- 1 root video 81, 0 Sep  7 14:37 /dev/video10

crw-rw---- 1 root video 81, 2 Sep  7 14:37 /dev/video11

crw-rw---- 1 root video 81, 5 Sep  7 14:37 /dev/video12

crw-rw---- 1 root video 81, 1 Sep  7 14:37 /dev/video13

crw-rw---- 1 root video 81, 3 Sep  7 14:37 /dev/video14

crw-rw---- 1 root video 81, 4 Sep  7 14:37 /dev/video15

crw-rw---- 1 root video 81, 6 Sep  7 14:37 /dev/video16

ubuntu@hale:~$ groups

ubuntu adm dialout cdrom floppy sudo audio dip video plugdev netdev lxd

ubuntu@hale:~

v4l2-error.jpg

camp .

unread,
Oct 24, 2021, 4:54:08 PM10/24/21
to HomeBrew Robotics Club
    Okay /dev/video0 should just show up when you plug the camera in. Is it plugged into the right socket? That is the CAMERA socket and not the DISPLAY socket.
 
- Camp

Ross Lunan

unread,
Oct 24, 2021, 5:04:00 PM10/24/21
to HomeBrew Robotics Club
Yup, I checked that 1st! (From your advice from a couple weeks ago). My boot user cfg.txt text are start_x=1 gpu_mem=128

I just tried :~v4l2-ctl —list-devices. Interesting there is no video0. Im going to boot the same Pi with an ordinary RPi Buster sd to check cable connections with raspistill.

ubuntu@hale:~/colcon_ws/src$ v4l2-ctl --list-devices
bcm2835-codec-decode (platform:bcm2835-codec):
/dev/video10
/dev/video11
/dev/video12
/dev/media0

bcm2835-isp (platform:bcm2835-isp):
/dev/video13
/dev/video14
/dev/video15
/dev/video16
/dev/media1

Cannot open device /dev/video0, exiting.
ubuntu@hale:~/colcon_ws/src

Ross Lunan

unread,
Oct 24, 2021, 5:22:13 PM10/24/21
to HomeBrew Robotics Club
Tried raspistill and raspivid on the same Raspi4 Board with a Buster SD, both showing a camera picture. Yeh

Also  ls -l /dev/v* lists crw-rw----+ 2 root video 81, ...../dev/video0

So the camera seems to be connected.

v4l2-ctl --list-devices lists all those /dev/video10-17 and mmal service /dev/video0

Near to giving up.....

Ross Lunan

unread,
Oct 24, 2021, 5:32:38 PM10/24/21
to HomeBrew Robotics Club
Maybe I should try compiling this v4l2 package and the cv_camera package, (which works on a UB20/ROS Noetic)

camp .

unread,
Oct 24, 2021, 5:57:19 PM10/24/21
to HomeBrew Robotics Club
> Near to giving up.....
 
 Stating the obvious: I believe we're back to "mmal" not being 64-bit compatible. I got it running on ROS2, but the robot's not here to check the configuration. I do start it by running "ros2 run v4l2_camera v4l2_camera_node". And I do believe this website was helpful in the setup: https://chuckmails.medium.com/enable-pi-camera-with-raspberry-pi4-ubuntu-20-10-327208312f6e
 
Perhaps it was "sudo apt-get install v4l-utils".
 
Never, never, never give up.  ;- )
 
- Camp

Ross Lunan

unread,
Oct 24, 2021, 7:13:14 PM10/24/21
to HomeBrew Robotics Club
You are a formidable motivator. OK, so I booted the Raspi Pi board I use for the Foxy Botvac, with the same SD card that boots to Noetic. The UB20/Noetic boot SD shows the dev/video0 with ls -i /dev/vid* AND v4l2-ctl --list-devices. BUT the UB20/Foxy boot SD on the same Board shows no video0, as we observed earlier. A Mystery as the problem has nothing to do with the Foxy stack. As I have that other weird colcon behavior, I believe the rational thing to do is burn a fresh UB20 Noetic, check the camera, and if OK load ROS Foxy (I have a nice script to do that while I'm sleeping) and Botvac stack.
Ross 

Ross Lunan

unread,
Oct 25, 2021, 8:17:53 PM10/25/21
to HomeBrew Robotics Club
Enabling Raspicam on "video0" solved ! Provisioned a fresh Ubuntu 20.04 Server arm64 Raspi image. Added start_x=1 and gpu_mem=256 to the /system-boot/firmware/config.txt. And run "$ 'v412-ctl --list-format" and "$ v4l2-ctl --list-devices" that lists video0 and other stuff. The problem configuration had the start_x=1 in the usercfg.txt, though that should have worked. Installed ffmpeg. Run: "$ ffmpeg -f video4linux2 -s 640x480 -i /dev/video0 -ss 0:0:2 -frames 1 capture_test.jpg" puts a camera image in the $HOME. yeh! Didn't run a continuous live video image though as I could easily find the ffmpeg /v4l2 command !

I referred to Ubuntu20 (NOT ROS1) parts of the the Robotis emanual for "Turtlebot3 Noetic" and their "Autorace2020 Package Camera" instructions for guidance.

Now to install ROS2 Foxy (also using a useful Robotis Turtlebot3 Foxy stack installation script), Camp-Nugen Botvac stack, and try "cv_camera" package (for which a ROS2 version is available that needs compiling), and "v4l2_camera" (which is a Debian package). I wonder if the camera streaming will bog down the RVIZ operations?

Much appreciation to assistance from Camp and Dr. Bot.

camp .

unread,
Oct 25, 2021, 8:54:01 PM10/25/21
to hbrob...@googlegroups.com
So where I am is FPS needed to be slowed to 5 and can view through rqt_image_view but not rviz, yet.  ;- ) 
 
Thanks,
Camp


On Mon, Oct 25, 2021 at 8:41 PM, 'Ross Lunan' via HomeBrew Robotics Club

camp .

unread,
Oct 25, 2021, 9:00:12 PM10/25/21
to hbrob...@googlegroups.com
v4l2-ctl -d /dev/video0 -p 5
 
Will change the frame rate from the default 30 to 5. Courtesy Michael Wimble I believe.
 
- Camp

Reply all
Reply to author
Forward
0 new messages