Skip to content

Add Newton physics backend support#276

Draft
yuecideng wants to merge 85 commits into
mainfrom
feature/newton-physics-backend
Draft

Add Newton physics backend support#276
yuecideng wants to merge 85 commits into
mainfrom
feature/newton-physics-backend

Conversation

@yuecideng

Copy link
Copy Markdown
Contributor

This adds Newton backend support to the simulation stack.

  • Introduces Newton-aware simulation configuration and manager setup
  • Adds a Newton rigid-body adapter for pose and velocity access
  • Updates rigid object handling to route reads and writes through Newton when available
  • Keeps the existing default backend path unchanged

yuecideng and others added 30 commits April 12, 2026 14:58
Co-authored-by: chenjian <chenjian@dexforce.com>
Co-authored-by: chenjian <chenjian@dexforce.com>
Co-authored-by: chenjian <chenjian@dexforce.com>
Co-authored-by: chenjian <chenjian@dexforce.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: chenjian <chenjian@dexforce.com>
Co-authored-by: Jietao Chen <chenjietao@dexforce.com>
Co-authored-by: Yueci Deng <dengyueci@qq.com>
Co-authored-by: chenjian <chenjian@dexforce.com>
Co-authored-by: chenjian <chenjian@dexforce.com>
Co-authored-by: yuanhaonan <yuanhaonan@dexforce.top>
…entation (#247)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: chenjian <chenjian@dexforce.com>
Co-authored-by: yuecideng <dengyueci@qq.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
…ration (#239)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Chen Jian <mtfl1996@outlook.com>
Co-authored-by: chenjian <chenjian@dexforce.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: chenjian <chenjian@dexforce.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: WaferLi <63717327+WaferLi@users.noreply.github.com>
Co-authored-by: liwenfeng <liwenfeng@dexforce.top>
Co-authored-by: chenjian <chenjian@dexforce.com>
Co-authored-by: daojun <lookangela@qq.com>
Co-authored-by: Chen Jian <mtfl1996@outlook.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
yuecideng and others added 28 commits May 26, 2026 15:38
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: chenjian <chenjian@dexforce.com>
…on backend

Wire DexSim Newton's new `NewtonRigidDataType` enum values (MASS,
INERTIA_DIAGONAL, FRICTION, RESTITUTION) through the backend adapter
layer, enabling runtime set/get of mass, friction, and inertia on the
Newton physics backend.

Changes:
- backends/base.py: Add 8 abstract methods for physical property
  fetch/apply (mass, inertia_diagonal, friction, restitution)
- backends/newton.py: Implement via batch_fetch/apply_rigid_body_data;
  add `_fetch_scalar` helper; fix body ID resolution to be lazy so IDs
  are correct after Newton finalization in multi-object scenes
- backends/default.py: Implement all new abstract methods via per-entity
  PhysX API
- rigid_object.py: Route set/get_mass, set/get_friction, set/get_inertia
  through body_view when ready; make gpu_indices a property for lazy
  body ID resolution; add _mass/_inertia/_friction data buffers
- sim_manager.py: Remove redundant _has_reset_newton_entities_after_finalize
  flag; add _newton_lifecycle_state() helper; simplify finalize_newton_physics()
- test_rigid_object.py: Assert set/get round-trips for mass, friction,
  inertia on Newton backend; fix initial inertia expectation to use
  actual Newton-computed values
- docs/sim_manager.md: Add Newton Physics Backend section with supported
  operations table

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
## Newton backend optimizations (backends/newton.py)
- Pass GPU int32 body_ids tensor directly to DexSim; remove per-call
  .detach().cpu().tolist() synchronization on every fetch/apply
- Pass torch buffers directly to batch_fetch/apply_rigid_body_data;
  drop manual wp.from_torch wrapping (DexSim handles it internally)
- Remove dead code: _entity_indices, _fetch_com_local_pose_from_entities,
  _apply_com_local_pose_to_entities, unused _fetch_vec3/_fetch_scalar helpers
- Remove now-unused imports (numpy, warp, convert_quat)

## Test coverage additions (test_rigid_object.py)
- test_geometry_data: get_triangles shape/dtype + get_vertices(scale=True)
- test_enable_collision: toggle collision on/off, partial env_ids
- test_reset: full and partial reset restores pose + clears dynamics
- test_local_pose_matrix: get_local_pose(to_matrix=True) shape, last row,
  orthogonality; consistency with 7-vec form
- test_body_data_vel_clear: body_data.vel combined (N,6) shape, partial
  clear_dynamics zeroing only the requested env

All 63 tests pass (CPU / CUDA / Newton).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: yuecideng <dengyueci@qq.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…s-backend

# Conflicts:
#	.github/workflows/main.yml
#	docs/source/features/generative_sim/simready_pipeline.md
#	docs/source/guides/cli.md
#	docs/source/guides/configuration.md
#	embodichain/agents/engine/data.py
#	embodichain/agents/rl/train.py
#	embodichain/gen_sim/simready_pipeline/cli/start.py
#	embodichain/gen_sim/simready_pipeline/configs/gen_config.json
#	embodichain/gen_sim/simready_pipeline/core/asset.py
#	embodichain/gen_sim/simready_pipeline/io/json_store.py
#	embodichain/gen_sim/simready_pipeline/parser/physics.py
#	embodichain/gen_sim/simready_pipeline/pipeline/ingest.py
#	embodichain/gen_sim/simready_pipeline/utils/ingest_utils.py
#	embodichain/gen_sim/simready_pipeline/utils/simready_utils.py
#	embodichain/lab/gym/envs/managers/observations.py
#	embodichain/lab/gym/utils/gym_utils.py
#	embodichain/lab/scripts/preview_asset.py
#	embodichain/lab/sim/atomic_actions/actions.py
#	embodichain/lab/sim/cfg.py
#	embodichain/lab/sim/objects/articulation.py
#	embodichain/lab/sim/objects/rigid_object.py
#	embodichain/lab/sim/robots/cobotmagic.py
#	embodichain/lab/sim/sim_manager.py
#	examples/sim/demo/grasp_cup_to_caffe.py
#	examples/sim/demo/pick_up_cloth.py
#	examples/sim/demo/press_softbody.py
#	examples/sim/demo/scoop_ice.py
#	examples/sim/gizmo/gizmo_camera.py
#	examples/sim/gizmo/gizmo_object.py
#	examples/sim/gizmo/gizmo_robot.py
#	examples/sim/gizmo/gizmo_scene.py
#	examples/sim/gizmo/gizmo_w1.py
#	examples/sim/scene/scene_demo.py
#	examples/sim/sensors/batch_camera.py
#	examples/sim/sensors/create_contact_sensor.py
#	examples/sim/utility/workspace_analyzer/analyze_cartesian_workspace.py
#	examples/sim/utility/workspace_analyzer/analyze_plane_workspace.py
#	pyproject.toml
#	scripts/benchmark/rl/runtime.py
#	scripts/tutorials/grasp/grasp_generator.py
#	scripts/tutorials/gym/modular_env.py
#	scripts/tutorials/gym/random_reach.py
#	scripts/tutorials/sim/atomic_actions.py
#	scripts/tutorials/sim/create_cloth.py
#	scripts/tutorials/sim/create_rigid_object_group.py
#	scripts/tutorials/sim/create_robot.py
#	scripts/tutorials/sim/create_scene.py
#	scripts/tutorials/sim/create_sensor.py
#	scripts/tutorials/sim/create_softbody.py
#	scripts/tutorials/sim/export_usd.py
#	scripts/tutorials/sim/gizmo_robot.py
#	scripts/tutorials/sim/import_usd.py
#	skills/add-test/SKILL.md
#	tests/agents/test_shared_rollout.py
#	tests/gen_sim/simready_pipeline/test_config.py
#	tests/gym/envs/test_base_env.py
#	tests/gym/envs/test_embodied_env.py
#	tests/gym/utils/test_gym_utils.py
#	tests/sim/objects/test_cloth_object.py
#	tests/sim/objects/test_rigid_object.py
#	tests/sim/objects/test_robot.py
#	tests/sim/objects/test_soft_object.py
#	tests/sim/objects/test_usd.py
#	tests/sim/planners/test_motion_generator.py
#	tests/sim/planners/test_toppra_planner.py
#	tests/sim/sensors/test_camera.py
#	tests/sim/sensors/test_contact.py
#	tests/sim/sensors/test_stereo.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

physics Things related to physics

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants