viz: let apps choose the XR reference space - #899
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe change adds Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant VizSessionConfig
participant VizSession
participant OpenXRSession
VizSessionConfig->>VizSession: provide xr_reference_space
VizSession->>OpenXRSession: set OpenXR reference_space_type
OpenXRSession->>OpenXRSession: enumerate supported reference spaces
OpenXRSession->>OpenXRSession: create requested reference space
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/viz/xr/cpp/openxr_session.cpp (1)
361-362: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winInclude the requested reference space in the creation error.
check_xrreceives only"xrCreateReferenceSpace". If creation fails, the exception does not name the requested space. The preceding log is conditional on successful enumeration.Proposed fix
+ const std::string create_label = + std::string("xrCreateReferenceSpace(") + reference_space_name(type) + ")"; XrSpace raw_ref = XR_NULL_HANDLE; - check_xr(xrCreateReferenceSpace(session_.get(), &info, &raw_ref), "xrCreateReferenceSpace"); + check_xr(xrCreateReferenceSpace(session_.get(), &info, &raw_ref), create_label.c_str());🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/viz/xr/cpp/openxr_session.cpp` around lines 361 - 362, Update the xrCreateReferenceSpace error context in the session initialization flow to include the requested reference-space identifier alongside the operation name. Modify the check_xr call after raw_ref is initialized, preserving the existing behavior while ensuring failures identify which reference space was requested.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/viz/xr/cpp/openxr_session.cpp`:
- Around line 361-362: Update the xrCreateReferenceSpace error context in the
session initialization flow to include the requested reference-space identifier
alongside the operation name. Modify the check_xr call after raw_ref is
initialized, preserving the existing behavior while ensuring failures identify
which reference space was requested.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 344fddce-2d9a-4159-9550-8f437cafd8ec
📒 Files selected for processing (9)
README.mdsrc/python/isaacteleop/viz/__init__.pysrc/viz/python/core_bindings.cppsrc/viz/python/session_bindings.cppsrc/viz/session/cpp/CMakeLists.txtsrc/viz/session/cpp/inc/viz/session/viz_session.hppsrc/viz/session/cpp/inc/viz/session/xr_reference_space.hppsrc/viz/session/cpp/viz_session.cppsrc/viz/xr/cpp/openxr_session.cpp
VizSession never set a reference space, so OpenXrSession fell through to its XR_REFERENCE_SPACE_TYPE_LOCAL default -- an origin at head height. Any app drawing world-locked geometry at a known height above the floor gets that height wrong by roughly a whole person, and the symptom is only visible on a headset. VizSessionConfig::xr_reference_space now names the choice (kLocal / kLocalFloor / kStage), exposed to Python as viz.XrReferenceSpace. The default stays kLocal, so no existing consumer changes behaviour. An unavailable space throws naming the space rather than silently substituting a different origin, and create_reference_space logs what the runtime does offer beside what was asked for. The CloudXR WebXR client has the other half of this problem: `auto` prefers local-floor while a -155 cm vertical offset is applied whichever space it lands on, so the two corrections stack. The README records the pairing that works; #871 asks why it is not the default. Signed-off-by: Jiwen Cai <jiwenc@nvidia.com>
e2dc74c to
0bc685c
Compare
Description
VizSessionnever set a reference space, soOpenXrSessionfell through to itsXR_REFERENCE_SPACE_TYPE_LOCALdefault — an origin at head height. Any app that draws world-locked geometry at a known height above the floor gets that height wrong by roughly a whole person, and the symptom is only visible on a headset.VizSessionConfig::xr_reference_spacenow names the choice (kLocal/kLocalFloor/kStage), exposed to Python asviz.XrReferenceSpace. The default stayskLocal, so no existing consumer changes behaviour.An unavailable space throws naming the space rather than silently substituting a different origin, and
create_reference_spacelogs what the runtime does offer beside what was asked for — the evidence anyone would want before adding a fallback chain.The CloudXR WebXR client has its own half of this problem:
autopreferslocal-floorwhile a −155 cm vertical offset is applied whichever space it lands on, so the two corrections stack. The root README records the pairing that works; #871 asks why it is not the default.Extracted from
jiwenc/mujoco-xr-app. #900 (examples/mujoco_xr) is the first consumer and stacks on this.Type of change
Testing
Ubuntu 22.04 / aarch64 (Tegra). Full
cmake --preset py3.12 -DBUILD_VIZ=ONbuild green;ctest -R vizgreen (4viz_python_*+ 3camera_viz_*). Verified from Python thatviz.XrReferenceSpaceimports andVizSessionConfig().xr_reference_spacedefaults tokLocal.kLocalFlooritself needs a headset and a CloudXR runtime, so the space actually being created is not exercised here.Checklist
SKIP=check-copyright-year pre-commit run --all-filesgit commit -s) per the DCOSummary by CodeRabbit
local-floorconfiguration, zero vertical offset, defaults, and fallback behavior.