Unverified Commit 710ac3da authored by Mayank Mittal's avatar Mayank Mittal Committed by GitHub

Adds method to set the visibility of the Asset's prims (#1752)

# Description

This MR adds a function to set the visibility of prims corresponding to
an Asset. This is useful for randomization of distractors for visual
effects.

Note: Currently, this is not implemented for RigidObjectCollection as it
seems unclear how to "index" the prims in there.

## Type of change

- New feature (non-breaking change which adds functionality)

## Screenshots

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.
-->

## Checklist

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

---------
Signed-off-by: 's avatarKelly Guo <kellyg@nvidia.com>
Co-authored-by: 's avatarKelly Guo <kellyguo123@hotmail.com>
Co-authored-by: 's avatarKelly Guo <kellyg@nvidia.com>
parent be41bb0d
[package]
# Note: Semantic Versioning is used: https://semver.org/
version = "0.39.5"
version = "0.39.6"
# Description
title = "Isaac Lab framework for Robot Learning"
......
Changelog
---------
0.39.6 (2025-01-30)
~~~~~~~~~~~~~~~~~~~
Added
^^^^^
* Added method :meth:`omni.isaac.lab.assets.AssetBase.set_visibility` to set the visibility of the asset
in the simulation.
0.39.5 (2025-05-16)
~~~~~~~~~~~~~~~~~~~
......
......@@ -7,11 +7,13 @@ from __future__ import annotations
import inspect
import re
import torch
import weakref
from abc import ABC, abstractmethod
from collections.abc import Sequence
from typing import TYPE_CHECKING, Any
import isaacsim.core.utils.prims as prim_utils
import omni.kit.app
import omni.timeline
from isaacsim.core.simulation_manager import SimulationManager
......@@ -162,6 +164,36 @@ class AssetBase(ABC):
Operations.
"""
def set_visibility(self, visible: bool, env_ids: Sequence[int] | None = None):
"""Set the visibility of the prims corresponding to the asset.
This operation affects the visibility of the prims corresponding to the asset in the USD stage.
It is useful for toggling the visibility of the asset in the simulator. For instance, one can
hide the asset when it is not being used to reduce the rendering overhead.
Note:
This operation uses the PXR API to set the visibility of the prims. Thus, the operation
may have an overhead if the number of prims is large.
Args:
visible: Whether to make the prims visible or not.
env_ids: The indices of the object to set visibility. Defaults to None (all instances).
"""
# resolve the environment ids
if env_ids is None:
env_ids = range(len(self._prims))
elif isinstance(env_ids, torch.Tensor):
env_ids = env_ids.detach().cpu().tolist()
# obtain the prims corresponding to the asset
# note: we only want to find the prims once since this is a costly operation
if not hasattr(self, "_prims"):
self._prims = sim_utils.find_matching_prims(self.cfg.prim_path)
# iterate over the environment ids
for env_id in env_ids:
prim_utils.set_prim_visibility(self._prims[env_id], visible)
def set_debug_vis(self, debug_vis: bool) -> bool:
"""Sets whether to visualize the asset data.
......
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