Skip to content

[Core] Refactor and cleanup core subpackage for 3.0 [15/N] - #8101

Merged
AntoineRichard merged 8 commits into
isaac-sim:developfrom
StafaH:core-cleanup/15-sim-runtime-utils
Oct 1, 2026
Merged

AntoineRichard merged 8 commits into
isaac-sim:developfrom
StafaH:core-cleanup/15-sim-runtime-utils

Conversation

@StafaH

@StafaH StafaH commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Part 15 of the split of #7949. It cleans up the simulation context, the USD prim, stage, query, semantics and transform utilities, and the USD frame view. It changes no public API or behavior. Every kept hunk was checked against develop for identical outputs and no slowdown; hunks that failed either check were dropped.

  • SimulationContext:
    • The three copies of "normalize cfg.visualizer_cfgs to a list" now share _configured_visualizer_cfgs().
    • Function-local importlib/warnings imports moved to module level, and getattr(mod, "KitVisualizerCfg") became mod.KitVisualizerCfg.
    • Simplified the stage-clearing predicate and the closed/not-running visualizer log (the messages are unchanged).
    • Completed the truncated _physics_step_count comment and added a docstring to get_scene_data_provider.
  • sim.utils.transforms:
    • standardize_xform_ops sets up the translate/orient/scale ops in one loop. Existing ops keep their precision and missing ones are created as double, as before.
    • The canonical op order is a module constant shared with validate_standard_xform_ops.
    • resolve_prim_pose, resolve_prim_scale and convert_world_pose_to_local are shorter, with the frame-convention comments kept.
  • sim.utils.semantics: add_labels, remove_labels, check_missing_labels and count_total_labels are simplified.
  • sim.utils.prims:
    • The spawn wrapper uses set_prim_visibility.
    • bind_visual_material and bind_physics_material pick the binding-strength token with an inline conditional.
    • Simplified change_prim_property and get_usd_references.
  • sim.utils.stage, sim.utils.queries, sim.utils.newton_model_utils:
    • _is_prim_deletable, clear_stage, get_current_stage, the breadth-first child searches and find_global_fixed_joint_prim are shorter.
    • Removed a redundant None check around _coerce_color, which already handles None.
  • UsdFrameView:
    • World and local pose reads share _poses_from_transforms().
    • The scale writer uses combined indexing (scales_np[idx, 0]).
  • Reflection: replaced 12 avoidable getattr/hasattr calls with direct attribute access: visualizer_type, max_visible_envs and enable_live_plots are fields on VisualizerCfg, default_visualizer_cfg on SimulationCfg, and UsdFrameView now initializes _prim_paths = None instead of checking hasattr. The remaining uses are dynamic by design (thread-local stage state, dataclass-field copying, USD Create{X}Attr lookups, optional visualizer-package fields, duck typing on Newton builders and array-likes).
  • Cross-file helpers: resolve_physics_cfg (simulation_context) and to_tuple (sim.utils.prims) drop their _ prefix because other files use them.

Not ported from #7949:

  • Deprecation-only changes: the forwarding shim in sim/__init__.py.
  • Import-only edits that would undo develop's relative imports.
  • Removing the typed FrameView.__new__, which matches the other backend factories.
  • delete_prim no longer inserting the stage into the StageCache: an observable side effect.
  • Dropping the logger.error before the TypeError in safe_set_attribute_on_usd_schema.
  • Always calling MaterialBindingAPI.Apply in bind_physics_material: it could author an extra API schema.
  • Changing the bind_physics_material error message.
  • Removing the None guard in register_interactive_scene: tests pass None through it.
  • Gf.Vec3d(*scale) in standardize_xform_ops: Gf.Vec3d(scale) also accepts other inputs.
  • The Newton color-replacement rewrite, because develop has since added timing around it.
  • Hunks that measured slower than develop: world-scale reads and a shared matrix-scale helper.

Type of change

  • Refactor (no functional change)

Verification

  • Develop vs this branch (the same script runs against each source tree with a fixed seed): 659 outputs, 0 differences (rerun against the latest develop after the reflection and rename changes), compared exactly (dtype, shape and bytes for arrays; float.hex for floats). Covered:

    • standardize_xform_ops, validate_standard_xform_ops, resolve_prim_pose (world, prim-relative and root-relative), resolve_prim_scale and convert_world_pose_to_local on 60 prims. The prims cover float and double precision, out-of-order ops, matrix ops, unitsResolve, reset-xform-stack and no ops.
    • UsdFrameView world and local poses and scales (all and selected indices) on 512 nested prims, before and after a world-space scale write.
    • Semantics: add, overwrite, merge, remove (incl. descendants), missing-label and count functions.
    • Queries: fixed-joint detection (enabled and disabled joints, generic Joint schema) and first/all/depth-limited child searches.
    • Prims: change_prim_property (missing, create, clear, invalid prim), visual and physics material binding, create_prim with world and local poses, get_usd_references.
    • Stage: _is_prim_deletable, clear_stage with and without a predicate, delete_prim.
    • Newton shader color lookup.
    • The exported USDA of every stage, and all 56 log records, are identical.
  • Performance (latest develop, median of 5 alternating runs; USD frame view with 512 prims):

    Path develop [us] PR [us] ratio
    standardize_xform_ops 35.6 32.7 0.92
    resolve_prim_pose 22.1 21.7 0.98
    UsdFrameView world-space set_scales 6497.0 6408.3 0.99
    UsdFrameView.get_world_poses 2850.7 2831.5 0.99
    UsdFrameView.get_local_poses 1867.8 1878.1 1.01
    UsdFrameView.get_local_scales 1752.8 1698.2 0.97
    UsdFrameView.get_world_scales 4309.4 4216.4 0.98
  • Tests, all passing:

    • test_utils_transforms (28), test_utils_prims (19), test_utils_queries (11), test_utils_semantics (6), test_utils_stage (15)
    • test_views_xform_prim (45), test_newton_model_utils (13)
    • test_simulation_context (30), test_simulation_context_visualizers (44, run inside Kit), test_simulation_stage_in_memory (3)
  • ruff check and ruff format are clean.

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with ./isaaclab.sh --format
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have added a changelog fragment under source/<package>/changelog.d/ for each changed package (see Changelog)
  • If this is a user-visible change, the fragment clearly describes it

Release backport

  • Backport this pull request to the active release branch after it merges into develop

@StafaH
StafaH requested a review from a team September 28, 2026 02:58
@github-actions github-actions Bot added the isaac-lab Related to Isaac Lab team label Sep 28, 2026
@greptile-apps

greptile-apps Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Refactors simulation utilities and helpers with no behavior changes.

The PR appears safe to merge; no actionable regression was identified.

Summary

The PR consolidates simulation-context and USD utility code without changing their public interfaces. Review of the changed paths found no actionable regression.

Reviews (1) · Last reviewed commit: "Clean up simulation context, USD utiliti..."

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Isaac Lab Review Bot

Reviewed the refactor across SimulationContext, USD utilities, and UsdFrameView. The extracted private helpers preserve module ownership and the rewritten paths retain the existing observable contracts in the supplied context.

  • Design and architecture: The new helpers remain internal to their owning modules. USD-specific transform extraction stays in UsdFrameView, while the canonical transform-op order is shared locally between standardization and validation without changing backend boundaries.
  • API: No public API is added, removed, renamed, or intentionally changed. The reviewed return shapes, exception paths, Fabric-stage behavior, and material/query utility contracts remain consistent with the replaced code. The package-level .skip fragment is appropriate for this non-user-visible refactor.
  • Implementation: The visualizer-config normalization, stage predicates, semantics traversal, material-binding token selection, transform-op handling, and pose extraction paths were traced against the removed implementations. Short-circuit behavior, canonical ordering, precision preservation, and log output remain equivalent. The main residual dependency is that calls delegated to existing helpers, such as set_prim_visibility and _coerce_color, continue to honor the behavior previously implemented inline.

No blocking issues. No inline issue met the actionable-evidence threshold; the assessment above records the review feedback.

Automated review; human maintainers own approval decisions.

@AntoineRichard AntoineRichard left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good, a lot of these are more comestic than anything, and I'm not sure they're easier to read. But from what I could see it looks good! :D

@StafaH

StafaH commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

run-ci

@isaaclab-bot isaaclab-bot Bot added ci:run-docker Trigger the on-demand Docker and GPU CI workflow and removed ci:run-docker Trigger the on-demand Docker and GPU CI workflow labels Oct 1, 2026

@AntoineRichard AntoineRichard left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@AntoineRichard
AntoineRichard enabled auto-merge (squash) October 1, 2026 06:59
@AntoineRichard
AntoineRichard merged commit 1b33921 into isaac-sim:develop Oct 1, 2026
58 checks passed
@StafaH
StafaH deleted the core-cleanup/15-sim-runtime-utils branch October 10, 2026 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants