Files
MultiRoombaRover/docs/pi-deployment.md
T
2025-11-10 15:35:31 -05:00

4.4 KiB
Raw Blame History

Pi Deployment Guide

Tooling

Fedora 43:

sudo dnf install golang libgpiod

Cross-compiling roverd for Pi Zero 2 W (ARMv7):

cd pi/roverd
mkdir -p ../../dist
make pi-build

The binary is placed in dist/roverd (relative to the repo root).

Once the binary (and repo) are on the Pi, run the helper script from the repo root:

cd ~/MultiRoombaRover
sudo ./pi/install_roverd.sh --mediamtx

What the script does:

  • creates the roverd (and optionally mediamtx) service users if missing and installs /usr/local/bin/roverd
  • copies pi/roverd/roverd.sample.yaml to /etc/roverd.yaml if the file is absent (existing configs are left untouched)
  • installs/enables the roverd.service systemd unit, restarting it automatically when a config already exists
  • when --mediamtx is passed, downloads the requested mediaMTX release for the Pis architecture, installs it to /usr/local/bin/mediamtx, drops the sample config + unit, enables the service, and restarts it

Flags:

Flag Purpose
-b PATH use a different roverd binary (defaults to dist/roverd)
-c PATH seed /etc/roverd.yaml from another template
--mediamtx download/install mediaMTX plus the provided config + unit
--mediamtx-version X.Y.Z override the mediaMTX release tag (default 1.8.6)

If the script installs the sample config, it will remind you to edit /etc/roverd.yaml before manually restarting the service: set name, serverUrl, serial device, BRC pin, battery thresholds, and the WHEP URL that the central server should expose.

Manual installation

  1. Copy the binary and config:

    sudo useradd -r -s /usr/sbin/nologin roverd || true
    sudo install -o roverd -g roverd -m 0755 dist/roverd /usr/local/bin/roverd
    sudo install -o roverd -g roverd -m 0640 pi/roverd/roverd.sample.yaml /etc/roverd.yaml
    

    Adjust /etc/roverd.yaml for each rover: name, serverUrl (e.g. ws://control-server:8080/rover), serial port path, battery thresholds, GPIO pin for BRC, and the media WHEP URL that points at the central distribution server.

  2. Install the systemd unit:

    sudo install -m 0644 pi/systemd/roverd.service /etc/systemd/system/roverd.service
    sudo systemctl daemon-reload
    sudo systemctl enable --now roverd.service
    

roverd requires access to /dev/ttyAMA0 and /sys/class/gpio; keeping it under its own user ensures the rest of the system stays isolated.
BRC note: writing to /sys/class/gpio/export typically requires root on Raspberry Pi OS. Until the pulser moves to libgpiod, either run the service as root or set brc.gpioPin: -1 (rover may eventually sleep).
If you set media.manage: true in /etc/roverd.yaml, make sure the roverd service account can invoke systemctl <action> <media.service> (either run the unit as root or grant sudo privileges for that command).

Configuring mediaMTX

  1. Download the latest mediaMTX release for ARMv7 and place the binary at /usr/local/bin/mediamtx.
  2. Copy the provided config:
    sudo useradd -r -s /usr/sbin/nologin mediamtx || true
    sudo install -d -o mediamtx -g mediamtx /etc/mediamtx
    sudo install -o mediamtx -g mediamtx -m 0644 pi/mediamtx/mediamtx.yml /etc/mediamtx/mediamtx.yml
    sudo install -m 0644 pi/systemd/mediamtx.service /etc/systemd/system/mediamtx.service
    sudo systemctl daemon-reload
    sudo systemctl enable --now mediamtx.service
    

The sample config uses the Raspberry Pi camera module as the source and exposes a WHEP endpoint at http://<pi-host>:8889/whep/rovercam. Point media.whepUrl in roverd.yaml at this URL so the central server can list it.
Expose the mediaMTX HTTP API locally (default http://127.0.0.1:9997) and set media.healthUrl so roverd can monitor the pipeline; media.service should match the systemd unit name (default mediamtx.service).

Server + UI

From the repo root:

cd server
npm install
npm run start

This launches the HTTP server (serving the barebones UI) and the rover WebSocket endpoint at ws://<server>:8080/rover. The UI expects roverd instances to send hello frames so it can populate the rover list. Use the mode buttons to emit Start/Safe/Full/Passive/Dock commands (they send the raw OI opcode bytes), tap the sensor toggle to request Group 100 streaming, and use WASD for drive testing; the UI emits Drive Direct commands ~8 times per second, so the rover sees them immediately.