mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-15 17:12:59 -04:00
sdfjashoiuo
This commit is contained in:
@@ -56,7 +56,7 @@ cd ~/MultiRoombaRover
|
||||
sudo ./pi/install_roverd.sh
|
||||
```
|
||||
|
||||
Then point each rover's `/etc/roverd.yaml` at `ws://<server>:8080/rover`, set `name` to the rover’s ID, and (optionally) override `media.publishUrl` if your control server isn’t `192.168.0.86`. The new WHIP publisher service (`whip-publisher.service`) continuously captures the Pi camera with `libcamera-vid`, pipes it through FFmpeg, and publishes straight into the server’s mediaMTX instance at `http://<server>:8889/whip/<name>`. Use the “Restart Camera” button if you enable media management so roverd can bounce the publisher service remotely.
|
||||
Then point each rover's `/etc/roverd.yaml` at `ws://<server>:8080/rover`, set `name` to the rover’s ID, and (optionally) override `media.publishUrl` if your control server isn’t `192.168.0.86`. The new WHIP publisher service (`whip-publisher.service`) uses GStreamer (`gst-launch-1.0 libcamerasrc ! ... ! whipclientsink`) to encode the Pi camera to H264 and publish straight into the server’s mediaMTX instance at `http://<server>:8889/whip/<name>`. Install `libcamera-apps` plus `gstreamer1.0-tools gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libcamera` on each Pi so the pipeline is available. Use the “Restart Camera” button if you enable media management so roverd can bounce the publisher service remotely.
|
||||
Heads-up: the BRC pulser now uses libgpiod; make sure the `roverd` service account is in the `gpio` group (or otherwise allowed to access `/dev/gpiochip*`) and set `brc.gpioChip` if your hardware exposes a different chip name.
|
||||
|
||||
## Fedora server deployment
|
||||
|
||||
+20
-2
@@ -32,6 +32,16 @@ Run the resulting `dist/roverd-dummy` on any machine; it will connect to the ser
|
||||
|
||||
## Automated installation (recommended)
|
||||
|
||||
Make sure the Pi has GStreamer 1.22+ plus the libcamera + bad plugin sets (Bookworm ships them):
|
||||
|
||||
```bash
|
||||
sudo apt update
|
||||
sudo apt install libcamera-apps \
|
||||
gstreamer1.0-tools gstreamer1.0-plugins-good \
|
||||
gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly \
|
||||
gstreamer1.0-libcamera
|
||||
```
|
||||
|
||||
Once the binary (and repo) are on the Pi, run the helper script from the repo root:
|
||||
|
||||
```bash
|
||||
@@ -79,8 +89,16 @@ If you set `media.manage: true` in `/etc/roverd.yaml`, make sure the `roverd` se
|
||||
|
||||
## WHIP publisher details
|
||||
|
||||
The `whip-publisher.service` unit runs `/usr/local/bin/whip-publisher`, a small shell wrapper that pipes `libcamera-vid` into FFmpeg and POSTs the result to `media.publishUrl`. roverd writes `/var/lib/roverd/whip.env` on startup (and whenever you restart the service) so the publisher inherits the correct `WHIP_URL`, resolution, FPS, and bitrate. Tweak those knobs under `media.videoWidth`, `media.videoHeight`, `media.videoFps`, and `media.videoBitrate` in `/etc/roverd.yaml` if you need different camera settings.
|
||||
Use `sudo systemctl status whip-publisher` to watch the pipeline logs; the unit auto-restarts whenever the network drops or FFmpeg exits.
|
||||
The `whip-publisher.service` unit runs `/usr/local/bin/whip-publisher`, a small shell wrapper that launches:
|
||||
|
||||
```bash
|
||||
gst-launch-1.0 libcamerasrc ! video/x-raw,width=WIDTH,height=HEIGHT,framerate=FPS/1 \
|
||||
! videoconvert ! x264enc tune=zerolatency bitrate=BITRATE_KB key-int-max=FPS \
|
||||
! h264parse config-interval=1 ! whipclientsink signaller::whip-endpoint=$WHIP_URL
|
||||
```
|
||||
|
||||
roverd writes `/var/lib/roverd/whip.env` on startup (and whenever you restart the service) so the publisher inherits the correct `WHIP_URL`, resolution, FPS, and bitrate. Tweak those knobs under `media.videoWidth`, `media.videoHeight`, `media.videoFps`, and `media.videoBitrate` in `/etc/roverd.yaml` if you need different camera settings.
|
||||
Use `sudo systemctl status whip-publisher` to watch the pipeline logs; the unit auto-restarts whenever the network drops or GStreamer exits.
|
||||
|
||||
## Server + UI
|
||||
|
||||
|
||||
+21
-39
@@ -18,49 +18,31 @@ VIDEO_HEIGHT="${VIDEO_HEIGHT:-720}"
|
||||
VIDEO_FPS="${VIDEO_FPS:-30}"
|
||||
VIDEO_BITRATE="${VIDEO_BITRATE:-3000000}"
|
||||
|
||||
FFMPEG_BIN="${FFMPEG_BIN:-/usr/bin/ffmpeg}"
|
||||
GST_BIN="${GST_BIN:-/usr/bin/gst-launch-1.0}"
|
||||
|
||||
if [[ -n "${LIBCAMERA_BIN:-}" ]]; then
|
||||
LIBCAMERA_BIN_PATH="$LIBCAMERA_BIN"
|
||||
elif command -v rpicam-vid >/dev/null 2>&1; then
|
||||
LIBCAMERA_BIN_PATH="$(command -v rpicam-vid)"
|
||||
elif command -v libcamera-vid >/dev/null 2>&1; then
|
||||
LIBCAMERA_BIN_PATH="$(command -v libcamera-vid)"
|
||||
else
|
||||
echo "Neither rpicam-vid nor libcamera-vid found; install the libcamera apps." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -x "$LIBCAMERA_BIN_PATH" ]]; then
|
||||
echo "Video capture binary not executable at ${LIBCAMERA_BIN_PATH}" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -x "$FFMPEG_BIN" ]]; then
|
||||
echo "ffmpeg not found at ${FFMPEG_BIN}" >&2
|
||||
exit 1
|
||||
if [[ ! -x "$GST_BIN" ]]; then
|
||||
if command -v gst-launch-1.0 >/dev/null 2>&1; then
|
||||
GST_BIN="$(command -v gst-launch-1.0)"
|
||||
else
|
||||
echo "gst-launch-1.0 not found; install gstreamer1.0-tools and plugins." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
run_pipeline() {
|
||||
"${LIBCAMERA_BIN_PATH}" \
|
||||
--inline \
|
||||
--timeout 0 \
|
||||
--width "${VIDEO_WIDTH}" \
|
||||
--height "${VIDEO_HEIGHT}" \
|
||||
--framerate "${VIDEO_FPS}" \
|
||||
--bitrate "${VIDEO_BITRATE}" \
|
||||
--codec h264 \
|
||||
--denoise cdn_off \
|
||||
--nopreview \
|
||||
--output - |
|
||||
"${FFMPEG_BIN}" \
|
||||
-hide_banner \
|
||||
-loglevel warning \
|
||||
-f h264 \
|
||||
-i pipe:0 \
|
||||
-c:v copy \
|
||||
-an \
|
||||
-f whip \
|
||||
"${WHIP_URL}"
|
||||
local bitrate_kbps=$((VIDEO_BITRATE / 1000))
|
||||
if [[ "$bitrate_kbps" -le 0 ]]; then
|
||||
bitrate_kbps=3000
|
||||
fi
|
||||
"${GST_BIN}" -e \
|
||||
libcamerasrc \
|
||||
! "video/x-raw,width=${VIDEO_WIDTH},height=${VIDEO_HEIGHT},framerate=${VIDEO_FPS}/1" \
|
||||
! queue \
|
||||
! videoconvert \
|
||||
! x264enc speed-preset=ultrafast tune=zerolatency bitrate="${bitrate_kbps}" key-int-max="${VIDEO_FPS}" byte-stream=true \
|
||||
! "video/x-h264,profile=baseline" \
|
||||
! h264parse config-interval=1 \
|
||||
! whipclientsink signaller::whip-endpoint="${WHIP_URL}"
|
||||
}
|
||||
|
||||
while true; do
|
||||
|
||||
+16
-5
@@ -80,11 +80,22 @@ log() {
|
||||
echo "[$(date -u +%Y-%m-%dT%H:%M:%SZ)] $*"
|
||||
}
|
||||
|
||||
if ! command -v rpicam-vid >/dev/null 2>&1 && ! command -v libcamera-vid >/dev/null 2>&1; then
|
||||
log "WARNING: neither rpicam-vid nor libcamera-vid found in PATH; install the Raspberry Pi libcamera apps (sudo apt install libcamera-apps)."
|
||||
fi
|
||||
if ! command -v ffmpeg >/dev/null 2>&1; then
|
||||
log "WARNING: ffmpeg not found in PATH; install ffmpeg for WHIP publishing"
|
||||
if ! command -v gst-launch-1.0 >/dev/null 2>&1; then
|
||||
log "WARNING: gst-launch-1.0 not found; install GStreamer (sudo apt install gstreamer1.0-tools gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-libcamera)."
|
||||
else
|
||||
if command -v gst-inspect-1.0 >/dev/null 2>&1; then
|
||||
if ! gst-inspect-1.0 whipclientsink >/dev/null 2>&1; then
|
||||
log "WARNING: whipclientsink element missing; install gstreamer1.0-plugins-bad (1.22+)."
|
||||
fi
|
||||
if ! gst-inspect-1.0 libcamerasrc >/dev/null 2>&1; then
|
||||
log "WARNING: libcamerasrc plugin missing; install gstreamer1.0-libcamera."
|
||||
fi
|
||||
if ! gst-inspect-1.0 x264enc >/dev/null 2>&1; then
|
||||
log "WARNING: x264enc element missing; install gstreamer1.0-plugins-ugly."
|
||||
fi
|
||||
else
|
||||
log "WARNING: gst-inspect-1.0 not found; unable to verify GStreamer plugins."
|
||||
fi
|
||||
fi
|
||||
|
||||
ensure_user roverd "dialout,gpio,video"
|
||||
|
||||
Reference in New Issue
Block a user