First off, I couldn’t have written this without https://www.youtube.com/watch?v=A3nw2M47K50. The channel is pretty great, it’s called Articulated Robotics and if you are interested in more robotics videos, especially in using ROS with robots, check them out!
sudo apt install libraspberrypi-bin v4l-utils ros-humble-v4l2-camera
sudo apt install ros-humble-image-transport-plugins
First we need to check if the current user has the correct permissions. Use the following command:
groups
Which should print out the list of groups that your current user is a part of. If you don’t see the group video
, then run the next command, then reboot:
sudo usermod -aG video USERNAME
raspi-config
Run the following command to install raspi-config
(to enable the camera)
sudo apt-get install raspi-config
sudo raspi-config
In the raspi-config
tool, enable SPI, I2C and legacy pi camera.
The following command will check if the camera is detected and connected properly:
vcgencmd get_camera
You should see supported=1 detected=1, libcamera interfaces=0
as the output. If detected=0
, try enabling again in raspi-config
.
Run the following command to start the camera node:
ros2 run v4l2_camera v4l2_camera_node --ros-args -p image_size:="[640,480]"