Skip to content

Fixes assets write to sim - #4799

Merged
kellyguo11 merged 2 commits into
isaac-sim:developfrom
AntoineRichard:antoiner/fix/asset_writers
Mar 3, 2026
Merged

kellyguo11 merged 2 commits into
isaac-sim:developfrom
AntoineRichard:antoiner/fix/asset_writers

Conversation

@AntoineRichard

Copy link
Copy Markdown
Collaborator

Description

Fixes training issues seen in some environments. This came from potentially using outdated data when writing root / joint propertis.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

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

@github-actions github-actions Bot added bug Something isn't working isaac-lab Related to Isaac Lab team labels Mar 3, 2026
@AntoineRichard AntoineRichard changed the title fix Fix assets write to sim Mar 3, 2026
@greptile-apps

greptile-apps Bot commented Mar 3, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a data-staleness bug across both the PhysX and Newton simulation backends where write_*_to_sim methods were manually marking cached buffers as "current" (by setting timestamp = _sim_timestamp) immediately after writing commanded values into them. This prevented the lazy-evaluation getters from re-fetching the actual post-physics-step state from the simulation, causing training observations to reflect commanded (pre-physics) values rather than the true simulation state.

Key changes:

  • All five files: Replaces direct private buffer accesses (self.data._X.data) with calls to the public property getter (self.data.X) in outputs= lists of warp kernel launches.
  • All five files: Removes the subsequent manual self.data._X.timestamp = self.data._sim_timestamp lines for all affected buffers (_root_com_pose_w, _root_link_pose_w, _root_link_vel_w, _root_com_vel_w, _body_com_acc_w, _joint_pos, _joint_vel, _joint_acc).
  • By not manually advancing timestamps after writes, the buffers become stale once _sim_timestamp advances in the next update() call, triggering a proper re-fetch from the physics engine on next access.
  • The pattern is applied consistently across PhysX articulation, PhysX rigid object, PhysX rigid object collection, Newton articulation, and Newton rigid object.

Confidence Score: 4/5

  • This PR is safe to merge — it corrects a systematic cache-staleness bug with no API changes or new dependencies.
  • The fix is mechanically consistent across all five files and both backends. The core logic (removing manual timestamp-current assignments and routing outputs through public property getters) aligns correctly with the lazy-evaluation design of the TimestampedBuffer pattern. One point keeping this below 5 is that calling the public property getter as an output argument may trigger an unnecessary re-fetch from physics before the commanded value is written (wasted work on the initial getter call), but this is a minor performance concern, not a correctness issue. No tests or interface contracts were broken.
  • No files require special attention; the change is uniform and low-risk.

Sequence Diagram

sequenceDiagram
    participant TL as Training Loop
    participant Asset as Asset (write_*_to_sim)
    participant DataProp as DataClass Property Getter
    participant Buf as TimestampedBuffer
    participant Phys as Physics Engine

    Note over TL,Phys: OLD (buggy) behaviour
    TL->>Asset: write_joint_vel_to_sim(env_ids, values)
    Asset->>Buf: outputs=[_joint_vel.data] (bypass getter)
    Phys-->>Buf: kernel writes commanded values
    Asset->>Buf: _joint_vel.timestamp = _sim_timestamp (marks "current")
    TL->>DataProp: read joint_vel
    DataProp->>Buf: timestamp == _sim_timestamp → SKIP re-fetch
    Buf-->>TL: returns commanded (pre-physics) values ❌

    Note over TL,Phys: NEW (fixed) behaviour
    TL->>Asset: write_joint_vel_to_sim(env_ids, values)
    Asset->>DataProp: outputs=[self.data.joint_vel] (calls getter)
    DataProp->>Phys: fetch current state (if stale)
    Phys-->>Buf: data assigned, timestamp updated
    DataProp-->>Asset: returns buffer reference
    Phys-->>Buf: kernel writes commanded values into buffer
    Note over Buf: No manual timestamp update
    TL->>Asset: physics step → _sim_timestamp advances
    TL->>DataProp: read joint_vel
    DataProp->>Buf: timestamp < _sim_timestamp → re-fetch
    DataProp->>Phys: get actual post-step state
    Phys-->>Buf: actual simulation state written
    Buf-->>TL: returns actual physics values ✅
Loading

Last reviewed commit: 5ed568d

@greptile-apps greptile-apps 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.

5 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@AntoineRichard AntoineRichard changed the title Fix assets write to sim Fixes assets write to sim Mar 3, 2026
@kellyguo11
kellyguo11 merged commit 14d9bfc into isaac-sim:develop Mar 3, 2026
6 of 12 checks passed
kellyguo11 added a commit to kellyguo11/IsaacLab-public that referenced this pull request Mar 4, 2026
…aac-sim#4803)

Conflict in parse_cfg.py: kept HEAD's hydra-import-free PresetCfg
resolution (_is_preset_cfg / _resolve_presets_to_default) to avoid
the circular-import that would arise from importing resolve_preset_defaults
from hydra.py (which itself imports load_cfg_from_registry from parse_cfg).

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants