Skip to content

tritonuas/camera-things

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

122 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pi Camera UDP Server | Camera-things

Build Camera

This is a repository for a camera server that runs on a Raspberry Pi Zero 2 W and sends images to a Jetson Orin Nano via UDP.

Dependencies

  • Raspberry Pi Zero 2 W
  • Jetson Orin Nano
  • Micro-USB to USB-A data cable

You can set up this project locally outside of the Pi using Docker

Quick Setup (Docker)

Follow this if you don't have access to the Pi, but want to develop and test the project.

Note: the docker container does not support networking to obcpp container as of yet

git clone https://github.com/tritonuas/camera-things.git
cd camera-things

# Build and run docker container
make build-docker
make run-docker

# Run mock server
mkdir build && cd build
cmake ..
make
./raspy

Using Mock Camera:

To test the project without a camera, you can use the mock camera

  1. Set "USE_MOCK_CAMERA": 1 in config/picam.json.
  2. Make sure you have images in /images/mock directory.
  3. The mock camera reads images in a round-robin fashion.

Not So Quick Setup (On Pi Zero 2 W)

Follow this if you have the Pi Zero 2 W and want to set up the project on it.

  1. Setup the Networking Connection
  2. Then setup the codebase below:
git clone git@github.com:tritonuas/camera-things.git
cd camera-things

# Install dependencies
sudo apt update
sudo apt install -y \
    build-essential \
    cmake \
    pkg-config \
    libcamera-dev \
    libevent-dev \
    libusb-1.0-0-dev

# Build the project
mkdir build && cd build
cmake ..    # configures the CMake build system
make

# Run the server
./raspy

Config Files

The server uses one config file config/picam.json.

{
    "UART_NAME": "/dev/serial0",    // UART port to use for MAVLink communication
    "BAUDRATE": 57600,              // Baudrate for MAVLink communication
    "DEBUG_MODE": 1,                // 1 for debug mode, 0 for normal mode
    "SEND_TO_OBC": 0,               // 1 to send images to OBC, 0 to send to Jetson
    "MAVLINK_ENABLED": 1            // 1 to enable MAVLink communication, 0 to disable
}

Network Setup

1. Enable USB Gadget Mode & Set Static MAC

We need to load the necessary kernel modules and force a specific MAC address so the Jetson always recognizes the Pi as the same device.

  1. Open config.txt:

    sudo nano /boot/firmware/config.txt
  2. Add this line to the very bottom:

    dtoverlay=dwc2
    
  3. Save and exit (Ctrl+O, Enter, Ctrl+X).

  4. Open cmdline.txt:

    sudo nano /boot/firmware/cmdline.txt
  5. Find the line of text. Do not create a new line. Add the following text strictly after rootwait:

    modules-load=dwc2,g_ether g_ether.host_addr=00:dc:c8:f7:75:14 g_ether.dev_addr=00:dd:dc:eb:6d:da
    

    Make sure there is a space before and after this addition.

2. Configure Static IP (192.168.77.2)

We configure NetworkManager to assign a static IP to the usb0 interface.

# Create the connection profile
sudo nmcli con add type ethernet con-name "usb-gadget" ifname usb0

# Set Static IP
sudo nmcli con modify "usb-gadget" ipv4.addresses 192.168.77.2/24
sudo nmcli con modify "usb-gadget" ipv4.method manual

# Disable IPv6 to reduce overhead (optional but recommended)
sudo nmcli con modify "usb-gadget" ipv6.method ignore

3. Add Crontab "Kickstarter"

To ensure the network comes up reliably on every boot, we add a cron job to force the connection.

  1. Open crontab:

    sudo crontab -e
  2. Add this line to the bottom:

    @reboot sleep 30 && /usr/bin/nmcli con up "usb-gadget" > /var/log/gadget_connect.log 2>&1
    
  3. Reboot the Pi: sudo reboot now


4. Physical Connection & Testing

1. Connect the Hardware

  1. Plug the Micro-USB end into the Data Port of the Pi Zero 2 W (the port labeled "USB", closest to the center).
  2. Plug the USB-A end into the Jetson Orin Nano.

2. Verify Connectivity

Wait about 45-60 seconds after plugging in (for the Pi to boot and the Crontab job to run).

On the Jetson:

# 1. Check if the interface exists
ip link show
# Look for an interface with MAC 00:dc:c8:f7:75:14

# 2. Ping the Pi (we should see the packet returning)
ping 192.168.77.2

About

UDP Camera Server Module for Raspberry Pi + Mavlink

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors