Repository navigation
Heterogeneous visual materials with GPU attribute randomization - #6299
kellyguo11 merged 20 commits into
Conversation
Greptile SummaryThis PR replaces the original Kit-only Replicator event with a fully refactored, three-backend visual-color randomization system (RTX/Isaac, kitless Newton, OVRTX). It introduces a shared backend-neutral
Confidence Score: 4/5Safe to merge with minor follow-up; the new multi-backend architecture is solid and the test suite is thorough across all three renderer paths. The rework is well-structured and heavily tested (69 tests across RTX, Newton, OVRTX, and unit suites). Two style-level concerns are worth noting: the colors identity dispatch in randomize_visual_color.call creates an undocumented coupling to the EventManager argument-passing behaviour, and the _find_matching_visual_prims token regex can misparse alternation body-name patterns, adding unexpected false-positive prims to the proxy-walk candidates. Neither causes incorrect output on any known codepath. source/isaaclab/isaaclab/utils/visual_color.py (regex token BFS) and source/isaaclab/isaaclab/envs/mdp/events.py (call color dispatch) warrant a second look; all other files are clean. Important Files Changed
Sequence Diagram%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant U as User / EnvCfg
participant EM as EventManager
participant RVC as randomize_visual_color
participant VCU as visual_color utils
participant W as Backend Writer
U->>EM: __init__(cfg)
EM->>EM: deepcopy(term_cfg) + validate mode
EM->>RVC: prepare_before_physics_ready(name, cfg, env)
RVC->>VCU: resolve_visual_color_target_plan()
VCU-->>RVC: VisualColorTargetPlan
RVC->>W: pre_physics_ready_setup(env, plan)
Note over W: RTX: de-instance prims
Note over W: OVRTX: author USD materials
Note over W: Newton: no-op
RVC->>RVC: store plan on cfg.__dict__
Note over EM,RVC: PHYSICS_READY
EM->>RVC: __init__(cfg, env)
RVC->>RVC: pop plan from cfg.__dict__
Note over EM,W: First reset
EM->>RVC: __call__(env, env_ids, colors)
RVC->>RVC: normalize env_ids to target_indices
RVC->>RVC: _ensure_writer() lazy construct
RVC->>W: write_colors(target_indices, random_colors)
W-->>RVC: colors written to renderer
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant U as User / EnvCfg
participant EM as EventManager
participant RVC as randomize_visual_color
participant VCU as visual_color utils
participant W as Backend Writer
U->>EM: __init__(cfg)
EM->>EM: deepcopy(term_cfg) + validate mode
EM->>RVC: prepare_before_physics_ready(name, cfg, env)
RVC->>VCU: resolve_visual_color_target_plan()
VCU-->>RVC: VisualColorTargetPlan
RVC->>W: pre_physics_ready_setup(env, plan)
Note over W: RTX: de-instance prims
Note over W: OVRTX: author USD materials
Note over W: Newton: no-op
RVC->>RVC: store plan on cfg.__dict__
Note over EM,RVC: PHYSICS_READY
EM->>RVC: __init__(cfg, env)
RVC->>RVC: pop plan from cfg.__dict__
Note over EM,W: First reset
EM->>RVC: __call__(env, env_ids, colors)
RVC->>RVC: normalize env_ids to target_indices
RVC->>RVC: _ensure_writer() lazy construct
RVC->>W: write_colors(target_indices, random_colors)
W-->>RVC: colors written to renderer
|
| if colors is self.cfg.params.get("colors"): | ||
| color_low, color_high = self._color_low, self._color_high | ||
| else: | ||
| colors = colors if colors else self._cfg.params.get("colors") | ||
|
|
||
| # parse the colors into replicator format | ||
| if isinstance(colors, dict): | ||
| # (r, g, b) - low, high --> (low_r, low_g, low_b) and (high_r, high_g, high_b) | ||
| color_low = [colors[key][0] for key in ["r", "g", "b"]] | ||
| color_high = [colors[key][1] for key in ["r", "g", "b"]] | ||
| colors = [color_low, color_high] | ||
| else: | ||
| colors = list(colors) | ||
|
|
||
| num_prims = len(self.material_prims) | ||
| random_colors = self.color_rng.generator.uniform(colors[0], colors[1], size=(num_prims, 3)) | ||
|
|
||
| rep.functional.modify.attribute(self.material_prims, "diffuse_color_constant", random_colors) | ||
| color_low_cpu, color_high_cpu = _visual_color_range(colors, "cpu") | ||
| color_low = color_low_cpu.to(env.device) | ||
| color_high = color_high_cpu.to(env.device) |
There was a problem hiding this comment.
Object-identity cache bypass is fragile.
colors is self.cfg.params.get("colors") works today because EventManager passes kwarg values directly from cfg.params without copying, so the colors argument and the stored value are the same Python object. If the dispatch layer ever wraps or reconstructs params, this check would always be False, silently moving every call site onto the per-call _visual_color_range validation path and allocating new device tensors every reset. A sentinel or an explicit _override_colors keyword would make the contract visible.
| if colors is self.cfg.params.get("colors"): | |
| color_low, color_high = self._color_low, self._color_high | |
| else: | |
| colors = colors if colors else self._cfg.params.get("colors") | |
| # parse the colors into replicator format | |
| if isinstance(colors, dict): | |
| # (r, g, b) - low, high --> (low_r, low_g, low_b) and (high_r, high_g, high_b) | |
| color_low = [colors[key][0] for key in ["r", "g", "b"]] | |
| color_high = [colors[key][1] for key in ["r", "g", "b"]] | |
| colors = [color_low, color_high] | |
| else: | |
| colors = list(colors) | |
| num_prims = len(self.material_prims) | |
| random_colors = self.color_rng.generator.uniform(colors[0], colors[1], size=(num_prims, 3)) | |
| rep.functional.modify.attribute(self.material_prims, "diffuse_color_constant", random_colors) | |
| color_low_cpu, color_high_cpu = _visual_color_range(colors, "cpu") | |
| color_low = color_low_cpu.to(env.device) | |
| color_high = color_high_cpu.to(env.device) | |
| # Use cached bounds when the caller passes the config's own colors object (the common | |
| # manager path). Any other object is treated as a per-call override and re-validated. | |
| if colors is self.cfg.params.get("colors"): | |
| color_low, color_high = self._color_low, self._color_high | |
| else: | |
| color_low_cpu, color_high_cpu = _visual_color_range(colors, "cpu") | |
| color_low = color_low_cpu.to(env.device) | |
| color_high = color_high_cpu.to(env.device) |
| for token in normalized_expr.split("/")[1:]: | ||
| token_pattern = re.compile(f"^{token}$") |
There was a problem hiding this comment.
Token-level regex compilation uses raw token strings as patterns without escaping.
re.compile(f"^{token}$") means a path component like env.0 would generate the pattern ^env.0$, which matches envX0, env_0, etc. USD prim names conventionally contain only [A-Za-z0-9_], so this is not an active bug, but adding re.escape for literal components makes the intent explicit and prevents silent mismatch if paths ever contain literal dots or other regex metacharacters.
| for token in normalized_expr.split("/")[1:]: | |
| token_pattern = re.compile(f"^{token}$") | |
| for token in normalized_expr.split("/")[1:]: | |
| # Escape literal components; leave explicit regex wildcards (.*) intact. | |
| safe_token = token if token == ".*" else re.escape(token) | |
| token_pattern = re.compile(f"^{safe_token}$") |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
3c0a3f9 to
19addc0
Compare
5c12e5c to
25aadef
Compare
698133f to
f5cba20
Compare
74ef76e to
6aa9155
Compare
5f9d7f0 to
5fc1039
Compare
pbarejko
left a comment
There was a problem hiding this comment.
Approved from perspective of stale golden images.
…7240) ## Summary Cherry-picks the following merged PRs from `develop` onto `release/3.0.0`, preserving each as an individual commit with `-x` provenance: - #7218 — Flesh out the Manus glove workflow and pin the Isaac Teleop build branch - #7231 — Move the migration guide - #6299 — Add heterogeneous visual materials with GPU attribute randomization - #7237 — Refresh Isaac Lab documentation The commits are applied in their chronological `develop` order. All four cherry-picks completed without conflicts. ## Validation - Verified all four backported commits have patch IDs identical to their source squash commits and retain their `cherry picked from` footers. - `git diff --check upstream/release/3.0.0..HEAD` - Release-base changelog validation passed. - Focused cross-backend tests: **45 passed** - Core kitless visual-material spawning: 4 passed - Visual-material event behavior: 3 passed - Core visual-material pipeline: 12 passed - Newton visual-shape events: 2 passed - Newton visual-material renderer: 5 passed - OVRTX visual-material synchronization (`--extra ov`): 12 passed - PhysX visual-material writer: 5 passed - Kit and Newton visualizer hooks: 2 passed - `uv run isaaclab -f` passed all code, formatting, whitespace, RST, YAML/TOML, license, and repository-hygiene hooks. Its changelog hook reported unrelated release/develop baseline fragments (`fix-usd-replicate-def-ancestors.rst` and `vidurv-nested-fragment-writers.rst`) followed by the known Windows CP1252 reporting error; the targeted release-base changelog check passed. ### Bounded integration attempts - `test_visual_material_scene.py` was retried with the declared `isaacsim` project extra and did not complete within the five-minute local bound; it produced no failure diagnostics. - The Kuka golden-image rendering integration did not complete within the local bound. CI remains the authoritative result for the full Isaac Sim and GPU/rendering paths. --------- Co-authored-by: rwiltz <[email protected]> Co-authored-by: Mustafa H <[email protected]> Co-authored-by: ooctipus <[email protected]>
Resolves golden-image conflicts in franka_cloth/franka_soft by taking develop's images (from the heterogeneous visual materials change, isaac-sim#6299), since our branch's images were captured against pre-isaac-sim#6299 code and don't include that feature. These will need to be regenerated again against the merged code to reflect both changes.
# Description Remove the `AppLauncher` startup from `test_shadow_hand_camera_presets.py`. The suite only constructs configuration objects, resolves presets, and validates configuration combinations; it does not create a stage, environment, sensor, or rendered frame. The renderer configuration classes are now importable without launching Kit. The other direct `AppLauncher` uses under `isaaclab_tasks/test` were audited and retained because they exercise live environments, physics authoring, rendering, cameras, determinism, controllers, or RL wrappers. The `test_preset_cli.py` reference only inspects the `AppLauncher` argument contract and does not instantiate it. No assertions, parametrization, or coverage were removed. ## Timing Local end-to-end pytest timing for this file: - before: 9.03 seconds - after: 3.36 seconds In PR #6299, this file reported 26.83 seconds wall time for 0.20 seconds of test execution, so the CI saving may be larger on cold workers. ## Type of change - Bug fix (non-breaking change which fixes an issue) ## Validation - `uv run --frozen python -m pytest -q source/isaaclab_tasks/test/core/test_shadow_hand_camera_presets.py` (42 passed) - `uv run isaaclab -f` ## Checklist - [x] I have read and understood the contribution guidelines - [x] I have run the pre-commit checks - [x] My changes generate no new warnings - [x] The existing 42 tests cover the unchanged behavior - [x] I have added a `.skip` changelog fragment for `isaaclab_tasks` - [x] My name is already present in `CONTRIBUTORS.md`
Summary
This PR rebases visual-material randomization onto current
developand keeps the original declarative scene API while moving runtime writes onto renderer-native GPU paths.Architecture and ownership
VisualMaterialCfgremains a first-classAssetBaseCfginInteractiveSceneCfg:{ENV_REGEX_NS}creates one material clone per environment; an absolute path creates one shared material.RenderContext.RenderContextconcatenates each numeric channel into one flat device buffer and asks active renderer/visualizer consumers for their writer.There is no owner-asset hierarchy, plan merging/reindexing, queued-material adapter, runtime relationship rewrite, or SimulationContext material service.
SimulationContextonly owns the sharedRenderContextlifecycle.Runtime backend paths
model.shape_colorwith one Warp launch.Runtime material writes do not author USD, walk the stage, transfer environment IDs to the CPU, convert tensors to lists, or loop over environment rows in Python. USD work is restricted to scene construction/import. OVRTX currently publishes the full dirty channel because its write API does not expose indexed row updates; the Lab-side partial reset remains a device scatter.
Public behavior
VisualMaterialCfg,VisualMaterial.write_channels,read_channel,randomize_visual_material,randomize_visual_color, and the Newton-onlyrandomize_visual_shapeevent remain available.Numeric channels are:
Texture asset paths remain construction-time USD data. One static texture may be preloaded and its numeric UV channels randomized, but runtime texture-path selection is intentionally unsupported by this GPU-only pipeline.
prestartupmaterial writes are also rejected because renderer writers exist only after scene cloning/finalization.Material and shape granularity stay separate:
randomize_visual_materialsamples per declared material and environment on supported renderers.randomize_visual_shapesamples per selected link and environment against Newton's live shape storage. Other renderers should declare one material per independently randomized part.Demo
scripts/demos/visual_color_randomization.pykeeps the original heterogeneous five-style ANYmal scene:Each family uses scene-declared per-environment materials for body, legs, and feet. The demo defaults to 512 environments and resets random subsets so partial writes are visible.
Validation
[2/3]: 78/78 files, 2,212 tests, 0 failures/errors, 16 skipped.git diff --checkpassed anduv.lockis unchanged.Synchronized RTX 5090 measurements for 4096 environments:
The production implementation is 862 net lines smaller than the previous PR revision (about 43%) while preserving the declarative asset/event/demo boundaries.