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
4 changes: 2 additions & 2 deletions apps/cam2v/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ postprocessor's output resolution so both panes are directly comparable.

```bash
uv run --no-sync flashdreams-run-v2 cam2v-<model-config-name> \
--mode webrtc --host 0.0.0.0 --port 8089 -- \
--mode webrtc --port 8089 -- \
--postprocess-preset <preset> \
--postprocess-comparison-ui
```
Expand Down Expand Up @@ -119,7 +119,7 @@ For UI development without loading a model:

```bash
uv run --no-sync flashdreams-run-v2 cam2v-dummy --mode webrtc \
--host 0.0.0.0 --port 8089 -- \
--port 8089 -- \
--step-wait-seconds 0.9 --frames-per-chunk 12
```

Expand Down
5 changes: 2 additions & 3 deletions apps/crazy_robotaxi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@ To use a browser client:

```bash
uv run --package flashdreams-omnidreams flashdreams-run-v2 \
crazy-robotaxi-omnidreams --mode webrtc --host 0.0.0.0 --port 8089
crazy-robotaxi-omnidreams --mode webrtc --port 8089
```

Open `http://127.0.0.1:8089/`, or use the host printed by the runner when
connecting remotely. Choose **TAXI**, **RACE**, or **FREE-ROAM**, then a map;
Open the link the runner prints; it pairs this browser tab. Choose **TAXI**, **RACE**, or **FREE-ROAM**, then a map;
race mode also asks for a course. **CONTROLS** and **OPTIONS** are available from
the mode menu.
The application prepares maps and loads the world model before showing the
Expand Down
1 change: 1 addition & 0 deletions apps/crazy_robotaxi/crazy_robotaxi/controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,7 @@ def apply(self, events: UserInputEvents) -> frozenset[ControlAction]:
if isinstance(event, FocusUserInputEvent):
if not event.focused:
self._pressed_keys.clear()
self._active_by_controller.clear()
continue
if isinstance(event, KeyboardUserInputEvent):
key = canonical_key(str(event.key))
Expand Down
14 changes: 11 additions & 3 deletions apps/crazy_robotaxi/crazy_robotaxi/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,11 +577,11 @@ def consume_input_events(self, events: UserInputEvents) -> None:
else:
self._pressed_keys.discard(key)
capturing = self._controls_capture is not None
actions = self._control_action_state.apply(events)
menu_actions = self._menu_back_action_state.apply(events)
if capturing:
self._consume_binding_capture(received)
else:
actions = self._control_action_state.apply(events)
menu_actions = self._menu_back_action_state.apply(events)
if (self._menu_stage == "game" and "return_to_menu" in actions) or (
self._menu_stage != "game" and "return_to_menu" in menu_actions
):
Expand All @@ -591,7 +591,11 @@ def consume_input_events(self, events: UserInputEvents) -> None:
if self._menu_stage == "game" and "toggle_hdmap" in actions:
self.show_hdmap = not self.show_hdmap
for event in received:
if isinstance(event, GamepadUserInputEvent):
if isinstance(event, FocusUserInputEvent) and not event.focused:
self._latest_gamepad_event = None
self._latest_wheel_event = None
self._active_control_device = "keyboard"
elif isinstance(event, GamepadUserInputEvent):
if event.action == "state":
self._latest_gamepad_event = event
self._active_control_device = "gamepad"
Expand Down Expand Up @@ -1022,6 +1026,10 @@ def _consume_binding_capture(self, received: Sequence[object]) -> None:
item for item in controls_fields(draft) if item.name == capture.action
)
for event in received:
if isinstance(event, FocusUserInputEvent) and not event.focused:
capture = replace(capture, baseline=None)
self._controls_capture = capture
continue
if isinstance(event, KeyboardUserInputEvent):
key = canonical_key(str(event.key))
if event.state is KeyboardInputState.RELEASED:
Expand Down
26 changes: 26 additions & 0 deletions apps/crazy_robotaxi/tests/test_controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
from omnidreams_game_engine.input import DriverInput

from flashdreams.runtime_v2.user_input_event import (
FocusUserInputEvent,
GamepadUserInputEvent,
GameWheelUserInputEvent,
KeyboardInputState,
KeyboardUserInputEvent,
)
Expand Down Expand Up @@ -126,6 +128,30 @@ def test_gamepad_axes_have_rescaled_deadzones() -> None:
assert half.brake == pytest.approx(0.5)


@pytest.mark.parametrize("device", ("keyboard", "gamepad", "wheel"))
def test_focus_loss_releases_action_latches(device: str) -> None:
controls = ControlsConfig()
controls = replace(
controls,
wheel=replace(controls.wheel, restart=(InputBinding("button", 0), None)),
)
held = {
"keyboard": _key_event("r", KeyboardInputState.PRESSED),
"gamepad": GamepadUserInputEvent(
timestamp=np.uint64(0), buttons=(0.0,) * 9 + (1.0,)
),
"wheel": GameWheelUserInputEvent(timestamp=np.uint64(0), buttons=(True,)),
}[device]
state = BoundActionState(controls)

assert state.apply(UserInputEvents([held])) == {"restart"}
assert not state.apply(UserInputEvents([held]))
assert not state.apply(
UserInputEvents([FocusUserInputEvent(timestamp=np.uint64(1), focused=False)])
)
assert state.apply(UserInputEvents([held])) == {"restart"}


def test_full_gamepad_and_keyboard_inputs_produce_the_same_drive_commands() -> None:
controls = ControlsConfig()
gamepad_forward_left = GamepadUserInputEvent(
Expand Down
42 changes: 42 additions & 0 deletions apps/crazy_robotaxi/tests/test_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
FocusUserInputEvent,
FullscreenEnabledOptimalWindowSizeUserInputEvent,
GamepadUserInputEvent,
GameWheelUserInputEvent,
KeyboardInputState,
KeyboardUserInputEvent,
)
Expand Down Expand Up @@ -2495,6 +2496,47 @@ def test_exit_hold_does_not_survive_input_interruption(
assert not state._exit_hold_started_at_s


@pytest.mark.parametrize("device", ("keyboard", "gamepad", "wheel"))
def test_focus_loss_releases_ui_controls_during_binding_capture(
device: Literal["keyboard", "gamepad", "wheel"],
) -> None:
state = TaxiHudState(640, 360, _calibration())
gamepad_held = GamepadUserInputEvent(
timestamp=np.uint64(1), axes=(-1.0,), buttons=(0.0,) * 5 + (1.0,)
)
state.consume_input_events(
UserInputEvents(
[
KeyboardUserInputEvent(
timestamp=np.uint64(0), key="w", state=KeyboardInputState.PRESSED
),
gamepad_held,
GameWheelUserInputEvent(timestamp=np.uint64(2), throttle=1.0),
]
)
)
state._controls_device = device
state._controls_draft = getattr(state.controls, device)
state._start_binding_capture("restart", 0)
draft = state._controls_draft

state.consume_input_events(
UserInputEvents([FocusUserInputEvent(timestamp=np.uint64(3), focused=False)])
)

assert not state._pressed_keys
assert state._latest_gamepad_event is None
assert state._latest_wheel_event is None
assert state._active_control_device == "keyboard"
assert state._controls_capture is not None
assert state._controls_capture.baseline is None
assert state._controls_draft is draft
assert not state.show_control_tooltips
state._controls_capture = None
state.consume_input_events(UserInputEvents([gamepad_held]))
assert state.show_control_tooltips


def test_h_toggles_gameplay_control_tooltips() -> None:
state = TaxiHudState(640, 360, _calibration())
released = KeyboardUserInputEvent(
Expand Down
27 changes: 17 additions & 10 deletions apps/handdreams/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ On DGX (replace the address and GPU as needed):
```bash
CUDA_VISIBLE_DEVICES=1 uv run --package flashdreams-cosmos3-nano-sim-bimanual \
flashdreams-run-v2 handdreams \
--mode webrtc --host 0.0.0.0 --port 8081 \
--mode webrtc --port 8081 \
--controller-host 10.111.69.99 --isaac-teleop-accept-eula -- \
--sample-dir /absolute/path/to/scenarios
```
Expand All @@ -87,7 +87,7 @@ For a **relay-only model host**, disable local CloudXR before the `--` separator
```bash
CUDA_VISIBLE_DEVICES=0 uv run --package flashdreams-cosmos3-nano-sim-bimanual \
flashdreams-run-v2 handdreams \
--mode webrtc --host 0.0.0.0 --port 8081 \
--mode webrtc --port 8081 \
--controller-host 10.111.69.99 --no-local-cloudxr -- \
--sample-dir /absolute/path/to/scenarios
```
Expand Down Expand Up @@ -184,7 +184,7 @@ browser with the local development certificate, run:
env -u QUEST_META_PIN CUDA_VISIBLE_DEVICES=1 \
uv run --package flashdreams-cosmos3-nano-sim-bimanual \
flashdreams-run-v2 handdreams \
--mode webrtc --host 0.0.0.0 --port 8081 --controller-host 10.111.69.99 \
--mode webrtc --port 8081 --controller-host 10.111.69.99 \
--isaac-teleop-accept-eula --quest-accept-server-certificate -- \
--sample-dir /absolute/path/to/scenarios
```
Expand Down Expand Up @@ -217,7 +217,9 @@ Isaac Teleop web client URL, and the active controller source in both output mod
Headset passcodes, privacy screens, immersive-VR Allow, and local-network
permissions may still require manual approval.

For a physical Quest attached to a separate VR client machine, such as your laptop:
For a physical Quest attached to a separate VR client machine, such as your
laptop, open the viewer and run the command below; then press **P** in the
viewer and type the code it shows when `remote-vr` asks:

```bash
env -u QUEST_META_PIN python3 integrations_v2/cosmos3_nano_sim_bimanual/apps/handdreams/launch.py remote-vr \
Expand All @@ -235,7 +237,8 @@ and any required credentials.

The server generates controller TLS credentials once under
`~/.config/flashdreams/quest-relay/`. The laptop obtains **only the certificate
and token** over verified SSH and reuses a private per-server copy. SSH access
and token** over verified SSH and reuses a private per-server copy; the pairing
code appears only in the viewer. SSH access
and the server's host identity must already be trusted; the launcher does not
accept unknown SSH keys or replace existing credentials. No manual token export,
certificate copy, or additional credential setup is needed.
Expand Down Expand Up @@ -277,7 +280,9 @@ opening the Quest tab and connecting through the USB loopback endpoint.
Clear any headset passcode/privacy or browser permission prompt if one appears.
For an already-running test, `--no-require-physical-wake` skips that gate.

With `--mode webrtc`, open **http://10.111.69.99:8081/** for generated video;
With `--mode webrtc`, forward port 8081 from the laptop
(`ssh -L 8081:127.0.0.1:8081 SERVER`) and open the viewer link the server prints
for generated video;
the viewer needs working WebRTC media connectivity, and loading its HTTP page
alone does not establish video connectivity. With `--mode native-window`,
watch the window on the model host. The laptop needs access to DGX controller
Expand Down Expand Up @@ -334,7 +339,7 @@ ADB, or `remote-vr` command is required for IWER.
An attached Quest does not select a different server route or require an IWER
restart; disconnect the active input before connecting another client.

1. Open `http://10.111.69.99:8081/` for generated video with `--mode webrtc`,
1. Open the viewer link the server prints (SSH-forwarded) for generated video with `--mode webrtc`,
or watch the model host's native window with `--mode native-window`.
2. Once CloudXR is listening, open its certificate URL
(`https://10.111.69.99:48322/` by default) and trust the development
Expand Down Expand Up @@ -434,8 +439,10 @@ performs normal cleanup; without the flag, failure cleanup is unchanged.
Closing the native window or stopping the demo/relay with Ctrl-C stops owned
CloudXR/browser services, restores managed headset settings, and sends the
managed headset to sleep. Closing only the WebRTC viewer tab leaves the server
running. Scene changes do not repeat the wake gate. After relay disconnection,
rerun `remote-vr`; the server can retain loaded model weights. If USB
running. Scene changes do not repeat the server-attached wake gate and keep a
laptop paired ([pairing lifecycle](controller_input/README.md)); `remote-vr`
reconnects by itself after a network drop. After restarting `remote-vr`, press
**P** and enter the new code; the server can retain loaded model weights. If USB
loss prevents cleanup, exit immersive VR and put the headset to sleep manually.

## Advanced use
Expand Down Expand Up @@ -500,7 +507,7 @@ For example, warm all scenes with the standard runtime:
```bash
uv run --package flashdreams-cosmos3-nano-sim-bimanual \
flashdreams-run-v2 handdreams \
--mode webrtc --host 0.0.0.0 --port 8081 --controller-host 10.111.69.99 \
--mode webrtc --port 8081 --controller-host 10.111.69.99 \
--isaac-teleop-accept-eula -- \
--sample-dir /absolute/path/to/scenarios \
--prewarm-all-scenes
Expand Down
45 changes: 39 additions & 6 deletions apps/handdreams/controller_input/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,23 @@ uses `remote-vr --accept-eula`; browser-only IWER connects
directly to CloudXR and the UI's hosted-client link without a relay,
headset, or ADB. The server's `--quest-cloudxr-port` defaults to `48322`.

For remote Quest input, run `remote-vr` on the laptop, press **P** in the
operator viewer, and type the code the viewer shows when `remote-vr` asks.
Verified SSH delivers only the pinned server certificate and shared token; the
code is shown only in the viewer, so SSH access alone cannot take control. No
new account or daemon is required.

The first connection exchanges the code for a reconnect key that the laptop
keeps in memory. The laptop stays paired through scene changes, viewer reloads
from the paired browser, and network drops, and `remote-vr` reconnects by
itself. **R**, a new **P** code, a different viewer, a tokenless (`--no-login`)
viewer reload, or stopping the demo ends the pairing; `remote-vr` then asks for
the next code. To switch laptops, press **P** and enter the code on the new one;
the previous laptop's key stops working. An unused code expires after five
minutes or five wrong entries. A producer's claimed session/device identity
cannot select the viewer. Controls already accepted for a model generation
cannot be undone by revocation.

For a Quest USB-authorized on the model host, use the app guide's
`--quest-device SERIAL` option before the V2 command's `--`. It manages the headset with ADB while
using the server's single CloudXR/Isaac runtime. The guide covers physical wake,
Expand All @@ -105,16 +122,19 @@ uv run --no-project --python 3.12 \
--accept-server-certificate
```

This lower-level command expects `FLASHDREAMS_CONTROLLER_TOKEN` in its environment.
Never put it in command arguments or logs. The companion checks the server
This lower-level command expects `FLASHDREAMS_CONTROLLER_TOKEN` in its
environment (the managed identity keeps it in `~/.config/flashdreams/quest-relay/token`;
loopback identities use the existing address-specific directory). It prompts
for the viewer's code, or takes it once with `--code`. Never put the token in
command arguments or logs. The companion checks the server
certificate and hostname; there is no insecure controller TLS fallback.
Physical wake is required by default, as with the launcher. Pass
`--no-require-physical-wake` to skip the gate for an already-running test;
`--require-physical-wake` remains available to enable it explicitly.
For a server-attached headset, keyboard **B** in either output window restarts
only its managed browser/USB setup and requires a fresh physical wake. The
shared CloudXR source stays alive; a relayed laptop headset is still restarted
by rerunning `remote-vr` on that laptop.
by rerunning `remote-vr` on that laptop and entering a new **P** code.

Each managed Quest startup, including a **B** retry, force-stops Quest Browser
on the selected headset before opening the teleop tab. A fresh browser process
Expand Down Expand Up @@ -205,7 +225,8 @@ by default and likewise requires a trusted network.
Inherited `CONTROL_TOKEN` values are ignored; any `CONTROL_TOKEN` entry in a
custom CloudXR env file is rejected. No control credential is sent in the
readiness probe or browser URL. The separate controller relay still requires
a shared token and verified TLS. The unified server reuses or creates its
a shared token, a viewer-code pairing, and verified TLS. The unified server
reuses or creates its
private identity automatically; explicit identity overrides must supply both
certificate/key paths and `FLASHDREAMS_CONTROLLER_TOKEN` together.

Expand All @@ -214,12 +235,24 @@ Clear `QUEST_META_PIN` for managed USB sessions: PIN-based settings changes can
require headset internet access and are rejected on this path. Proximity
restoration is best effort on firmware that cannot report its previous state.

Scene changes and resets retain the controller connection and do not repeat
the wake gate. Source capture timestamps determine action cadence; server
In-place resets retain the controller connection and do not repeat the wake
gate. Replacing the runtime session (including a scene replacement) keeps the
paired laptop but discards its earlier poses; local USB input keeps its
existing lifecycle. Source capture
timestamps determine action cadence; server
receipt timestamps determine freshness. Different machines' monotonic clocks
are not subtracted. Queues are bounded: overflow, stale input, and disconnect
break continuity rather than replay old movement.

Pairing decides which laptop may drive the hands. It does not attest the
laptop, headset, or physical intent: a compromised paired relay can still
submit finite, structurally valid false poses and grip values.
The existing finite-value, quaternion, analog-range, sequencing, freshness,
queue, and tracking-loss checks remain in force. Deploy remote input only
where this remaining control-integrity risk is acceptable; pairing alone does
not eliminate it. CloudXR connection metadata is lifecycle information, not
pose attestation.

A new producer tracking session requests a V2 reset and recalibration because
its tracking origin may have changed. Brief tracking loss within the ownership
lease preserves calibration; acquiring input after the lease expires resets
Expand Down
Loading
Loading