Skip to content

Add Multi Data Types, Simulation Backends, and Rendering Backends for Cartpole - #4816

Merged
kellyguo11 merged 11 commits into
isaac-sim:developfrom
bdilinila:feature/develop/cartpole-multi-data-type
Mar 5, 2026
Merged

kellyguo11 merged 11 commits into
isaac-sim:developfrom
bdilinila:feature/develop/cartpole-multi-data-type

Conversation

@bdilinila

Copy link
Copy Markdown
Contributor

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.
List any dependencies that are required for this change.

Fixes # (issue)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (existing functionality will not work without user modification)
  • Documentation update

Screenshots

Please attach before and after screenshots of the change if applicable.

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 updated the changelog and the corresponding version in the extension's config/extension.toml file
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

@bdilinila
bdilinila changed the base branch from main to develop March 4, 2026 15:54
@github-actions github-actions Bot added documentation Improvements or additions to documentation enhancement New feature or request isaac-sim Related to Isaac Sim team isaac-mimic Related to Isaac Mimic team infrastructure isaac-lab Related to Isaac Lab team labels Mar 4, 2026
@bdilinila
bdilinila force-pushed the feature/develop/cartpole-multi-data-type branch from 2e735ed to 53fab9a Compare March 4, 2026 16:08
@bdilinila
bdilinila force-pushed the feature/develop/cartpole-multi-data-type branch from 53fab9a to d2f918c Compare March 4, 2026 16:12
@bdilinila
bdilinila marked this pull request as ready for review March 4, 2026 16:12
@greptile-apps

greptile-apps Bot commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR extends the Cartpole camera-preset environment with multi-physics and multi-renderer backends (Newton + RTX, PhysX + RTX, Newton + Warp renderer), adds a Newton physics preset to the locomotion velocity env, and refactors several RL training/play scripts to use @hydra_task_config decorators. The changes also add a sync_state_to_usd() path in NewtonManager so Newton's physics state is mirrored to the USD/Fabric stage for RTX rendering.

Key concerns found during review:

  • Double AppLauncher initialization in rl_games/play.py, rsl_rl/play.py, and sb3/play.py: a module-level AppLauncher(args_cli) is created before main(), while main() still calls launch_simulation() which spawns a second AppLauncher internally — this will crash or produce undefined behaviour for Kit-based backends.
  • CUDA graph incompatibility in newton_manager.py: sync_state_to_usd() is called inside _simulate(), which is captured into a CUDA graph during initialize_solver(). The method performs wp.synchronize() and .numpy() CPU transfers that cannot be captured in a CUDA graph, causing failures or silent rendering corruption at runtime.
  • Duplicate definitions in sb3/train.py: import logging and logger = logging.getLogger(__name__) are each defined twice.
  • Dead-code no-op blocks in skrl/play.py and skrl/train.py: the added if ml_framework.startswith(...) guard always holds and its body is just pass.
  • Object aliasing in MultiBackendRendererCfg: isaac_sim_rtx is assigned the same IsaacRtxRendererCfg() instance as default, so mutating one will silently affect the other.

Confidence Score: 1/5

  • Not safe to merge — two critical runtime bugs (double AppLauncher initialization, CUDA graph incompatibility) will cause crashes in the primary new use-cases introduced by this PR.
  • The double AppLauncher initialization across three play scripts will crash immediately for any Kit-based backend. The CUDA graph incompatibility in newton_manager will cause failures or silent rendering corruption for the Newton + RTX preset, which is the core new feature being added. Both bugs affect the happy path of the PR's own described functionality.
  • Pay close attention to source/isaaclab_newton/isaaclab_newton/physics/newton_manager.py (CUDA graph / sync_state_to_usd placement) and all three play scripts (scripts/reinforcement_learning/rl_games/play.py, scripts/reinforcement_learning/rsl_rl/play.py, scripts/reinforcement_learning/sb3/play.py) for the double AppLauncher issue.

Important Files Changed

Filename Overview
scripts/reinforcement_learning/rl_games/play.py Adds module-level AppLauncher initialization and @hydra_task_config decorator, but the existing launch_simulation context manager in main() would create a second AppLauncher — critical double-initialization bug.
scripts/reinforcement_learning/rsl_rl/play.py Same double AppLauncher initialization pattern as rl_games/play.py; module-level AppLauncher conflicts with launch_simulation inside main().
scripts/reinforcement_learning/sb3/play.py Same double AppLauncher initialization as rl_games/play.py and rsl_rl/play.py.
scripts/reinforcement_learning/sb3/train.py Adds @hydra_task_config decorator to main(); introduces duplicate import logging, duplicate logger assignment, and a duplicate PLACEHOLDER comment — redundant but not runtime-breaking.
scripts/reinforcement_learning/skrl/play.py Adds a no-op if block that always evaluates to True with a pass body — dead code, but otherwise no functional impact.
scripts/reinforcement_learning/skrl/train.py Same no-op if block as skrl/play.py, plus a duplicate logger = logging.getLogger(name) assignment.
source/isaaclab_newton/isaaclab_newton/physics/newton_manager.py Adds sync_state_to_usd() for Newton+RTX rendering, but placing the call inside _simulate() (which is captured into a CUDA graph) will break at capture time or silently corrupt rendering, because the method performs CPU-side numpy transfers and USD API calls incompatible with CUDA graph capture.
source/isaaclab_tasks/isaaclab_tasks/direct/cartpole/cartpole_camera_presets_env_cfg.py Moves MultiBackendRendererCfg definition into this file and adds IsaacRtxRendererCfg / NewtonWarpRendererCfg presets; has an object-aliasing bug where isaac_sim_rtx shares the same instance as default.
source/isaaclab_tasks/isaaclab_tasks/manager_based/locomotion/velocity/velocity_env_cfg.py Refactors EventsCfg hierarchy, adds PhysicsCfg with Newton preset, and changes events field from MISSING to EventsCfg(); a reasonable change but removes a safeguard that forced subclasses to explicitly provide event config.
source/isaaclab_tasks/isaaclab_tasks/utils/sim_launcher.py Correctly extends needs_kit logic to handle Newton Physics + RTX Renderer (Kit cameras) combinations; docstring updated accordingly. No issues found in this file itself.

Sequence Diagram

sequenceDiagram
    participant Script as play.py / train.py
    participant ML1 as AppLauncher (module-level)
    participant Main as main()
    participant LS as launch_simulation()
    participant ML2 as AppLauncher (sim_launcher)
    participant NM as NewtonManager
    participant CUDA as CUDA Graph

    Script->>ML1: AppLauncher(args_cli) [NEW - module level]
    ML1-->>Script: simulation_app

    Script->>Main: main() via @hydra_task_config

    Main->>LS: launch_simulation(env_cfg, args_cli)
    Note over LS: needs_kit = has_kit_cameras OR not is_newton
    LS->>ML2: AppLauncher(launcher_args) [CONFLICT: 2nd init]

    Main->>NM: reset() → initialize_solver()
    NM->>CUDA: wp.ScopedCapture → _simulate()
    Note over CUDA: Graph capture begins
    NM->>NM: sync_state_to_usd() [PROBLEM: called inside graph]
    NM->>CUDA: wp.synchronize() + .numpy() [NOT graph-compatible]
    Note over CUDA: Graph capture ends (broken)
Loading

Last reviewed commit: d2f918c

Comment on lines +34 to +38
class MultiBackendRendererCfg(PresetCfg):
default: IsaacRtxRendererCfg = IsaacRtxRendererCfg()
newton_renderer: NewtonWarpRendererCfg = NewtonWarpRendererCfg()
isaac_sim_rtx: IsaacRtxRendererCfg = default

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.

Shared object reference / aliasing between default and isaac_sim_rtx

isaac_sim_rtx: IsaacRtxRendererCfg = default assigns the same object reference as default to isaac_sim_rtx. Because both names point to the single IsaacRtxRendererCfg() instance created on the first line of the class body, mutating one attribute (e.g. cfg.isaac_sim_rtx.some_field = ...) will silently also change cfg.default. This is a classic mutable-default aliasing bug in dataclass-style configs.

To get an independent copy, use:

Suggested change
class MultiBackendRendererCfg(PresetCfg):
default: IsaacRtxRendererCfg = IsaacRtxRendererCfg()
newton_renderer: NewtonWarpRendererCfg = NewtonWarpRendererCfg()
isaac_sim_rtx: IsaacRtxRendererCfg = default
@configclass
class MultiBackendRendererCfg(PresetCfg):
default: IsaacRtxRendererCfg = IsaacRtxRendererCfg()
newton_renderer: NewtonWarpRendererCfg = NewtonWarpRendererCfg()
isaac_sim_rtx: IsaacRtxRendererCfg = IsaacRtxRendererCfg()


@configclass
class MultiBackendRendererCfg(PresetCfg):
default: IsaacRtxRendererCfg = IsaacRtxRendererCfg()

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.

can you make this change to
from isaaclab_tasks.utils.presets import MultiBackendRendererCfg?

also @kellyguo11 what do you think the final naming for presets under MultiBackendRendererCfg?
we definitely don't want ovrtx, but do we finalize to isaac_sim_rtx?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Re-added MultiBackendRendererCfg import

Additionally, greptile commented to make
isaac_sim_rtx: IsaacRtxRendererCfg = default
into
isaac_sim_rtx: IsaacRtxRendererCfg = IsaacRtxRendererCfg

But I think that is fine?

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.

class MultiBackendRendererCfg(PresetCfg):
default: IsaacRtxRendererCfg = IsaacRtxRendererCfg()
newton_renderer: NewtonWarpRendererCfg = NewtonWarpRendererCfg()
ovrtx_renderer: OVRTXRendererCfg = OVRTXRendererCfg()
isaacsim_rtx_renderer = default

I think Piotr changed to this ^^^, maybe we can do something consistent?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I see the difference: I'll change isaac_sim_rtx to isaacsim_rtx_renderer.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done!


@configclass
class MultiBackendRendererCfg(PresetCfg):
default: IsaacRtxRendererCfg = IsaacRtxRendererCfg()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Re-added MultiBackendRendererCfg import

Additionally, greptile commented to make
isaac_sim_rtx: IsaacRtxRendererCfg = default
into
isaac_sim_rtx: IsaacRtxRendererCfg = IsaacRtxRendererCfg

But I think that is fine?


# Sync Newton state to USD/Fabric for RTX rendering (e.g., Newton Physics + RTX Renderer preset)
if cls._usdrt_stage is not None:
cls.sync_transforms_to_usd()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hey, @ooctipus . I cannot jump/respond to your previous comment, but I noticed that in develop that sync_transforms_to_usd was used for the Kit viewer. I instead use it for updating the RTX transforms and added https://github.com/isaac-sim/IsaacLab/pull/4816/changes#diff-bf71fc0993ef30acc0b03f2c6f2feb3aa39b8c2b9951cc7458e1b5e52c3759cbR177.

@bdilinila
bdilinila force-pushed the feature/develop/cartpole-multi-data-type branch from b6bf8d3 to f5b5a48 Compare March 4, 2026 19:53
wp.synchronize_device(PhysicsManager._device)
if hasattr(usdrt, "hierarchy") and usdrt.hierarchy:
try:
fabric_hierarchy = usdrt.hierarchy.IFabricHierarchy().get_fabric_hierarchy(

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.

do you need the try: except: logic here? is there anycase if it fails we don't want to report?

device=PhysicsManager._device,
)
wp.synchronize_device(PhysicsManager._device)
if hasattr(usdrt, "hierarchy") and usdrt.hierarchy:

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.

Suggested change
if hasattr(usdrt, "hierarchy") and usdrt.hierarchy:
if hasattr(usdrt, "hierarchy"):

the and usdrt.hierarchy seems redundant? is it a boolean?

@kellyguo11

Copy link
Copy Markdown
Contributor

@bdilinila do you mind filling in some information for the description of the PR? just a quick sentence or two on what the change is for and why it was needed.

@kellyguo11
kellyguo11 merged commit 79ba7b5 into isaac-sim:develop Mar 5, 2026
7 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request infrastructure isaac-lab Related to Isaac Lab team isaac-mimic Related to Isaac Mimic team isaac-sim Related to Isaac Sim team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants