-
Notifications
You must be signed in to change notification settings - Fork 76
feat(deviceio): identify the headset from its interaction profile #926
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jsepulveda-nvidia
wants to merge
2
commits into
main
Choose a base branch
from
jsepulveda/headset_detection
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
src/core/retargeting_engine_tests/python/test_headset_identity.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """ | ||
| Tests for identifying a headset from its OpenXR interaction profile. | ||
|
|
||
| The two profiles asserted against real hardware are marked below. Everything | ||
| else must resolve to None rather than a guess: a wrong answer here feeds a | ||
| robot the wrong skeleton correction, and permuted joint axes are not a | ||
| recoverable error. | ||
| """ | ||
|
|
||
| import pytest | ||
|
|
||
| from isaacteleop.cloudxr.headset import ( | ||
| HEADSET_BY_INTERACTION_PROFILE, | ||
| identify_headset, | ||
| ) | ||
|
|
||
| # Measured: PICO 4 Ultra and Quest 3 over CloudXR, both hands, both sessions. | ||
| MEASURED = { | ||
| "/interaction_profiles/bytedance/pico4_controller": "pico", | ||
| "/interaction_profiles/oculus/touch_controller": "quest", | ||
| } | ||
|
|
||
|
|
||
| class TestMeasuredHardware: | ||
| @pytest.mark.parametrize("profile,expected", sorted(MEASURED.items())) | ||
| def test_matches_observed_hardware(self, profile, expected): | ||
| assert identify_headset(profile) == expected | ||
|
|
||
| def test_the_two_headsets_are_distinguished(self): | ||
| """The whole point: these must not collapse to the same answer.""" | ||
| answers = {identify_headset(p) for p in MEASURED} | ||
| assert answers == {"pico", "quest"} | ||
| assert None not in answers | ||
|
|
||
|
|
||
| class TestUnknownInput: | ||
| @pytest.mark.parametrize( | ||
| "value", | ||
| [ | ||
| None, | ||
| "", | ||
| "/interaction_profiles/khr/simple_controller", | ||
| "/interaction_profiles/htc/vive_controller", | ||
| "/interaction_profiles/valve/index_controller", | ||
| "quest3", | ||
| "pico", | ||
| "bytedance/pico4_controller", | ||
| "/INTERACTION_PROFILES/BYTEDANCE/PICO4_CONTROLLER", | ||
| " /interaction_profiles/bytedance/pico4_controller ", | ||
| ], | ||
| ) | ||
| def test_unknown_returns_none(self, value): | ||
| """Includes 'quest3', the CloudXR device-profile string that names the | ||
| wrong vendor on a PICO session, and near-misses that must not fuzzy-match.""" | ||
| assert identify_headset(value) is None | ||
|
|
||
| def test_empty_is_not_an_error(self): | ||
| """Nothing is bound until actions sync, so empty is an expected state.""" | ||
| assert identify_headset("") is None | ||
|
|
||
|
|
||
| class TestTable: | ||
| def test_every_value_is_a_known_headset(self): | ||
| assert set(HEADSET_BY_INTERACTION_PROFILE.values()) <= {"pico", "quest"} | ||
|
|
||
| def test_keys_are_full_openxr_paths(self): | ||
| for profile in HEADSET_BY_INTERACTION_PROFILE: | ||
| assert profile.startswith("/interaction_profiles/") | ||
|
|
||
| def test_vendor_prefix_agrees_with_headset(self): | ||
| """A bytedance path must never map to quest, or vice versa.""" | ||
| for profile, headset in HEADSET_BY_INTERACTION_PROFILE.items(): | ||
| if "/bytedance/" in profile: | ||
| assert headset == "pico", profile | ||
| else: | ||
| assert headset == "quest", profile | ||
|
|
||
| def test_no_duplicate_or_empty_keys(self): | ||
| assert all(HEADSET_BY_INTERACTION_PROFILE) | ||
| assert len(HEADSET_BY_INTERACTION_PROFILE) == len( | ||
| set(HEADSET_BY_INTERACTION_PROFILE) | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """ | ||
| Identify the headset behind a streaming runtime from its interaction profile. | ||
|
|
||
| A remote-streaming runtime presents every headset through the same OpenXR | ||
| surface, so system and device-profile fields do not distinguish them: CloudXR | ||
| reports ``NV_DEVICE_PROFILE=Quest3`` with a PICO connected. The interaction | ||
| profile the runtime binds for the controllers does track the real hardware, | ||
| measured on a PICO 4 Ultra and a Quest 3. | ||
|
|
||
| Callers that drive hardware from this should treat ``None`` as "ask the | ||
| operator", never as a default: applying a skeleton correction meant for the | ||
| other headset feeds a robot permuted joint axes. | ||
| """ | ||
|
|
||
| from typing import Optional | ||
|
|
||
| # OpenXR interaction profile -> headset key. | ||
| # | ||
| # bytedance/pico4_controller is a positive match: only PICO hardware binds it. | ||
| # oculus/touch_controller is identification by elimination -- it is the generic | ||
| # Meta-compatible fallback, and a Quest 3 binds it when no Meta-specific profile | ||
| # is suggested. Anything else stays unknown rather than guessing. | ||
| HEADSET_BY_INTERACTION_PROFILE = { | ||
| "/interaction_profiles/bytedance/pico4_controller": "pico", | ||
| "/interaction_profiles/bytedance/pico_neo3_controller": "pico", | ||
| "/interaction_profiles/bytedance/pico_g3_controller": "pico", | ||
| "/interaction_profiles/meta/touch_controller_plus": "quest", | ||
| "/interaction_profiles/meta/touch_controller_quest_2": "quest", | ||
| "/interaction_profiles/facebook/touch_controller_pro": "quest", | ||
| "/interaction_profiles/oculus/touch_controller": "quest", | ||
| } | ||
|
|
||
|
|
||
| def identify_headset(interaction_profile: Optional[str]) -> Optional[str]: | ||
| """ | ||
| Map an OpenXR interaction profile to a headset key. | ||
|
|
||
| Args: | ||
| interaction_profile: Profile path from | ||
| :meth:`ControllerTracker.get_interaction_profile`. Empty or ``None`` | ||
| means the runtime has not bound one yet. | ||
|
|
||
| Returns: | ||
| ``"pico"``, ``"quest"``, or ``None`` when the headset cannot be | ||
| determined. ``None`` is a normal early-session state: nothing is bound | ||
| until actions have synced at least once. | ||
| """ | ||
| if not interaction_profile: | ||
| return None | ||
| return HEADSET_BY_INTERACTION_PROFILE.get(interaction_profile) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I better place for this will be python/isaacteleop/cloudxr
context: the deviceio module is meant to be C++ only and the python bits are its bindings.