diff --git a/docs/pages/concepts/environment/environment_definition.rst b/docs/pages/concepts/environment/environment_definition.rst index 2fa8edfbe33..b40645ee74c 100644 --- a/docs/pages/concepts/environment/environment_definition.rst +++ b/docs/pages/concepts/environment/environment_definition.rst @@ -358,13 +358,12 @@ in ``params`` → ``OpenableObjectReference`` (and ``object_type: articulation`` otherwise → ``ObjectReference``. Python: you pick. Use the plain class for a door and you get a door with nothing to open. -**Object set members.** YAML constructs set members with no constructor args, so -they cannot carry a ``usd_path``. SimReady assets fail at load time and cannot be -set members. Python ``PerEnvironmentObject`` takes live instances — SimReady is fine: - -.. code-block:: python - - PerEnvironmentObject(name="bottles", objects=[simready_bottle, ycb_bottle]) +**Per-environment objects.** Declare concrete assets under ``objects`` and +``PerEnvironmentObject`` entries under ``per_environment_objects``. Each member +of an entry's ``objects`` list accepts its own ``params``, including a SimReady +``usd_path`` or scale. Relations and tasks reference the entry's ``id`` regardless +of which asset an environment receives. See :doc:`../scene/concept_object_variants` +for Python and YAML examples. ``object_sets`` is no longer a graph field. How to spawn an environment --------------------------- diff --git a/docs/pages/concepts/scene/concept_object_variants.rst b/docs/pages/concepts/scene/concept_object_variants.rst index 5a2100085bb..f747b12e44e 100644 --- a/docs/pages/concepts/scene/concept_object_variants.rst +++ b/docs/pages/concepts/scene/concept_object_variants.rst @@ -35,24 +35,26 @@ Declare the alternatives .. tab-item:: YAML - The YAML schema still uses ``object_sets`` and constructs a - ``PerEnvironmentObject`` for each entry: + Declare ordinary assets under ``objects`` and ``PerEnvironmentObject`` + entries under ``per_environment_objects``: .. code-block:: yaml objects: - id: bowl registry_name: bowl_ycb_robolab - object_sets: + per_environment_objects: - id: fruit - members: - - banana_ycb_robolab - - orange_01_fruits_veggies_robolab - random_choice: false - - Relations and tasks reference ``fruit``. ``random_choice: false`` selects - sequential assignment; ``true`` selects random assignment. Members use - their library defaults; per-member constructor parameters are not supported. + objects: + - registry_name: banana_ycb_robolab + - registry_name: orange_01_fruits_veggies_robolab + params: + scale: [0.8, 0.8, 0.8] + assign_to_environments: sequential + + Relations and tasks reference ``fruit``. Entry-level ``params`` configure + its initial pose; member ``params`` configure individual assets, including + scale or a SimReady ``usd_path``. The former ``object_sets`` section is rejected. Assign assets to environments ----------------------------- diff --git a/docs/pages/example_workflows/agentic_env_gen/tabletop_pnp_heterogeneous_object/index.rst b/docs/pages/example_workflows/agentic_env_gen/tabletop_pnp_heterogeneous_object/index.rst index 747cc5f5818..9175b93c0a3 100644 --- a/docs/pages/example_workflows/agentic_env_gen/tabletop_pnp_heterogeneous_object/index.rst +++ b/docs/pages/example_workflows/agentic_env_gen/tabletop_pnp_heterogeneous_object/index.rst @@ -20,8 +20,8 @@ on the table. The scene is *heterogeneous* because each parallel environment spawns a different fruit, while the embodiment, background scene, spatial relationships -and task stay the same. The fruit is declared as an **object set**: a group of -interchangeable assets under a single id, distributed one member per +and task stay the same. The fruit is declared as a ``PerEnvironmentObject``: +interchangeable assets under a single id, distributed one asset per environment. Running with ``--num_envs 1`` shows a single fruit, so raise ``--num_envs`` to see the variation. diff --git a/docs/pages/example_workflows/agentic_env_gen/tabletop_pnp_heterogeneous_object/step_1_launch_runner.rst b/docs/pages/example_workflows/agentic_env_gen/tabletop_pnp_heterogeneous_object/step_1_launch_runner.rst index c1968ea6b33..6df43c98536 100644 --- a/docs/pages/example_workflows/agentic_env_gen/tabletop_pnp_heterogeneous_object/step_1_launch_runner.rst +++ b/docs/pages/example_workflows/agentic_env_gen/tabletop_pnp_heterogeneous_object/step_1_launch_runner.rst @@ -12,8 +12,8 @@ The agent runs in two modes: Use it for scripted or batch generation. Describe the object to pick up as a category rather than as a single asset, and -say that it varies across environments. That is the cue for the agent to emit an -``object_sets`` entry instead of a fixed ``objects`` entry. +say that it varies across environments. That is the cue for the agent to emit a +``per_environment_objects`` entry whose ``objects`` list names the alternatives. .. tab-set:: @@ -34,8 +34,8 @@ say that it varies across environments. That is the cue for the agent to emit an Each environment should get a different fruit. The returned YAML is loaded into the editor and assets are rendered on the right side of the editor. - An object set is drawn as a single node, with a thumbnail per member, so you can - check the whole set at a glance. + A per-environment object is drawn as a single node, with a thumbnail per member, so you can + check all alternatives at a glance. .. figure:: ../../../../images/agentic_environment_generation/tabletop_agentic_env_fruits_gui.png :width: 100% diff --git a/docs/pages/example_workflows/agentic_env_gen/tabletop_pnp_heterogeneous_object/step_2_edit_environment_graph_spec.rst b/docs/pages/example_workflows/agentic_env_gen/tabletop_pnp_heterogeneous_object/step_2_edit_environment_graph_spec.rst index 1c148e86d3a..7b2f35675d0 100644 --- a/docs/pages/example_workflows/agentic_env_gen/tabletop_pnp_heterogeneous_object/step_2_edit_environment_graph_spec.rst +++ b/docs/pages/example_workflows/agentic_env_gen/tabletop_pnp_heterogeneous_object/step_2_edit_environment_graph_spec.rst @@ -5,7 +5,7 @@ Review the spec before building the environment. The agent infers it from the pr LLM, so what comes back is non-deterministic: the same prompt can return a different spec on the next run, and a spec that validates can still be mistaken in its choices. See :doc:`../../../concepts/agentic_environment_generation/model_selection` for more details. -For an object set, check that the members are the assets you expected as those are added based on semantic similarity by the agent. +For a ``PerEnvironmentObject``, check that the alternatives match the assets you intended. Understanding the YAML ^^^^^^^^^^^^^^^^^^^^^^ @@ -23,24 +23,24 @@ The generated spec has one block per part of the environment graph: id: maple_table registry_name: maple_table_robolab params: {} - objects: # one entry per fixed asset in the scene + objects: # concrete assets used in every environment - id: bowl # the placement destination registry_name: bowl_ycb_robolab params: {} - object_sets: # the heterogeneous object + per_environment_objects: # assets that can differ between environments - id: fruit - members: # every environment spawns one of these - - apple_01_objaverse_robolab - - apple_02_objaverse_robolab - - avocado01_fruits_veggies_robolab - - lemon_01_fruits_veggies_robolab - - lemon_02_fruits_veggies_robolab - - lime01_fruits_veggies_robolab - - orange_01_fruits_veggies_robolab - - orange_02_fruits_veggies_robolab - - pomegranate01_fruits_veggies_robolab - - lychee01_fruits_veggies_robolab - random_choice: true # each env samples its member independently + objects: # every environment spawns one of these + - registry_name: apple_01_objaverse_robolab + - registry_name: apple_02_objaverse_robolab + - registry_name: avocado01_fruits_veggies_robolab + - registry_name: lemon_01_fruits_veggies_robolab + - registry_name: lemon_02_fruits_veggies_robolab + - registry_name: lime01_fruits_veggies_robolab + - registry_name: orange_01_fruits_veggies_robolab + - registry_name: orange_02_fruits_veggies_robolab + - registry_name: pomegranate01_fruits_veggies_robolab + - registry_name: lychee01_fruits_veggies_robolab + assign_to_environments: random # each env samples independently params: {} relations: # spatial constraints solved at build time - kind: is_anchor @@ -51,7 +51,7 @@ The generated spec has one block per part of the environment graph: reference: maple_table params: {} - kind: 'on' - subject: fruit # a set is referenced by id, like an object + subject: fruit # the object role is referenced by id reference: maple_table params: {} task: @@ -61,11 +61,11 @@ The generated spec has one block per part of the environment graph: subtasks: - kind: PickAndPlaceTask params: - pick_up_object: fruit # the set id, so the task follows whichever member spawned + pick_up_object: fruit # the object id, whichever member spawned destination_location: bowl background_scene: maple_table -An object set is referenced by its ``id`` exactly like an object — in the +A ``PerEnvironmentObject`` is referenced by its ``id`` in the ``relations`` that place it and in the ``task`` params that name the target. The rest of the graph is written once and stays valid whichever member an environment spawns. @@ -73,39 +73,41 @@ environment spawns. For more details on the Env Spec, see :doc:`Environment Definition <../../../concepts/environment/environment_definition>`. -Editing the object set -^^^^^^^^^^^^^^^^^^^^^^ +Editing per-environment objects +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Widening or narrowing the variation is a one-block edit — ``members`` and -``random_choice`` — that leaves the relations and the task untouched. For the -asset concept behind object sets, see +Edit a ``per_environment_objects`` entry's ``objects`` list and +``assign_to_environments`` to change which assets appear across environments. +The relations and task continue to refer to the same ``id``. +For the ``PerEnvironmentObject`` concept, see :doc:`../../../concepts/scene/concept_object_variants`. -#. Add or remove a member to change which assets the environments draw from. - Members are registered rigid-object names from the Arena asset catalog: +#. Add or remove an ``objects`` member to change which assets the environments draw from. + Members name registered rigid objects from the Arena asset catalog: .. code-block:: yaml + per_environment_objects: - id: fruit - members: - - apple_01_objaverse_robolab - - banana_ycb_robolab - random_choice: true + objects: + - registry_name: apple_01_objaverse_robolab + - registry_name: banana_ycb_robolab + assign_to_environments: random params: {} -#. Set ``random_choice`` to choose how members map to environments. With ``true`` each environment samples its - member independently; with ``false``, it follows the declared member order across environments. +#. Set ``assign_to_environments`` to choose how members map to environments. + ``random`` samples independently, with possible repeats; ``sequential`` cycles + through the declared order. Assignment stays fixed across resets. .. code-block:: yaml - random_choice: false + assign_to_environments: sequential .. note:: - A SimReady searched asset cannot be an object-set member, because a member - has nowhere to carry the ``usd_path`` it needs. Use it as an entry under - ``objects`` instead, as in :doc:`../tabletop_pnp_composite_task/index`. + Each member accepts its own ``params``. A searched SimReady asset uses + ``registry_name: simready_usd_object`` with its ``usd_path`` under ``params``. Applying your edits ^^^^^^^^^^^^^^^^^^^ @@ -123,7 +125,7 @@ Applying your edits #. Click **Save to .yaml** to write the spec to ``.yaml`` in the output directory. Set the number of parallel environments in the sim preview controls to more than - one to see the members spread across environments. + one to see the assets distributed across environments. See :doc:`../../../concepts/agentic_environment_generation/gui_runner` for the full UI walkthrough. diff --git a/docs/pages/references/release_notes.rst b/docs/pages/references/release_notes.rst index 47c55adf604..3828d0e1ca7 100644 --- a/docs/pages/references/release_notes.rst +++ b/docs/pages/references/release_notes.rst @@ -4,11 +4,15 @@ Release Notes Unreleased ---------- -- Replaced the Python ``RigidObjectSet`` API with ``PerEnvironmentObject``. - ``assign_to_environments="sequential"`` cycles through the declared objects; - ``"random"`` samples independently. Python environment selection now uses - ``--object_variants`` instead of ``--object_set``. YAML still accepts - ``object_sets`` and translates its ``random_choice`` setting. +- Replaced ``RigidObjectSet`` with ``PerEnvironmentObject``, backed by Isaac Lab native + multi-asset spawning. ``Object`` continues to use one asset across environments. + Scene assignment is shared with placement, per-variant scale stays native, and + USD hierarchy preparation is isolated from scene objects. +- Environment YAML now separates concrete ``objects`` from + ``per_environment_objects``. Each per-environment entry declares an ``objects`` + list with constructor parameters for each member, including SimReady USD paths. + The ``object_sets`` field has been removed. Python environment selection now + uses ``--object_variants`` instead of ``--object_set``. v0.3.1 ------- diff --git a/isaaclab_arena/agentic_environment_generation/catalogues.py b/isaaclab_arena/agentic_environment_generation/catalogues.py index 3b379485801..1e09acd5d58 100644 --- a/isaaclab_arena/agentic_environment_generation/catalogues.py +++ b/isaaclab_arena/agentic_environment_generation/catalogues.py @@ -77,7 +77,7 @@ def build_asset_catalogue(registry: AssetRegistry | None = None) -> AssetCatalog catalogue.backgrounds.append({"name": name, "tags": [t for t in tags if t != "background"]}) # Only assets existed in the catalogue are exposed. elif "object" in tags: - # Exposed so the agent can honour type constraints, e.g. object-set members must be rigid. + # Exposed so the agent can require rigid members for per-environment objects. object_type = getattr(cls, "object_type", None) catalogue.objects.append({ "name": name, diff --git a/isaaclab_arena/agentic_environment_generation/environment_generation_agent.py b/isaaclab_arena/agentic_environment_generation/environment_generation_agent.py index 4f4ab4a51a6..0edee7d08dc 100644 --- a/isaaclab_arena/agentic_environment_generation/environment_generation_agent.py +++ b/isaaclab_arena/agentic_environment_generation/environment_generation_agent.py @@ -155,37 +155,19 @@ def generate_spec( if resolved is None: return None, spec.to_dict() spec = resolved - unusable = self._add_simready_usd_path_to_searched_objects(spec) - if unusable is not None: - self._traces.append(unusable) - return None, spec.to_dict() + self._add_simready_usd_path_to_searched_objects(spec) return spec, None - def _add_simready_usd_path_to_searched_objects(self, spec: ArenaEnvGraphSpec) -> str | None: - """Point the spec's searched objects at the generic SimReady asset, USD path in params. - - A search name only exists in the process that searched, so a spec keeping it loads nowhere else. - - Args: - spec: Generated spec, rewritten in place. - - Returns: - An error message, or None when every searched object was rewritten. - """ - # TODO(xinjieyao, 2026-08-03): Lift this once ObjectSetSpec.members can carry a usd_path. - for object_set in spec.object_sets or []: - searched_members = [name for name in object_set.members if name in self._simready_usd_paths] - if searched_members: - return ( - f"Object set '{object_set.id}' has searched SimReady members {searched_members}." - " Members have nowhere to carry a usd_path; use them as objects instead." - ) - for obj in spec.objects: - usd_path = self._simready_usd_paths.get(obj.registry_name) + def _add_simready_usd_path_to_searched_objects(self, spec: ArenaEnvGraphSpec) -> None: + """Replace searched names with portable SimReady references in both object sections.""" + object_sources = list(spec.objects) + for obj in spec.per_environment_objects: + object_sources.extend(obj.objects) + for source in object_sources: + usd_path = self._simready_usd_paths.get(source.registry_name) if usd_path is not None: - obj.registry_name = SIMREADY_USD_OBJECT_REGISTRY_NAME - obj.params = {**obj.params, "usd_path": usd_path} - return None + source.registry_name = SIMREADY_USD_OBJECT_REGISTRY_NAME + source.params = {**source.params, "usd_path": usd_path} def _extend_catalogue_with_simready(self, prompt: str, asset_catalog: AssetCatalogue) -> AssetCatalogue: """Search SimReady for the objects the catalog misses, and add what it finds to the catalog. diff --git a/isaaclab_arena/agentic_environment_generation/spec_inference.py b/isaaclab_arena/agentic_environment_generation/spec_inference.py index f264bf1e430..1c5f1da6b8c 100644 --- a/isaaclab_arena/agentic_environment_generation/spec_inference.py +++ b/isaaclab_arena/agentic_environment_generation/spec_inference.py @@ -145,7 +145,8 @@ def _system_prompt() -> str: - Follow the per-field ``description`` strings in the schema. - REQUIRED: leave ``placer_params`` and ``cli_override_specs`` null. - Use only exact names from the catalog for ``registry_name``: - EMBODIMENTS for ``embodiment``, BACKGROUNDS for ``background``, and OBJECTS for ``objects``. + EMBODIMENTS for ``embodiment``, BACKGROUNDS for ``background``, and OBJECTS for + ``objects`` and members of ``per_environment_objects``. - Do NOT hallucinate asset names — every ``registry_name`` must appear verbatim in the catalog. If the prompt includes the exact registry name, use it. If no reasonable match can be found, return empty string. @@ -154,8 +155,12 @@ def _system_prompt() -> str: variance of that family in EMBODIMENTS, pick the one with the default tag. - For multiple instances of the same registry asset, use semantic (left/right) or numerical (1/2/3) suffixes in ``id``. -- Use ``object_sets`` only when one object varies across environments; list its variants as ``members``. - Every member must be an OBJECTS entry marked ``type=rigid``. +- Put objects using the same asset in every environment under ``objects``, each with a ``registry_name``. +- When an object varies across environments, declare it under ``per_environment_objects`` with a shared + ``id`` and an ``objects`` list. Each member has its own ``registry_name`` and optional ``params``; + every member must be an OBJECTS entry marked ``type=rigid``. + ``assign_to_environments`` is "sequential" by default; use "random" for independent sampling. + Relations and task params reference the parent ``id``, not individual members. - An ``object_reference`` names a prim inside the background. Add one for every surface or appliance the prompt names that the background merely contains — the floor the robot stands on, a counter top, a sink, a fridge, a microwave. Name it after the appliance or surface itself, never after the moving diff --git a/isaaclab_arena/agentic_environment_generation/spec_validation.py b/isaaclab_arena/agentic_environment_generation/spec_validation.py index 5845e48820b..73cdd2934c4 100644 --- a/isaaclab_arena/agentic_environment_generation/spec_validation.py +++ b/isaaclab_arena/agentic_environment_generation/spec_validation.py @@ -61,17 +61,13 @@ def collect_agent_ready_validation_trace( traces.append(f"Embodiment registry_name {spec.embodiment.registry_name!r} is not in the EMBODIMENTS catalog") if spec.background.registry_name not in asset_names["BACKGROUNDS"]: traces.append(f"Background registry_name {spec.background.registry_name!r} is not in the BACKGROUNDS catalog") - # Each movable object must resolve to a known OBJECTS entry. - for obj in spec.objects: - if obj.registry_name not in asset_names["OBJECTS"]: - traces.append(f"Object {obj.id!r} registry_name {obj.registry_name!r} is not in the OBJECTS catalog") - # Object-set members are registry names too; validate each one the same way. - for object_set in spec.object_sets or []: - for member in object_set.members: - if member not in asset_names["OBJECTS"]: - traces.append( - f"Object set {object_set.id!r} member registry_name {member!r} is not in the OBJECTS catalog" - ) + # Fixed objects and every alternative must appear in the OBJECTS catalogue. + object_sources = [(obj.id, obj) for obj in spec.objects] + for obj in spec.per_environment_objects: + object_sources.extend((obj.id, member) for member in obj.objects) + for object_id, source in object_sources: + if source.registry_name not in asset_names["OBJECTS"]: + traces.append(f"Object {object_id!r} registry_name {source.registry_name!r} is not in the OBJECTS catalog") # Check each subtask kind and its params against the task catalogue. task_entries = {entry.name: entry for entry in task_catalog.tasks} diff --git a/isaaclab_arena/environment_spec/arena_env_graph_conversion_utils.py b/isaaclab_arena/environment_spec/arena_env_graph_conversion_utils.py index e278631a62e..6a70726d24e 100644 --- a/isaaclab_arena/environment_spec/arena_env_graph_conversion_utils.py +++ b/isaaclab_arena/environment_spec/arena_env_graph_conversion_utils.py @@ -122,7 +122,7 @@ def _scene_already_has_light(graph_spec: ArenaEnvGraphSpec, assets_by_node_id: d """Return whether the scene is already lit, either explicitly or via a baked-in USD light.""" if any("light" in (getattr(asset, "tags", None) or []) for asset in assets_by_node_id.values()): return True - for asset_spec in [graph_spec.background, *graph_spec.objects]: + for asset_spec in [graph_spec.background, *graph_spec.objects, *graph_spec.per_environment_objects]: asset = assets_by_node_id[asset_spec.id] usd_path = getattr(getattr(asset, "spawn_cfg", None), "usd_path", None) if isinstance(usd_path, str) and usd_path: @@ -187,13 +187,18 @@ def instantiate_assets_from_spec( params.setdefault("instance_name", obj.id) assets_by_node_id[obj.id] = asset_registry.get_asset_by_name(obj.registry_name)(**params) - # TODO(migration): Replace object_sets with per_environment_objects when migrating the YAML schema. - for object_set in graph_spec.object_sets or []: - assets_by_node_id[object_set.id] = PerEnvironmentObject( - name=object_set.id, - objects=[asset_registry.get_asset_by_name(registry_name)() for registry_name in object_set.members], - assign_to_environments="random" if object_set.random_choice else "sequential", - **parse_asset_params(object_set.params), + for obj in graph_spec.per_environment_objects: + objects = [] + for member_spec in obj.objects: + member = asset_registry.get_asset_by_name(member_spec.registry_name)( + **parse_asset_params(member_spec.params) + ) + objects.append(member) + assets_by_node_id[obj.id] = PerEnvironmentObject( + name=obj.id, + objects=objects, + assign_to_environments=obj.assign_to_environments, + **parse_asset_params(obj.params), ) for ref in graph_spec.object_references or []: diff --git a/isaaclab_arena/environment_spec/arena_env_graph_spec.py b/isaaclab_arena/environment_spec/arena_env_graph_spec.py index 853f88f7fcc..523dd186ba8 100644 --- a/isaaclab_arena/environment_spec/arena_env_graph_spec.py +++ b/isaaclab_arena/environment_spec/arena_env_graph_spec.py @@ -16,7 +16,8 @@ CliOverrideSpec, CompositeTaskSpec, ObjectReferenceSpec, - ObjectSetSpec, + ObjectSpec, + PerEnvironmentObjectSpec, SpatialRelationSpec, TaskSpec, ) @@ -35,13 +36,13 @@ class ArenaEnvGraphSpec(BaseModel): env_name: str = Field(min_length=1, description="Short snake_case label summarizing the scene and tasks.") embodiment: AssetSpec = Field(description="The robot that performs the tasks.") background: AssetSpec = Field(description="The static scene the robot and objects sit in.") - objects: list[AssetSpec] = Field(default_factory=list, description="Movable scene objects, including distractors.") - object_sets: list[ObjectSetSpec] | None = Field( - default=None, - description=( - "Optional sets of rigid objects distributed among parallel environments, one object per environment," - " sharing the same task." - ), + objects: list[ObjectSpec] = Field( + default_factory=list, + description="Registered scene objects instanced in every environment.", + ) + per_environment_objects: list[PerEnvironmentObjectSpec] = Field( + default_factory=list, + description="Scene objects with one rigid member assigned to each environment.", ) object_references: list[ObjectReferenceSpec] | None = Field( default=None, description="Optional prims inside the background exposed as assets (e.g. a table surface)." @@ -70,7 +71,7 @@ class ArenaEnvGraphSpec(BaseModel): default=None, description="Optional authoring-time CLI flags that swap an asset's registry_name; usually empty." ) - @field_validator("object_sets", "object_references", "cli_override_specs", mode="before") + @field_validator("object_references", "cli_override_specs", mode="before") @classmethod def _none_if_empty_list(cls, value: Any) -> Any: if value == []: @@ -91,8 +92,10 @@ def _validate_placer_params(cls, value: dict[str, Any] | None) -> dict[str, Any] # TODO(qianl, 2026-09-22): [env-spec-refactor] Set extra="forbid" on ArenaEnvGraphSpec model and remove this. @model_validator(mode="before") @classmethod - def _reject_legacy_placement_validators(cls, value: Any) -> Any: - """Detects the removed yaml key before parsing graph spec.""" + def _reject_removed_fields(cls, value: Any) -> Any: + """Reject removed graph fields before parsing so they cannot be silently ignored.""" + if isinstance(value, dict) and "object_sets" in value: + raise ValueError("object_sets was removed; use per_environment_objects") if isinstance(value, dict) and "placement_validators" in value: raise ValueError("placement_validators was removed; put validator fields under placer_params") return value @@ -102,7 +105,10 @@ def validate(self) -> Self: """Check unique asset ids, cross-references, task params, and CLI overrides.""" known_ids = self._assert_asset_ids_unique() if self.object_references: - valid_parent_ids = {self.background.id, *(obj.id for obj in self.objects)} + valid_parent_ids = { + self.background.id, + *(obj.id for obj in self.objects), + } self._assert_object_reference_parents(self.object_references, valid_parent_ids) self._assert_relation_references(self.relations, known_ids) self._assert_task_param_references(self.task.subtasks, known_ids) @@ -117,8 +123,8 @@ def _assert_asset_ids_unique(self) -> set[str]: self.embodiment.id, self.background.id, *(obj.id for obj in self.objects), - *(object_set.id for object_set in (self.object_sets or [])), - *(ref.id for ref in (self.object_references or [])), + *(obj.id for obj in self.per_environment_objects), + *(ref.id for ref in self.object_references or []), ): if asset_id in seen: duplicates.add(asset_id) @@ -134,7 +140,7 @@ def _assert_object_reference_parents( for ref in object_references: assert ref.parent_id in valid_parent_ids, ( f"Object reference '{ref.id}' references invalid parent '{ref.parent_id}'; " - "parent must be the background or an object id" + "parent must be the background or an id declared under objects" ) @staticmethod @@ -143,12 +149,12 @@ def _assert_relation_references(relations: list[SpatialRelationSpec], known_ids: for index, relation in enumerate(relations): assert relation.subject in known_ids, ( f"Relation[{index}] kind '{relation.kind}' references unknown subject" - f" '{relation.subject}'. Add it to 'objects' or 'object_references'." + f" '{relation.subject}'. Add it to 'objects', 'per_environment_objects', or 'object_references'." ) if relation.reference is not None: assert relation.reference in known_ids, ( f"Relation[{index}] kind '{relation.kind}' references unknown reference" - f" '{relation.reference}'. Add it to 'objects' or 'object_references'." + f" '{relation.reference}'. Add it to 'objects', 'per_environment_objects', or 'object_references'." ) @staticmethod @@ -159,14 +165,14 @@ def _assert_task_param_references(subtasks: list[TaskSpec], known_ids: set[str]) if isinstance(param_value, str): assert param_value in known_ids, ( f"Task '{task.kind}' param '{param_name}' references unknown node" - f" '{param_value}'. Add it to 'objects' or 'object_references'." + f" '{param_value}'. Add it to 'objects', 'per_environment_objects', or 'object_references'." ) def summary(self) -> str: """Return a one-line summary of object, task, and relation counts.""" parts = [f"{len(self.objects)} objects"] - if self.object_sets: - parts.append(f"{len(self.object_sets)} object sets") + if self.per_environment_objects: + parts.append(f"{len(self.per_environment_objects)} per-environment objects") parts.append(f"{len(self.task.subtasks)} atomic tasks ({self.task.composition})") parts.append(f"{len(self.relations)} relations") return " · ".join(parts) @@ -187,7 +193,7 @@ def _validate_cli_override_specs(self) -> None: override.target_node_id in swappable_ids ), f"CLI override '--{override.arg}' targets unknown or non-swappable asset '{override.target_node_id}'" - def _asset_by_id(self, asset_id: str) -> AssetSpec: + def _asset_by_id(self, asset_id: str) -> AssetSpec | ObjectSpec: if self.embodiment.id == asset_id: return self.embodiment if self.background.id == asset_id: diff --git a/isaaclab_arena/environment_spec/arena_env_graph_types.py b/isaaclab_arena/environment_spec/arena_env_graph_types.py index c5017f67dff..6dbb7a4bfab 100644 --- a/isaaclab_arena/environment_spec/arena_env_graph_types.py +++ b/isaaclab_arena/environment_spec/arena_env_graph_types.py @@ -9,13 +9,12 @@ from enum import Enum from numbers import Real -from typing import Any +from typing import Any, Literal -from pydantic import BaseModel, Field, field_validator, model_validator +from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator from isaaclab_arena.assets.object_type import ObjectType from isaaclab_arena.assets.registries import AssetRegistry, ObjectRelationLibraryRegistry, TaskRegistry -from isaaclab_arena.assets.simready_constants import SIMREADY_USD_OBJECT_REGISTRY_NAME def _extract_asset_usd_path(asset_cls: type, **params: Any) -> str | None: @@ -96,54 +95,88 @@ def resolve_usd_path(self) -> str: return usd_path -class ObjectSetSpec(BaseModel): - """A set of rigid objects distributed among parallel environments, one object per environment.""" +class ObjectSpec(AssetSpec): + """One registered Object instanced in every environment.""" - id: str = Field( - min_length=1, - description=( - "Unique id for this object set (e.g. 'bottles'). Referenced by relations and task " - "params exactly like an object id." - ), + model_config = ConfigDict(extra="forbid") + + @field_validator("params") + @classmethod + def _validate_params(cls, value: dict[str, Any]) -> dict[str, Any]: + reserved = {"objects", "variants", "assign_to_environments"} + duplicate_params = sorted(reserved & value.keys()) + assert ( + not duplicate_params + ), f"Object params must not set {duplicate_params}; use per_environment_objects for alternatives" + return value + + +class ObjectMemberSpec(BaseModel): + """One registered rigid Object and its constructor parameters in a PerEnvironmentObject.""" + + model_config = ConfigDict(extra="forbid") + + registry_name: str = Field(min_length=1, description="Exact registered rigid object name from OBJECTS.") + params: dict[str, Any] = Field( + default_factory=dict, + description="Constructor kwargs for this object, including scale or a SimReady usd_path.", ) - members: list[str] = Field( + + @field_validator("registry_name") + @classmethod + def _validate_registry_name(cls, value: str) -> str: + return _assert_registered_asset_name(value, ObjectType.RIGID) + + @field_validator("params") + @classmethod + def _validate_params(cls, value: dict[str, Any]) -> dict[str, Any]: + nested_fields = {"objects", "variants"} & value.keys() + assert not nested_fields, "Object member params cannot contain nested objects or variants" + assert "assign_to_environments" not in value, "Object member params must not set assign_to_environments" + return AssetSpec._drop_catalogue_tags(value) + + +class PerEnvironmentObjectSpec(BaseModel): + """Declare a PerEnvironmentObject with one rigid member assigned to each environment.""" + + model_config = ConfigDict(extra="forbid") + + id: str = Field(min_length=1, description="Unique scene id referenced by relations and task params.") + objects: list[ObjectMemberSpec] = Field( min_length=1, - description=( - "Exact registered object names from OBJECTS marked type=rigid that this set draws " - "from; every environment spawns one of them." - ), + description="Registered rigid objects; every environment spawns one of them.", ) - random_choice: bool = Field( - default=False, + assign_to_environments: Literal["sequential", "random"] = Field( + default="sequential", description=( - "Sample each environment's member independently at random. When false, members are " - "assigned by repeating their declared order across environments." + "Assign one object per environment during construction: sequential repeats their declared order; " + "random samples independently. The assignment stays fixed across resets." ), ) params: dict[str, Any] = Field( default_factory=dict, - description="Optional constructor kwargs forwarded to PerEnvironmentObject; leave empty by default.", + description="Constructor kwargs for the scene object, such as initial_pose; configure scale on its members.", ) - # TODO(xinjieyao, 2026-08-03): Support searched SimReady assets as object set members. - @field_validator("members") - @classmethod - def _validate_member_registry_names(cls, value: list[str]) -> list[str]: - for registry_name in value: - # ObjectSet members are built with no arguments, but Simready assets need usd_path. Only an object's params can carry. - assert registry_name != SIMREADY_USD_OBJECT_REGISTRY_NAME, ( - f"'{registry_name}' cannot be an object set member, because a member has nowhere to" - " carry the usd_path it needs. Use it as an object instead." - ) - return [_assert_registered_asset_name(registry_name, ObjectType.RIGID) for registry_name in value] - @field_validator("params") @classmethod - def _reject_reserved_params(cls, value: dict[str, Any]) -> dict[str, Any]: - # These are forwarded from the fields above, so a duplicate here would be a TypeError at - # build time, and an 'objects' override would skip the rigid-member check on members. - reserved = sorted({"name", "objects", "random_choice", "assign_to_environments"} & set(value)) - assert not reserved, f"params must not set {reserved}; use the id, members, random_choice fields instead" + def _validate_params(cls, value: dict[str, Any]) -> dict[str, Any]: + reserved = { + "name", + "instance_name", + "objects", + "variants", + "assign_to_environments", + "object_type", + "usd_path", + "spawn_cfg", + "scale", + "spawn_cfg_addon", + } + duplicate_params = sorted(reserved & value.keys()) + assert ( + not duplicate_params + ), f"Per-environment object params must not set {duplicate_params}; use the top-level fields or member params" return value diff --git a/isaaclab_arena/scripts/record_placement_layouts.py b/isaaclab_arena/scripts/record_placement_layouts.py index 934714db817..fd2c18881c7 100644 --- a/isaaclab_arena/scripts/record_placement_layouts.py +++ b/isaaclab_arena/scripts/record_placement_layouts.py @@ -122,7 +122,7 @@ def record_settled_placement_layouts( if arena_env is None: spec = ArenaEnvGraphSpec.from_yaml(cfg.env_spec) assert not any( - len(object_set.members) > 1 for object_set in (spec.object_sets or []) + len(obj.objects) > 1 for obj in spec.per_environment_objects ), "Select concrete object variants before recording reusable layouts" arena_env = spec.to_arena_env() assert arena_env.placement_layouts is None, "Remove cached placement layouts before recording" diff --git a/isaaclab_arena/tests/test_arena_env_graph_conversion.py b/isaaclab_arena/tests/test_arena_env_graph_conversion.py index 2d995ac771a..080bb80d97e 100644 --- a/isaaclab_arena/tests/test_arena_env_graph_conversion.py +++ b/isaaclab_arena/tests/test_arena_env_graph_conversion.py @@ -20,6 +20,7 @@ from isaaclab_arena.environment_spec.arena_env_graph_types import ( AssetSpec, CompositeTaskSpec, + ObjectSpec, TaskCompositionType, TaskSpec, ) @@ -128,40 +129,44 @@ def test_get_arena_builder_from_cli_builds_env_from_graph_yaml(): assert result -def _test_arena_env_graph_conversion_builds_object_set_node(simulation_app, random_choice): +def _test_arena_env_graph_conversion_builds_per_environment_object(simulation_app): + from isaaclab_arena.assets.object import Object from isaaclab_arena.assets.per_environment_object import PerEnvironmentObject + from isaaclab_arena.relations.relations import On from isaaclab_arena.scene.object_variant_assignment import assign_object_variants - spec = ArenaEnvGraphSpec.from_yaml(TEST_DATA_DIR / "object_set_maple_table_env_graph.yaml") - spec.object_sets[0].random_choice = random_choice + spec = ArenaEnvGraphSpec.from_yaml(TEST_DATA_DIR / "object_variants_maple_table_env_graph.yaml") arena_env = spec.to_arena_env() - object_set = arena_env.scene.assets["pick_up_object_set"] - assert isinstance(object_set, PerEnvironmentObject) - assert object_set.has_multiple_assets - assert len(object_set.spawn_cfg.assets_cfg) == 2 - assert object_set.assign_to_environments == ("random" if random_choice else "sequential") - - # The set is a single node: the task manipulates it, and each env gets one of its members. - assert arena_env.task.pick_up_object is object_set - assign_object_variants([object_set], num_envs=4, seed=42) - assert len(object_set.asset_indices_by_env) == 4 - assert len(object_set.spawn_cfg.assets_cfg) == 2 - + varied_object = arena_env.scene.assets["pick_up_object"] + assert isinstance(varied_object, PerEnvironmentObject) + assert varied_object.has_multiple_assets + assert len(varied_object.spawn_cfg.assets_cfg) == 2 + assert varied_object.assign_to_environments == "random" + assert arena_env.task.pick_up_object is varied_object + destination = arena_env.scene.assets["bowl_ycb_robolab"] + assert isinstance(destination, Object) + assert not isinstance(destination, PerEnvironmentObject) + assert arena_env.task.destination_location is destination + background = arena_env.scene.assets["maple_table_robolab"] + for scene_object in (varied_object, destination): + on_relation = next(relation for relation in scene_object.get_relations() if isinstance(relation, On)) + assert on_relation.parent is background + + assign_object_variants([varied_object], num_envs=4, seed=42) + assert len(varied_object.asset_indices_by_env) == 4 + assert len(varied_object.spawn_cfg.assets_cfg) == 2 return True -@pytest.mark.parametrize("random_choice", [False, True]) -def test_arena_env_graph_conversion_builds_object_set_node(random_choice): +def test_arena_env_graph_conversion_builds_per_environment_object(): from isaaclab_arena.tests.utils.persistent_simulation_app import run_function_with_persistent_simulation_app - result = run_function_with_persistent_simulation_app( - _test_arena_env_graph_conversion_builds_object_set_node, random_choice=random_choice - ) + result = run_function_with_persistent_simulation_app(_test_arena_env_graph_conversion_builds_per_environment_object) assert result -def _minimal_scene_spec(*, objects: list[AssetSpec]) -> ArenaEnvGraphSpec: +def _minimal_scene_spec(*, objects: list[ObjectSpec]) -> ArenaEnvGraphSpec: return ArenaEnvGraphSpec( env_name="lighting_test", embodiment=AssetSpec(id="robot", registry_name="droid_abs_joint_pos"), @@ -193,7 +198,7 @@ def _test_default_light_is_injected_when_scene_has_none(simulation_app): # A single YCB object with no light asset and no light baked into its USD: the converter # must inject a default light so the env does not render black. - spec = _minimal_scene_spec(objects=[AssetSpec(id="mug", registry_name="mug_ycb_robolab")]) + spec = _minimal_scene_spec(objects=[ObjectSpec(id="mug", registry_name="mug_ycb_robolab")]) arena_env = spec.to_arena_env() assert len(_lights_of_type(arena_env, DomeLight)) == 1 @@ -207,8 +212,8 @@ def _test_default_light_is_injected_when_scene_has_none(simulation_app): # An explicit light suppresses injection — no double-lighting, and no directional light either. explicit = _minimal_scene_spec( objects=[ - AssetSpec(id="mug", registry_name="mug_ycb_robolab"), - AssetSpec(id="my_light", registry_name="light"), + ObjectSpec(id="mug", registry_name="mug_ycb_robolab"), + ObjectSpec(id="my_light", registry_name="light"), ] ) explicit_env = explicit.to_arena_env() @@ -232,7 +237,7 @@ def test_default_light_is_injected_when_scene_has_none(): def _test_direction_variation_lights_injected_directional_light(simulation_app): from isaaclab_arena.assets.object_library import DirectionalLight, DomeLight - spec = _minimal_scene_spec(objects=[AssetSpec(id="mug", registry_name="mug_ycb_robolab")]) + spec = _minimal_scene_spec(objects=[ObjectSpec(id="mug", registry_name="mug_ycb_robolab")]) arena_env = spec.to_arena_env() dome_light = _lights_of_type(arena_env, DomeLight)[0] directional_light = _lights_of_type(arena_env, DirectionalLight)[0] diff --git a/isaaclab_arena/tests/test_arena_env_graph_spec.py b/isaaclab_arena/tests/test_arena_env_graph_spec.py index 070906df921..17bddf5ace7 100644 --- a/isaaclab_arena/tests/test_arena_env_graph_spec.py +++ b/isaaclab_arena/tests/test_arena_env_graph_spec.py @@ -22,7 +22,7 @@ TEST_DATA_DIR = Path(__file__).parent / "test_data" _GRAPH = TEST_DATA_DIR / "pick_and_place_maple_table_env_graph.yaml" -_OBJECT_SET_GRAPH = TEST_DATA_DIR / "object_set_maple_table_env_graph.yaml" +_OBJECT_VARIANTS_GRAPH = TEST_DATA_DIR / "object_variants_maple_table_env_graph.yaml" _DEBUG_VIEW_GRAPH = TEST_DATA_DIR / "placement_debug_view_env_graph.yaml" @@ -245,61 +245,255 @@ def test_graph_spec_accepts_legacy_position_limits_box_name(): assert isinstance(relation, PositionLimitsBox) -def test_graph_spec_loads_object_set_yaml(): - spec = ArenaEnvGraphSpec.from_yaml(_OBJECT_SET_GRAPH) +def test_graph_spec_loads_per_environment_objects_yaml(): + spec = ArenaEnvGraphSpec.from_yaml(_OBJECT_VARIANTS_GRAPH) - assert len(spec.object_sets) == 1 - object_set = spec.object_sets[0] - assert object_set.id == "pick_up_object_set" - assert object_set.members == ["sweet_potato", "jug"] - assert object_set.random_choice - assert object_set.params == {} + assert len(spec.objects) == 1 + assert spec.objects[0].id == "bowl_ycb_robolab" + (per_environment_object,) = spec.per_environment_objects + assert per_environment_object.id == "pick_up_object" + assert [member.registry_name for member in per_environment_object.objects] == [ + "sweet_potato", + "jug", + ] + assert per_environment_object.assign_to_environments == "random" + assert per_environment_object.params == {} + + on_relations = {relation.subject: relation for relation in spec.relations if relation.kind == "on"} + assert on_relations[per_environment_object.id].reference == "maple_table_robolab" + assert on_relations[spec.objects[0].id].reference == "maple_table_robolab" + task_params = spec.task.subtasks[0].params + assert task_params["pick_up_object"] == per_environment_object.id + assert task_params["destination_location"] == spec.objects[0].id + assert ArenaEnvGraphSpec.from_dict(spec.to_dict()) == spec + + +def test_graph_spec_accepts_relations_between_object_sections(): + data = _minimal_env_graph_data() + data["per_environment_objects"] = [{"id": "fruit", "objects": [{"registry_name": "sweet_potato"}]}] + data["relations"].extend([ + {"kind": "on", "subject": "fruit", "reference": "table"}, + { + "kind": "next_to", + "subject": "cube", + "reference": "fruit", + "params": {"side": "positive_x"}, + }, + ]) + data["task"]["subtasks"][0]["params"]["pick_up_object"] = "fruit" + + spec = ArenaEnvGraphSpec.from_dict(data) - # An object set is one scene node: relations and task params address it by id like an object. - on_relation = next(relation for relation in spec.relations if relation.subject == "pick_up_object_set") - assert on_relation.kind == "on" - assert on_relation.reference == "maple_table_robolab" - assert spec.task.subtasks[0].params["pick_up_object"] == "pick_up_object_set" + assert spec.relations[-1].subject == spec.objects[0].id + assert spec.relations[-1].reference == spec.per_environment_objects[0].id + assert spec.task.subtasks[0].params["pick_up_object"] == "fruit" + assert spec.task.subtasks[0].params["destination_location"] == "cube" -def test_graph_spec_rejects_object_set_id_colliding_with_object(): +def test_graph_spec_rejects_duplicate_ids_across_object_sections(): data = _minimal_env_graph_data() - data["object_sets"] = [{"id": "cube", "members": ["sweet_potato", "jug"]}] + data["per_environment_objects"] = [{"id": "cube", "objects": [{"registry_name": "sweet_potato"}]}] with pytest.raises(ValidationError, match="Duplicate graph asset ids"): ArenaEnvGraphSpec.from_dict(data) -def test_graph_spec_rejects_object_set_without_valid_members(): +@pytest.mark.parametrize( + ("object_spec", "message"), + [ + ({"id": "fruit"}, "Field required"), + ( + { + "id": "fruit", + "registry_name": "sweet_potato", + "variants": [{"registry_name": "jug"}], + }, + "Extra inputs are not permitted", + ), + ( + { + "id": "fruit", + "registry_name": "sweet_potato", + "assign_to_environments": "random", + }, + "Extra inputs are not permitted", + ), + ( + { + "id": "fruit", + "registry_name": "sweet_potato", + "params": {"variants": []}, + }, + "Object params must not set", + ), + ], +) +def test_graph_spec_rejects_invalid_concrete_object_sources(object_spec, message): data = _minimal_env_graph_data() - data["object_sets"] = [{"id": "variants", "members": []}] - with pytest.raises(ValidationError, match="at least 1 item"): + data["objects"].append(object_spec) + with pytest.raises(ValidationError, match=message): ArenaEnvGraphSpec.from_dict(data) - data["object_sets"] = [{"id": "variants", "members": ["not_a_real_asset"]}] - with pytest.raises(ValidationError, match="Unknown asset registry_name"): + +@pytest.mark.parametrize( + ("object_spec", "message"), + [ + ({"id": "fruit"}, "Field required"), + ({"id": "fruit", "objects": []}, "at least 1 item"), + ( + {"id": "fruit", "objects": [{"registry_name": "not_a_real_asset"}]}, + "Unknown asset registry_name", + ), + ( + {"id": "fruit", "objects": [{"registry_name": "ground_plane"}]}, + "must be a rigid object", + ), + ( + { + "id": "fruit", + "objects": [{"id": "member", "registry_name": "sweet_potato"}], + }, + "Extra inputs are not permitted", + ), + ( + { + "id": "fruit", + "objects": [{"registry_name": "sweet_potato", "objects": []}], + }, + "Extra inputs are not permitted", + ), + ( + { + "id": "fruit", + "objects": [{"registry_name": "sweet_potato", "params": {"objects": []}}], + }, + "cannot contain nested objects or variants", + ), + ( + { + "id": "fruit", + "objects": [{"registry_name": "sweet_potato", "params": {"variants": []}}], + }, + "cannot contain nested objects or variants", + ), + ( + { + "id": "fruit", + "objects": [{ + "registry_name": "sweet_potato", + "params": {"assign_to_environments": "random"}, + }], + }, + "Object member params must not set assign_to_environments", + ), + ( + { + "id": "fruit", + "objects": [{"registry_name": "sweet_potato"}], + "params": {"variants": []}, + }, + "params must not set", + ), + ( + { + "id": "fruit", + "objects": [{"registry_name": "sweet_potato"}], + "params": {"objects": []}, + }, + "params must not set", + ), + ( + { + "id": "fruit", + "objects": [{"registry_name": "sweet_potato"}], + "assign_to_environments": "cycle_in_order", + }, + "Input should be 'sequential' or 'random'", + ), + ( + { + "id": "fruit", + "objects": [{"registry_name": "sweet_potato"}], + "params": {"assign_to_environments": "random"}, + }, + "params must not set", + ), + ( + { + "id": "fruit", + "objects": [{"registry_name": "sweet_potato"}], + "params": {"scale": [2.0, 2.0, 2.0]}, + }, + "params must not set", + ), + ( + { + "id": "fruit", + "objects": [{"registry_name": "sweet_potato"}], + "random_choice": True, + }, + "Extra inputs are not permitted", + ), + ], +) +def test_graph_spec_rejects_invalid_per_environment_objects(object_spec, message): + data = _minimal_env_graph_data() + data["per_environment_objects"] = [object_spec] + with pytest.raises(ValidationError, match=message): ArenaEnvGraphSpec.from_dict(data) -def test_graph_spec_rejects_non_rigid_object_set_member(): +def test_graph_spec_preserves_per_environment_object_and_member_params(): + data = _minimal_env_graph_data() + initial_pose = { + "position_xyz": [0, 0, 1], + "rotation_xyzw": [0, 0, 0, 1], + } + data["per_environment_objects"] = [{ + "id": "fruit", + "objects": [ + {"registry_name": "sweet_potato", "params": {"scale": [0.5, 0.5, 0.5]}}, + {"registry_name": "sweet_potato", "params": {"scale": [2.0, 2.0, 2.0]}}, + ], + "params": {"initial_pose": initial_pose}, + }] + spec = ArenaEnvGraphSpec.from_dict(data) + (per_environment_object,) = spec.per_environment_objects + assert per_environment_object.assign_to_environments == "sequential" + assert per_environment_object.params == {"initial_pose": initial_pose} + assert per_environment_object.objects[0].params == {"scale": [0.5, 0.5, 0.5]} + assert per_environment_object.objects[1].params == {"scale": [2.0, 2.0, 2.0]} + dumped = spec.to_dict() + assert dumped["objects"] == [{"id": "cube", "registry_name": "rubiks_cube_hot3d_robolab", "params": {}}] + assert dumped["per_environment_objects"][0]["objects"] == data["per_environment_objects"][0]["objects"] + assert ArenaEnvGraphSpec.from_dict(dumped) == spec + + +@pytest.mark.parametrize("legacy_value", [[], [{"id": "fruit", "members": ["sweet_potato"]}]]) +def test_graph_spec_rejects_removed_object_sets(legacy_value): data = _minimal_env_graph_data() - data["object_sets"] = [{"id": "variants", "members": ["sweet_potato", "ground_plane"]}] - with pytest.raises(ValidationError, match="must be a rigid object"): + data["object_sets"] = legacy_value + with pytest.raises(ValidationError, match="object_sets was removed; use per_environment_objects"): ArenaEnvGraphSpec.from_dict(data) -@pytest.mark.parametrize("reserved_param", ["objects", "assign_to_environments"]) -def test_graph_spec_rejects_object_set_params_shadowing_spec_fields(reserved_param): +def test_graph_spec_rejects_cli_registry_override_for_per_environment_object(): data = _minimal_env_graph_data() - data["object_sets"] = [{"id": "variants", "members": ["sweet_potato"], "params": {reserved_param: []}}] - with pytest.raises(ValidationError, match="params must not set"): + data["per_environment_objects"] = [{"id": "fruit", "objects": [{"registry_name": "sweet_potato"}]}] + data["cli_override_specs"] = [{"arg": "fruit", "target_node_id": "fruit"}] + with pytest.raises(ValidationError, match="non-swappable asset"): ArenaEnvGraphSpec.from_dict(data) -def test_graph_spec_rejects_relation_referencing_unknown_object_set(): +def test_graph_spec_rejects_prim_reference_inside_per_environment_object(): data = _minimal_env_graph_data() - data["object_sets"] = [{"id": "variants", "members": ["sweet_potato", "jug"]}] - data["relations"].append({"kind": "on", "subject": "other_variants", "reference": "table"}) - with pytest.raises(ValidationError, match="unknown subject"): + data["per_environment_objects"] = [{"id": "fruit", "objects": [{"registry_name": "sweet_potato"}]}] + data["object_references"].append({ + "id": "fruit_body", + "parent_id": "fruit", + "prim_path": "body", + "object_type": "rigid", + }) + with pytest.raises(ValidationError, match="invalid parent"): ArenaEnvGraphSpec.from_dict(data) @@ -522,7 +716,7 @@ def test_graph_spec_accepts_missing_optional_fields(): data["task"]["subtasks"][0]["params"]["destination_location"] = "background" spec = ArenaEnvGraphSpec.from_dict(data) assert spec.object_references is None - assert spec.object_sets is None + assert spec.per_environment_objects == [] assert spec.cli_override_specs is None @@ -531,7 +725,6 @@ def test_graph_spec_omits_empty_optional_fields_from_dict(): del data["object_references"] data["relations"] = [{"kind": "is_anchor", "subject": "background"}] data["task"]["subtasks"][0]["params"]["destination_location"] = "background" - data["object_sets"] = [] spec = ArenaEnvGraphSpec.from_dict(data) dumped = spec.to_dict() assert "object_references" not in dumped @@ -576,13 +769,18 @@ def test_a_searched_simready_object_loads_in_a_fresh_process(tmp_path): assert f"USD_PATH={usd_path}" in result.stdout -def test_the_generic_simready_asset_is_rejected_as_an_object_set_member(): +def test_simready_object_member_preserves_its_usd_path(): data = _minimal_env_graph_data() - data["object_sets"] = [{"id": "kettles", "members": ["simready_usd_object"]}] - - # It is rigid, so it passes the member type check; what it cannot do is arrive with a usd_path. - with pytest.raises(ValidationError, match="cannot be an object set member"): - ArenaEnvGraphSpec.from_dict(data) + data["per_environment_objects"] = [{ + "id": "kettles", + "objects": [{ + "registry_name": "simready_usd_object", + "params": {"usd_path": "s3://bucket/kettle.usd"}, + }], + }] + spec = ArenaEnvGraphSpec.from_dict(data) + assert spec.per_environment_objects[0].objects[0].params == {"usd_path": "s3://bucket/kettle.usd"} + assert ArenaEnvGraphSpec.from_dict(spec.to_dict()) == spec def test_a_spec_naming_a_searched_simready_asset_by_its_search_name_is_rejected(tmp_path): diff --git a/isaaclab_arena/tests/test_data/object_set_maple_table_env_graph.yaml b/isaaclab_arena/tests/test_data/object_variants_maple_table_env_graph.yaml similarity index 75% rename from isaaclab_arena/tests/test_data/object_set_maple_table_env_graph.yaml rename to isaaclab_arena/tests/test_data/object_variants_maple_table_env_graph.yaml index 0c7a270386b..3a94560f5ea 100644 --- a/isaaclab_arena/tests/test_data/object_set_maple_table_env_graph.yaml +++ b/isaaclab_arena/tests/test_data/object_variants_maple_table_env_graph.yaml @@ -3,7 +3,7 @@ # # SPDX-License-Identifier: Apache-2.0 -env_name: pick_and_place_object_set_maple_table +env_name: pick_and_place_object_variants_maple_table embodiment: id: franka_ik registry_name: franka_ik @@ -13,12 +13,12 @@ background: objects: - id: bowl_ycb_robolab registry_name: bowl_ycb_robolab -object_sets: -- id: pick_up_object_set - members: - - sweet_potato - - jug - random_choice: true +per_environment_objects: +- id: pick_up_object + objects: + - registry_name: sweet_potato + - registry_name: jug + assign_to_environments: random relations: - kind: is_anchor subject: maple_table_robolab @@ -26,7 +26,7 @@ relations: subject: bowl_ycb_robolab reference: maple_table_robolab - kind: 'on' - subject: pick_up_object_set + subject: pick_up_object reference: maple_table_robolab task: composition: atomic @@ -34,6 +34,6 @@ task: subtasks: - kind: PickAndPlaceTask params: - pick_up_object: pick_up_object_set + pick_up_object: pick_up_object destination_location: bowl_ycb_robolab background_scene: maple_table_robolab diff --git a/isaaclab_arena/tests/test_environment_generation_agent.py b/isaaclab_arena/tests/test_environment_generation_agent.py index ce75f078dc7..893e312a673 100644 --- a/isaaclab_arena/tests/test_environment_generation_agent.py +++ b/isaaclab_arena/tests/test_environment_generation_agent.py @@ -273,23 +273,31 @@ def test_a_searched_simready_object_reaches_the_spec_with_its_usd_path(self, moc assert all("tags" not in asset["params"] for asset in spec.to_dict()["objects"]) @patch("isaaclab_arena.agentic_environment_generation.environment_generation_agent.search_simready_objects") - def test_a_searched_simready_object_in_an_object_set_is_rejected(self, mock_search, agent): + def test_a_searched_simready_object_member_preserves_its_usd_path(self, mock_search, agent): agent_obj, client = agent mock_search.return_value = SimReadyCandidateCatalogue( - candidates=[SimReadyObjectCandidate(search_phrase="green trash can", usd_path="s3://bucket/trash_can.usd")] + candidates=[ + SimReadyObjectCandidate( + search_phrase="green trash can", + usd_path="s3://bucket/trash_can.usd", + ) + ] ) spec_dict = minimal_spec_dict() - spec_dict["object_sets"] = [{"id": "bins", "members": ["simready_green_trash_can"]}] + spec_dict["per_environment_objects"] = [ + {"id": "bins", "objects": [{"registry_name": "simready_green_trash_can"}]} + ] client.chat.completions.create.side_effect = [ self._missing_objects_response("green trash can"), chat_response(content=json.dumps(spec_dict)), ] spec, data = self._generate_with_simready(agent_obj) - # A member is a bare registered name with nowhere to carry a usd_path, so the set would - # name a search entry that exists in no other process. - assert spec is None - assert isinstance(data, dict) - assert any("nowhere to carry a usd_path" in trace for trace in agent_obj.traces) + assert isinstance(spec, ArenaEnvGraphSpec) + assert data is None + (member,) = spec.per_environment_objects[0].objects + assert member.registry_name == SIMREADY_USD_OBJECT_REGISTRY_NAME + assert member.params == {"usd_path": "s3://bucket/trash_can.usd"} + assert ArenaEnvGraphSpec.from_dict(spec.to_dict()) == spec @patch("isaaclab_arena.agentic_environment_generation.environment_generation_agent.search_simready_objects") def test_a_catalogue_object_keeps_its_own_registry_name(self, mock_search, agent): diff --git a/isaaclab_arena_environments/maple_table_top/droid_pick_fruit_and_bottle_into_bin_maple_table.yaml b/isaaclab_arena_environments/maple_table_top/droid_pick_fruit_and_bottle_into_bin_maple_table.yaml index 100b4a77a42..5ffb08547cd 100644 --- a/isaaclab_arena_environments/maple_table_top/droid_pick_fruit_and_bottle_into_bin_maple_table.yaml +++ b/isaaclab_arena_environments/maple_table_top/droid_pick_fruit_and_bottle_into_bin_maple_table.yaml @@ -22,36 +22,36 @@ objects: - id: distractor_wood_block registry_name: wood_block_ycb_robolab params: {} -object_sets: +per_environment_objects: - id: bin - members: - - bin_b03_vomp_robolab - - blue_sorting_bin - - container_f24_vomp_robolab - random_choice: false + objects: + - registry_name: bin_b03_vomp_robolab + - registry_name: blue_sorting_bin + - registry_name: container_f24_vomp_robolab + assign_to_environments: sequential params: {} - id: fruit - members: - - avocado01_fruits_veggies_robolab - - lemon_01_fruits_veggies_robolab - - pomegranate01_fruits_veggies_robolab - - banana_ycb_robolab - random_choice: false + objects: + - registry_name: avocado01_fruits_veggies_robolab + - registry_name: lemon_01_fruits_veggies_robolab + - registry_name: pomegranate01_fruits_veggies_robolab + - registry_name: banana_ycb_robolab + assign_to_environments: sequential params: {} - id: bottle - members: - - ketchup_bottle_hope_robolab - - mayonnaise_bottle_hope_robolab - - bbq_sauce_bottle_hope_robolab - random_choice: false + objects: + - registry_name: ketchup_bottle_hope_robolab + - registry_name: mayonnaise_bottle_hope_robolab + - registry_name: bbq_sauce_bottle_hope_robolab + assign_to_environments: sequential params: {} - id: tool - members: - - spoon_handal_robolab - - ladle_handal_robolab - - salad_tongs_handal_robolab - - hammer_handal_robolab - random_choice: false + objects: + - registry_name: spoon_handal_robolab + - registry_name: ladle_handal_robolab + - registry_name: salad_tongs_handal_robolab + - registry_name: hammer_handal_robolab + assign_to_environments: sequential params: {} relations: - kind: is_anchor diff --git a/isaaclab_arena_environments/maple_table_top/droid_pick_fruit_into_bowl_maple_table.yaml b/isaaclab_arena_environments/maple_table_top/droid_pick_fruit_into_bowl_maple_table.yaml index 0ab21402e20..312c313915e 100644 --- a/isaaclab_arena_environments/maple_table_top/droid_pick_fruit_into_bowl_maple_table.yaml +++ b/isaaclab_arena_environments/maple_table_top/droid_pick_fruit_into_bowl_maple_table.yaml @@ -16,20 +16,20 @@ objects: - id: bowl registry_name: bowl_ycb_robolab params: {} -object_sets: +per_environment_objects: - id: fruit - members: - - apple_01_objaverse_robolab - - apple_02_objaverse_robolab - - avocado01_fruits_veggies_robolab - - lemon_01_fruits_veggies_robolab - - lemon_02_fruits_veggies_robolab - - lime01_fruits_veggies_robolab - - orange_01_fruits_veggies_robolab - - orange_02_fruits_veggies_robolab - - pomegranate01_fruits_veggies_robolab - - lychee01_fruits_veggies_robolab - random_choice: true + objects: + - registry_name: apple_01_objaverse_robolab + - registry_name: apple_02_objaverse_robolab + - registry_name: avocado01_fruits_veggies_robolab + - registry_name: lemon_01_fruits_veggies_robolab + - registry_name: lemon_02_fruits_veggies_robolab + - registry_name: lime01_fruits_veggies_robolab + - registry_name: orange_01_fruits_veggies_robolab + - registry_name: orange_02_fruits_veggies_robolab + - registry_name: pomegranate01_fruits_veggies_robolab + - registry_name: lychee01_fruits_veggies_robolab + assign_to_environments: random params: {} relations: - kind: is_anchor diff --git a/isaaclab_arena_examples/agentic_environment_generation/cli_runner.py b/isaaclab_arena_examples/agentic_environment_generation/cli_runner.py index ce1958689b5..8700fcaad02 100644 --- a/isaaclab_arena_examples/agentic_environment_generation/cli_runner.py +++ b/isaaclab_arena_examples/agentic_environment_generation/cli_runner.py @@ -268,6 +268,10 @@ def _iter_printable_assets(spec: ArenaEnvGraphSpec): yield "background", spec.background.id, spec.background.registry_name, spec.background.params for obj in spec.objects: yield "object", obj.id, obj.registry_name, obj.params + for obj in spec.per_environment_objects: + yield "per_environment_object", obj.id, None, obj.params + for member_index, member in enumerate(obj.objects): + yield "object_member", f"{obj.id}[{member_index}]", member.registry_name, member.params def print_env_graph(spec: ArenaEnvGraphSpec) -> None: @@ -277,7 +281,8 @@ def print_env_graph(spec: ArenaEnvGraphSpec) -> None: print("\nassets:") for role, asset_id, registry_name, params in _iter_printable_assets(spec): params_str = f" params={params}" if params else "" - print(f" {asset_id:24s} role={role:18s} registry_name={registry_name}{params_str}") + source_str = f"registry_name={registry_name}" if registry_name is not None else "objects" + print(f" {asset_id:24s} role={role:18s} {source_str}{params_str}") if spec.object_references: print("\nobject_references:") diff --git a/isaaclab_arena_examples/agentic_environment_generation/review_gui/simapp/thumbnail_capture.py b/isaaclab_arena_examples/agentic_environment_generation/review_gui/simapp/thumbnail_capture.py index cc10bb18cc7..dd614201585 100644 --- a/isaaclab_arena_examples/agentic_environment_generation/review_gui/simapp/thumbnail_capture.py +++ b/isaaclab_arena_examples/agentic_environment_generation/review_gui/simapp/thumbnail_capture.py @@ -45,7 +45,7 @@ wait_for_stage_load, ) from isaaclab_arena_examples.agentic_environment_generation.review_gui.spec_visualization.asset_cards import ( - object_set_member_key, + object_variant_key, ) PANORAMA_CAMERA_PRIM_PATH = "/World/_ReviewPanoramaCamera" @@ -78,12 +78,13 @@ def render_thumbnails_with_app( assets_by_node_id = instantiate_assets_from_spec(spec, AssetRegistry()) # Exclude embodiment from thumbnail rendering. assets_by_node_id.pop(spec.embodiment.id) - asset_node_ids = [spec.background.id, *(obj.id for obj in spec.objects)] + asset_node_ids = [ + spec.background.id, + *(obj.id for obj in spec.objects), + ] asset_paths = resolve_node_usd_paths(assets_by_node_id, asset_node_ids) - # Object sets hold one USD per member rather than a single usd_path, so resolve them separately - # and snapshot every member. - member_paths, member_dimensions = _resolve_object_set_members(spec, assets_by_node_id) - asset_paths.update(member_paths) + variant_paths, variant_dimensions = _resolve_object_variants(spec, assets_by_node_id) + asset_paths.update(variant_paths) background_viewer_cfg = assets_by_node_id[spec.background.id].get_viewer_cfg() cache_dir = thumbnail_cache_dir() @@ -134,7 +135,10 @@ def render_thumbnails_with_app( jobs = list(jobs_by_usd.values()) if not asset_paths and not jobs and not thumbnail_paths: - print("[thumbnail_capture] no asset USD paths resolved; skipping thumbnail rendering.", file=sys.stderr) + print( + "[thumbnail_capture] no asset USD paths resolved; skipping thumbnail rendering.", + file=sys.stderr, + ) return {}, {} if jobs: @@ -154,30 +158,33 @@ def render_thumbnails_with_app( if node_id in captured and cache_path.exists() and cache_path.stat().st_size > 0: thumbnail_paths[node_id] = cache_path else: - print(f"[thumbnail_capture] all {len(thumbnail_paths)} thumbnail(s) served from cache.", file=sys.stderr) + print( + f"[thumbnail_capture] all {len(thumbnail_paths)} thumbnail(s) served from cache.", + file=sys.stderr, + ) aabb_dimensions_m = resolve_aabb_dimensions_m(assets_by_node_id) - aabb_dimensions_m.update(member_dimensions) + aabb_dimensions_m.update(variant_dimensions) return thumbnail_paths, aabb_dimensions_m -def _resolve_object_set_members( +def _resolve_object_variants( spec: ArenaEnvGraphSpec, assets_by_node_id: dict[str, Any] ) -> tuple[dict[str, str], dict[str, AabbDimensionsM]]: - """Return each object-set member's native USD path and AABB under its card lookup key.""" + """Return each per-environment member's preview and AABB under its card lookup key.""" usd_paths: dict[str, str] = {} dimensions: dict[str, AabbDimensionsM] = {} - for object_set in spec.object_sets or []: - live_object_set = assets_by_node_id[object_set.id] - spawn_cfg = live_object_set.spawn_cfg - member_configs = spawn_cfg.assets_cfg if isinstance(spawn_cfg, MultiAssetSpawnerCfg) else [spawn_cfg] - for registry_name, member_cfg in zip(object_set.members, member_configs, strict=True): - member_key = object_set_member_key(object_set.id, registry_name) - usd_paths[member_key] = cached_rigid_asset_preview(member_cfg, thumbnail_cache_dir()) - geometry = ObjectGeometry(member_cfg, live_object_set.object_type) - member_dimensions = aabb_dimensions_from_asset(geometry) - if member_dimensions is not None: - dimensions[member_key] = member_dimensions + for obj in spec.per_environment_objects: + live_object = assets_by_node_id[obj.id] + spawn_cfg = live_object.spawn_cfg + variant_configs = spawn_cfg.assets_cfg if isinstance(spawn_cfg, MultiAssetSpawnerCfg) else [spawn_cfg] + for variant_index, variant_cfg in enumerate(variant_configs): + variant_key = object_variant_key(obj.id, variant_index) + usd_paths[variant_key] = cached_rigid_asset_preview(variant_cfg, thumbnail_cache_dir()) + geometry = ObjectGeometry(variant_cfg, live_object.object_type) + variant_dimensions = aabb_dimensions_from_asset(geometry) + if variant_dimensions is not None: + dimensions[variant_key] = variant_dimensions return usd_paths, dimensions diff --git a/isaaclab_arena_examples/agentic_environment_generation/review_gui/spec_visualization/asset_cards.py b/isaaclab_arena_examples/agentic_environment_generation/review_gui/spec_visualization/asset_cards.py index df2a176345c..5f6a9124683 100644 --- a/isaaclab_arena_examples/agentic_environment_generation/review_gui/spec_visualization/asset_cards.py +++ b/isaaclab_arena_examples/agentic_environment_generation/review_gui/spec_visualization/asset_cards.py @@ -22,9 +22,9 @@ class AssetCard: is_panorama: bool = False -def object_set_member_key(object_set_id: str, registry_name: str) -> str: - """Return the thumbnail and AABB lookup key for one member of an object set.""" - return f"{object_set_id}::{registry_name}" +def object_variant_key(object_id: str, variant_index: int) -> str: + """Return the thumbnail and AABB lookup key for one object variant.""" + return f"{object_id}::variant_{variant_index}" def build_asset_cards( @@ -33,25 +33,23 @@ def build_asset_cards( aabb_dimensions_m: dict[str, tuple[float, float, float]] | None = None, panorama_node_ids: set[str] | None = None, ) -> list[AssetCard]: - """Build one AssetCard per node (background, object references, objects, object-set members) for native rendering.""" + """Build cards for the background, object references, and each object source.""" thumbnails = thumbnails or {} aabb_dimensions_m = aabb_dimensions_m or {} panorama_node_ids = panorama_node_ids or set() entries: list[tuple[str, AssetSpec | ObjectReferenceSpec, str]] = [] entries.append(("background", spec.background, spec.background.id)) - entries.extend(("object_reference", ref, ref.id) for ref in (spec.object_references or [])) + entries.extend(("object_reference", ref, ref.id) for ref in spec.object_references or []) entries.extend(("object", obj, obj.id) for obj in spec.objects) - # carry one card per object set member - entries.extend( - ( - "object_set", - AssetSpec(id=object_set.id, registry_name=registry_name), - object_set_member_key(object_set.id, registry_name), - ) - for object_set in (spec.object_sets or []) - for registry_name in object_set.members - ) + for obj in spec.per_environment_objects: + for member_index, member in enumerate(obj.objects): + member_asset = AssetSpec( + id=obj.id, + registry_name=member.registry_name, + params=member.params, + ) + entries.append(("per_environment_object", member_asset, object_variant_key(obj.id, member_index))) return [ AssetCard( diff --git a/isaaclab_arena_examples/agentic_environment_generation/review_gui/spec_visualization/mermaid_graph.py b/isaaclab_arena_examples/agentic_environment_generation/review_gui/spec_visualization/mermaid_graph.py index c84aea5bf74..4cd17443add 100644 --- a/isaaclab_arena_examples/agentic_environment_generation/review_gui/spec_visualization/mermaid_graph.py +++ b/isaaclab_arena_examples/agentic_environment_generation/review_gui/spec_visualization/mermaid_graph.py @@ -19,8 +19,8 @@ def _mermaid_nodes(spec: ArenaEnvGraphSpec) -> list[tuple[str, str]]: (spec.background.id, "background"), ] nodes.extend((obj.id, "object") for obj in spec.objects) - nodes.extend((object_set.id, "object_set") for object_set in (spec.object_sets or [])) - nodes.extend((ref.id, "object_reference") for ref in (spec.object_references or [])) + nodes.extend((obj.id, "per_environment_object") for obj in spec.per_environment_objects) + nodes.extend((ref.id, "object_reference") for ref in spec.object_references or []) return nodes @@ -67,7 +67,7 @@ def render_mermaid_graph(spec: ArenaEnvGraphSpec) -> str: "background": ("#3a4f7a", "#7aa0d8"), "embodiment": ("#7a3a3a", "#d87a7a"), "object": ("#7a6b3a", "#d8c47a"), - "object_set": ("#7a5a3a", "#d8a87a"), + "per_environment_object": ("#7a6b3a", "#d8c47a"), "object_reference": ("#6b3a7a", "#c47ad8"), } for node_id, role in nodes: diff --git a/isaaclab_arena_examples/tests/test_review_gui.py b/isaaclab_arena_examples/tests/test_review_gui.py index 763ba8880f3..c3fa796b3ce 100644 --- a/isaaclab_arena_examples/tests/test_review_gui.py +++ b/isaaclab_arena_examples/tests/test_review_gui.py @@ -57,7 +57,7 @@ ) from isaaclab_arena_examples.agentic_environment_generation.review_gui.spec_visualization.asset_cards import ( build_asset_cards, - object_set_member_key, + object_variant_key, ) from isaaclab_arena_examples.agentic_environment_generation.review_gui.spec_visualization.mermaid_graph import ( estimate_mermaid_height_px, @@ -135,28 +135,52 @@ def test_includes_object_references(self): assert card_ids assert any(ref.id in card_ids for ref in spec.object_references) - def test_object_set_yields_one_card_per_member(self): + def test_object_variants_yield_one_card_per_variant(self): spec = ArenaEnvGraphSpec.from_yaml( - _REPO_ROOT / "isaaclab_arena/tests/test_data/object_set_maple_table_env_graph.yaml" + _REPO_ROOT / "isaaclab_arena/tests/test_data/object_variants_maple_table_env_graph.yaml" ) - (object_set,) = spec.object_sets - sweet_potato_key = object_set_member_key(object_set.id, "sweet_potato") + varied_object = spec.per_environment_objects[0] + sweet_potato_key = object_variant_key(varied_object.id, 0) cards = build_asset_cards( spec, thumbnails={sweet_potato_key: b"fake"}, aabb_dimensions_m={sweet_potato_key: (0.1, 0.1, 0.2)}, ) - member_cards = [card for card in cards if card.role == "object_set"] - assert [card.spec.registry_name for card in member_cards] == object_set.members - assert all(card.spec.id == object_set.id for card in member_cards) + variant_cards = [card for card in cards if card.spec.id == varied_object.id] + assert [card.spec.registry_name for card in variant_cards] == [ + "sweet_potato", + "jug", + ] + assert all(card.role == "per_environment_object" for card in variant_cards) + assert variant_cards[0].thumbnail_bytes == b"fake" + assert variant_cards[0].aabb_dimensions_m == (0.1, 0.1, 0.2) + assert variant_cards[1].thumbnail_bytes is None - # Snapshots are keyed per member, so one member's thumbnail never leaks onto its siblings. - sweet_potato = next(card for card in member_cards if card.spec.registry_name == "sweet_potato") - assert sweet_potato.thumbnail_bytes == b"fake" - assert sweet_potato.aabb_dimensions_m == (0.1, 0.1, 0.2) - jug = next(card for card in member_cards if card.spec.registry_name == "jug") - assert jug.thumbnail_bytes is None + def test_variants_with_the_same_registry_name_keep_separate_cards(self): + spec = ArenaEnvGraphSpec.from_yaml( + _REPO_ROOT / "isaaclab_arena/tests/test_data/object_variants_maple_table_env_graph.yaml" + ) + data = spec.to_dict() + data["per_environment_objects"][0]["objects"] = [ + {"registry_name": "sweet_potato", "params": {"scale": [0.5, 0.5, 0.5]}}, + {"registry_name": "sweet_potato", "params": {"scale": [2.0, 2.0, 2.0]}}, + ] + data["per_environment_objects"][0]["params"] = { + "initial_pose": { + "position_xyz": [0.0, 0.0, 1.0], + "rotation_xyzw": [0.0, 0.0, 0.0, 1.0], + } + } + spec = ArenaEnvGraphSpec.from_dict(data) + varied_object = spec.per_environment_objects[0] + cards = build_asset_cards(spec, thumbnails={object_variant_key(varied_object.id, 1): b"large"}) + variant_cards = [card for card in cards if card.spec.id == varied_object.id] + assert len(variant_cards) == 2 + assert variant_cards[0].spec.params == {"scale": [0.5, 0.5, 0.5]} + assert variant_cards[0].thumbnail_bytes is None + assert variant_cards[1].spec.params == {"scale": [2.0, 2.0, 2.0]} + assert variant_cards[1].thumbnail_bytes == b"large" class TestMermaidHtml: