Raspberry Pi 5 ROS2 Jazzy Setup Guide

Updated 4 Oct 2026

Step 1: Prepare Raspberry Pi 5

1.1 Flash Ubuntu 24.04 LTS Server (64-bit)

# Download Raspberry Pi Imager
# Flash Ubuntu 24.04 LTS Server (64-bit) to SD card
# Enable SSH during flashing (recommended)

1.2 Initial System Setup (Ubuntu Server)

# SSH into your Pi (or use direct connection)
ssh ubuntu@<your-pi-ip>
 
# Check Ubuntu version
cat /etc/os-release
# Should show Ubuntu 24.04.2 LTS
 
# Update system
sudo apt update && sudo apt upgrade -y
 
# Install essential tools
sudo apt install -y curl wget git vim nano htop
 
# For Ubuntu Server, we configure hardware manually (no raspi-config)
# Enable camera and hardware interfaces via config files
sudo nano /boot/firmware/config.txt
 
# Add these lines to config.txt:
# Camera configuration
camera_auto_detect=1
dtoverlay=imx708  # For Pi Camera Module 3 (adjust if using different camera)
 
# I2C configuration  
dtparam=i2c_arm=on
 
# SPI configuration
dtparam=spi=on
 
# GPU memory split (important for camera)
gpu_mem=128
 
# Save and exit (Ctrl+X, Y, Enter)
 
# Alternative: Add all settings at once
echo "camera_auto_detect=1" | sudo tee -a /boot/firmware/config.txt
echo "dtparam=i2c_arm=on" | sudo tee -a /boot/firmware/config.txt  
echo "dtparam=spi=on" | sudo tee -a /boot/firmware/config.txt
echo "gpu_mem=128" | sudo tee -a /boot/firmware/config.txt
 
# Reboot to apply changes
sudo reboot

Step 2: Install ROS2 Jazzy

2.1 Add ROS2 Repository

# Set locale
sudo apt update && sudo apt install locales
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8
 
# Add ROS2 apt repository
sudo apt install software-properties-common
sudo add-apt-repository universe
 
# Add ROS2 GPG key
sudo apt update && sudo apt install curl -y
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
 
# Add repository to sources list
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null

2.2 Install ROS2 Jazzy

# Update package index
sudo apt update
 
# Install ROS2 Jazzy Desktop (includes rqt, rviz, demos)
sudo apt install ros-jazzy-desktop
 
# Or install ROS2 Jazzy Base (minimal installation)
# sudo apt install ros-jazzy-ros-base
 
# Install development tools
sudo apt install ros-dev-tools
 
# Install colcon for building packages
sudo apt install python3-colcon-common-extensions

2.3 Setup ROS2 Environment

# Add to bashrc for automatic sourcing
echo "source /opt/ros/jazzy/setup.bash" >> ~/.bashrc
source ~/.bashrc
 
# Verify installation
ros2 --help

Step 3: Camera Setup

3.1 Install Camera Dependencies (Ubuntu Server - Fixed)

# Install camera-related packages
sudo apt install -y v4l-utils
 
# Install available libcamera packages in Ubuntu
sudo apt install -y libcamera-dev libcamera0
 
# For Pi Camera, we'll use a different approach
# Install additional tools
sudo apt install -y python3-picamera2
 
# Install ROS2 camera packages
sudo apt install -y ros-jazzy-camera-ros
sudo apt install -y ros-jazzy-cv-bridge
sudo apt install -y ros-jazzy-image-transport
sudo apt install -y ros-jazzy-compressed-image-transport
 
# Install OpenCV for Python
sudo apt install -y python3-opencv python3-pip
 
# Add user to video group for camera access
sudo usermod -a -G video $USER
 
# Install additional useful packages
sudo apt install -y ffmpeg
 
# Logout and login again (or reboot) for group changes to take effect
sudo reboot

3.2 Test Camera Hardware (Ubuntu Server - Updated)

# After reboot, check what cameras are available
v4l2-ctl --list-devices
 
# Check for video devices
ls -la /dev/video*
 
# For Pi Camera Module, check if it's detected
dmesg | grep -i camera
 
# Test USB camera (if you have one connected)
v4l2-ctl --device=/dev/video0 --info
 
# Test camera with ffmpeg (works with both Pi Camera and USB)
# For USB camera:
ffmpeg -f v4l2 -video_size 640x480 -i /dev/video0 -frames 1 test_usb.jpg
 
# Alternative: Use Python to test camera
python3 -c "
import cv2
cap = cv2.VideoCapture(0)
if cap.isOpened():
    ret, frame = cap.read()
    if ret:
        cv2.imwrite('test_opencv.jpg', frame)
        print('Camera working! Image saved as test_opencv.jpg')
    else:
        print('Failed to capture frame')
    cap.release()
else:
    print('Cannot open camera')
"
 
# Check if test images were created
ls -la test*.jpg

3.3 Install Pi Camera Specific Tools (if using Pi Camera)

# Install libcamera tools
sudo apt install -y libcamera-apps
 
# Test Pi Camera
libcamera-hello --list-cameras
libcamera-still -o test.jpg
 
# If successful, you'll see camera info and capture a test image

Step 4: Create Basic Camera Test Package

4.1 Create Workspace

# Create ROS2 workspace
mkdir -p ~/ros2_ws/src
cd ~/ros2_ws
 
# Create simple camera test package
cd src
ros2 pkg create --build-type ament_python camera_test_pkg --dependencies rclpy sensor_msgs cv_bridge

4.2 Create Camera Test Node

cd camera_test_pkg/camera_test_pkg

4.3 Update Package Configuration

Edit the setup.py file:

nano ~/ros2_ws/src/camera_test_pkg/setup.py

Add these entry points:

entry_points={
    'console_scripts': [
        'camera_test = camera_test_pkg.basic_camera_test:main',
        'camera_viewer = camera_test_pkg.camera_viewer:main',
    ],
},

4.4 Build and Test

# Build the package
cd ~/ros2_ws
colcon build --packages-select camera_test_pkg
 
# Source the workspace
source install/setup.bash
 
# Add to bashrc for convenience
echo "source ~/ros2_ws/install/setup.bash" >> ~/.bashrc

Step 5: Testing Camera Setup

5.1 Test Hardware Camera Detection

# Check what cameras are available
ls /dev/video*
 
# Get detailed camera info
v4l2-ctl --list-devices
 
# Test camera capture (if you have a USB camera on /dev/video0)
v4l2-ctl --device=/dev/video0 --all
 
# Quick test capture
ffmpeg -f v4l2 -video_size 640x480 -i /dev/video0 -frames 1 test_image.jpg

5.2 Run ROS2 Camera Test

# Terminal 1: Run camera publisher
ros2 run camera_test_pkg camera_test
 
# Terminal 2: Check if images are being published
ros2 topic list
ros2 topic echo /camera/image_raw --once
 
# Terminal 3: Run camera viewer (if you have display)
ros2 run camera_test_pkg camera_viewer
 
# Alternative: Save images to check camera works
ros2 run camera_test_pkg camera_test --ros-args -p save_images:=true

5.3 Troubleshooting

If camera doesn't work:

# Check permissions
sudo usermod -a -G video $USER
# Logout and login again
 
# Check if camera is being used by another process
sudo lsof /dev/video0
 
# Try different camera indices
# Edit the camera_test node to try different indices (0, 1, 2, etc.)
 
# For Pi Camera specifically:
sudo raspi-config
# Enable camera interface and reboot
 
# Check Pi Camera status
vcgencmd get_camera
 
# Try libcamera (newer Pi Camera interface)
libcamera-hello --list-cameras

Step 6: Verify Everything Works

6.1 Final Test Commands

# Check ROS2 installation
ros2 doctor
 
# List available topics (should see /camera/image_raw)
ros2 topic list
 
# Check camera topic info
ros2 topic info /camera/image_raw
 
# Monitor topic rate
ros2 topic hz /camera/image_raw
 
# View topic data structure
ros2 interface show sensor_msgs/msg/Image

6.2 Expected Output

When everything works, you should see:

  • Camera test node publishing at ~10 FPS
  • Topic /camera/image_raw available
  • Images with timestamp and camera info overlay
  • No error messages in the logs

Next Steps

Once camera is working:

  1. ✅ Camera hardware detected
  2. ✅ ROS2 Jazzy installed and working
  3. ✅ Camera publishing to ROS2 topics
  4. 🔄 Ready for vision processing development
  5. 🔄 Ready for robot integration

Now you can proceed with developing the vision rescue system on top of this working foundation!