Commit 54df6620 authored by matthewtrepte's avatar matthewtrepte Committed by Kelly Guo

Updates fabric cloning for environments that support it (#510)

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

Add cfg field to InteractiveSceneCfg for enabling fabric cloning
Thread cfg field to cloner calls in InteractiveScene and spawners
Disable fabric cloning by default and enable for a subset of
environments which pass with non_rl_benchmarks.py

<!-- 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)
- New feature (non-breaking change which adds functionality)
- Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- This change requires a documentation update

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

- [ ] 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

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

---------
Co-authored-by: 's avatarKelly Guo <kellyg@nvidia.com>
parent 50446e76
[package] [package]
# Note: Semantic Versioning is used: https://semver.org/ # Note: Semantic Versioning is used: https://semver.org/
version = "0.42.23" version = "0.42.24"
# Description # Description
title = "Isaac Lab framework for Robot Learning" title = "Isaac Lab framework for Robot Learning"
......
Changelog Changelog
--------- ---------
0.42.23 (2025-06-25) 0.42.24 (2025-06-25)
~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
Added Added
...@@ -12,7 +12,7 @@ Added ...@@ -12,7 +12,7 @@ Added
env instance env instance
0.42.22 (2025-07-11) 0.42.23 (2025-07-11)
~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
Fixed Fixed
...@@ -22,7 +22,7 @@ Fixed ...@@ -22,7 +22,7 @@ Fixed
restricting the resetting joint indices be that user defined joint indices. restricting the resetting joint indices be that user defined joint indices.
0.42.21 (2025-07-11) 0.42.22 (2025-07-11)
~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
Fixed Fixed
...@@ -32,7 +32,7 @@ Fixed ...@@ -32,7 +32,7 @@ Fixed
env_ids are passed. env_ids are passed.
0.42.20 (2025-07-09) 0.42.21 (2025-07-09)
~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
Added Added
...@@ -49,7 +49,7 @@ Fixed ...@@ -49,7 +49,7 @@ Fixed
buffer on recording. buffer on recording.
0.42.19 (2025-07-10) 0.42.20 (2025-07-10)
~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
Added Added
...@@ -80,7 +80,17 @@ Changed ...@@ -80,7 +80,17 @@ Changed
* Changed the implementation of :func:`~isaaclab.utils.math.copysign` to better reflect the documented functionality. * Changed the implementation of :func:`~isaaclab.utils.math.copysign` to better reflect the documented functionality.
0.42.18 (2025-07-09) 0.42.19 (2025-07-09)
~~~~~~~~~~~~~~~~~~~~
Changed
^^^^^^^
* Added clone_in_fabric config flag to :class:`~isaaclab.scene.interactive_scene_cfg.InteractiveSceneCfg`
* Enable clone_in_fabric for envs which work with limited benchmark_non_rl.py script
0.42.18 (2025-07-07)
~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
Changed Changed
......
...@@ -13,6 +13,7 @@ import omni.usd ...@@ -13,6 +13,7 @@ import omni.usd
from isaacsim.core.cloner import GridCloner from isaacsim.core.cloner import GridCloner
from isaacsim.core.prims import XFormPrim from isaacsim.core.prims import XFormPrim
from isaacsim.core.utils.stage import get_current_stage from isaacsim.core.utils.stage import get_current_stage
from isaacsim.core.version import get_version
from pxr import PhysxSchema from pxr import PhysxSchema
import isaaclab.sim as sim_utils import isaaclab.sim as sim_utils
...@@ -141,16 +142,31 @@ class InteractiveScene: ...@@ -141,16 +142,31 @@ class InteractiveScene:
# when replicate_physics=False, we assume heterogeneous environments and clone the xforms first. # when replicate_physics=False, we assume heterogeneous environments and clone the xforms first.
# this triggers per-object level cloning in the spawner. # this triggers per-object level cloning in the spawner.
if not self.cfg.replicate_physics: if not self.cfg.replicate_physics:
# clone the env xform # check version of Isaac Sim to determine whether clone_in_fabric is valid
env_origins = self.cloner.clone( isaac_sim_version = float(".".join(get_version()[2]))
source_prim_path=self.env_prim_paths[0], if isaac_sim_version < 5:
prim_paths=self.env_prim_paths, # clone the env xform
replicate_physics=False, env_origins = self.cloner.clone(
copy_from_source=True, source_prim_path=self.env_prim_paths[0],
enable_env_ids=( prim_paths=self.env_prim_paths,
self.cfg.filter_collisions if self.device != "cpu" else False replicate_physics=False,
), # this won't do anything because we are not replicating physics copy_from_source=True,
) enable_env_ids=(
self.cfg.filter_collisions if self.device != "cpu" else False
), # this won't do anything because we are not replicating physics
)
else:
# clone the env xform
env_origins = self.cloner.clone(
source_prim_path=self.env_prim_paths[0],
prim_paths=self.env_prim_paths,
replicate_physics=False,
copy_from_source=True,
enable_env_ids=(
self.cfg.filter_collisions if self.device != "cpu" else False
), # this won't do anything because we are not replicating physics
clone_in_fabric=self.cfg.clone_in_fabric,
)
self._default_env_origins = torch.tensor(env_origins, device=self.device, dtype=torch.float32) self._default_env_origins = torch.tensor(env_origins, device=self.device, dtype=torch.float32)
else: else:
# otherwise, environment origins will be initialized during cloning at the end of environment creation # otherwise, environment origins will be initialized during cloning at the end of environment creation
...@@ -166,13 +182,25 @@ class InteractiveScene: ...@@ -166,13 +182,25 @@ class InteractiveScene:
# replicate physics if we have more than one environment # replicate physics if we have more than one environment
# this is done to make scene initialization faster at play time # this is done to make scene initialization faster at play time
if self.cfg.replicate_physics and self.cfg.num_envs > 1: if self.cfg.replicate_physics and self.cfg.num_envs > 1:
self.cloner.replicate_physics( # check version of Isaac Sim to determine whether clone_in_fabric is valid
source_prim_path=self.env_prim_paths[0], isaac_sim_version = float(".".join(get_version()[2]))
prim_paths=self.env_prim_paths, if isaac_sim_version < 5:
base_env_path=self.env_ns, self.cloner.replicate_physics(
root_path=self.env_regex_ns.replace(".*", ""), source_prim_path=self.env_prim_paths[0],
enable_env_ids=self.cfg.filter_collisions if self.device != "cpu" else False, prim_paths=self.env_prim_paths,
) base_env_path=self.env_ns,
root_path=self.env_regex_ns.replace(".*", ""),
enable_env_ids=self.cfg.filter_collisions if self.device != "cpu" else False,
)
else:
self.cloner.replicate_physics(
source_prim_path=self.env_prim_paths[0],
prim_paths=self.env_prim_paths,
base_env_path=self.env_ns,
root_path=self.env_regex_ns.replace(".*", ""),
enable_env_ids=self.cfg.filter_collisions if self.device != "cpu" else False,
clone_in_fabric=self.cfg.clone_in_fabric,
)
# since env_ids is only applicable when replicating physics, we have to fallback to the previous method # since env_ids is only applicable when replicating physics, we have to fallback to the previous method
# to filter collisions if replicate_physics is not enabled # to filter collisions if replicate_physics is not enabled
...@@ -199,16 +227,31 @@ class InteractiveScene: ...@@ -199,16 +227,31 @@ class InteractiveScene:
" This may adversely affect PhysX parsing. We recommend disabling this property." " This may adversely affect PhysX parsing. We recommend disabling this property."
) )
# clone the environment # check version of Isaac Sim to determine whether clone_in_fabric is valid
env_origins = self.cloner.clone( isaac_sim_version = float(".".join(get_version()[2]))
source_prim_path=self.env_prim_paths[0], if isaac_sim_version < 5:
prim_paths=self.env_prim_paths, # clone the environment
replicate_physics=self.cfg.replicate_physics, env_origins = self.cloner.clone(
copy_from_source=copy_from_source, source_prim_path=self.env_prim_paths[0],
enable_env_ids=( prim_paths=self.env_prim_paths,
self.cfg.filter_collisions if self.device != "cpu" else False replicate_physics=self.cfg.replicate_physics,
), # this automatically filters collisions between environments copy_from_source=copy_from_source,
) enable_env_ids=(
self.cfg.filter_collisions if self.device != "cpu" else False
), # this automatically filters collisions between environments
)
else:
# clone the environment
env_origins = self.cloner.clone(
source_prim_path=self.env_prim_paths[0],
prim_paths=self.env_prim_paths,
replicate_physics=self.cfg.replicate_physics,
copy_from_source=copy_from_source,
enable_env_ids=(
self.cfg.filter_collisions if self.device != "cpu" else False
), # this automatically filters collisions between environments
clone_in_fabric=self.cfg.clone_in_fabric,
)
# since env_ids is only applicable when replicating physics, we have to fallback to the previous method # since env_ids is only applicable when replicating physics, we have to fallback to the previous method
# to filter collisions if replicate_physics is not enabled # to filter collisions if replicate_physics is not enabled
......
...@@ -109,3 +109,14 @@ class InteractiveSceneCfg: ...@@ -109,3 +109,14 @@ class InteractiveSceneCfg:
Collisions can only be filtered automatically in direct workflows when physics replication is enabled. Collisions can only be filtered automatically in direct workflows when physics replication is enabled.
If ``replicated_physics=False`` and collision filtering is desired, make sure to call ``scene.filter_collisions()``. If ``replicated_physics=False`` and collision filtering is desired, make sure to call ``scene.filter_collisions()``.
""" """
clone_in_fabric: bool = False
"""Enable/disable cloning in fabric. Default is False.
If True, cloning happens through Omniverse fabric, which is a more optimized method for performing cloning in
scene creation. However, this limits flexibility in accessing the stage through USD APIs and instead, the stage
must be accessed through USDRT.
If False, cloning will happen through regular USD APIs.
.. note::
Cloning in fabric can only be enabled if physics replication is also enabled.
If ``replicated_physics=False``, we will automatically default cloning in fabric to be False.
"""
...@@ -39,6 +39,7 @@ def spawn_from_usd( ...@@ -39,6 +39,7 @@ def spawn_from_usd(
cfg: from_files_cfg.UsdFileCfg, cfg: from_files_cfg.UsdFileCfg,
translation: tuple[float, float, float] | None = None, translation: tuple[float, float, float] | None = None,
orientation: tuple[float, float, float, float] | None = None, orientation: tuple[float, float, float, float] | None = None,
**kwargs,
) -> Usd.Prim: ) -> Usd.Prim:
"""Spawn an asset from a USD file and override the settings with the given config. """Spawn an asset from a USD file and override the settings with the given config.
...@@ -62,6 +63,7 @@ def spawn_from_usd( ...@@ -62,6 +63,7 @@ def spawn_from_usd(
case the translation specified in the USD file is used. case the translation specified in the USD file is used.
orientation: The orientation in (w, x, y, z) to apply to the prim w.r.t. its parent prim. Defaults to None, orientation: The orientation in (w, x, y, z) to apply to the prim w.r.t. its parent prim. Defaults to None,
in which case the orientation specified in the USD file is used. in which case the orientation specified in the USD file is used.
**kwargs: Additional keyword arguments, like ``clone_in_fabric``.
Returns: Returns:
The prim of the spawned asset. The prim of the spawned asset.
...@@ -79,6 +81,7 @@ def spawn_from_urdf( ...@@ -79,6 +81,7 @@ def spawn_from_urdf(
cfg: from_files_cfg.UrdfFileCfg, cfg: from_files_cfg.UrdfFileCfg,
translation: tuple[float, float, float] | None = None, translation: tuple[float, float, float] | None = None,
orientation: tuple[float, float, float, float] | None = None, orientation: tuple[float, float, float, float] | None = None,
**kwargs,
) -> Usd.Prim: ) -> Usd.Prim:
"""Spawn an asset from a URDF file and override the settings with the given config. """Spawn an asset from a URDF file and override the settings with the given config.
...@@ -102,6 +105,7 @@ def spawn_from_urdf( ...@@ -102,6 +105,7 @@ def spawn_from_urdf(
case the translation specified in the generated USD file is used. case the translation specified in the generated USD file is used.
orientation: The orientation in (w, x, y, z) to apply to the prim w.r.t. its parent prim. Defaults to None, orientation: The orientation in (w, x, y, z) to apply to the prim w.r.t. its parent prim. Defaults to None,
in which case the orientation specified in the generated USD file is used. in which case the orientation specified in the generated USD file is used.
**kwargs: Additional keyword arguments, like ``clone_in_fabric``.
Returns: Returns:
The prim of the spawned asset. The prim of the spawned asset.
...@@ -120,6 +124,7 @@ def spawn_ground_plane( ...@@ -120,6 +124,7 @@ def spawn_ground_plane(
cfg: from_files_cfg.GroundPlaneCfg, cfg: from_files_cfg.GroundPlaneCfg,
translation: tuple[float, float, float] | None = None, translation: tuple[float, float, float] | None = None,
orientation: tuple[float, float, float, float] | None = None, orientation: tuple[float, float, float, float] | None = None,
**kwargs,
) -> Usd.Prim: ) -> Usd.Prim:
"""Spawns a ground plane into the scene. """Spawns a ground plane into the scene.
...@@ -138,6 +143,7 @@ def spawn_ground_plane( ...@@ -138,6 +143,7 @@ def spawn_ground_plane(
case the translation specified in the USD file is used. case the translation specified in the USD file is used.
orientation: The orientation in (w, x, y, z) to apply to the prim w.r.t. its parent prim. Defaults to None, orientation: The orientation in (w, x, y, z) to apply to the prim w.r.t. its parent prim. Defaults to None,
in which case the orientation specified in the USD file is used. in which case the orientation specified in the USD file is used.
**kwargs: Additional keyword arguments, like ``clone_in_fabric``.
Returns: Returns:
The prim of the spawned asset. The prim of the spawned asset.
...@@ -225,6 +231,7 @@ def _spawn_from_usd_file( ...@@ -225,6 +231,7 @@ def _spawn_from_usd_file(
cfg: from_files_cfg.FileCfg, cfg: from_files_cfg.FileCfg,
translation: tuple[float, float, float] | None = None, translation: tuple[float, float, float] | None = None,
orientation: tuple[float, float, float, float] | None = None, orientation: tuple[float, float, float, float] | None = None,
**kwargs,
) -> Usd.Prim: ) -> Usd.Prim:
"""Spawn an asset from a USD file and override the settings with the given config. """Spawn an asset from a USD file and override the settings with the given config.
...@@ -241,6 +248,7 @@ def _spawn_from_usd_file( ...@@ -241,6 +248,7 @@ def _spawn_from_usd_file(
case the translation specified in the generated USD file is used. case the translation specified in the generated USD file is used.
orientation: The orientation in (w, x, y, z) to apply to the prim w.r.t. its parent prim. Defaults to None, orientation: The orientation in (w, x, y, z) to apply to the prim w.r.t. its parent prim. Defaults to None,
in which case the orientation specified in the generated USD file is used. in which case the orientation specified in the generated USD file is used.
**kwargs: Additional keyword arguments, like ``clone_in_fabric``.
Returns: Returns:
The prim of the spawned asset. The prim of the spawned asset.
......
...@@ -22,6 +22,7 @@ def spawn_light( ...@@ -22,6 +22,7 @@ def spawn_light(
cfg: lights_cfg.LightCfg, cfg: lights_cfg.LightCfg,
translation: tuple[float, float, float] | None = None, translation: tuple[float, float, float] | None = None,
orientation: tuple[float, float, float, float] | None = None, orientation: tuple[float, float, float, float] | None = None,
**kwargs,
) -> Usd.Prim: ) -> Usd.Prim:
"""Create a light prim at the specified prim path with the specified configuration. """Create a light prim at the specified prim path with the specified configuration.
...@@ -39,6 +40,7 @@ def spawn_light( ...@@ -39,6 +40,7 @@ def spawn_light(
translation: The translation of the prim. Defaults to None, in which case this is set to the origin. translation: The translation of the prim. Defaults to None, in which case this is set to the origin.
orientation: The orientation of the prim as (w, x, y, z). Defaults to None, in which case this orientation: The orientation of the prim as (w, x, y, z). Defaults to None, in which case this
is set to identity. is set to identity.
**kwargs: Additional keyword arguments, like ``clone_in_fabric``.
Raises: Raises:
ValueError: When a prim already exists at the specified prim path. ValueError: When a prim already exists at the specified prim path.
......
...@@ -28,6 +28,7 @@ def spawn_mesh_sphere( ...@@ -28,6 +28,7 @@ def spawn_mesh_sphere(
cfg: meshes_cfg.MeshSphereCfg, cfg: meshes_cfg.MeshSphereCfg,
translation: tuple[float, float, float] | None = None, translation: tuple[float, float, float] | None = None,
orientation: tuple[float, float, float, float] | None = None, orientation: tuple[float, float, float, float] | None = None,
**kwargs,
) -> Usd.Prim: ) -> Usd.Prim:
"""Create a USD-Mesh sphere prim with the given attributes. """Create a USD-Mesh sphere prim with the given attributes.
...@@ -44,6 +45,7 @@ def spawn_mesh_sphere( ...@@ -44,6 +45,7 @@ def spawn_mesh_sphere(
this is set to the origin. this is set to the origin.
orientation: The orientation in (w, x, y, z) to apply to the prim w.r.t. its parent prim. Defaults to None, orientation: The orientation in (w, x, y, z) to apply to the prim w.r.t. its parent prim. Defaults to None,
in which case this is set to identity. in which case this is set to identity.
**kwargs: Additional keyword arguments, like ``clone_in_fabric``.
Returns: Returns:
The created prim. The created prim.
...@@ -65,6 +67,7 @@ def spawn_mesh_cuboid( ...@@ -65,6 +67,7 @@ def spawn_mesh_cuboid(
cfg: meshes_cfg.MeshCuboidCfg, cfg: meshes_cfg.MeshCuboidCfg,
translation: tuple[float, float, float] | None = None, translation: tuple[float, float, float] | None = None,
orientation: tuple[float, float, float, float] | None = None, orientation: tuple[float, float, float, float] | None = None,
**kwargs,
) -> Usd.Prim: ) -> Usd.Prim:
"""Create a USD-Mesh cuboid prim with the given attributes. """Create a USD-Mesh cuboid prim with the given attributes.
...@@ -81,6 +84,7 @@ def spawn_mesh_cuboid( ...@@ -81,6 +84,7 @@ def spawn_mesh_cuboid(
this is set to the origin. this is set to the origin.
orientation: The orientation in (w, x, y, z) to apply to the prim w.r.t. its parent prim. Defaults to None, orientation: The orientation in (w, x, y, z) to apply to the prim w.r.t. its parent prim. Defaults to None,
in which case this is set to identity. in which case this is set to identity.
**kwargs: Additional keyword arguments, like ``clone_in_fabric``.
Returns: Returns:
The created prim. The created prim.
...@@ -101,6 +105,7 @@ def spawn_mesh_cylinder( ...@@ -101,6 +105,7 @@ def spawn_mesh_cylinder(
cfg: meshes_cfg.MeshCylinderCfg, cfg: meshes_cfg.MeshCylinderCfg,
translation: tuple[float, float, float] | None = None, translation: tuple[float, float, float] | None = None,
orientation: tuple[float, float, float, float] | None = None, orientation: tuple[float, float, float, float] | None = None,
**kwargs,
) -> Usd.Prim: ) -> Usd.Prim:
"""Create a USD-Mesh cylinder prim with the given attributes. """Create a USD-Mesh cylinder prim with the given attributes.
...@@ -117,6 +122,7 @@ def spawn_mesh_cylinder( ...@@ -117,6 +122,7 @@ def spawn_mesh_cylinder(
this is set to the origin. this is set to the origin.
orientation: The orientation in (w, x, y, z) to apply to the prim w.r.t. its parent prim. Defaults to None, orientation: The orientation in (w, x, y, z) to apply to the prim w.r.t. its parent prim. Defaults to None,
in which case this is set to identity. in which case this is set to identity.
**kwargs: Additional keyword arguments, like ``clone_in_fabric``.
Returns: Returns:
The created prim. The created prim.
...@@ -146,6 +152,7 @@ def spawn_mesh_capsule( ...@@ -146,6 +152,7 @@ def spawn_mesh_capsule(
cfg: meshes_cfg.MeshCapsuleCfg, cfg: meshes_cfg.MeshCapsuleCfg,
translation: tuple[float, float, float] | None = None, translation: tuple[float, float, float] | None = None,
orientation: tuple[float, float, float, float] | None = None, orientation: tuple[float, float, float, float] | None = None,
**kwargs,
) -> Usd.Prim: ) -> Usd.Prim:
"""Create a USD-Mesh capsule prim with the given attributes. """Create a USD-Mesh capsule prim with the given attributes.
...@@ -162,6 +169,7 @@ def spawn_mesh_capsule( ...@@ -162,6 +169,7 @@ def spawn_mesh_capsule(
this is set to the origin. this is set to the origin.
orientation: The orientation in (w, x, y, z) to apply to the prim w.r.t. its parent prim. Defaults to None, orientation: The orientation in (w, x, y, z) to apply to the prim w.r.t. its parent prim. Defaults to None,
in which case this is set to identity. in which case this is set to identity.
**kwargs: Additional keyword arguments, like ``clone_in_fabric``.
Returns: Returns:
The created prim. The created prim.
...@@ -191,6 +199,7 @@ def spawn_mesh_cone( ...@@ -191,6 +199,7 @@ def spawn_mesh_cone(
cfg: meshes_cfg.MeshConeCfg, cfg: meshes_cfg.MeshConeCfg,
translation: tuple[float, float, float] | None = None, translation: tuple[float, float, float] | None = None,
orientation: tuple[float, float, float, float] | None = None, orientation: tuple[float, float, float, float] | None = None,
**kwargs,
) -> Usd.Prim: ) -> Usd.Prim:
"""Create a USD-Mesh cone prim with the given attributes. """Create a USD-Mesh cone prim with the given attributes.
...@@ -207,6 +216,7 @@ def spawn_mesh_cone( ...@@ -207,6 +216,7 @@ def spawn_mesh_cone(
this is set to the origin. this is set to the origin.
orientation: The orientation in (w, x, y, z) to apply to the prim w.r.t. its parent prim. Defaults to None, orientation: The orientation in (w, x, y, z) to apply to the prim w.r.t. its parent prim. Defaults to None,
in which case this is set to identity. in which case this is set to identity.
**kwargs: Additional keyword arguments, like ``clone_in_fabric``.
Returns: Returns:
The created prim. The created prim.
...@@ -242,6 +252,7 @@ def _spawn_mesh_geom_from_mesh( ...@@ -242,6 +252,7 @@ def _spawn_mesh_geom_from_mesh(
translation: tuple[float, float, float] | None = None, translation: tuple[float, float, float] | None = None,
orientation: tuple[float, float, float, float] | None = None, orientation: tuple[float, float, float, float] | None = None,
scale: tuple[float, float, float] | None = None, scale: tuple[float, float, float] | None = None,
**kwargs,
): ):
"""Create a `USDGeomMesh`_ prim from the given mesh. """Create a `USDGeomMesh`_ prim from the given mesh.
...@@ -263,6 +274,7 @@ def _spawn_mesh_geom_from_mesh( ...@@ -263,6 +274,7 @@ def _spawn_mesh_geom_from_mesh(
orientation: The orientation in (w, x, y, z) to apply to the prim w.r.t. its parent prim. Defaults to None, orientation: The orientation in (w, x, y, z) to apply to the prim w.r.t. its parent prim. Defaults to None,
in which case this is set to identity. in which case this is set to identity.
scale: The scale to apply to the prim. Defaults to None, in which case this is set to identity. scale: The scale to apply to the prim. Defaults to None, in which case this is set to identity.
**kwargs: Additional keyword arguments, like ``clone_in_fabric``.
Raises: Raises:
ValueError: If a prim already exists at the given path. ValueError: If a prim already exists at the given path.
......
...@@ -54,6 +54,7 @@ def spawn_camera( ...@@ -54,6 +54,7 @@ def spawn_camera(
cfg: sensors_cfg.PinholeCameraCfg | sensors_cfg.FisheyeCameraCfg, cfg: sensors_cfg.PinholeCameraCfg | sensors_cfg.FisheyeCameraCfg,
translation: tuple[float, float, float] | None = None, translation: tuple[float, float, float] | None = None,
orientation: tuple[float, float, float, float] | None = None, orientation: tuple[float, float, float, float] | None = None,
**kwargs,
) -> Usd.Prim: ) -> Usd.Prim:
"""Create a USD camera prim with given projection type. """Create a USD camera prim with given projection type.
...@@ -73,6 +74,7 @@ def spawn_camera( ...@@ -73,6 +74,7 @@ def spawn_camera(
this is set to the origin. this is set to the origin.
orientation: The orientation in (w, x, y, z) to apply to the prim w.r.t. its parent prim. Defaults to None, orientation: The orientation in (w, x, y, z) to apply to the prim w.r.t. its parent prim. Defaults to None,
in which case this is set to identity. in which case this is set to identity.
**kwargs: Additional keyword arguments, like ``clone_in_fabric``.
Returns: Returns:
The created prim. The created prim.
......
...@@ -23,6 +23,7 @@ def spawn_sphere( ...@@ -23,6 +23,7 @@ def spawn_sphere(
cfg: shapes_cfg.SphereCfg, cfg: shapes_cfg.SphereCfg,
translation: tuple[float, float, float] | None = None, translation: tuple[float, float, float] | None = None,
orientation: tuple[float, float, float, float] | None = None, orientation: tuple[float, float, float, float] | None = None,
**kwargs,
) -> Usd.Prim: ) -> Usd.Prim:
"""Create a USDGeom-based sphere prim with the given attributes. """Create a USDGeom-based sphere prim with the given attributes.
...@@ -41,6 +42,7 @@ def spawn_sphere( ...@@ -41,6 +42,7 @@ def spawn_sphere(
this is set to the origin. this is set to the origin.
orientation: The orientation in (w, x, y, z) to apply to the prim w.r.t. its parent prim. Defaults to None, orientation: The orientation in (w, x, y, z) to apply to the prim w.r.t. its parent prim. Defaults to None,
in which case this is set to identity. in which case this is set to identity.
**kwargs: Additional keyword arguments, like ``clone_in_fabric``.
Returns: Returns:
The created prim. The created prim.
...@@ -61,6 +63,7 @@ def spawn_cuboid( ...@@ -61,6 +63,7 @@ def spawn_cuboid(
cfg: shapes_cfg.CuboidCfg, cfg: shapes_cfg.CuboidCfg,
translation: tuple[float, float, float] | None = None, translation: tuple[float, float, float] | None = None,
orientation: tuple[float, float, float, float] | None = None, orientation: tuple[float, float, float, float] | None = None,
**kwargs,
) -> Usd.Prim: ) -> Usd.Prim:
"""Create a USDGeom-based cuboid prim with the given attributes. """Create a USDGeom-based cuboid prim with the given attributes.
...@@ -83,6 +86,7 @@ def spawn_cuboid( ...@@ -83,6 +86,7 @@ def spawn_cuboid(
this is set to the origin. this is set to the origin.
orientation: The orientation in (w, x, y, z) to apply to the prim w.r.t. its parent prim. Defaults to None, orientation: The orientation in (w, x, y, z) to apply to the prim w.r.t. its parent prim. Defaults to None,
in which case this is set to identity. in which case this is set to identity.
**kwargs: Additional keyword arguments, like ``clone_in_fabric``.
Returns: Returns:
The created prim. The created prim.
...@@ -106,6 +110,7 @@ def spawn_cylinder( ...@@ -106,6 +110,7 @@ def spawn_cylinder(
cfg: shapes_cfg.CylinderCfg, cfg: shapes_cfg.CylinderCfg,
translation: tuple[float, float, float] | None = None, translation: tuple[float, float, float] | None = None,
orientation: tuple[float, float, float, float] | None = None, orientation: tuple[float, float, float, float] | None = None,
**kwargs,
) -> Usd.Prim: ) -> Usd.Prim:
"""Create a USDGeom-based cylinder prim with the given attributes. """Create a USDGeom-based cylinder prim with the given attributes.
...@@ -124,6 +129,7 @@ def spawn_cylinder( ...@@ -124,6 +129,7 @@ def spawn_cylinder(
this is set to the origin. this is set to the origin.
orientation: The orientation in (w, x, y, z) to apply to the prim w.r.t. its parent prim. Defaults to None, orientation: The orientation in (w, x, y, z) to apply to the prim w.r.t. its parent prim. Defaults to None,
in which case this is set to identity. in which case this is set to identity.
**kwargs: Additional keyword arguments, like ``clone_in_fabric``.
Returns: Returns:
The created prim. The created prim.
...@@ -144,6 +150,7 @@ def spawn_capsule( ...@@ -144,6 +150,7 @@ def spawn_capsule(
cfg: shapes_cfg.CapsuleCfg, cfg: shapes_cfg.CapsuleCfg,
translation: tuple[float, float, float] | None = None, translation: tuple[float, float, float] | None = None,
orientation: tuple[float, float, float, float] | None = None, orientation: tuple[float, float, float, float] | None = None,
**kwargs,
) -> Usd.Prim: ) -> Usd.Prim:
"""Create a USDGeom-based capsule prim with the given attributes. """Create a USDGeom-based capsule prim with the given attributes.
...@@ -162,6 +169,7 @@ def spawn_capsule( ...@@ -162,6 +169,7 @@ def spawn_capsule(
this is set to the origin. this is set to the origin.
orientation: The orientation in (w, x, y, z) to apply to the prim w.r.t. its parent prim. Defaults to None, orientation: The orientation in (w, x, y, z) to apply to the prim w.r.t. its parent prim. Defaults to None,
in which case this is set to identity. in which case this is set to identity.
**kwargs: Additional keyword arguments, like ``clone_in_fabric``.
Returns: Returns:
The created prim. The created prim.
...@@ -182,6 +190,7 @@ def spawn_cone( ...@@ -182,6 +190,7 @@ def spawn_cone(
cfg: shapes_cfg.ConeCfg, cfg: shapes_cfg.ConeCfg,
translation: tuple[float, float, float] | None = None, translation: tuple[float, float, float] | None = None,
orientation: tuple[float, float, float, float] | None = None, orientation: tuple[float, float, float, float] | None = None,
**kwargs,
) -> Usd.Prim: ) -> Usd.Prim:
"""Create a USDGeom-based cone prim with the given attributes. """Create a USDGeom-based cone prim with the given attributes.
...@@ -200,6 +209,7 @@ def spawn_cone( ...@@ -200,6 +209,7 @@ def spawn_cone(
this is set to the origin. this is set to the origin.
orientation: The orientation in (w, x, y, z) to apply to the prim w.r.t. its parent prim. Defaults to None, orientation: The orientation in (w, x, y, z) to apply to the prim w.r.t. its parent prim. Defaults to None,
in which case this is set to identity. in which case this is set to identity.
**kwargs: Additional keyword arguments, like ``clone_in_fabric``.
Returns: Returns:
The created prim. The created prim.
......
...@@ -27,6 +27,8 @@ def spawn_multi_asset( ...@@ -27,6 +27,8 @@ def spawn_multi_asset(
cfg: wrappers_cfg.MultiAssetSpawnerCfg, cfg: wrappers_cfg.MultiAssetSpawnerCfg,
translation: tuple[float, float, float] | None = None, translation: tuple[float, float, float] | None = None,
orientation: tuple[float, float, float, float] | None = None, orientation: tuple[float, float, float, float] | None = None,
clone_in_fabric: bool = False,
replicate_physics: bool = False,
) -> Usd.Prim: ) -> Usd.Prim:
"""Spawn multiple assets based on the provided configurations. """Spawn multiple assets based on the provided configurations.
...@@ -39,6 +41,8 @@ def spawn_multi_asset( ...@@ -39,6 +41,8 @@ def spawn_multi_asset(
cfg: The configuration for spawning the assets. cfg: The configuration for spawning the assets.
translation: The translation of the spawned assets. Default is None. translation: The translation of the spawned assets. Default is None.
orientation: The orientation of the spawned assets in (w, x, y, z) order. Default is None. orientation: The orientation of the spawned assets in (w, x, y, z) order. Default is None.
clone_in_fabric: Whether to clone in fabric. Default is False.
replicate_physics: Whether to replicate physics. Default is False.
Returns: Returns:
The created prim at the first prim path. The created prim at the first prim path.
...@@ -85,7 +89,14 @@ def spawn_multi_asset( ...@@ -85,7 +89,14 @@ def spawn_multi_asset(
setattr(asset_cfg, attr_name, attr_value) setattr(asset_cfg, attr_name, attr_value)
# spawn single instance # spawn single instance
proto_prim_path = f"{template_prim_path}/Asset_{index:04d}" proto_prim_path = f"{template_prim_path}/Asset_{index:04d}"
asset_cfg.func(proto_prim_path, asset_cfg, translation=translation, orientation=orientation) asset_cfg.func(
proto_prim_path,
asset_cfg,
translation=translation,
orientation=orientation,
clone_in_fabric=clone_in_fabric,
replicate_physics=replicate_physics,
)
# append to proto prim paths # append to proto prim paths
proto_prim_paths.append(proto_prim_path) proto_prim_paths.append(proto_prim_path)
...@@ -125,6 +136,8 @@ def spawn_multi_usd_file( ...@@ -125,6 +136,8 @@ def spawn_multi_usd_file(
cfg: wrappers_cfg.MultiUsdFileCfg, cfg: wrappers_cfg.MultiUsdFileCfg,
translation: tuple[float, float, float] | None = None, translation: tuple[float, float, float] | None = None,
orientation: tuple[float, float, float, float] | None = None, orientation: tuple[float, float, float, float] | None = None,
clone_in_fabric: bool = False,
replicate_physics: bool = False,
) -> Usd.Prim: ) -> Usd.Prim:
"""Spawn multiple USD files based on the provided configurations. """Spawn multiple USD files based on the provided configurations.
...@@ -136,6 +149,8 @@ def spawn_multi_usd_file( ...@@ -136,6 +149,8 @@ def spawn_multi_usd_file(
cfg: The configuration for spawning the assets. cfg: The configuration for spawning the assets.
translation: The translation of the spawned assets. Default is None. translation: The translation of the spawned assets. Default is None.
orientation: The orientation of the spawned assets in (w, x, y, z) order. Default is None. orientation: The orientation of the spawned assets in (w, x, y, z) order. Default is None.
clone_in_fabric: Whether to clone in fabric. Default is False.
replicate_physics: Whether to replicate physics. Default is False.
Returns: Returns:
The created prim at the first prim path. The created prim at the first prim path.
...@@ -175,4 +190,4 @@ def spawn_multi_usd_file( ...@@ -175,4 +190,4 @@ def spawn_multi_usd_file(
multi_asset_cfg.activate_contact_sensors = cfg.activate_contact_sensors multi_asset_cfg.activate_contact_sensors = cfg.activate_contact_sensors
# call the original function # call the original function
return spawn_multi_asset(prim_path, multi_asset_cfg, translation, orientation) return spawn_multi_asset(prim_path, multi_asset_cfg, translation, orientation, clone_in_fabric, replicate_physics)
...@@ -292,8 +292,24 @@ def clone(func: Callable) -> Callable: ...@@ -292,8 +292,24 @@ def clone(func: Callable) -> Callable:
# clone asset using cloner API # clone asset using cloner API
if len(prim_paths) > 1: if len(prim_paths) > 1:
cloner = Cloner(stage=stage) cloner = Cloner(stage=stage)
# clone the prim # check version of Isaac Sim to determine whether clone_in_fabric is valid
cloner.clone(prim_paths[0], prim_paths[1:], replicate_physics=False, copy_from_source=cfg.copy_from_source) isaac_sim_version = float(".".join(get_version()[2]))
if isaac_sim_version < 5:
# clone the prim
cloner.clone(
prim_paths[0], prim_paths[1:], replicate_physics=False, copy_from_source=cfg.copy_from_source
)
else:
# clone the prim
clone_in_fabric = kwargs.get("clone_in_fabric", False)
replicate_physics = kwargs.get("replicate_physics", False)
cloner.clone(
prim_paths[0],
prim_paths[1:],
replicate_physics=replicate_physics,
copy_from_source=cfg.copy_from_source,
clone_in_fabric=clone_in_fabric,
)
# return the source prim # return the source prim
return prim return prim
......
...@@ -98,7 +98,9 @@ class AllegroHandEnvCfg(DirectRLEnvCfg): ...@@ -98,7 +98,9 @@ class AllegroHandEnvCfg(DirectRLEnvCfg):
}, },
) )
# scene # scene
scene: InteractiveSceneCfg = InteractiveSceneCfg(num_envs=8192, env_spacing=0.75, replicate_physics=True) scene: InteractiveSceneCfg = InteractiveSceneCfg(
num_envs=8192, env_spacing=0.75, replicate_physics=True, clone_in_fabric=True
)
# reset # reset
reset_position_noise = 0.01 # range of position at reset reset_position_noise = 0.01 # range of position at reset
reset_dof_pos_noise = 0.2 # range of dof pos at reset reset_dof_pos_noise = 0.2 # range of dof pos at reset
......
...@@ -45,7 +45,9 @@ class AntEnvCfg(DirectRLEnvCfg): ...@@ -45,7 +45,9 @@ class AntEnvCfg(DirectRLEnvCfg):
) )
# scene # scene
scene: InteractiveSceneCfg = InteractiveSceneCfg(num_envs=4096, env_spacing=4.0, replicate_physics=True) scene: InteractiveSceneCfg = InteractiveSceneCfg(
num_envs=4096, env_spacing=4.0, replicate_physics=True, clone_in_fabric=True
)
# robot # robot
robot: ArticulationCfg = ANT_CFG.replace(prim_path="/World/envs/env_.*/Robot") robot: ArticulationCfg = ANT_CFG.replace(prim_path="/World/envs/env_.*/Robot")
......
...@@ -40,7 +40,9 @@ class CartpoleEnvCfg(DirectRLEnvCfg): ...@@ -40,7 +40,9 @@ class CartpoleEnvCfg(DirectRLEnvCfg):
pole_dof_name = "cart_to_pole" pole_dof_name = "cart_to_pole"
# scene # scene
scene: InteractiveSceneCfg = InteractiveSceneCfg(num_envs=4096, env_spacing=4.0, replicate_physics=True) scene: InteractiveSceneCfg = InteractiveSceneCfg(
num_envs=4096, env_spacing=4.0, replicate_physics=True, clone_in_fabric=True
)
# reset # reset
max_cart_pos = 3.0 # the cart is reset if it exceeds that position [m] max_cart_pos = 3.0 # the cart is reset if it exceeds that position [m]
......
...@@ -116,7 +116,7 @@ class FactoryEnvCfg(DirectRLEnvCfg): ...@@ -116,7 +116,7 @@ class FactoryEnvCfg(DirectRLEnvCfg):
), ),
) )
scene: InteractiveSceneCfg = InteractiveSceneCfg(num_envs=128, env_spacing=2.0) scene: InteractiveSceneCfg = InteractiveSceneCfg(num_envs=128, env_spacing=2.0, clone_in_fabric=True)
robot = ArticulationCfg( robot = ArticulationCfg(
prim_path="/World/envs/env_.*/Robot", prim_path="/World/envs/env_.*/Robot",
......
...@@ -46,7 +46,9 @@ class FrankaCabinetEnvCfg(DirectRLEnvCfg): ...@@ -46,7 +46,9 @@ class FrankaCabinetEnvCfg(DirectRLEnvCfg):
) )
# scene # scene
scene: InteractiveSceneCfg = InteractiveSceneCfg(num_envs=4096, env_spacing=3.0, replicate_physics=True) scene: InteractiveSceneCfg = InteractiveSceneCfg(
num_envs=4096, env_spacing=3.0, replicate_physics=True, clone_in_fabric=True
)
# robot # robot
robot = ArticulationCfg( robot = ArticulationCfg(
......
...@@ -45,7 +45,9 @@ class HumanoidEnvCfg(DirectRLEnvCfg): ...@@ -45,7 +45,9 @@ class HumanoidEnvCfg(DirectRLEnvCfg):
) )
# scene # scene
scene: InteractiveSceneCfg = InteractiveSceneCfg(num_envs=4096, env_spacing=4.0, replicate_physics=True) scene: InteractiveSceneCfg = InteractiveSceneCfg(
num_envs=4096, env_spacing=4.0, replicate_physics=True, clone_in_fabric=True
)
# robot # robot
robot: ArticulationCfg = HUMANOID_CFG.replace(prim_path="/World/envs/env_.*/Robot") robot: ArticulationCfg = HUMANOID_CFG.replace(prim_path="/World/envs/env_.*/Robot")
......
...@@ -85,7 +85,9 @@ class QuadcopterEnvCfg(DirectRLEnvCfg): ...@@ -85,7 +85,9 @@ class QuadcopterEnvCfg(DirectRLEnvCfg):
) )
# scene # scene
scene: InteractiveSceneCfg = InteractiveSceneCfg(num_envs=4096, env_spacing=2.5, replicate_physics=True) scene: InteractiveSceneCfg = InteractiveSceneCfg(
num_envs=4096, env_spacing=2.5, replicate_physics=True, clone_in_fabric=True
)
# robot # robot
robot: ArticulationCfg = CRAZYFLIE_CFG.replace(prim_path="/World/envs/env_.*/Robot") robot: ArticulationCfg = CRAZYFLIE_CFG.replace(prim_path="/World/envs/env_.*/Robot")
......
...@@ -205,7 +205,9 @@ class ShadowHandEnvCfg(DirectRLEnvCfg): ...@@ -205,7 +205,9 @@ class ShadowHandEnvCfg(DirectRLEnvCfg):
}, },
) )
# scene # scene
scene: InteractiveSceneCfg = InteractiveSceneCfg(num_envs=8192, env_spacing=0.75, replicate_physics=True) scene: InteractiveSceneCfg = InteractiveSceneCfg(
num_envs=8192, env_spacing=0.75, replicate_physics=True, clone_in_fabric=True
)
# reset # reset
reset_position_noise = 0.01 # range of position at reset reset_position_noise = 0.01 # range of position at reset
......
...@@ -160,7 +160,7 @@ class AntEnvCfg(ManagerBasedRLEnvCfg): ...@@ -160,7 +160,7 @@ class AntEnvCfg(ManagerBasedRLEnvCfg):
"""Configuration for the MuJoCo-style Ant walking environment.""" """Configuration for the MuJoCo-style Ant walking environment."""
# Scene settings # Scene settings
scene: MySceneCfg = MySceneCfg(num_envs=4096, env_spacing=5.0) scene: MySceneCfg = MySceneCfg(num_envs=4096, env_spacing=5.0, clone_in_fabric=True)
# Basic settings # Basic settings
observations: ObservationsCfg = ObservationsCfg() observations: ObservationsCfg = ObservationsCfg()
actions: ActionsCfg = ActionsCfg() actions: ActionsCfg = ActionsCfg()
......
...@@ -159,7 +159,7 @@ class CartpoleEnvCfg(ManagerBasedRLEnvCfg): ...@@ -159,7 +159,7 @@ class CartpoleEnvCfg(ManagerBasedRLEnvCfg):
"""Configuration for the cartpole environment.""" """Configuration for the cartpole environment."""
# Scene settings # Scene settings
scene: CartpoleSceneCfg = CartpoleSceneCfg(num_envs=4096, env_spacing=4.0) scene: CartpoleSceneCfg = CartpoleSceneCfg(num_envs=4096, env_spacing=4.0, clone_in_fabric=True)
# Basic settings # Basic settings
observations: ObservationsCfg = ObservationsCfg() observations: ObservationsCfg = ObservationsCfg()
actions: ActionsCfg = ActionsCfg() actions: ActionsCfg = ActionsCfg()
......
...@@ -197,7 +197,7 @@ class HumanoidEnvCfg(ManagerBasedRLEnvCfg): ...@@ -197,7 +197,7 @@ class HumanoidEnvCfg(ManagerBasedRLEnvCfg):
"""Configuration for the MuJoCo-style Humanoid walking environment.""" """Configuration for the MuJoCo-style Humanoid walking environment."""
# Scene settings # Scene settings
scene: MySceneCfg = MySceneCfg(num_envs=4096, env_spacing=5.0) scene: MySceneCfg = MySceneCfg(num_envs=4096, env_spacing=5.0, clone_in_fabric=True)
# Basic settings # Basic settings
observations: ObservationsCfg = ObservationsCfg() observations: ObservationsCfg = ObservationsCfg()
actions: ActionsCfg = ActionsCfg() actions: ActionsCfg = ActionsCfg()
......
...@@ -21,6 +21,8 @@ class AllegroCubeEnvCfg(inhand_env_cfg.InHandObjectEnvCfg): ...@@ -21,6 +21,8 @@ class AllegroCubeEnvCfg(inhand_env_cfg.InHandObjectEnvCfg):
# switch robot to allegro hand # switch robot to allegro hand
self.scene.robot = ALLEGRO_HAND_CFG.replace(prim_path="{ENV_REGEX_NS}/Robot") self.scene.robot = ALLEGRO_HAND_CFG.replace(prim_path="{ENV_REGEX_NS}/Robot")
# enable clone in fabric
self.scene.clone_in_fabric = True
@configclass @configclass
......
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