Skip to content

Make an object's asset a repeatable variation - #1458

Merged
cvolkcvolk merged 146 commits into
mainfrom
cvolkcvolk/feature/asset-selection-per-build
Oct 26, 2026
Merged

cvolkcvolk merged 146 commits into
mainfrom
cvolkcvolk/feature/asset-selection-per-build

Conversation

@cvolkcvolk

@cvolkcvolk cvolkcvolk commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Add a disabled asset_selection variation to every rigid Object, so an Experiment Run can spawn a different registered asset in each rebuild. To support it, build the task contact sensors and the default task description after the selection, so they match the selected asset, and name the pick_and_place_maple_table objects pick_up_object and destination_location, so their variation keys stay the same whichever asset they spawn.

Why this change?

Lighting, HDR maps, camera poses and object mass are variations: an experiment turns them on, the seed decides their values, every episode row records them, and recorded variation replay repeats them. The pick-up object is not. An environment fixes it in code or with an option such as pick_up_object, so comparing objects takes one Run per object, and the object is not seeded, recorded or replayed like the variations.

RigidObjectSet varies objects across the environments of one build, but it does not record which object an environment got, and supports_recorded_placement() turns off placement recording for a build that contains one.

What changes?

  • Every rigid Object except a RigidObjectSet gets a disabled asset_selection variation, a RigidAssetSelectionVariation. When enabled, each build spawns one of its registry_names in all environments. Rebuild k takes the k-th name, using SequentialSampler from Add SequentialSampler #1517, or a random one with sampler_cfg.random_choice: true. A name listed twice is selected more often. Each build checks every name but constructs only the selected one.
  • The selection runs before placement, so placement and the task's contact sensors use the selected asset. Episode rows record the name, and recorded variation replay spawns it again. A replay record with placement samples must include the value of every enabled build-time variation that sets the new changes_object_geometry flag, which RigidAssetSelectionVariation does.
  • The selected name becomes the object's registry_name, and the default descriptions of PickAndPlaceTask and AssemblyTask name it.
  • Scene.validate_simulation_cfg() runs the check of the asset a selection spawns, through the new Asset.get_spawned_asset(). A selected Newton-only gear fails a PhysX build, and a declared gear that selects a PhysX asset passes one.
  • The Experiment Runner passes the rebuild index to ArenaEnvBuilder. A warning for in-order selections with fewer rebuilds than names follows in Warn when in-order asset selection skips names #1520.
  • The swap_objects Run of getting_started_experiment.yaml selects its pick-up object from a list, one per build, and the variations docs cover it in the build-time explanation and the table of variations.

Breaking changes:

  • PickAndPlaceTask, ObjectInTask and SortMultiObjectTask build their contact sensors in get_scene_cfg(). scene_config, make_scene_cfg() and SortMultiObjectTask.pick_up_object_contact_sensor_list are removed.
  • PickAndPlaceTask.task_description and AssemblyTask.task_description hold only a description passed to the constructor. Call get_task_description() for the generated one.
  • The pick_and_place_maple_table object names change, and with them their variation keys, scene entity names and placement keys. Variation overrides, replay files and HDF5 demos recorded on main with the old names need the new ones.
  • Variations that override configure_at_build_time(seed, variation_key) must also accept rebuild_index, because ArenaEnvBuilder now passes it.

Limitations:

  • Only the spawn configuration, the simulation check and registry_name change. The object keeps its declared class's scale, spawn_cfg_addon and other methods.
  • An unknown name, or one whose class declares another object type, fails in the first build. A name the physics backend cannot simulate, or one whose type is known only after construction, such as an embodiment, fails when a rebuild selects it.
  • Outside the Experiment Runner, for example in record_demos.py, every build is rebuild 0, so in-order selection spawns the first name.
  • The descriptions of GearInsertionTask and PlaceUprightTask still name the declared asset, and a SimReadyUsdObject is described as simready_usd_object.
  • Metrics cover all selected objects together. Group episode rows by pick_up_object.asset_selection for per-object results.
  • A hand-written language_instruction applies to every rebuild.
  • A bounding_box override fails the build when the selection is enabled.
  • An ObjectReference into a selected object still reads the declared asset's usd_path.

Usage example

Before, one Run per object:

runs:
  rubiks_cube:
    environment:
      type: pick_and_place_maple_table
      pick_up_object: rubiks_cube_hot3d_robolab
  mustard_bottle:
    environment:
      type: pick_and_place_maple_table
      pick_up_object: mustard_bottle_hot3d_robolab

The object is set outside the variation system, so:

  • the seed, the episode rows' variations and recorded variation replay do not cover it;
  • objects cannot be drawn from a list, in order or at random;
  • every object needs its own Run.

After, one Run that spawns another object in each rebuild (the swap_objects Run of getting_started_experiment.yaml, which takes the rest of the environment from shared):

runs:
  swap_objects:
    environment:
      destination_location: wooden_bowl_hot3d_robolab
    num_rebuilds: 3
    rollout_limit:
      num_episodes: 3
    variations:
      pick_up_object.asset_selection.enabled: true
      pick_up_object.asset_selection.registry_names: [mustard_bottle_hot3d_robolab, orange_01_fruits_veggies_robolab, rubiks_cube_hot3d_robolab]

Set pick_up_object.asset_selection.sampler_cfg.random_choice: true to draw a name at random in each build instead.

Validation

  • On ce7302e, the getting-started Experiment loading tests pass in the local container. On d8596bf, so did the selection tests that run without simulation and test_recorded_variation_samples.py.
  • On d3623d0, the plain Python tests pass in the local container: the selection tests that run without simulation, test_run_execution.py, test_recorded_variation_samples.py and test_variation_base.py.
  • On 3588692, before the merge of main, 102 related tests pass in the local container, including the Experiment Runner rebuild and replay subprocess tests. The asset selection example experiment of that commit records the three objects in order over rebuilds 0 to 2.
  • The simulation tests cannot run locally after the merge of main: the local Docker image predates Update Arena to Isaac Lab 3.0 release #1481, and Isaac Lab 3.0 fails to import with its warp 1.16.0. CI runs the full suite.

@cvolkcvolk
cvolkcvolk force-pushed the cvolkcvolk/feature/asset-selection-per-build branch from ec0cddc to 70fe37d Compare October 16, 2026 10:16
@cvolkcvolk
cvolkcvolk changed the base branch from cvolkcvolk/feature/variation-build-context to cvolkcvolk/feature/seed-build-time-variations October 16, 2026 10:16
@cvolkcvolk
cvolkcvolk force-pushed the cvolkcvolk/feature/asset-selection-per-build branch 4 times, most recently from 7cab19c to 4aa0b8c Compare October 19, 2026 14:31

@cvolkcvolk cvolkcvolk left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quick pass self review

Comment thread isaaclab_arena/assets/asset.py Resolved
Comment thread isaaclab_arena/assets/object.py Resolved
PickAndPlaceTask, ObjectInTask and SortMultiObjectTask built their
contact sensors in their constructors, so each sensor kept the
rigid-body path of the spawn configuration its object had then. Object
geometry follows object_cfg.spawn since #1430, but a spawn
configuration replaced after the task was built left the sensor and
its filter on the old body. Build the sensors in get_scene_cfg()
instead, which ArenaEnvBuilder.compose_manager_cfg() calls after the
build-time variations.

The three tasks no longer have a scene_config attribute, and
SortMultiObjectTask no longer has pick_up_object_contact_sensor_list.
Nothing in the repository read them.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Object takes asset=(name, spawn_cfg) and keeps a copy of the spawn
configuration. Object(name) without usd_path, spawner_cfg or asset
no longer asserts at construction: it is rigid with no spawn
configuration, and get_object_cfg() and geometry queries fail with a
message that names the object. The assert that usd_path and
spawner_cfg are not both given gets a message that says so.

AssetRegistry.get_asset_definition() returns a registered rigid
object's name and a copy of its spawn configuration.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
ChoiceSampler.sample takes a keyword-only start_index. With it, the
sampler returns the choices in order from that index, wrapping
around, instead of drawing at random. Rows from a replay sampler
still come first and are checked against the choices, and listeners
receive the result as before.

AssetSelectionVariation, added in a later commit, takes its in-order
candidate this way by build seed, so that pick is recorded and
replayed like a random draw.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Asset.add_variation calls the variation's attach_to_asset hook before
it stores the variation. VariationBase's hook accepts any asset and
keeps nothing. A variation overrides it to reject an asset it cannot
act on, or to keep the asset. During the call, asset.get_variations()
does not list the variation yet, and an asset that fails the check
does not get it.

AssetSelectionVariation, added next, overrides the hook to check its
Object and keep it.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
AssetSelectionVariation gives a rigid Object one of several candidate
spawn configurations per build, the same in every environment. With
random_choice off, a build takes asset_names[seed % n], so consecutive
build seeds step through the names; the variation keeps the seed that
configure_at_build_time receives for this. With random_choice on, it
draws from its sampler's generator, which configure_at_build_time
seeds from the build seed and the variation key. Both draws go
through the ChoiceSampler, so the recorder writes the chosen name in
every episode row and recorded variation replay returns it.

Its attach_to_asset hook rejects a RigidObjectSet, a non-rigid
Object, an Object with a bounding_box override, a second selection
on one Object and one selection added to two Objects, and keeps the
Object it writes the selected spawn configuration into. Unknown or
repeated asset_names are rejected at construction and at every
override.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
A recorded variation replay file can hold placement poses and no
value for an enabled AssetSelectionVariation, for example a layout
file written by write_placement_samples. Replay then leaves the
selection to draw live, so the recorded poses, solved for the asset
of the recording build, can be applied to another candidate.

compose_manager_cfg now asserts, right after the replay file is
loaded and before any build-time draw, that such a file also holds
the selection's value. The message names the variation key.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Add an "Asset selection" section and a table row to the variations
page. The section shows how to declare candidates, the three
configuration fields, in-order and random selection by build seed,
an experiment with three rebuilds, recording and replay, and the
rules and limits.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Describe Asset.add_variation without naming its callers, and say why
AssetSelectionVariation can keep its Object as a plain attribute.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Rename the local list of candidate names to names_in_use, because it
falls back to every candidate when asset_names is empty. Name
self.sampler.sample() as the call that reports the name to the
variation recorder and returns the recorded name during replay.

State which name a build takes in the random_choice docstring, and
what the Object kept by attach_to_asset is for. Replace the
configure_at_build_time docstring with the reason for the override,
and the comment above self._object with the cycle it avoids.

Write TaskBase.get_scene_cfg as a rule for implementers instead of
a fact about every task.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
The AssetSelectionVariation assert messages now name the fix, not
only the problem. A malformed candidate is named by its index
instead of printing the whole spawn configuration.

Object._assert_has_asset no longer assumes a selection was added:
its message says to add one and enable it.

The placement replay check offered disabling the selection for any
object declared with asset=. That is right only if the recorded
poses were solved for the asset= default, so the message now offers
it only when the poses were recorded with the selection disabled.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Keep what an environment or experiment author needs: how to declare
candidates, objects with and without asset=, which name a build
takes, an experiment that takes each candidate once, and that the
selection belongs on a plain Object.

Drop the rules that an assert message already reports when they are
broken, and the record and replay details that
experiment_record_replay.rst states for every build-time variation.

Move the two unchecked limits, a later build starting from the
selected asset and Scene.export_to_usd or an ObjectReference reading
the declared usd_path, to the AssetSelectionVariation docstring.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Object(asset=) and the AssetSelectionVariation candidate loop each
checked a (name, spawn configuration) pair with their own assert.
Both now call assert_asset_definition() in
asset_selection_variation.py, which asserts a 2-tuple, a non-empty
name and one SpawnerCfg that is not a MultiAssetSpawnerCfg or
MultiUsdFileCfg. Each message starts with the receiver, such as
"Object 'pickup' asset=" or "AssetSelectionVariation
'asset_selection' candidate 0". The candidate loop keeps only its
duplicate-name check on top.

AssetRegistry.get_asset_definition() keeps the Object and rigid
checks and drops the RigidObjectSet, bounding_box and multi-spawner
asserts. No registered rigid object can trigger them, and both
consumers of the pair reject a multi-spawner configuration.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
AssetSelectionVariation rejected an Object's bounding_box override in
attach_to_asset, when add_variation ran. An override set after that
went unchecked, and placement then used it for every candidate.

_realize_at_build_time now asserts that the Object has no
bounding_box override before it draws a name, so the check sees the
Object as the build uses it. The message says to set bounding_box to
None. The test case sets the override after add_variation and
composes a build.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
One condition, "asset is not None or (usd_path is None and
spawner_cfg is None)", covered both declarations, and its first
assert could fail only for asset=. The asset= check now has its own
block, and the block for an Object without usd_path or spawner_cfg
holds the rigid assert, the scale and spawn_cfg_addon assert with the
comment that explains it, and the copy of the asset= spawn
configuration. Same behavior.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Asset.add_variation() does the attaching; the hook only checks or
keeps the asset. "attach" also names VariationRecorder.attach(),
which does something else. Rename the hook in VariationBase,
Asset.add_variation(), AssetSelectionVariation and its test, and say
in the base docstring that it checks or keeps the asset that is
adding the variation.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
PickAndPlaceTask builds its description from the object's name when
the task is built, before any selection, so a language-conditioned
policy is told "Pick up the pickup, ..." for every candidate. Say so
on the variations page, and say to pin one name per run with
asset_names and set environment_builder.language_instruction. Making
the description follow the selection is a follow-up.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Signed-off-by: Clemens Volk <cvolk@nvidia.com>
AssetRegistry.get_asset_definition() returns a registered rigid
object's name and a copy of its spawn configuration. Rename it to
get_named_spawn_cfg(), and the helper assert_asset_definition() to
assert_named_spawn_cfg(). Update the callers, the test, the assert
messages and the variations page, and shorten the registry
docstring.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
One assert now rejects more than one of usd_path, spawner_cfg and
asset, with one message. The block for an Object without usd_path or
spawner_cfg keeps the rigid assert and the scale and spawn_cfg_addon
assert, and a separate asset= block checks the named spawn
configuration and copies it into spawner_cfg. Same behavior apart
from the merged message. The class docstring now says that a rigid
Object can leave its asset open, or give a default with asset, and
let an AssetSelectionVariation choose it.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
TaskBase.get_scene_cfg() keeps only its one-line summary. The
AssetSelectionVariation docstring now says what the variation does,
that scene export and ObjectReference fail for an Object declared
without a usd_path, and what each argument is.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
get_spawned_asset() returned the object itself or the selected asset,
which read as if an object only sometimes had an asset. Every object
now holds its spawned asset from construction, the object itself
until an asset selection replaces it, and get_spawned_asset() returns
it.

The object still plays two roles, its place in the scene and the
asset it spawns, which is why a selection cannot replace scale,
spawn_cfg_addon or the class's methods. A TODO notes the separation.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
cvolkcvolk added a commit that referenced this pull request Oct 25, 2026
Signed-off-by: Clemens Volk <cvolk@nvidia.com>
The PR body lists what an asset selection does not replace, and the
follow-up is tracked outside the code.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
cvolkcvolk added a commit that referenced this pull request Oct 25, 2026
Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Scene.export_to_usd() referenced the declared asset's USD file and
scale, so after an asset selection the exported scene showed the
declared asset. Read both from the spawned asset. The prim keeps the
object's name and pose.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
cvolkcvolk added a commit that referenced this pull request Oct 25, 2026
Signed-off-by: Clemens Volk <cvolk@nvidia.com>
cvolkcvolk added a commit that referenced this pull request Oct 25, 2026
Add `SequentialSampler`, a sampler that returns consecutive items of a
list from a given start index, starting over after the last item.

## Why this change?

The samplers in `isaaclab_arena/variations` draw their values at random.
`ChoiceSampler` picks a random item of a list. Asset selection
([#1458](#1458)) also
needs to take a list in order, so that rebuild k of an Experiment Run
spawns the k-th asset. Taking the item through a sampler keeps it
recorded and replayed like any other variation sample.

## What changes?

- New `SequentialSampler` and `SequentialSamplerCfg` in
`isaaclab_arena/variations/sequential_sampler.py`. `sample(num_samples,
choices, start_index=...)` returns `num_samples` consecutive items from
`start_index`, starting over after the last item. The sampler keeps no
state, so the result depends only on the arguments.
- Like `ChoiceSampler`, it returns replayed rows when a replay sampler
supplies them, checks that they belong to `choices`, and notifies
listeners. It draws no random numbers, so the generator does not affect
it.

## Usage example

```python
sampler = SequentialSamplerCfg().build()
registry_name = sampler.sample(1, ["cracker_box", "sugar_box", "mustard_bottle"], start_index=rebuild_index)[0]
```

## Validation

- `pre-commit` passes on the changed files.
- The sampler tests in `test_recorded_variation_samples.py` and
`test_variation_recorder.py` pass in the local container on #1458's
branch, which has the same three files (at 9a2955f).

---------

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Comment thread isaaclab_arena/assets/object.py Resolved
Signed-off-by: Clemens Volk <cvolk@nvidia.com>
@cvolkcvolk
cvolkcvolk changed the base branch from cvolkcvolk/feature/sequential-sampler to main October 25, 2026 22:22
cvolkcvolk added a commit that referenced this pull request Oct 25, 2026
Signed-off-by: Clemens Volk <cvolk@nvidia.com>

@qianl-nv qianl-nv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for keep the changes very well organized!
Added some suggestions for doc/API updates.

This PR also opens up opportunity for further codebase hygiene such as migrating the object swap CLIs to use the asset selection variation (wondering if this was part of the "full hydra config" conversion plan to replace legacy CLI), and potentially extending asset selection beyond rigid object, but those are better left for follow up PRs.

Comment thread isaaclab_arena/assets/object.py Resolved
RigidObjectSet is a rigid Object, so Object.__init__ gave it an
asset_selection variation. Enabling it replaced the set's spawn
config with one asset: a set with several members then failed with a
TypeError during placement, and otherwise placement used the members'
bounds. The set now removes the variation, so --list_variations no
longer offers it and an override on it fails with the list of valid
variation paths.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Replaying recorded placement requires every enabled asset selection to
be recorded too. The replay check found asset selections by their
class, so the next variation that changes geometry, such as an object
scale, would have needed another isinstance check. A build-time
variation now sets changes_object_geometry, and the check reads it.
The flag sits on BuildTimeVariationBase because only build-time
variations change what a build spawns, and a run-time variation's
value is never among the recorded build-time samples.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Every build constructed each listed name so that a wrong name failed
in the first build, though it spawned only one of them. Each build now
checks every name without constructing it: the name must be
registered, and its class must not declare another object type. Only
the selected name is constructed. A name whose type is known only
after construction, such as an embodiment, now fails in the rebuild
that selects it.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
AssetSelectionVariationCfg had two fields for one decision:
random_choice and sampler_cfg. apply_cfg() replaced sampler_cfg from
random_choice, so a sampler_cfg passed in was silently dropped. Every
other variation keeps its sampler settings inside sampler_cfg, whose
type fixes the sampler. random_choice now lives in
AssetSelectionSamplerCfg, which builds a SequentialSampler or a
ChoiceSampler, so the apply_cfg() override and the check that the
sampler matches random_choice go away. In a Run, the setting is now
`<object>.asset_selection.sampler_cfg.random_choice`.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
cvolkcvolk added a commit that referenced this pull request Oct 26, 2026
Signed-off-by: Clemens Volk <cvolk@nvidia.com>
cvolkcvolk added a commit that referenced this pull request Oct 26, 2026
#1458 moved random_choice into AssetSelectionSamplerCfg, so the
warning reads variation.cfg.sampler_cfg.random_choice and names that
path in its message.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
Object kept a reference to itself in _spawned_asset until a selection
replaced it. _selected_asset now starts as None, and
get_spawned_asset() returns the object itself when nothing is
selected, so callers get the same asset as before.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
The variation supports only rigid objects, so the class, its cfg, its
module and its test file now say so. The variation key stays
asset_selection, so YAML overrides and recorded episode rows do not
change, and AssetSelectionSamplerCfg keeps its name because it only
picks a registry name.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
The asset selection example was a separate experiment. It is now the
multiple_pick_up_objects Run of getting_started_experiment.yaml, next
to swap_objects, so the first Arena Experiment page shows it and the
variations docs include it from there. asset_selection_experiment.yaml
is removed.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
The getting-started Experiment had a fifth Run for asset selection next
to swap_objects. swap_objects now selects its pick-up object from a
mustard bottle, an orange and a Rubik's cube, one per build, and keeps
the wooden bowl as an environment option, so the Experiment is back to
four Runs.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
The variations page had a separate "Asset selection" section, though no
other variation has one. The in-order rule and the reason
RigidObjectSet is not a variation move next to the build-time and
run-time explanation, the table row says how names are picked and
links to the getting-started Run, and the class docstring takes the
remaining details.

Signed-off-by: Clemens Volk <cvolk@nvidia.com>
@cvolkcvolk
cvolkcvolk merged commit 80b4823 into main Oct 26, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants