Repository navigation
Make an object's asset a repeatable variation - #1458
Merged
Merged
Conversation
cvolkcvolk
force-pushed
the
cvolkcvolk/feature/asset-selection-per-build
branch
from
October 16, 2026 10:16
ec0cddc to
70fe37d
Compare
cvolkcvolk
changed the base branch from
cvolkcvolk/feature/variation-build-context
to
cvolkcvolk/feature/seed-build-time-variations
October 16, 2026 10:16
cvolkcvolk
force-pushed
the
cvolkcvolk/feature/asset-selection-per-build
branch
4 times, most recently
from
October 19, 2026 14:31
7cab19c to
4aa0b8c
Compare
cvolkcvolk
commented
Oct 19, 2026
cvolkcvolk
left a comment
Collaborator
Author
There was a problem hiding this comment.
quick pass self review
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>
xyao-nv
reviewed
Oct 25, 2026
Signed-off-by: Clemens Volk <cvolk@nvidia.com>
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>
xyao-nv
reviewed
Oct 25, 2026
xyao-nv
reviewed
Oct 25, 2026
xyao-nv
reviewed
Oct 25, 2026
xyao-nv
reviewed
Oct 25, 2026
qianl-nv
approved these changes
Oct 26, 2026
qianl-nv
left a comment
Collaborator
There was a problem hiding this comment.
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.
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a disabled
asset_selectionvariation to every rigidObject, 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 thepick_and_place_maple_tableobjectspick_up_objectanddestination_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.RigidObjectSetvaries objects across the environments of one build, but it does not record which object an environment got, andsupports_recorded_placement()turns off placement recording for a build that contains one.What changes?
Objectexcept aRigidObjectSetgets a disabledasset_selectionvariation, aRigidAssetSelectionVariation. When enabled, each build spawns one of itsregistry_namesin all environments. Rebuild k takes the k-th name, usingSequentialSamplerfrom Add SequentialSampler #1517, or a random one withsampler_cfg.random_choice: true. A name listed twice is selected more often. Each build checks every name but constructs only the selected one.changes_object_geometryflag, whichRigidAssetSelectionVariationdoes.registry_name, and the default descriptions ofPickAndPlaceTaskandAssemblyTaskname it.Scene.validate_simulation_cfg()runs the check of the asset a selection spawns, through the newAsset.get_spawned_asset(). A selected Newton-only gear fails a PhysX build, and a declared gear that selects a PhysX asset passes one.ArenaEnvBuilder. A warning for in-order selections with fewer rebuilds than names follows in Warn when in-order asset selection skips names #1520.swap_objectsRun ofgetting_started_experiment.yamlselects 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,ObjectInTaskandSortMultiObjectTaskbuild their contact sensors inget_scene_cfg().scene_config,make_scene_cfg()andSortMultiObjectTask.pick_up_object_contact_sensor_listare removed.PickAndPlaceTask.task_descriptionandAssemblyTask.task_descriptionhold only a description passed to the constructor. Callget_task_description()for the generated one.pick_and_place_maple_tableobject 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.configure_at_build_time(seed, variation_key)must also acceptrebuild_index, becauseArenaEnvBuildernow passes it.Limitations:
registry_namechange. The object keeps its declared class'sscale,spawn_cfg_addonand other methods.record_demos.py, every build is rebuild 0, so in-order selection spawns the first name.GearInsertionTaskandPlaceUprightTaskstill name the declared asset, and aSimReadyUsdObjectis described assimready_usd_object.pick_up_object.asset_selectionfor per-object results.language_instructionapplies to every rebuild.bounding_boxoverride fails the build when the selection is enabled.ObjectReferenceinto a selected object still reads the declared asset'susd_path.Usage example
Before, one Run per object:
The object is set outside the variation system, so:
variationsand recorded variation replay do not cover it;After, one Run that spawns another object in each rebuild (the
swap_objectsRun ofgetting_started_experiment.yaml, which takes the rest of the environment fromshared):Set
pick_up_object.asset_selection.sampler_cfg.random_choice: trueto draw a name at random in each build instead.Validation
test_recorded_variation_samples.py.test_run_execution.py,test_recorded_variation_samples.pyandtest_variation_base.py.