Repository navigation
[6Biii] Select visualizer consumers before launching runtimes - #8126
Conversation
|
run-ci |
|
| if livestream and sim_cfg.visualizer_cfgs == []: | ||
| raise ValueError("Livestreaming requires the Kit visualizer; visualizer=none disables it.") | ||
| if not any(viewer.launcher_type == _KIT_LAUNCHER for viewer in viewers): | ||
| sim_cfg.visualizer_cfgs = [*viewers, KitVisualizerCfg(headless=bool(launcher_args.get("xr", False)))] |
There was a problem hiding this comment.
|
run-ci |
There was a problem hiding this comment.
Isaac Lab Review Bot
The pre-launch visualizer composition design is coherent, but three concrete issues remain: URDF/MJCF previews ignore the selected device, tuple traversal cannot support the documented in-place config replacement, and legacy preset aliases now have duplicated sources of truth.
- Design and architecture: Moving visualizer selection into preset composition and attaching runtime requirements to concrete configs removes the settings round trip cleanly. However, legacy alias mappings are duplicated between the shared preset utility and PresetTarget, with stale ownership documentation and a maintenance risk if the tables diverge.
- API: The refactor preserves launch_simulation's namespace/dict inputs and resolved-physics yield, but two observable contracts need correction: --device no longer affects URDF/MJCF previews on kitless paths, and scan claims tuple support even though tuple-held replaceable configs fail deterministically.
- Implementation: The launch and device-resolution flow otherwise traces consistently, but convert_urdf.py and convert_mjcf.py must initialize SimulationCfg with args_cli.device. The scan replacement logic must either rebuild tuple containers through their parent or stop advertising tuple traversal. Preset alias ownership should also be consolidated into one maintained table.
Minor fixes needed. Posted 3 actionable findings inline.
Automated review; human maintainers own approval decisions.
| @@ -173,7 +170,8 @@ def main(): | |||
| print("-" * 80) | |||
| print("-" * 80) | |||
|
|
|||
| with launch_simulation(cfg=PhysicsCfg(), launcher_args=args_cli) as physics_cfg: | |||
| sim_cfg = sim_utils.SimulationCfg() | |||
There was a problem hiding this comment.
🟡 Warning · Implementation — URDF/MJCF preview ignores --device
The preview config previously used SimulationCfg(device=args_cli.device, physics=physics_cfg); it is now SimulationCfg(). In the preferred kit-less path (standalone importers present, newton_mjwarp) no launcher runs, so nothing overwrites sim_cfg.device and --device cpu silently previews on the default cuda:0. scripts/tools/convert_mjcf.py:162 has the same regression, while convert_mesh.py kept the argument. Pass device=args_cli.device.
| setattr(parent, key, node) | ||
| else: | ||
| effective_cfg = node | ||
| owner[key] = node = _make_physics_cfg(physics_str) |
There was a problem hiding this comment.
🟡 Warning · Implementation — Tuple-held configs cannot be replaced
scan now documents and walks tuples, and owner may be a tuple, but the replacement paths assign owner[key] = ... for --physics overrides (line 264) and for auto-PhysX/auto-RTX resolution (lines 313, 330). A PhysicsCfg or auto-RTX placeholder stored in a tuple therefore raises TypeError deterministically. Rebuild and reattach the tuple through its parent when replacing an element, or restrict the documented traversal to mutable containers.
|
|
||
| from .configclass import configclass | ||
|
|
||
| _LEGACY_PRESET_ALIASES = { |
There was a problem hiding this comment.
🔵 Suggestion · Design Architecture — Legacy alias table duplicated from PresetTarget
_LEGACY_PRESET_ALIASES re-declares the mappings owned by PresetTarget.legacy_aliases, and the resolver no longer consults PresetTarget.all_legacy_aliases(). The two tables can now drift silently, and preset_target.py's docstrings still state that _normalize_preset_name consults them. Keep one source of truth: have the hydra path pass PresetTarget.all_legacy_aliases() through the existing aliases parameter, or drop the enum's alias data and its docs.
|
run-ci |
|
run-ci |
4ed1834 to
23e1808
Compare
|
run-ci |
|
run-ci |
|
run-ci |
|
run-ci |
|
run-ci |
|
run-ci |
|
run-ci |
2 similar comments
|
run-ci |
|
run-ci |
StafaH
left a comment
There was a problem hiding this comment.
Found three selection issues and two test cleanups. The focused checks passed 62 tests; the five summary cases fail without CUDA.
| viewers = env_cfg.sim.visualizer_cfgs | ||
| viewers = viewers if isinstance(viewers, list) else [viewers] if viewers else [] | ||
| for viewer in viewers: | ||
| vars(choices)[viewer.visualizer_type] = viewer |
There was a problem hiding this comment.
This keeps only the last viewer of each type. With two configured NewtonGLVisualizerCfg instances, --viz newton_gl silently drops the first, unlike the standalone launcher. Please preserve all matching instances in order and only create a default when none match.
| if not value or value.startswith("-") or "=" in value: | ||
| parser.error(f"{key} requires a preset name.") | ||
| key = "visualizer" if key == "--viz" else key[2:] | ||
| token = f"{key}={value}" |
There was a problem hiding this comment.
record_demos.py, replay_demos.py, and teleop_se3_agent.py still intersect these normalized tokens with the external callback's raw remainder. That drops --viz newton_gl, since it no longer matches visualizer=newton_gl; physics and renderer aliases have the same issue. Please normalize those callback remainders too, as the RSL-RL entrypoints now do.
| f"'{task_name}'. Choose a declared preset, or remove the selector(s) to use its registered default " | ||
| "configuration." | ||
| ) | ||
| if PresetTarget.VISUALIZER.matches in selectors.keys() - consumed_selectors: |
There was a problem hiding this comment.
With a declared MultiBackendVisualizerCfg, visualizer=kit env.sim.visualizer_cfgs=newton_gl ends up selecting Kit. The explicit path resolves first, leaving the global selector unconsumed, so this fallback overwrites it. Please skip the fallback when an explicit path already selected the viewer.
| scan(env_cfg, args_cli) | ||
| monkeypatch.setattr(physx_app, "KitLauncher", SimulationLauncher) | ||
| monkeypatch.setattr(ov_app, "OvrtxLauncher", SimulationLauncher) | ||
| with launch_simulation(env_cfg, args_cli): |
There was a problem hiding this comment.
Could this just call validate_launch(env_cfg, args_cli)? The mocked launch still checks the task's default cuda:0 device, so all five cases fail with CUDA_VISIBLE_DEVICES="". Direct validation covers what the summary needs and removes the launcher mocks and imports.
| """Preset selection preserves declared settings; physics aliases do not also select a viewer.""" | ||
| assert importlib.util.find_spec("isaaclab.utils.presets") is None | ||
| assert importlib.util.find_spec("isaaclab_visualizers.presets") is None | ||
| assert "resolve_simulation_cfg" not in vars(sim_launcher) |
There was a problem hiding this comment.
nit: Please drop these three assertions and the unused importlib.util import. They constrain module layout rather than selection behavior; the assertions below already cover the behavior this test describes.
| parse_visualizer_csv, | ||
| ) | ||
| from ..visualizers import ImageViewCfg, PerspectiveCameraCfg, SceneCameraCfg, VisualizerCfg | ||
| from ..visualizers.visualizer_cfg import VISUALIZER_ALIASES, _apply_visualizer_defaults |
There was a problem hiding this comment.
_ function is being imported, remove _ if it's used outside of file
There was a problem hiding this comment.
Agreed, the underscore is misleading since this is shared across modules. I left it unchanged here because #8704 removes this helper and the default-merging logic entirely. That follow-up replaces them with shared visualizer configuration, so there will be no cross-module helper to rename.
| @@ -3,12 +3,7 @@ | |||
| # | |||
There was a problem hiding this comment.
Does the code get simpler if we just seperate the kit into kit_launcher() and then sim_launcher is just kit-less? Theres so much code that tries to determine if kit is needed, how would it look if there was just a clear seperation?
|
run-ci |
|
run-ci |
Launch decisions were split between a
Scanresult, global settings, and simulation construction. This makes the configuration passed tolaunch_simulationthe source of truth: task selection resolves first,validate_launchprepares consumers and rejects incompatible runtimes, and each required runtime starts once. Recording selects or reuses its producer without opening a window.Before and after:
uv run isaaclab train --task Isaac-Cartpole-Direct --rl_library rsl_rl visualizer=newton_glnow selects the viewer during task composition;--viz newton_glis the equivalent spelling. Physics and renderer flags follow the same preset boundary.SimulationCfg(visualizer_cfgs=[NewtonGLVisualizerCfg(...)])previously needed--viz newton_glto run that declared viewer. It now runs as configured.--viz nonedisables windows; an empty config remains windowless by default.--video viz:newton_gl:streaming_viewretains headless, on-demand capture and enables the requested sensor view. Multiple recorders sharing a view reuse one producer.Removed
Scan,scan, duplicate selection helpers, and the settings-based viewer handoff. One traversal now collects and replaces runtime configs while preserving shared references; configuration tests call validation directly without mocking runtime startup. Standalone scripts pass the same simulation config to launch and construction. RTX perspective cameras remain ordinary scene cameras declared before construction.Scope: 6Biii, 84 files, +1,125 / −1,369. The shared
VisualizerCfg/backend API and its task/example migration are now in #8704 (6Biv). This PR retains the existing backend config API.Validation: 308 focused tests passed across launch/runtime selection, device propagation, recording, simulation lifecycle, Kit arguments, task presets, and standalone configuration. An RTX particle-motion test passed on GPU0.
uv run isaaclab -fpassed.