Add Newton physics backend with XPBD solver support#89
Conversation
Complete Newton physics backend implementation for the ARK simulator framework. This adds Newton as a fourth backend option alongside PyBullet, MuJoCo, and Genesis. The Newton backend provides GPU-accelerated physics simulation using Newton's XPBD (Extended Position-Based Dynamics) solver with full integration into ARK's existing architecture. Core Framework Changes: - simulator_node.py: Added Newton backend option to backend selection logic. When backend_type: "newton" is specified, the simulator imports and instantiates NewtonBackend. - subscriber.py: Minor enhancement to subscriber handling for improved message processing. Newton Backend Implementation: - newton_backend.py: Main backend class implementing SimulatorBackend ABC. Handles initialization, physics stepping, collision detection, and component lifecycle management. Configurable via YAML with gravity, substeps, solver iterations, and joint control parameters. - newton_builder.py: Wrapper around Newton's ModelBuilder with comprehensive defensive programming. Provides safe URDF loading, joint configuration defaults, and scene metadata tracking. - newton_robot_driver.py: Robot driver implementing RobotDriver interface. Supports TARGET_POSITION, TARGET_VELOCITY, and FORCE joint control modes. Publishes joint_state_t and subscribes to joint_group_command_t for arm/gripper control. - newton_camera_driver.py: Camera sensor driver for RGB and depth capture using Newton's viewer for GPU-accelerated rendering. - newton_lidar_driver.py: LiDAR sensor driver using Newton's ray-casting capabilities with configurable scan parameters. - newton_multibody.py: Rigid body management for non-articulated objects (cubes, spheres, etc.). - newton_viewer.py: Viewer manager supporting GUI mode (OpenGL) and headless mode for render loop and state visualization. - geometry_descriptors.py: Solver-agnostic geometry representation for shape descriptors adaptable to different Newton solvers. Solver Adapters: - scene_adapters/base_adapter.py: Abstract base class defining the adapter interface for solver-specific scene building. - scene_adapters/xpbd_adapter.py: XPBD solver adapter using Newton's native add_ground_plane() and standard contact handling. - scene_adapters/mujoco_adapter.py: MuJoCo solver adapter with workaround for ground plane limitations using box geometry. The Newton backend is 100% Newton-native - it uses only Newton APIs for physics, kinematics, and collision detection.
| observation_channels: dict[str, type] | None = None, | ||
| action_channels: dict[str, type] | None = None, | ||
| namespace: str = "ark", | ||
| ): |
There was a problem hiding this comment.
why did you remove this . please keep latest changes
| self.global_config["observation_channels"] = observation_channels | ||
| self.global_config["action_channels"] = action_channels | ||
| self.global_config["namespace"] = namespace | ||
|
|
There was a problem hiding this comment.
Please keep the latest changes exists in the main branch [not only these changes]
|
Hi @Douglas-Tilley thanks so much for this contribution, from the above comments from @Refinath i suspect you may need to rebase your branch. If you can do this asap, I will merge 😄 |
|
I’ve updated the PR with the latest changes from main. However, when I tried running Newton Physics, I encountered the following error: I’m using Newton version 0.2.0. |
|
Newton has updated and removed this as an Attribute. I will update the code to reflect this. " I'll rebase and update appropriately |
Collision Pipeline Factory: - New CollisionPipelineFactory for creating collision pipelines from YAML config - Supports standard and unified pipeline modes - Unified pipeline enables contact-rich simulation with configurable parameters: - Broad phase modes (NXN, SAP, EXPLICIT) - Per-pair contact budgets for stable friction - SDF hydroelastic contacts for volumetric compliance - Contact matching for temporal coherence - Automatic fallback to standard pipeline on errors - Warp compatibility checks for tiled BVH queries Backend and Driver Updates: - Extended default joint config: effort_limit, velocity_limit, friction - Added parse_visuals_as_colliders option for URDF loading - Simplified joint target writing via direct control assignment - Added ArticulationView body_names logging for EE index debugging - Removed deprecated commented-out code blocks Scene Adapter Updates: - Extended base adapter with additional configuration options - Updated MuJoCo and XPBD adapters for driver interface compatibility
Summary
Complete Newton physics backend implementation for the ARK simulator framework. This adds Newton as a fourth backend option alongside PyBullet, MuJoCo, and Genesis.
The Newton backend provides GPU-accelerated physics simulation using Newton's XPBD (Extended Position-Based Dynamics) solver with full integration into ARK's existing architecture.
Files Changed (14 files)
Core Framework Changes (2 files)
ark/system/simulation/simulator_node.pybackend_type: "newton"is specified in config, the simulator now imports and instantiatesNewtonBackend.ark/client/comm_handler/subscriber.pyNewton Backend Implementation (12 files)
ark/system/newton/newton_backend.pySimulatorBackendABC. Handles initialization, physics stepping via XPBD solver, collision detection, and component lifecycle management. Configurable via YAML with gravity, substeps, solver iterations, and joint control parameters.ark/system/newton/newton_builder.pyModelBuilderwith comprehensive defensive programming. Provides safe URDF loading, joint configuration defaults, and scene metadata tracking. Ensures robots are loaded before primitives to preserve body indices.ark/system/newton/newton_robot_driver.pyRobotDriverinterface. Supports TARGET_POSITION, TARGET_VELOCITY, and FORCE joint control modes. Publishesjoint_state_tmessages and subscribes tojoint_group_command_tfor arm/gripper control.ark/system/newton/newton_camera_driver.pyark/system/newton/newton_lidar_driver.pyark/system/newton/newton_multibody.pyark/system/newton/newton_viewer.pyark/system/newton/geometry_descriptors.pySolver Adapters (4 files)
ark/system/newton/scene_adapters/__init__.pyark/system/newton/scene_adapters/base_adapter.pyark/system/newton/scene_adapters/xpbd_adapter.pyadd_ground_plane()and standard contact handling. Default adapter for most use cases.ark/system/newton/scene_adapters/mujoco_adapter.pyArchitecture
The Newton backend follows ARK's existing backend pattern:
SimulatorBackendABC (same interface as PyBullet/MuJoCo backends)NewtonRobotDriverimplementingRobotDriverinterfacebackend_type: "newton"in global config YAMLConfiguration Example
Test Plan
backend_type: "newton"correctly loads NewtonBackendVerification
The Newton backend is 100% Newton-native - it uses only Newton APIs for physics, kinematics, and collision detection. No PyBullet or MuJoCo code is used within the Newton backend implementation.
Future Work (TODO)