Commit 11142959 authored by rwiltz's avatar rwiltz Committed by Kelly Guo

Refactors remove_camera_cfg (#422)

This will refactor the remove_camera_cfg out of record_demos.py into
xr_cfg.py so it can be used across end user scripts (record_demos.py,
teleop_se3_agent.py, etc)

<!--
Thank you for your interest in sending a pull request. Please make sure
to check the contribution guidelines.

Link:
https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html
-->

Please include a summary of the change and which issue is fixed. Please
also include relevant motivation and context.
List any dependencies that are required for this change.

Fixes # (issue)

<!-- As a practice, it is recommended to open an issue to have
discussions on the proposed pull request.
This makes it easier for the community to keep track of what is being
developed or added, and if a given feature
is demanded by more than one party. -->

<!-- As you go through the list, delete the ones that are not
applicable. -->

- Bug fix (non-breaking change which fixes an issue)

Please attach before and after screenshots of the change if applicable.

<!--
Example:

| Before | After |
| ------ | ----- |
| _gif/png before_ | _gif/png after_ |

To upload images to a PR -- simply drag and drop an image while in edit
mode and it should upload the image directly. You can then paste that
source into the above before/after sections.
-->

- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./isaaclab.sh --format`
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] I have updated the changelog and the corresponding version in the
extension's `config/extension.toml` file
- [x] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there

<!--
As you go through the checklist above, you can mark something as done by
putting an x character in it

For example,
- [x] I have done this task
- [ ] I have not done this task
-->

---------
Signed-off-by: 's avatarKelly Guo <kellyg@nvidia.com>
Co-authored-by: 's avatarKelly Guo <kellyg@nvidia.com>
parent 5df26d99
......@@ -58,6 +58,7 @@ import torch
import omni.log
from isaaclab.devices import Se3Gamepad, Se3GamepadCfg, Se3Keyboard, Se3KeyboardCfg, Se3SpaceMouse, Se3SpaceMouseCfg
from isaaclab.devices.openxr import remove_camera_configs
from isaaclab.devices.teleop_device_factory import create_teleop_device
from isaaclab.managers import TerminationTermCfg as DoneTerm
......@@ -90,6 +91,12 @@ def main() -> None:
# add termination condition for reaching the goal otherwise the environment won't reset
env_cfg.terminations.object_reached_goal = DoneTerm(func=mdp.object_reached_goal)
if args_cli.xr:
# External cameras are not supported with XR teleop
# Check for any camera configs and disable them
env_cfg = remove_camera_configs(env_cfg)
env_cfg.sim.render.antialiasing_mode = "DLSS"
try:
# create environment
env = gym.make(args_cli.task, cfg=env_cfg).unwrapped
......
......@@ -90,6 +90,7 @@ import omni.log
import omni.ui as ui
from isaaclab.devices import Se3Keyboard, Se3KeyboardCfg, Se3SpaceMouse, Se3SpaceMouseCfg
from isaaclab.devices.openxr import remove_camera_configs
from isaaclab.devices.teleop_device_factory import create_teleop_device
import isaaclab_mimic.envs # noqa: F401
......@@ -100,11 +101,10 @@ if args_cli.enable_pinocchio:
from collections.abc import Callable
from isaaclab.envs import DirectRLEnvCfg, ManagerBasedEnvCfg, ManagerBasedRLEnvCfg
from isaaclab.envs import DirectRLEnvCfg, ManagerBasedRLEnvCfg
from isaaclab.envs.mdp.recorders.recorders_cfg import ActionStateRecorderManagerCfg
from isaaclab.envs.ui import EmptyWindow
from isaaclab.managers import DatasetExportMode, SceneEntityCfg
from isaaclab.sensors import CameraCfg
from isaaclab.managers import DatasetExportMode
import isaaclab_tasks # noqa: F401
from isaaclab_tasks.utils.parse_cfg import parse_env_cfg
......@@ -166,26 +166,6 @@ def setup_output_directories() -> tuple[str, str]:
return output_dir, output_file_name
def remove_camera_configs(env_cfg: ManagerBasedEnvCfg):
"""Removes cameras from environments when recording since XR does not work together with rendering."""
for attr_name in dir(env_cfg.scene):
attr = getattr(env_cfg.scene, attr_name)
if isinstance(attr, CameraCfg):
delattr(env_cfg.scene, attr_name)
omni.log.info(f"Removed camera config: {attr_name}")
# Remove any ObsTerms for the camera
for obs_name in dir(env_cfg.observations.policy):
obsterm = getattr(env_cfg.observations.policy, obs_name)
if hasattr(obsterm, "params") and obsterm.params:
for param_value in obsterm.params.values():
if isinstance(param_value, SceneEntityCfg) and param_value.name == attr_name:
delattr(env_cfg.observations.policy, attr_name)
omni.log.info(f"Removed camera observation term: {attr_name}")
break
return env_cfg
def create_environment_config(
output_dir: str, output_file_name: str
) -> tuple[ManagerBasedRLEnvCfg | DirectRLEnvCfg, object | None]:
......
......@@ -281,17 +281,17 @@ Changed
:meth:`~isaaclab.utils.math.quat_apply` and :meth:`~isaaclab.utils.math.quat_apply_inverse` for speed.
0.40.8 (2025-05-19)
0.40.9 (2025-05-19)
~~~~~~~~~~~~~~~~~~~
Fixed
^^^^^^
^^^^^
* Raising exceptions in step, render and reset if they occurred inside the initialization callbacks
of assets and sensors.used from the experience files and the double definition is removed.
0.40.7 (2025-01-30)
0.40.8 (2025-01-30)
~~~~~~~~~~~~~~~~~~~
Added
......@@ -301,7 +301,7 @@ Added
in the simulation.
0.40.6 (2025-05-16)
0.40.7 (2025-05-16)
~~~~~~~~~~~~~~~~~~~
Added
......@@ -316,7 +316,7 @@ Changed
resampling call.
0.40.5 (2025-05-16)
0.40.6 (2025-05-16)
~~~~~~~~~~~~~~~~~~~
Fixed
......@@ -325,7 +325,7 @@ Fixed
* Fixed penetration issue for negative border height in :class:`~isaaclab.terrains.terrain_generator.TerrainGeneratorCfg`.
0.40.4 (2025-05-16)
0.40.5 (2025-05-16)
~~~~~~~~~~~~~~~~~~~
Changed
......@@ -340,7 +340,7 @@ Added
* Added :meth:`~isaaclab.utils.math.rigid_body_twist_transform`
0.40.3 (2025-05-15)
0.40.4 (2025-05-15)
~~~~~~~~~~~~~~~~~~~
Fixed
......@@ -354,13 +354,22 @@ Fixed
unused USD camera parameters.
0.40.2 (2025-05-14)
0.40.3 (2025-05-14)
~~~~~~~~~~~~~~~~~~~
* Added a new attribute :attr:`articulation_root_prim_path` to the :class:`~isaaclab.assets.ArticulationCfg` class
to allow explicitly specifying the prim path of the articulation root.
0.40.2 (2025-05-14)
~~~~~~~~~~~~~~~~~~~
Changed
^^^^^^^
* Refactored remove_camera_configs to be a function that can be used in the record_demos and teleop scripts.
0.40.1 (2025-05-14)
~~~~~~~~~~~~~~~~~~~
......
......@@ -6,4 +6,4 @@
"""Keyboard device for SE(2) and SE(3) control."""
from .openxr_device import OpenXRDevice, OpenXRDeviceCfg
from .xr_cfg import XrCfg
from .xr_cfg import XrCfg, remove_camera_configs
......@@ -26,7 +26,7 @@ class XrCfg:
Specifically: this position will appear at the origin of the XR device's local coordinate frame.
"""
anchor_rot: tuple[float, float, float] = (1.0, 0.0, 0.0, 0.0)
anchor_rot: tuple[float, float, float, float] = (1.0, 0.0, 0.0, 0.0)
"""Specifies the rotation (as a quaternion) of the simulation when viewed in an XR device.
Specifically: this rotation will determine how the simulation is rotated with respect to the
......@@ -40,3 +40,45 @@ class XrCfg:
This value determines the closest distance at which objects will be rendered in the XR device.
"""
from typing import Any
def remove_camera_configs(env_cfg: Any) -> Any:
"""Removes cameras from environments when using XR devices.
XR does not support additional cameras in the environment as they can cause
rendering conflicts and performance issues. This function scans the environment
configuration for camera objects and removes them, along with any associated
observation terms that reference these cameras.
Args:
env_cfg: The environment configuration to modify.
Returns:
The modified environment configuration with cameras removed.
"""
import omni.log
from isaaclab.managers import SceneEntityCfg
from isaaclab.sensors import CameraCfg
for attr_name in dir(env_cfg.scene):
attr = getattr(env_cfg.scene, attr_name)
if isinstance(attr, CameraCfg):
delattr(env_cfg.scene, attr_name)
omni.log.info(f"Removed camera config: {attr_name}")
# Remove any ObsTerms for the camera
if hasattr(env_cfg.observations, "policy"):
for obs_name in dir(env_cfg.observations.policy):
obsterm = getattr(env_cfg.observations.policy, obs_name)
if hasattr(obsterm, "params") and obsterm.params:
for param_value in obsterm.params.values():
if isinstance(param_value, SceneEntityCfg) and param_value.name == attr_name:
delattr(env_cfg.observations.policy, attr_name)
omni.log.info(f"Removed camera observation term: {attr_name}")
break
return env_cfg
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment