Skip to content
Draft
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
19 changes: 18 additions & 1 deletion source/isaaclab/isaaclab/devices/openxr/openxr_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,20 @@ def __init__(
self._previous_joint_poses_right = {name: default_pose.copy() for name in HAND_JOINT_NAMES}
self._previous_headpose = default_pose.copy()

xr_anchor = SingleXFormPrim("/XRAnchor", position=self._xr_cfg.anchor_pos, orientation=self._xr_cfg.anchor_rot)
# Create XR anchor based on configuration
if self._xr_cfg.anchor_prim_path is not None:
# Create XR anchor as child of specified prim for dynamic positioning
xr_anchor_path = f"{self._xr_cfg.anchor_prim_path}/XRAnchor"
# Use relative positioning when attached to a prim
xr_anchor = SingleXFormPrim(
xr_anchor_path, position=self._xr_cfg.anchor_pos, orientation=self._xr_cfg.anchor_rot
)
else:
# Use static positioning at root level (original behavior)
xr_anchor = SingleXFormPrim(
"/XRAnchor", position=self._xr_cfg.anchor_pos, orientation=self._xr_cfg.anchor_rot
)

carb.settings.get_settings().set_float("/persistent/xr/profile/ar/render/nearPlane", self._xr_cfg.near_plane)
carb.settings.get_settings().set_string("/persistent/xr/profile/ar/anchorMode", "custom anchor")
carb.settings.get_settings().set_string("/xrstage/profile/ar/customAnchor", xr_anchor.prim_path)
Expand Down Expand Up @@ -136,6 +149,10 @@ def __str__(self) -> str:
msg = f"OpenXR Hand Tracking Device: {self.__class__.__name__}\n"
msg += f"\tAnchor Position: {self._xr_cfg.anchor_pos}\n"
msg += f"\tAnchor Rotation: {self._xr_cfg.anchor_rot}\n"
if self._xr_cfg.anchor_prim_path is not None:
msg += f"\tAnchor Prim Path: {self._xr_cfg.anchor_prim_path} (Dynamic Anchoring)\n"
else:
msg += f"\tAnchor Mode: Static (Root Level)\n"

# Add retargeter information
if self._retargeters:
Expand Down
10 changes: 10 additions & 0 deletions source/isaaclab/isaaclab/devices/openxr/xr_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ class XrCfg:
This quantity is only effective if :attr:`xr_anchor_pos` is set.
"""

anchor_prim_path: str | None = None
"""Specifies the prim path to attach the XR anchor to for dynamic positioning.

When set, the XR anchor will be attached to the specified prim (e.g., robot root prim),
allowing the XR camera to move with the prim. This is particularly useful for locomotion
robot teleoperation where the robot moves and the XR camera should follow it.

If None, the anchor will use the static :attr:`anchor_pos` and :attr:`anchor_rot` values.
"""

near_plane: float = 0.15
"""Specifies the near plane distance for the XR device.

Expand Down
Loading