Skip to content
Closed
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
2 changes: 2 additions & 0 deletions docs/source/api/lab/isaaclab.cloner.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ Additional Public Classes
:show-inheritance:

.. autoclass:: InclusionSet
:members:
:show-inheritance:
:exclude-members: __init__

.. autoclass:: ReplicateContext
:members:
Expand Down
7 changes: 7 additions & 0 deletions docs/source/api/lab/isaaclab.managers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
CurriculumTermCfg
RecorderManager
RecorderTermCfg
HeterogeneousTaskManager

Scene Entity
------------
Expand Down Expand Up @@ -271,6 +272,12 @@ applications explicitly close any additional resources they own.
:members:
:exclude-members: __init__

Heterogeneous Task Manager
--------------------------

.. autoclass:: HeterogeneousTaskManager
:members:

Additional Public Classes
-------------------------

Expand Down
15 changes: 14 additions & 1 deletion docs/source/how-to/multi_asset_spawning.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,26 @@ variant because their batched Newton views currently require a uniform body layo
:end-at: scene_cfg.robot.spawn.usd_path = scene_cfg.robot.spawn.usd_path[0]
:dedent: 8

Clone planning creates one world prototype per choice of variant of every multi-variant asset, so their number is the
product of the variant counts. When only some compositions are legal, or the product is too large to enumerate, list
them by pinning variants with :attr:`~isaaclab.cloner.InclusionSet.variants`. Each combination then expands only over
the assets it leaves unpinned, and the clone strategy distributes the worlds over the combinations by their weights:

.. code-block:: python

scene_cfg.clone_cfg.clone_combinations = [
InclusionSet(assets=["part", "fixture"], variants={"part": 0, "fixture": 2}),
InclusionSet(assets=["part", "fixture"], variants={"part": 1, "fixture": 0}, weight=3.0),
]

For more detail on prototype assignment and replication, see :doc:`cloning`.

Reset-time selection
~~~~~~~~~~~~~~~~~~~~

A rigid object's multi-asset spawner defines the variants and their IDs in list order. Clone composition chooses
the initial variant for each world. A reset event can change it before writing the episode's pose and velocity:
the initial variant for each world; pinned variants use the same IDs. A reset event can change it before writing the
episode's pose and velocity:

.. code-block:: python

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
* Added :class:`~isaaclab.managers.HeterogeneousTaskManager` so that each environment runs one of several tasks and
switches tasks on reset, where its task changed. :meth:`~isaaclab.managers.HeterogeneousTaskManager.compose_tasks`
adds the tasks' rigid objects, termination terms and episode lengths to an environment configuration; a task leaves
a slot empty with :meth:`~isaaclab.managers.HeterogeneousTaskManager.placeholder`, kinematic in the slots of
kinematic objects. The objects are selected as reset-time mesh variants, which need the Newton backend with the
XPBD solver, or with the MJWarp solver and ``use_mujoco_contacts=False``, and of the camera renderers only
:class:`~isaaclab_newton.renderers.NewtonWarpRendererCfg` shows the selected objects.
Empty file.
2 changes: 2 additions & 0 deletions source/isaaclab/changelog.d/pinned-clone-variants.added.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Added :attr:`~isaaclab.cloner.InclusionSet.variants` to pin the spawner variant of assets in a clone combination, so
scenes can list their legal variant-level compositions instead of enumerating the product of all variant counts.
Empty file.
15 changes: 15 additions & 0 deletions source/isaaclab/isaaclab/cloner/cloner_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ class InclusionSet:
weight: float = 1.0
"""Relative sampling weight for this clone combination."""

variants: dict[str, int] = {}
"""Spawner variant pinned for assets of this clone combination, keyed by scene asset name.

The value indexes the asset's multi-asset spawner list. A pinned asset contributes only that
variant, in each of its repeated instances and each member of a rigid object collection. Every
other multi-variant asset of the combination still contributes all of its variants, so the
combination expands into their product; pinning all of them states one world composition. The
asset must be active in the combination: listed in :attr:`assets`, or referenced by no
combination.
"""


@configclass
class CloneCfg:
Expand All @@ -65,6 +76,10 @@ class CloneCfg:
Each entry names the assets that are active in one legal combination.
Assets not referenced by any entry are active in every combination. An
empty list keeps the homogeneous/default behavior.

A combination expands into one world prototype per choice of spawner variant
of its multi-variant assets. Pin variants with :attr:`InclusionSet.variants`
to list the legal variant-level compositions instead of their product.
"""

clone_template: str = DEFAULT_ENV_TEMPLATE
Expand Down
14 changes: 13 additions & 1 deletion source/isaaclab/isaaclab/cloner/replicate_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ def make_valid_clone_combinations(

Repeated names create repeated instances. Each combination's weight is divided equally
between its variant combinations; neither padding nor duplicate weighted worlds is needed.
Only the assets a combination does not pin through :attr:`InclusionSet.variants` are
enumerated, so a combination pinning every multi-variant asset is one world prototype.

Args:
asset_names: Names of the replicated asset declarations.
Expand All @@ -68,10 +70,20 @@ def make_valid_clone_combinations(
for combination in combinations:
if unknown := set(combination.assets) - known:
raise ValueError(f"Unknown assets in clone combination: {sorted(unknown)}.")
active = {name for name in asset_names if name in combination.assets or name not in claimed}
if inactive := set(combination.variants) - active:
raise ValueError(f"Clone combination pins variants of assets it does not replicate: {sorted(inactive)}.")
choices = []
for index, name in enumerate(asset_names):
count = combination.assets.count(name) if name in claimed else 1
choices.extend([range(*offsets[index : index + 2])] * count)
rows = range(*offsets[index : index + 2])
if name in combination.variants:
variant = combination.variants[name]
is_index = isinstance(variant, (int, np.integer)) and not isinstance(variant, bool)
if not is_index or not 0 <= variant < len(rows):
raise ValueError(f"Cannot pin variant {variant!r} of {name!r}: it declares {len(rows)}.")
rows = (rows[int(variant)],)
choices.extend([rows] * count)
variants = tuple(itertools.product(*choices))
worlds.extend(variants)
weights.extend([combination.weight / len(variants)] * len(variants))
Expand Down
2 changes: 2 additions & 0 deletions source/isaaclab/isaaclab/managers/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ __all__ = [
"CommandTerm",
"CurriculumManager",
"EventManager",
"HeterogeneousTaskManager",
"ManagerBase",
"ManagerTermBase",
"ActionTermCfg",
Expand All @@ -36,6 +37,7 @@ from .action_manager import ActionManager, ActionTerm
from .command_manager import CommandManager, CommandTerm
from .curriculum_manager import CurriculumManager
from .event_manager import EventManager
from .heterogeneous_task_manager import HeterogeneousTaskManager
from .manager_base import ManagerBase, ManagerTermBase
from .manager_term_cfg import (
ActionTermCfg,
Expand Down
Loading
Loading