Newton Physics Engine

repository·main·Indexed 26 days ago

https://github.com/newton-physics/newton

A GPU-accelerated physics simulation engine for robotics simulation built on NVIDIA Warp. Version 1.5.0.dev0 integrates MuJoCo Warp as a primary backend and supports OpenUSD, differentiability, and user-defined extensibility. It includes SolverKamino (BETA 1), a physics solver for arbitrary mechanical assemblies capable of handling kinematic loops and under-/overactuation using a Proximal-ADMM forward dynamics solver.

Tokens
85.2K
Snippets
166
Records
398
Agent score
90%

What's inside newton

  1. Overview of Newton Actuators

    main

    Actuators in Newton are composable, vectorized implementations that read physics simulation state, compute effort (control law), and accumulate (scatter-add) that effort into control arrays. They are designed for efficiency in RL workflows and can be used with any simulator that provides the required state and control arrays.

    Key Architecture Components:

    1. Delay (optional): Models communication/processing latency by delaying command inputs by N timesteps.
    2. Controller: Computes raw effort (e.g., PD, PID, or Neural Network) from simulator state and targets.
    3. Clamping: Applies post-controller limits (e.g., saturation, DC motor characteristics, or position-dependent limits). Multiple clamping stages can be stacked.

    Pipeline per step: Delay read $\rightarrow$ Controller $\rightarrow$ Clamping $\rightarrow$ Scatter-add $\rightarrow$ State updates (controller + delay write).

  2. Overview of the MuJoCo Solver

    main

    The newton.solvers.SolverMuJoCo class wraps mujoco_warp to provide a MuJoCo-based backend for Newton. Because MuJoCo uses its own modeling conventions, many Newton properties are mapped differently or not at all.

    Key integration details:

    • Version Alignment: Newton uses compatible-release pins (~=) for both mujoco and mujoco-warp to ensure compatibility.
    • Custom Attributes: MuJoCo-specific behaviors that lack a Newton-core equivalent are exposed via the custom-attribute namespace.
    • State Exchange: References to mjModel and mjData fields (e.g., mjData.contact, mjData.mocap_pos) use canonical MuJoCo names, which are exposed on GPU-resident analogues in mujoco_warp.
  3. Overview of Newton Physics Engine

    main

    Newton is a GPU-accelerated, extensible, and differentiable physics simulation engine designed for robotics, research, and advanced simulation workflows. It is built on NVIDIA Warp and integrates MuJoCo Warp to provide high-performance simulation with modern Python APIs.

    Key capabilities include:

    • GPU Acceleration: Uses NVIDIA Warp for scalable simulation.
    • Multiple Solvers: Supports XPBD, VBD, MuJoCo, Featherstone, SemiImplicit, Kamino, ImplicitMPM, and Style3D.
    • Differentiable Simulation: Enables machine learning and optimization workflows.
    • Rich Import/Export: Supports URDF, MJCF, and USD formats.
  4. Overview of Newton Solvers

    main

    Newton solvers integrate the dynamics of a newton.Model using a common SolverBase interface. The library provides specialized backends for various simulation types, including:

    • Rigid articulated systems
    • Maximal-coordinate constraints
    • Particles
    • Deformable simulation

    For detailed guidance on selecting a solver based on features, contact-material properties, joint support, or differentiability, refer to the official Solvers guide.

  5. Overview of SolverKamino

    main

    SolverKamino is a physics solver designed for simulating arbitrary mechanical assemblies. It is capable of handling kinematic loops and under-/overactuation.

    Key Capabilities:

    • Constrained rigid multi-body systems with arbitrary joint topologies.
    • Support for common and advanced bilateral joint constraints.
    • Unilateral joint-limit and contact constraints (including spatial friction and restitutive impacts).
    • Configurable constraint stabilization per constraint subset.
    • Hard joint-limit and contact constraints enforced via a Proximal-ADMM forward dynamics solver.

    ⚠️ Disclaimer: SolverKamino is currently in BETA 1. It is not recommended for production dependencies. A BETA 2 version is planned for summer 2026.

  6. Understand Newton's core capabilities and architecture

    main

    Newton is an open-source, GPU-accelerated, and differentiable physics engine designed for robotics and high-performance robot learning. It is built on top of NVIDIA Warp and provides high-level simulation APIs, interchangeable solvers, and asset I/O.

    Key features include:

    • Asset Support: Imports OpenUSD, URDF, and MJCF formats.
    • Solver Backends: Multiple interchangeable solvers within a unified architecture.
    • Differentiability: Built on Warp to support differentiable physics for learning tasks.
    • MuJoCo Integration: Leverages MuJoCo Warp (a GPU-accelerated reimplementation of MuJoCo) as a key solver.
  7. Explore Newton submodules

    main

    The newton package is organized into several specialized submodules. Depending on your task, you should import from the relevant submodule:

    • newton.actuators: Actuator models and control.
    • newton.geometry: Geometric primitives and operations.
    • newton.ik: Inverse Kinematics solvers.
    • newton.math: Mathematical utilities.
    • newton.selection: Selection and querying tools.
    • newton.sensors: Sensor models.
    • newton.solvers: Physics and optimization solvers.
    • newton.usd: Universal Scene Description (USD) integration.
    • newton.utils: General utility functions.
    • newton.viewer: Visualization tools.
  8. Use the newton.sensors module

    main

    The newton.sensors module provides classes for interacting with various sensor types in a physics simulation or robotic context. Available sensor classes include:

    • SensorContact: For detecting contact points and forces.
    • SensorFrameTransform: For managing coordinate frame transformations related to sensors.
    • SensorIMU: For Inertial Measurement Unit data (acceleration, angular velocity).
    • SensorTiledCamera: For handling camera data, potentially across multiple tiles or sensors.
  9. Core Concepts of Newton Physics

    main

    Newton's architecture is organized around several key entities:

    • newton.ModelBuilder: The entry point for constructing simulation models from primitives or imported assets (URDF, MJCF, USD).
    • newton.Model: Encapsulates the physical structure, parameters, and configuration of the simulation world (bodies, joints, shapes, etc.).
    • newton.State: Represents the dynamic state (positions and velocities) that solvers update each step. It can include extended attributes for derived quantities like accelerations.
    • newton.Contacts: Stores the active contact set produced by the collision pipeline.
    • newton.Control: Encodes control inputs like joint targets and applied forces.
    • Solver: The component that advances the simulation by integrating physics and enforcing constraints.
    • Sensors: Compute observations from State, Contacts, sites, and shapes.
    • Importer: Methods on ModelBuilder used to load external formats via add_urdf, add_mjcf, and add_usd.
  10. Understand Newton's USD Schema Resolvers

    main

    Newton uses Schema Resolvers to bridge the gap between solver-specific USD schemas (like PhysX or MuJoCo) and Newton's internal representation. They perform three main functions:

    1. Attribute Remapping: Automatically converting attributes authored for other solvers into Newton properties.
    2. Priority-Based Resolution: Handling conflicts when multiple solvers define the same attribute on a single USD prim.
    3. Attribute Collection: Preserving solver-native attributes for inspection or custom pipelines via the schema_attrs key in the import result.

    Note: The schema_resolvers argument in newton.ModelBuilder.add_usd is currently experimental and may change without notice.

  11. Understand Generalized vs Maximal Coordinates in Articulations

    main

    Newton uses two ways to represent the configuration of an articulation (a collection of rigid bodies connected by joints):

    1. Generalized (Reduced) Coordinates: Describes the state via joint positions and velocities.

      • Joint positions are stored in newton.State.joint_q.
      • Joint velocities are stored in newton.State.joint_qd.
      • For floating-base articulations (connected to the world via a FREE joint), these include the base link's 3D position and XYZW quaternion.
    2. Maximal Coordinates: Describes the state via individual body link poses and velocities.

      • Body poses are stored in newton.State.body_q (7 parameters: 3D position + XYZW quaternion).
      • Body velocities are stored in newton.State.body_qd (6 parameters: 3D linear + 3D angular velocity).
      • For FREE and DISTANCE joints, newton.State.joint_qd stores the child-COM twist in the joint parent frame.

    Conversion:

    • Use newton.eval_fk (Forward Kinematics) to convert generalized coordinates to maximal coordinates.
    • Use newton.eval_ik (Inverse Kinematics) to convert maximal coordinates to generalized coordinates.

    Solver Compatibility:

    • Generalized-coordinate solvers (newton.solvers.SolverMuJoCo, newton.solvers.SolverFeatherstone) use joint_q and joint_qd as the primary state.
    • Maximal-coordinate solvers (newton.solvers.SolverXPBD, newton.solvers.SolverSemiImplicit, newton.solvers.SolverVBD) use body_q and body_qd as the primary state.
    • Note: Collision detection via newton.CollisionPipeline.collide requires maximal coordinates to be current in the state.