Fix GPU physics initialization sync#303
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
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()andArticulation.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
added a commit
that referenced
this pull request
Jun 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
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.pypython -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.pyNotes
gym_project/directory was intentionally excluded from this PR because it is generated data, is about 4.1 GB, and contains a plaintext.envwith an API key.Checklist
black .command to format the code base.