streamer movement

This commit is contained in:
legop3
2026-11-16 22:59:38 -05:00
parent b0de727d3e
commit 91c9194856
52 changed files with 909 additions and 2518 deletions
+26 -10
View File
@@ -1,6 +1,6 @@
# Rover hardware configuration notes
This document records hardware-specific requirements while the roverd rework is in progress. The existing installer still contains machine-specific setup; the universal bootstrap and media profiles are not implemented yet. Final profile names and JSON examples will be added when those interfaces exist.
This document records hardware-specific requirements while the roverd rework is in progress. Media profiles and shared audio routing are implemented. The standalone bootstrap remains unfinished; current installation uses a checkout. Configuration selections are recorded below.
## Universal configuration requirements
@@ -16,11 +16,11 @@ Roverd configuration selects one physical input device and one physical output d
The microphone streamer uses the selected input. TTS, horn, and forwarded audio share the selected output while retaining simultaneous playback and separate volume controls. Profiles use the generated logical devices supplied through their environment; they do not each hardcode or independently select physical audio hardware. Use ALSA conversion where supported instead of requiring all devices to accept the existing HAT playback format.
AIY setup enables its hardware and uses this same routing system. The bootstrap still asks only for rover name and server address. This design is agreed but not yet implemented.
AIY setup enables its hardware and uses this same routing system. The bootstrap still asks only for rover name and server address. Audio routing is implemented; the standalone bootstrap remains planned.
## Existing AIY Voice HAT setup
## Historical AIY Voice HAT setup
These facts come from the repository's existing installer/configuration, not a live hardware check:
These facts record the previous installer/configuration, not a live hardware check or the current implementation:
- The Pi installer enables `dtoverlay=googlevoicehat-soundcard` and `dtparam=i2s=on`, and disables onboard audio with `dtparam=audio=off`.
- The README records that this setup worked on Raspberry Pi OS Bookworm and had problems on Trixie. The rework must not imply that the HAT is verified on every Debian release.
@@ -40,12 +40,28 @@ For the new internal GPIO peripheral, enable `piGpio.enabled` on a rover that us
The parent switch now defaults to disabled. Saved child settings do not enable GPIO on their own. External peripherals must not advertise the same enabled role unless the conflicting internal role is disabled.
## Remaining implementation work
## Implementation and verification tracking
- [ ] Add AIY capture/playback profiles alongside generic selectable ALSA device profiles.
- [ ] Make TTS, horn, forwarded audio, and mixer routing use configured devices consistently.
- [ ] Generate ALSA routing from the shared input/output configuration, including distinct input/output cards, logical profile devices, format conversion, and independent playback volume controls.
- [x] Add AIY capture/playback profiles alongside generic selectable ALSA device profiles.
- [x] Make TTS, horn, forwarded audio, and mixer routing use configured devices consistently.
- [x] Generate ALSA routing from the shared input/output configuration, including distinct input/output cards, logical profile devices, format conversion, and independent playback volume controls.
- [ ] Audit fixed card numbers, named PCM assumptions, capture formats, camera orientation/sensor defaults, serial device defaults, and architecture-specific TTS assets.
- [ ] Keep required one-time host boot changes visible; distinguish a hardware-overlay reboot from ordinary roverd update/restart behavior.
- [ ] Add exact final profile selections and JSON settings for the existing AIY rover.
- [x] Keep required one-time host boot changes visible; distinguish a hardware-overlay reboot from ordinary roverd update/restart behavior.
- [x] Add exact final profile selections and JSON settings for the existing AIY rover.
- [ ] Verify on the actual HAT and at least one non-HAT audio device; record results rather than assuming compatibility.
## Implemented profile/audio selections (2026-11-16)
The new supervisor and generated ALSA routing are implemented, but not hardware-verified. See [media profile documentation](rover-media-profiles.md). Bundled setup/run commands are contained in YAML, not repository shell helpers.
For the existing AIY v1 setup, start with these fields in a complete current config:
- `media.video.profile`: `rpicam`, enabled for the CSI camera; retain the existing resolution/bitrate, inverted mounting, and sensor mode if appropriate.
- `media.audioCapture.profile` and `media.audioPlayback.profile`: `aiy`, enabling each required streamer. Their inline setup enables I2S and the Google Voice HAT overlay. Reboot once if setup changes boot configuration.
- `audio.inputDevice` and `audio.outputDevice`: `hw:CARD=sndrpigooglevoi,DEV=0`, **after verifying that identifier on the rover**.
- `audio.mixerCard`: `sndrpigooglevoi`, matching the verified output card.
- `audio.outputSampleRate`: `16000`; `audio.outputChannels`: `1`, preserving the old HAT mixing format.
- `audio.ttsEnabled`: true if desired; choose `audio.defaultEngine` explicitly. Chrome speech assets now live outside the checkout under `/var/lib/roverd/googletts`.
- Enable the parent `piGpio.enabled` and the desired child roles as described above. The old automatic PWM-overlay installer is gone; the GPIO12/13 PWM overlay remains a documented host wiring requirement, not an audio-profile side effect.
The HAT setup does not disable unrelated onboard audio or force a card index. Use the configured stable device/card names. Existing installed media systemd units must be removed/disabled before running the new supervisor. Remove any old roverd-specific host ALSA configuration before deployment: the generated config includes the system ALSA definitions, whose hooks can still load host configuration. The old media launchers are no longer used.
+57
View File
@@ -0,0 +1,57 @@
# Rover media profiles and audio
Roverd reads three YAML catalogs directly from its checkout: `rover/profiles/video.yaml`, `audioCapture.yaml`, and `audioPlayback.yaml`. Each is a list of profiles with `id`, `name`, `description`, optional `setup`, and `run`.
Commands live in the YAML itself. Bundled profiles must not delegate their setup or run implementation to an in-repository shell helper. Multiline shell commands, arrays, and pipelines are supported through Bash with error/pipe failure handling. Profile identifiers use lowercase letters, digits, underscores, and hyphens; `custom` is reserved.
Each enabled streamer runs its selected setup on every daemon startup. Setups are serialized to avoid competing package-manager operations; successful setup is not tracked on disk. Each run command then starts independently and retries after two seconds on exit. A failed setup leaves only that streamer stopped. Shutdown kills the complete process group and waits for it. Nothing installs media systemd services.
Working directories are `/var/lib/roverd/profiles/<category>/<id>`. Commands receive environment variables, not interpolated shell source. Quote variables normally.
| Variables | Meaning |
| --- | --- |
| `ROVER_NAME`, `ROVER_SERVER_HOST` | Identity and server hostname |
| `ROVER_PROFILE_DIR`, `ROVER_REPO_DIR` | Persistent working directory and checkout |
| `ROVER_VIDEO_DEVICE`, `ROVER_VIDEO_INPUT_FORMAT` | Camera input |
| `ROVER_VIDEO_WIDTH`, `ROVER_VIDEO_HEIGHT`, `ROVER_VIDEO_FPS`, `ROVER_VIDEO_BITRATE` | Camera/encoder settings |
| `ROVER_VIDEO_INVERTED`, `ROVER_VIDEO_SENSOR_MODE` | Orientation and optional rpicam mode |
| `ROVER_VIDEO_PUBLISH_URL`, `ROVER_AUDIO_PUBLISH_URL`, `ROVER_AUDIO_PLAYBACK_URL` | Complete derived RTSP URLs |
| `ROVER_AUDIO_INPUT_DEVICE`, `ROVER_AUDIO_OUTPUT_DEVICE` | Generated logical ALSA microphone and forwarded-audio routes |
| `ROVER_AUDIO_SAMPLE_RATE`, `ROVER_AUDIO_CHANNELS`, `ROVER_AUDIO_BITRATE` | Microphone encoding settings |
| `ROVER_AUDIO_NORMALIZE`, `ROVER_AUDIO_NORMALIZE_FILTER` | Forwarded-audio normalization |
The bundled options are `v4l2` / `rpicam` for video and `alsa` / `aiy` for capture and playback. Hardware encoders or other transports can be supplied as custom commands without adding roverd code.
## Configuration and UI
Select `media.video.profile`, `media.audioCapture.profile`, and `media.audioPlayback.profile`, with each category's `enabled` switch. Fleet management renders profile names from the catalogs and has a “Media profiles and output” section for descriptions, current status, output, and custom editing.
There is one custom profile per category, stored under `/etc/roverd/profiles/<category>.yaml`. Saving it restarts roverd; select `custom` in configuration to use it. Bundled files remain in the checkout. The admin API is `roverManagement:saveProfile` with `{ roverId, category, profile }`.
Output is always forwarded while management is connected, without viewer subscriptions. Rover queues and server/browser history are bounded; a noisy process can lose old output but cannot indefinitely block streaming or grow history. Current streamer status is retained separately and included in management hello.
## Audio routing
`audio.inputDevice` and `audio.outputDevice` select physical ALSA devices independently. Use hardware PCM identifiers such as `hw:CARD=Device,DEV=0`; find the actual identifiers with `arecord -l` and `aplay -l`. The output must support ALSA dmix's hardware slave; arbitrary sound-server/plugin PCM names are not interchangeable with a hardware PCM.
`audio.mixerCard` selects the output card's mixer identifier. `audio.outputSampleRate` and `audio.outputChannels` configure its hardware mix format. Choose a format supported by that device; `plug` handles client conversion to that format. Input and output may be on separate cards.
Roverd generates `/var/lib/roverd/asound.conf` and sets `ALSA_CONFIG_PATH` for its children. It does not overwrite the host's ALSA configuration. Its system ALSA include can still load host configuration through ALSA hooks; remove old roverd-specific host ALSA definitions before deployment. Logical devices are `rover_capture`, `rover_tts`, `rover_horn`, and `rover_forward`. TTS, horn, and forwarded audio share a dmix output and have independent soft-volume controls. `amixer` targets the configured mixer card, never a fallback card zero. Some soft-volume controls appear only once their PCM has first been opened; verify volume behavior after playback begins.
Chrome TTS uses the same generated playback route. Its architecture-specific library/voice files are runtime data under `/var/lib/roverd/googletts`; the installer invokes the independent TTS dependency installer. ARMv6 hosts must use flite/espeak if no matching Chrome library is available. The server no longer substitutes Chrome TTS when a command omits an engine; roverd's configured default applies.
## Inspection without hardware or setup execution
```sh
./dist/roverd-linux-amd64 -repo "$PWD" -print-media-profiles
./dist/roverd-linux-amd64 -config rover/roverd/roverd.sample.json -check-config
./dist/roverd-linux-amd64 -config rover/roverd/roverd.sample.json -print-audio-config
```
These commands do not install packages, open devices, or start streams. Configuration/schema and architecture binaries have changed together; old JSON objects are not migrated.
## Deployment checks still required
Before deploying over an old installation, explicitly disable/remove its old media units so they cannot compete for devices or publish duplicate streams. This rework does not migrate an installed host. The checkout installer now installs only the roverd service and runtime dependencies; standalone bootstrap/update redesign remains a later stage.
On the actual rover, confirm all selected profiles complete setup, observe output/status in fleet management, and verify video, microphone, forwarded audio, TTS, horn, simultaneous playback, and each gain control. Restart the server or interrupt Wi-Fi: media commands should retry without restarting roverd. Save configuration and verify no media child processes remain from the previous daemon. Capture journal output and observed results. AIY overlay changes require a one-time host reboot; ordinary configuration saves only restart roverd.
+2 -2
View File
@@ -24,7 +24,7 @@ Select the appropriate architecture binary on a rover. The default object suppli
- Management starts independently of hardware initialization and remains available after serial/peripheral startup failure.
- Control disconnect docking/reboot behavior still depends on control connectivity. A live management connection does not count as a working control connection.
- The server maintains management records independently of the control roster, only in memory. Management disconnect removes the record; hello repopulates it.
- Profile catalogs in hello are currently empty. YAML media profiles are the next media implementation stage, not installed catalogs hidden elsewhere.
- Profile catalogs and current media status arrive in hello; see [media profiles](rover-media-profiles.md).
## Configuration page
@@ -72,7 +72,7 @@ Record acknowledgement errors, reconnect hello contents, relevant journal/server
## Pending stages
Browser/live verification of configuration and operational state, YAML media catalogs/child supervision, universal ALSA routing, standalone bootstrap, and replacement update workflow remain pending. The current updater and systemd media supervisor have moved transport but retain their existing implementations until those stages.
YAML media catalogs, child supervision, shared ALSA routing, and Fleet Management profile controls are implemented. Browser/live verification of configuration, operational state, media, and audio remains pending. Standalone bootstrap and the replacement update workflow are the next implementation stage.
Apply-field targets the currently management-connected fleet. It clones each rover’s own configuration, replaces an existing field, and sends the complete object for rover-side validation. Inspect individual results for failures. Missing fields and changed connections are reported; offline changes are not queued. Paths traverse object fields, not array elements. Array-valued fields can be replaced as a whole.
+19 -7
View File
@@ -1,6 +1,6 @@
# Roverd rework plan and implementation tracker
Status: implementation authorized on 2026-11-16; repository/build, internal GPIO, and JSON/management backend implemented; live management verification and remaining stages pending.
Status: implementation authorized on 2026-11-16; repository/build, internal GPIO, JSON/management, Fleet UI, rover state, media profiles/supervision, and shared audio routing implemented; deployment verification, standalone bootstrap, and update redesign remain pending.
This is the persistent plan and progress record for the roverd rework. Update it as implementation proceeds, recording completed work, decisions, verification evidence, and remaining work. Keep unfinished work unchecked; distinguish implemented behavior from runtime-verified behavior.
@@ -168,15 +168,15 @@ The order below is a working sequence, not a requirement to leave incompatible i
- [x] Move reboot, update, media management, host statistics, and daemon status messages to management; update consumers. Preserve the separately authorized user reboot path.
- [x] Separate management lifecycle from hardware startup failures (deployment verification pending).
- [x] Implement full-object `roverState` and consolidate server/UI operational-state consumers (live verification pending).
- [ ] Add bundled YAML catalogs and one custom YAML profile per media category.
- [ ] Preserve AIY HAT as an explicit profile and expose ordinary audio-device selection on every architecture, including TTS/horn/mixer paths.
- [ ] Generate ALSA routing from shared input/output selections; connect microphone, TTS, horn, forwarded audio, and independent volume controls to the resulting logical devices.
- [x] Add bundled YAML catalogs and one custom YAML profile per media category. (Live verification pending.)
- [x] Preserve AIY HAT as an explicit profile and expose ordinary audio-device selection on every architecture, including TTS/horn/mixer paths. (Live verification pending.)
- [x] Generate ALSA routing from shared input/output selections; connect microphone, TTS, horn, forwarded audio, and independent volume controls to the resulting logical devices. (Live verification pending.)
- [ ] Document exact configuration for the existing AIY rover and audit other machine-specific assumptions.
- [ ] Implement command environments, persistent working directories, and setup on each daemon startup.
- [ ] Replace media systemd management with child-process supervision and continuous bounded output forwarding.
- [x] Implement command environments, persistent working directories, and setup on each daemon startup. (Live verification pending.)
- [x] Replace media systemd management with child-process supervision and continuous bounded output forwarding. (Live verification pending.)
- [x] Implement per-rover schema editor and complete-object saves (browser/live verification pending).
- [x] Implement apply-one-field-to-all-connected-rovers with individual results (browser/live verification pending).
- [ ] Add profile editing/selection, media output/status, reboot, and update UI.
- [x] Add profile editing/selection, media output/status, reboot, and update UI. (Live verification pending.)
- [ ] Implement standalone bootstrap with only name/address input and automatic OS architecture selection.
- [ ] Implement shared checkout installation and self-update with reconnect-visible results.
- [ ] Remove obsolete services, configuration files, scripts, build distinctions, and documentation.
@@ -273,3 +273,15 @@ Verification for this stage:
- All four architecture binaries rebuilt successfully; focused frontend lint and server syntax checks passed. The two existing roster lifecycle tests passed after updating their state fixture. No new tests added.
- Still verify live initial state, toggles through both GPIO/Firmata, reconnect state, disconnect clearing, and darkness restoration. Production UI assets have not been rebuilt.
- Next implementation stage: YAML media profiles, command environments and child-process supervision, alongside the planned universal audio routing.
### Media profiles, supervision, and audio (2026-11-16)
- Added three YAML catalogs with six profiles: V4L2/rpicam video, generic ALSA/AIY microphone and playback. All bundled setup/run commands are inline YAML; the user explicitly rejected delegation to repository shell helpers, and the AIY helper was removed.
- Each enabled streamer has a persistent working directory, startup setup, independent command restart, complete process-group cleanup, and bounded continuously forwarded output. Setup is serialized for package-manager access with no persistent completion markers.
- Management hello includes catalogs and current media status. Fleet management exposes profile selection, exactly one editable custom profile per category, status, and output. Output is not emitted as chat alerts.
- Shared audio input/output settings generate a private ALSA config for microphone, TTS, horn, and forwarded audio, retaining mixing and independent gains. Hardware output PCM, mixer card, rate, and channels are explicit settings. See hardware notes for AIY values and limitations.
- Removed old media services/launchers, old machine-specific installer modules, static ALSA configs, and duplicate Chrome daemon. The checkout installer now installs only roverd plus runtime dependencies. Standalone bootstrap and self-update redesign remain unfinished.
- The server now respects roverd's configured default speech engine. TTS assets live under `/var/lib/roverd/googletts`; the generic dependency helper selects architecture-specific libraries.
- Added real CLI inspection for catalogs and generated ALSA configuration, without setup execution or hardware access.
- Verification: all four architecture builds passed; six profiles loaded through the actual daemon and all setup/run commands passed Bash syntax checks; current sample config validation and ALSA config rendering passed; installer/TTS shell syntax and server JS syntax passed. Focused frontend lint passed including the final status-display changes. No camera/audio streaming, setup commands, host installation, or browser/server processes were run here.
- Next: verify the remaining frontend check, then standalone bootstrap and update flow. Actual device formats, concurrent playback/gains, child cleanup and network recovery still require the documented rover-side checks.