-
Notifications
You must be signed in to change notification settings - Fork 16
Add Newton physics backend with XPBD solver support #89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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.
| """ | ||
|
|
||
| from abc import ABC, abstractmethod | ||
| from typing import TYPE_CHECKING, Any, Dict |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use 'dict' type instead of Dict
| observation_channels: dict[str, type] | None = None, | ||
| action_channels: dict[str, type] | None = None, | ||
| namespace: str = "ark", | ||
| ): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep the latest changes exists in the main branch [not only these changes]
Refinath
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the PR
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)