Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 100 additions & 23 deletions examples/egocap/CALIBRATION_TOOLS.md

Large diffs are not rendered by default.

108 changes: 103 additions & 5 deletions examples/egocap/CAMERA_SETTINGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ camera on the SIPL backend: HEVC at 30 fps and 4 Mbit/s.
The file is specific to that rig. A different SIPL platform or camera changes the `sipl` block (platform file, config
name, link masks, tuning directory) and possibly the stream id and size. The Argus backend has no `sipl` block: it
selects a sensor mode with `cameras[].mode`, can set `capture.mode` and `alignment`, enforces `output.fps` with a rate
limiter and can set output dimensions. Keep one file per rig and pass the right one with `--sender-config`. The launcher itself supports one stream per
file and requires an explicit `output.fps`.
limiter and can set output dimensions. Keep one file per rig and pass the right one with `--sender-config`. The
launcher takes a profile of one to three mono streams, one for each station camera (see
"A profile for three cameras"), and requires an explicit `output.fps`, the same for every stream.

`tools/start_system.py` loads this file by default. Command-line overrides (`--fps`, `--bitrate-mbps`,
`--sender-port`) are applied to the loaded mapping, and the result is what is uploaded. The same
values feed the bridge and the CaptureServer descriptor, so they cannot disagree.
`--sender-port`) are applied to the loaded mapping, the first two to every stream of it, and the result is what is
uploaded. The same values feed the bridge and the CaptureServer descriptor, so they cannot disagree.

### How the file reaches the sender

Expand Down Expand Up @@ -82,6 +83,81 @@ These settings fix what the timestamps mean; they do not reduce the actual delay
against the link, queues in the kernel and the application, and encoder and decoder throughput. When a stamp is
missing, timing is unqualified or the mapping has not settled, the page shows no figure instead of a guess.

## A profile for three cameras

A station with a head camera and two wrist cameras on one Orin runs them as three mono streams of one profile.
[`configs/three-camera-settings.example.yaml`](configs/three-camera-settings.example.yaml) shows the structure. It
is an example, not a station's file: every value that belongs to one station is written `PLACEHOLDER_...` with a
comment that says where the station finds it, and the launcher refuses the file while one is left (*... still
holds placeholders (...); replace each with this station's value, which the comment beside it says where to
find*). An override on the command line does not stand in for a placeholder. Copy the file, fill the copy in and
keep it outside the repository.

```bash
uv run python tools/start_system.py --orin user@orin --deploy-script PATH --livekit-server PATH --bridge PATH \
--sender-config YOUR_COPY --station-config YOUR_STATION_FILE \
--stream-role head=ego --stream-role left_wrist=wrist_left --stream-role right_wrist=wrist_right
```

The station file is needed as well: the launcher's default one asks CaptureServer for cameras of its own, and the
launcher refuses to start without them.
[`recording/egocap/stations/ego_stations.bridged.example.yaml`](recording/egocap/stations/ego_stations.bridged.example.yaml)
is a template for a station whose cameras all arrive through the bridge; with it, and a filled-in profile, the
command above starts as written.

**What the three streams share, and what each has of its own.**

| Shared by all streams | Each stream's own |
|---|---|
| One sender process and one deployment on the Orin, from one uploaded file | Its SIPL pipeline index (`cameras[].device`), which is not the GMSL link number |
| One TCP connection to the PC (`network.port`), so one link carries all of them | Its picture size, which on the SIPL backend is the sensor's own |
| One receiver process and one bridge process on the PC | Its HEVC bitrate (`output.bitrate_mbps`) |
| One frame rate: the bridge's `--fps` is one value for every stream, so the launcher refuses streams at different rates | Its receiver output and CUDA IPC name, which is the stream's id |
| One LiveKit room and publisher | Its LiveKit track, its camera role, its calibration, its saved correction and its remap table |

- **The streams' order is the sender's numbering.** The sender's wire format carries no stream ids: the receiver
knows a stream by its place in the profile's list, and the launcher writes the receiver config in that order.
- **The stream's id is the camera's name** in the receiver, the bridge, the page, the recordings and the
calibration solved for it. Changing an id after a lens was solved makes that lens another camera's, and the
launcher then refuses to correct with it.
- **Roles are said at every start**, with `--stream-role STREAM=ROLE` for each stream. The launcher takes no role
from a stream's id or from its place in the list, and refuses a profile of several streams while one has no
role. See [`CALIBRATION_TOOLS.md`](CALIBRATION_TOOLS.md#what-the-launcher-does-at-start) for every refusal.
- **Each stream states its size.** The sensor size the launcher assumes for a one-stream profile is the head
camera's; among several streams none is assumed, so set `output.width` and `output.height` on each (the SIPL
backend accepts them only when they repeat the sensor's size), or pass `--width` and `--height` when all three
cameras send the same size.
- **The station's roles on the page** (Settings, Station) are set to the same cameras by their stream ids; the
calibration tools, the Devices checklist and the camera grid go by them.
- **The station file** names no CaptureServer camera in `video_sources` when all the video comes from the Orin,
and what it says about a camera says it by the stream's id: `alignment.index_source` is the head stream's id
(with another name no take is time-aligned, and only the backend's log says so), and a
`data_check.guardrails.camera_expected_fps` entry is keyed by a stream's id. The template named above is laid
out so.
- **A profile cut down to one stream is the head camera again.** A profile's only stream is taken for `ego`
whatever its id, so the example with only `left_wrist` left in it would be corrected as the head camera. To run
one wrist camera alone, say so: `--stream-role left_wrist=wrist_left`.
- **Lens files name their camera.** Among several bridged streams the launcher refuses a lens file that names no
camera, and two roles whose lens files are one file; solve each camera's lens from the page, which stamps it.

**Bitrate.** The shipped one-camera profile's 4 Mbit/s is sized for a wireless link between the Orin and the PC.
Three streams share that link, so what it has to carry is the sum of the three `bitrate_mbps` values. The launcher
adds them up and prints the sum at start (`3 streams at 30 fps, 12 Mbit/s in all ('head' 4, 'left_wrist' 4,
'right_wrist' 4)`), and that is all it does with it: there is no limit in the code, and no warning, however large
the sum. Whether the sum fits the link is the station's to make sure of: measure the link with
`deploy_sender.py user@orin linktest` and leave headroom. `--bitrate-mbps` sets every stream to the same figure. The bridge's own
bitrate is a separate setting on the other leg, from the PC into LiveKit: its `--bitrate-mbps` is a maximum for
each track, 8 Mbit/s unless given, which the launcher does not pass. The bridge's README says the encoder starts
at 2 Mbps and follows LiveKit's congestion control up to that maximum, that a 20 Mbps maximum on the head built a
standing backlog of about 1.2 s, and to keep the maximum near 8 Mbps; with three tracks the room can therefore
carry up to three times that.

**On the PC's GPU** each stream has a decoder in the receiver, a ring of six decoded pictures there
(`ring_depth`), and in the bridge a thread, a GPU pipeline and an encoder of its own. A corrected stream also holds
its remap table on the GPU: the file is 48 bytes plus 8 bytes for each pixel of the picture the table makes, and
the bridge uploads it with a half-size chroma table once, when the stream starts. Neither the receiver's nor the
bridge's guide states what a stream takes in all, and it was not measured.

## Sender profile keys

These keys belong to the sender release the profile targets, which is not part of this tree: it supports the SIPL
Expand Down Expand Up @@ -131,7 +207,8 @@ shipped profile.

## Receiver keys

The receiver reads its own file once at start; the launcher generates it from the sender profile and the stream size.
The receiver reads its own file once at start; the launcher generates it from the sender profile and each stream's
size, with one entry for each stream in the profile's order.

| Key | Default / requirement | Meaning |
|---|---|---|
Expand Down Expand Up @@ -180,3 +257,24 @@ timestamps; it does not configure the Orin or join LiveKit for anyone.
| `livekit.streams[].width` | Required valid descriptor value | Advertised image width; match processed output. |
| `livekit.streams[].height` | Required valid descriptor value | Advertised image height. |
| `livekit.streams[].fps` | Required valid descriptor value | Advertised nominal FPS; the launcher sets it to the sender's effective `output.fps`, and it does not command the sender. |

## Not yet verified on hardware

- **Three cameras through the launcher have never been run on an Orin.** No Jetson, GMSL camera or CUDA GPU was
at hand. The launcher's three-stream start was run against stand-ins for every program it starts; the receiver
config, the mock sender's command, the deploy commands and the stream descriptor it writes were read by those
programs' own parsers; the bridge's command line was held only to the rules its guide states, since the bridge
needs CUDA to build. `configs/three-camera-settings.example.yaml` holds a placeholder for every station value
and was never deployed. A first run on a station must check:
- that each stream arrives as the camera its role says: cover one lens at a time and see which tile goes dark,
against the `stream '<id>': <role>, ...` lines the launcher prints;
- that each corrected picture is corrected with its own camera's calibration: straight edges come out straight
in all three, and a take's `rectification.json` names each role's own intrinsics file;
- the GPU's memory and load with three decode, remap and encode pipelines running, and that the GPU allows that
many decoder and encoder sessions at once; neither guide of the receiver or the bridge states a figure;
- the bitrate the link between the Orin and the PC carries with three streams, against the sum the profile
asks for (`deploy_sender.py user@orin linktest`), and the receiver's measured rate for each stream;
- that time sync settles and all three streams carry capture times, so takes are aligned;
- what happens when one camera drops: whether the sender keeps sending the other two, what the receiver and the
bridge report for the missing one, and that a bridge that exits stops the whole stack, as the launcher means
it to. A take is given up when any one of its cameras sends no frame.
16 changes: 15 additions & 1 deletion examples/egocap/LIVEKIT_PREVIEW.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,11 @@ to the backend's log only, since a server's error body can hold anything.
A LiveKit stream is recorded as it is published. When the publisher is the camera bridge started by
`tools/start_system.py`, the published picture is corrected (rectified) whenever the station's rectification plan
is switched on for that camera: the launcher gives the bridge a remap table, declares the corrected size in the
streams file, and tells the backend what it applied through `EGOCAP_STREAMS_STATE`. The backend then adds
streams file, and tells the backend what it applied through `EGOCAP_STREAMS_STATE`. The launcher bridges every
stream of its sender profile, up to the head camera and the two wrist cameras: the streams file it writes then
lists each camera under its own track (`sensing-head`, `sensing-wrist-left`, `sensing-wrist-right`) at the size
that camera is published at, all in one room under one publisher and at one frame rate, and each camera is
corrected, or not, by itself. The backend then adds
`rectification.json`, the corrected camera and the lens it was corrected from to every session, and its
calibration tools refuse to calibrate a lens from that video. See
[`CALIBRATION_TOOLS.md`](CALIBRATION_TOOLS.md#rectification).
Expand All @@ -187,6 +191,16 @@ corrected video is what the launcher is for.

## Not yet verified on hardware

- **Three cameras through the launcher have never been run on an Orin.** No Jetson, GMSL camera or CUDA GPU was
at hand: the three-stream start was run against stand-ins for the programs it starts, and
`configs/three-camera-settings.example.yaml` holds a placeholder for every station value. A first run must check
that each stream arrives as the camera its role says, that each corrected picture is corrected with its own
camera's calibration, the GPU's memory and load with three decode, remap and encode pipelines, the bitrate the
link between the Orin and the PC carries, that time sync settles for all three streams, and what happens when
one camera drops. [`CAMERA_SETTINGS.md`](CAMERA_SETTINGS.md#not-yet-verified-on-hardware) says how to check each.
With three cameras the checklist has an item for each camera the station's roles name, the page reports what
its preview receives of each, and a take is given up when any one of the three sends no frame within ten
seconds; none of that was seen with three real streams.
- The page's reports have been exercised against a scripted room and a scripted video element, and the checklist
against scripted reports. No LiveKit server, camera sender or emulator was run by this work, so a pass has not
been seen for a real stream.
Expand Down
46 changes: 40 additions & 6 deletions examples/egocap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -399,21 +399,55 @@ The sender settings come from the checked-in profile `configs/default-camera-set
built from the same effective values. [`CAMERA_SETTINGS.md`](CAMERA_SETTINGS.md) says which component owns which
setting and lists every key.

**All the station's cameras.** A profile may hold from one to three mono streams, one for each station camera:
the head camera and the two wrist cameras. The launcher then deploys and starts one sender for all of them, writes
one receiver config that lists each stream with its own size and CUDA IPC name, and starts one bridge with a
`--stream` for each, every stream under a LiveKit track of its own. Which stream is which camera is said at every
start, with `--stream-role STREAM=ROLE` for each stream; the launcher takes no role from a stream's name or its
place in the profile, and refuses to start while a stream of several has none:

```bash
uv run python tools/start_system.py --orin user@orin --deploy-script PATH --livekit-server PATH --bridge PATH \
--sender-config YOUR_COPY_OF_THE_EXAMPLE --station-config YOUR_STATION_FILE \
--stream-role head=ego --stream-role left_wrist=wrist_left --stream-role right_wrist=wrist_right
```

The station file is part of the command: the default one requests CaptureServer cameras, which the launcher
refuses to start without. `recording/egocap/stations/ego_stations.bridged.example.yaml` is a template for a
station whose cameras all arrive through the bridge.

`configs/three-camera-settings.example.yaml` shows such a profile, with a placeholder for every value that belongs
to one station; the launcher refuses it until each is filled in. The streams run at one frame rate, share the one
link between the Orin and the PC, and `--fps` and `--bitrate-mbps` set every stream alike. See
[`CAMERA_SETTINGS.md`](CAMERA_SETTINGS.md#a-profile-for-three-cameras) for what the streams share, what the
station file and the station's roles on the page must then name, and the bitrate.

**Rectification.** When the station's rectification plan (`rectification/plan.json` in the calibration directory,
saved by the page's Rectification tool) switches on the camera role of the bridged stream, the launcher plans that
correction from the role's installed lens calibration before anything is started, writes a remap table into its
run directory and starts the bridge with `--gpu-step <stream>:rectify=<table>`. The video is then published, shown
saved by the page's Rectification tool) switches on the camera role of a bridged stream, the launcher plans that
correction from the role's own installed lens calibration before anything is started, writes a remap table into its
run directory and starts the bridge with `--gpu-step <stream>:rectify=<table>`. Each bridged stream is planned by
itself, from its own role's calibration and saved choice, and has a table of its own. The video is then published, shown
and recorded corrected, at the plan's output size, and every session recorded in the run says so: its
`rectification.json` records the correction, its intrinsics file for that camera describes the corrected picture,
and the lens it was corrected from is kept beside it. Where the plan states an oversample, the table makes a
picture that many times the size and the bridge's downscale shrinks it to the output. A plan that cannot be built
stops the start with the reason; there is no fallback to uncorrected video. `--no-rectify` publishes the video as received whatever the plan says, which calibrating a
camera's lens needs. `--stream-role STREAM=ROLE` names the camera role a bridged stream fills (the profile's stream
is `ego` by default). The launcher tells the backend what it applied through a file named in
stops the start with the reason, for whichever camera it is; there is no fallback to uncorrected video, and no run in which one camera of several is left uncorrected without a word. `--no-rectify` publishes the video as received whatever the plan says, which calibrating a
camera's lens needs. `--stream-role STREAM=ROLE` names the camera role a bridged stream fills (a profile's only
stream is `ego` by default). The launcher tells the backend what it applied to each camera through a file named in
`EGOCAP_STREAMS_STATE`. See
[`CALIBRATION_TOOLS.md`](CALIBRATION_TOOLS.md#what-the-launcher-does-at-start) for the steps and the refusals, and
its [Limits](CALIBRATION_TOOLS.md#limits) for what of this has and has not been run.

Not yet verified on hardware:

- **Three cameras through the launcher have never been run on an Orin.** No Jetson, GMSL camera or CUDA GPU was
at hand: the three-stream start was run against stand-ins for the programs it starts, and
`configs/three-camera-settings.example.yaml` holds a placeholder for every station value. A first run must check
that each stream arrives as the camera its role says, that each corrected picture is corrected with its own
camera's calibration, the GPU's memory and load with three decode, remap and encode pipelines, the bitrate the
link between the Orin and the PC carries, that time sync settles for all three streams, and what happens when
one camera drops. [`CAMERA_SETTINGS.md`](CAMERA_SETTINGS.md#not-yet-verified-on-hardware) says how to check each.

### Integration boundary

The launcher composes the current capture, receiver and browser stack. Its orchestration may be consolidated with
Expand Down
Loading
Loading