Skip to main content

A differentiable physics engine and multibody dynamics library for control and robot learning.

Project description

JaxSim

JaxSim is a differentiable physics engine and multibody dynamics library designed for applications in control and robot learning, implemented with JAX.

Its design facilitates research and accelerates prototyping in the intersection of robotics and artificial intelligence.



Features

  • Physics engine in reduced coordinates supporting fixed-base and floating-base robots.
  • Multibody dynamics library providing all the necessary components for developing model-based control algorithms.
  • Completely developed in Python with google/jax following a functional programming paradigm.
  • Transparent support for running on CPUs, GPUs, and TPUs.
  • Full support for JIT compilation for increased performance.
  • Full support for automatic vectorization for massive parallelization of open-loop and closed-loop architectures.
  • Support for SDF models and, upon conversion with sdformat, URDF models.
  • Visualization based on the passive viewer of Mujoco.

JaxSim as a simulator

  • Wide range of fixed-step explicit Runge-Kutta integrators.
  • Support for variable-step integrators implemented as embedded Runge-Kutta schemes.
  • Improved stability by optionally integrating the base orientation on the $\text{SO}(3)$ manifold.
  • Soft contacts model supporting full friction cone and sticking-slipping transition.
  • Collision detection between points rigidly attached to bodies and uneven ground surfaces.

JaxSim as a multibody dynamics library

  • Provides rigid body dynamics algorithms (RBDAs) like RNEA, ABA, CRBA, and Jacobians.
  • Provides all the quantities included in the Euler-Poincarè formulation of the equations of motion.
  • Supports body-fixed, inertial-fixed, and mixed velocity representations.
  • Exposes all the necessary quantities to develop controllers in centroidal coordinates.
  • Supports running open-loop and full closed-loop control architectures on hardware accelerators.

JaxSim for robot learning

  • Being developed with JAX, all the RBDAs support automatic differentiation both in forward and reverse modes.
  • Support for automatically differentiating against kinematics and dynamics parameters.
  • All fixed-step integrators are forward and reverse differentiable.
  • All variable-step integrators are forward differentiable.
  • Ideal for sampling synthetic data for reinforcement learning (RL).
  • Ideal for designing physics-informed neural networks (PINNs) with loss functions requiring model-based quantities.
  • Ideal for combining model-based control with learning-based components.

[!WARNING] This project is still experimental, APIs could change between releases without notice.

[!NOTE] JaxSim currently focuses on locomotion applications. Only contacts between bodies and smooth ground surfaces are supported.

Documentation

The JaxSim API documentation is available at jaxsim.readthedocs.io.

Installation

With conda

You can install the project using conda as follows:

conda install jaxsim -c conda-forge

You can enforce GPU support, if needed, by also specifying "jaxlib = * = *cuda*".

With pip

You can install the project using pypa/pip, preferably in a virtual environment, as follows:

pip install jaxsim

Check pyproject.toml for the complete list of optional dependencies. You can obtain a full installation using jaxsim[all].

If you need GPU support, follow the official installation instructions of JAX.

Contributors installation

If you want to contribute to the project, we recommend creating the following jaxsim conda environment first:

conda env create -f environment.yml

Then, activate the environment and install the project in editable mode:

conda activate jaxsim
pip install --no-deps -e .

Overview

Structure of the Python package
# tree -L 2 -I "__pycache__" -I "__init__*" -I "__main__*" src/jaxsim

src/jaxsim
|-- api..........................# Package containing the main functional APIs.
|   |-- com.py...................# |-- APIs for computing quantities related to the center of mass.
|   |-- common.py................# |-- Common utilities used in the current package.
|   |-- contact.py...............# |-- APIs for computing quantities related to the collidable points.
|   |-- data.py..................# |-- Class storing the data of a simulated model.
|   |-- frame.py.................# |-- APIs for computing quantities related to additional frames.
|   |-- joint.py.................# |-- APIs for computing quantities related to the joints.
|   |-- kin_dyn_parameters.py....# |-- Class storing kinematic and dynamic parameters of a model.
|   |-- link.py..................# |-- APIs for computing quantities related to the links.
|   |-- model.py.................# |-- Class defining a simulated model and APIs for computing related quantities.
|   |-- ode.py...................# |-- APIs for computing quantities related to the system dynamics.
|   |-- ode_data.py..............# |-- Set of classes to store the data of the system dynamics.
|   `-- references.py............# `-- Helper class to create references (link forces and joint torques).
|-- exceptions.py................# Module containing functions to raise exceptions from JIT-compiled functions.
|-- integrators..................# Package containing the integrators used to simulate the system dynamics.
|   |-- common.py................# |-- Common utilities used in the current package.
|   |-- fixed_step.py............# |-- Fixed-step integrators (explicit Runge-Kutta schemes).
|   `-- variable_step.py.........# `-- Variable-step integrators (embedded Runge-Kutta schemes).
|-- logging.py...................# Module containing logging utilities.
|-- math.........................# Package containing mathematical utilities.
|   |-- adjoint.py...............# |-- APIs for creating and manipulating 6D transformations.
|   |-- cross.py.................# |-- APIs for computing cross products of 6D quantities.
|   |-- inertia.py...............# |-- APIs for creating and manipulating 6D inertia matrices.
|   |-- joint_model.py...........# |-- APIs defining the supported joint model and the corresponding transformations.
|   |-- quaternion.py............# |-- APIs for creating and manipulating quaternions.
|   |-- rotation.py..............# |-- APIs for creating and manipulating rotation matrices.
|   |-- skew.py..................# |-- APIs for creating and manipulating skew-symmetric matrices.
|   `-- transform.py.............# `-- APIs for creating and manipulating homogeneous transformations.
|-- mujoco.......................# Package containing utilities to interact with the Mujoco passive viewer.
|   |-- loaders.py...............# |-- Utilities for converting JaxSim models to Mujoco models.
|   |-- model.py.................# |-- Class providing high-level methods to compute quantities using Mujoco.
|   `-- visualizer.py............# `-- Class that simplifies opening the passive viewer and recording videos.
|-- parsers......................# Package containing utilities to parse model descriptions (SDF and URDF models).
|   |-- descriptions/............# |-- Package containing the intermediate representation of a model description.
|   |-- kinematic_graph.py.......# |-- Definition of the kinematic graph associated with a parsed model description.
|   `-- rod/.....................# `-- Package to create the intermediate representation from model descriptions using ROD.
|-- rbda.........................# Package containing the low-level rigid body dynamics algorithms.
|   |-- aba.py...................# |-- The Articulated Body Algorithm.
|   |-- collidable_points.py.....# |-- Kinematics of collidable points.
|   |-- contacts/................# |-- Package containing the supported contact models.
|   |-- crba.py..................# |-- The Composite Rigid Body Algorithm.
|   |-- forward_kinematics.py....# |-- Forward kinematics of the model.
|   |-- jacobian.py..............# |-- Full Jacobian and full Jacobian derivative.
|   |-- rnea.py..................# |-- The Recursive Newton-Euler Algorithm.
|   `-- utils.py.................# `-- Common utilities used in the current package.
|-- terrain......................# Package containing resources to specify the terrain.
|   `-- terrain.py...............# `-- Classes defining the supported terrains.
|-- typing.py....................# Module containing type hints.
`-- utils........................# Package of common utilities.
    |-- jaxsim_dataclass.py......# |-- Utilities to operate on pytree dataclasses.
    |-- tracing.py...............# |-- Utilities to use when JAX is tracing functions.
    `-- wrappers.py..............# `-- Utilities to wrap objects for specific use cases on pytree dataclass attributes.

Credits

The RBDAs are based on the theory of the Rigid Body Dynamics Algorithms book by Roy Featherstone. The algorithms and some simulation features were inspired by its accompanying code.

The development of JaxSim started in late 2021, inspired by early versions of google/brax. At that time, Brax was implemented in maximal coordinates, and we wanted a physics engine in reduced coordinates. We are grateful to the Brax team for their work and showing the potential of JAX in this field.

Brax v2 was later implemented reduced coordinates, following an approach comparable to JaxSim. The development then shifted to MJX, which today provides a JAX-based implementation of the Mujoco APIs.

The main differences between MJX/Brax and JaxSim are as follows:

  • JaxSim supports out-of-the-box all SDF models with Pose Frame Semantics.
  • JaxSim only supports collisions between points rigidly attached to bodies and a compliant ground surface. Our contact model requires careful tuning of its spring-damper parameters, but being an instantaneous function of the state $(\mathbf{q}, \boldsymbol{\nu})$, it doesn't require running any optimization algorithm when stepping the simulation forward.
  • JaxSim mitigates the stiffness of the contact-aware system dynamics by providing variable-step integrators.

Contributing

We welcome contributions from the community. Please read the contributing guide to get started.

Citing

@software{ferigo_jaxsim_2022,
  author = {Diego Ferigo and Filippo Luca Ferretti and Silvio Traversaro and Daniele Pucci},
  title = {{JaxSim}: A Differentiable Physics Engine and Multibody Dynamics Library for Control and Robot Learning},
  url = {http://github.com/ami-iit/jaxsim},
  year = {2022},
}

Theoretical aspects of JaxSim are based on Chapters 7 and 8 of the following Ph.D. thesis:

@phdthesis{ferigo_phd_thesis_2022,
  title = {Simulation Architectures for Reinforcement Learning applied to Robotics},
  author = {Diego Ferigo},
  school = {University of Manchester},
  type = {PhD Thesis},
  month = {July},
  year = {2022},
}

People

Author Maintainers

License

BSD3

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jaxsim-0.4.3.dev298.tar.gz (192.8 kB view details)

Uploaded Source

Built Distribution

jaxsim-0.4.3.dev298-py3-none-any.whl (170.6 kB view details)

Uploaded Python 3

File details

Details for the file jaxsim-0.4.3.dev298.tar.gz.

File metadata

  • Download URL: jaxsim-0.4.3.dev298.tar.gz
  • Upload date:
  • Size: 192.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for jaxsim-0.4.3.dev298.tar.gz
Algorithm Hash digest
SHA256 ec537530d827aad8b0ca373a4200952d856d9f5e788de675d7d2db0d5e36b944
MD5 2d3dd4a4b97c40e5e31c6f02b4455b81
BLAKE2b-256 804ee4d96622c39a09ec0b1eb28a8ca35e3007d9f7881035f07672ae19ff03b3

See more details on using hashes here.

Provenance

The following attestation bundles were made for jaxsim-0.4.3.dev298.tar.gz:

Publisher: ci_cd.yml on ami-iit/jaxsim

Attestations:

File details

Details for the file jaxsim-0.4.3.dev298-py3-none-any.whl.

File metadata

File hashes

Hashes for jaxsim-0.4.3.dev298-py3-none-any.whl
Algorithm Hash digest
SHA256 e9589e71298452059238b530c958379e82f54e1c823256cc7166a97ecdc3d62c
MD5 49ec578960979f1badffb1479d63cee0
BLAKE2b-256 8a8c0d0be87b370a0b29825a03c46e631a9baece72d686522c6342e7f8a4e96c

See more details on using hashes here.

Provenance

The following attestation bundles were made for jaxsim-0.4.3.dev298-py3-none-any.whl:

Publisher: ci_cd.yml on ami-iit/jaxsim

Attestations:

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page