Skip to content

Commit 84b2d2d

Browse files
author
David Hoeller
authored
Adds a rigid body collection class (#1288)
# Description Adds a rigid body collection class, which allows to spawn multiple objects in each environment and access/modify the quantities with a unified (env_ids, object_ids) API. ## Type of change - New feature (non-breaking change which adds functionality) ## Checklist - [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
1 parent b9a49ca commit 84b2d2d

File tree

14 files changed

+1530
-27
lines changed

14 files changed

+1530
-27
lines changed
-7.94 KB
Loading

docs/source/api/lab/omni.isaac.lab.assets.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
RigidObject
1313
RigidObjectData
1414
RigidObjectCfg
15+
RigidObjectCollection
16+
RigidObjectCollectionData
17+
RigidObjectCollectionCfg
1518
Articulation
1619
ArticulationData
1720
ArticulationCfg
@@ -51,6 +54,26 @@ Rigid Object
5154
:show-inheritance:
5255
:exclude-members: __init__, class_type
5356

57+
Rigid Object Collection
58+
-----------------------
59+
60+
.. autoclass:: RigidObjectCollection
61+
:members:
62+
:inherited-members:
63+
:show-inheritance:
64+
65+
.. autoclass:: RigidObjectCollectionData
66+
:members:
67+
:inherited-members:
68+
:show-inheritance:
69+
:exclude-members: __init__
70+
71+
.. autoclass:: RigidObjectCollectionCfg
72+
:members:
73+
:inherited-members:
74+
:show-inheritance:
75+
:exclude-members: __init__, class_type
76+
5477
Articulation
5578
------------
5679

docs/source/how-to/multi_asset_spawning.rst

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
1+
12
Spawning Multiple Assets
23
========================
34

45
.. currentmodule:: omni.isaac.lab
56

6-
Typical, spawning configurations (introduced in the :ref:`tutorial-spawn-prims` tutorial) copy the same
7+
Typical spawning configurations (introduced in the :ref:`tutorial-spawn-prims` tutorial) copy the same
78
asset (or USD primitive) across the different resolved prim paths from the expressions.
89
For instance, if the user specifies to spawn the asset at "/World/Table\_.*/Object", the same
910
asset is created at the paths "/World/Table_0/Object", "/World/Table_1/Object" and so on.
1011

11-
However, at times, it might be desirable to spawn different assets under the prim paths to
12-
ensure a diversity in the simulation. This guide describes how to create different assets under
13-
each prim path using the spawning functionality.
12+
However, we also support multi-asset spawning with two mechanisms:
13+
14+
1. Rigid object collections. This allows the user to spawn multiple rigid objects in each environment and access/modify
15+
them with a unified API, improving performance.
16+
17+
2. Spawning different assets under the same prim path. This allows the user to create diverse simulations, where each
18+
environment has a different asset.
19+
20+
This guide describes how to use these two mechanisms.
1421

1522
The sample script ``multi_asset.py`` is used as a reference, located in the
1623
``IsaacLab/source/standalone/demos`` directory.
@@ -20,28 +27,49 @@ The sample script ``multi_asset.py`` is used as a reference, located in the
2027

2128
.. literalinclude:: ../../../source/standalone/demos/multi_asset.py
2229
:language: python
23-
:emphasize-lines: 101-123, 130-149
30+
:emphasize-lines: 109-131, 135-179, 184-203
2431
:linenos:
2532

26-
This script creates multiple environments, where each environment has a rigid object that is either a cone,
27-
a cube, or a sphere, and an articulation that is either the ANYmal-C or ANYmal-D robot.
33+
This script creates multiple environments, where each environment has:
34+
35+
* a rigid object collection containing a cone, a cube, and a sphere
36+
* a rigid object that is either a cone, a cube, or a sphere, chosen at random
37+
* an articulation that is either the ANYmal-C or ANYmal-D robot, chosen at random
2838

2939
.. image:: ../_static/demos/multi_asset.jpg
3040
:width: 100%
3141
:alt: result of multi_asset.py
3242

33-
Using Multi-Asset Spawning Functions
34-
------------------------------------
3543

36-
It is possible to spawn different assets and USDs in each environment using the spawners
44+
Rigid Object Collections
45+
------------------------
46+
47+
Multiple rigid objects can be spawned in each environment and accessed/modified with a unified ``(env_ids, obj_ids)`` API.
48+
While the user could also create multiple rigid objects by spawning them individually, the API is more user-friendly and
49+
more efficient since it uses a single physics view under the hood to handle all the objects.
50+
51+
.. literalinclude:: ../../../source/standalone/demos/multi_asset.py
52+
:language: python
53+
:lines: 135-179
54+
:dedent:
55+
56+
The configuration :class:`~assets.RigidObjectCollectionCfg` is used to create the collection. It's attribute :attr:`~assets.RigidObjectCollectionCfg.rigid_objects`
57+
is a dictionary containing :class:`~assets.RigidObjectCfg` objects. The keys serve as unique identifiers for each
58+
rigid object in the collection.
59+
60+
61+
Spawning different assets under the same prim path
62+
--------------------------------------------------
63+
64+
It is possible to spawn different assets and USDs under the same prim path in each environment using the spawners
3765
:class:`~sim.spawners.wrappers.MultiAssetSpawnerCfg` and :class:`~sim.spawners.wrappers.MultiUsdFileCfg`:
3866

3967
* We set the spawn configuration in :class:`~assets.RigidObjectCfg` to be
4068
:class:`~sim.spawners.wrappers.MultiAssetSpawnerCfg`:
4169

4270
.. literalinclude:: ../../../source/standalone/demos/multi_asset.py
4371
:language: python
44-
:lines: 99-125
72+
:lines: 107-133
4573
:dedent:
4674

4775
This function allows you to define a list of different assets that can be spawned as rigid objects.
@@ -53,14 +81,14 @@ It is possible to spawn different assets and USDs in each environment using the
5381

5482
.. literalinclude:: ../../../source/standalone/demos/multi_asset.py
5583
:language: python
56-
:lines: 128-161
84+
:lines: 182-215
5785
:dedent:
5886

5987
Similar to before, this configuration allows the selection of different USD files representing articulated assets.
6088

6189

6290
Things to Note
63-
--------------
91+
~~~~~~~~~~~~~~
6492

6593
Similar asset structuring
6694
~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -85,7 +113,7 @@ anymore. Hence the flag :attr:`scene.InteractiveScene.replicate_physics` must be
85113

86114
.. literalinclude:: ../../../source/standalone/demos/multi_asset.py
87115
:language: python
88-
:lines: 221-224
116+
:lines: 280-283
89117
:dedent:
90118

91119
The Code Execution

source/extensions/omni.isaac.lab/config/extension.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22

33
# Note: Semantic Versioning is used: https://semver.org/
4-
version = "0.27.13"
4+
version = "0.27.14"
55

66
# Description
77
title = "Isaac Lab framework for Robot Learning"

source/extensions/omni.isaac.lab/docs/CHANGELOG.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
Changelog
22
---------
33

4+
0.27.14 (2024-10-23)
5+
~~~~~~~~~~~~~~~~~~~~
6+
7+
Added
8+
^^^^^
9+
10+
* Added the class :class:`~omni.isaac.lab.assets.RigidObjectCollection` which allows to spawn
11+
multiple objects in each environment and access/modify the quantities with a unified (env_ids, object_ids) API.
12+
13+
414
0.27.13 (2024-10-30)
515
~~~~~~~~~~~~~~~~~~~~
616

@@ -13,7 +23,7 @@ Added
1323

1424

1525
0.27.12 (2024-01-04)
16-
~~~~~~~~~~~~~~~~~~~
26+
~~~~~~~~~~~~~~~~~~~~
1727

1828
Removed
1929
^^^^^^^

source/extensions/omni.isaac.lab/omni/isaac/lab/assets/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,4 @@
4343
from .asset_base_cfg import AssetBaseCfg
4444
from .deformable_object import DeformableObject, DeformableObjectCfg, DeformableObjectData
4545
from .rigid_object import RigidObject, RigidObjectCfg, RigidObjectData
46+
from .rigid_object_collection import RigidObjectCollection, RigidObjectCollectionCfg, RigidObjectCollectionData
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright (c) 2022-2024, The Isaac Lab Project Developers.
2+
# All rights reserved.
3+
#
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
6+
"""Sub-module for rigid object collection."""
7+
8+
from .rigid_object_collection import RigidObjectCollection
9+
from .rigid_object_collection_cfg import RigidObjectCollectionCfg
10+
from .rigid_object_collection_data import RigidObjectCollectionData

0 commit comments

Comments
 (0)