Skip to content

Fix GPU physics initialization sync#303

Merged
yuecideng merged 1 commit into
mainfrom
fix-gpu-physics-update-sync
Jun 14, 2026
Merged

Fix GPU physics initialization sync#303
yuecideng merged 1 commit into
mainfrom
fix-gpu-physics-update-sync

Conversation

@yuecideng

@yuecideng yuecideng commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Description

This PR updates articulation pose synchronization so the simulation world is updated after both CPU and GPU pose writes. It also adjusts example/tutorial initialization to initialize GPU physics only when GPU physics is active, and after the optional window setup.

Fixes # (issue)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (non-breaking change which improves an existing functionality)

Screenshots

Not applicable.

Verification

  • python -m black embodichain/lab/sim/objects/articulation.py embodichain/lab/sim/robots/cobotmagic.py examples/sim/demo/grasp_cup_to_caffe.py scripts/tutorials/sim/atomic_actions.py
  • python -m py_compile embodichain/lab/sim/objects/articulation.py embodichain/lab/sim/robots/cobotmagic.py examples/sim/demo/grasp_cup_to_caffe.py scripts/tutorials/sim/atomic_actions.py

Notes

  • The untracked gym_project/ directory was intentionally excluded from this PR because it is generated data, is about 4.1 GB, and contains a plaintext .env with an API key.

Checklist

  • I have run the black . command to format the code base.
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • Dependencies have been updated, if applicable.

Copilot AI review requested due to automatic review settings June 14, 2026 09:00

Copilot AI 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.

Pull request overview

This PR aims to fix GPU physics initialization / synchronization issues by ensuring simulation state is updated after pose writes (CPU and GPU), and by adjusting example/tutorial startup so GPU physics is only initialized when running on CUDA and after optional window setup.

Changes:

  • Update Articulation.set_local_pose() and Articulation.reset() to synchronize the simulation world after GPU pose/kinematics writes.
  • Make tutorial/demo scripts initialize GPU physics conditionally (sim.is_use_gpu_physics) and after window initialization.
  • Minor example adjustments (e.g., removing an eager sim.update(step=1)).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
scripts/tutorials/sim/atomic_actions.py Adjusts sim device selection and conditional GPU physics init ordering in the tutorial entrypoint.
examples/sim/demo/grasp_cup_to_caffe.py Updates demo initialization order and adds conditional GPU physics init.
embodichain/lab/sim/robots/cobotmagic.py Updates the module’s __main__ demo to use CUDA and initialize GPU physics conditionally.
embodichain/lab/sim/objects/articulation.py Ensures world synchronization happens after both CPU and GPU pose writes / kinematics updates.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 427 to +431
if not args.headless:
sim.open_window()

if sim.is_use_gpu_physics:
sim.init_gpu_physics()
Comment on lines 206 to +210
cfg = CobotMagicCfg.from_dict(config)
robot = sim.add_robot(cfg=cfg)
sim.open_window()

if sim.is_use_gpu_physics:
Comment on lines 101 to +102
headless=True,
sim_device="cuda",
sim_device=args.device,
@yuecideng yuecideng merged commit bbe65f1 into main Jun 14, 2026
7 checks passed
@yuecideng yuecideng deleted the fix-gpu-physics-update-sync branch June 14, 2026 09:48
yuecideng added a commit that referenced this pull request Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants