jaxsim 0.5.1.dev99__py3-none-any.whl → 0.5.1.dev123__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- jaxsim/__init__.py +11 -3
- jaxsim/_version.py +2 -2
- jaxsim/exceptions.py +3 -2
- {jaxsim-0.5.1.dev99.dist-info → jaxsim-0.5.1.dev123.dist-info}/METADATA +102 -38
- {jaxsim-0.5.1.dev99.dist-info → jaxsim-0.5.1.dev123.dist-info}/RECORD +8 -8
- {jaxsim-0.5.1.dev99.dist-info → jaxsim-0.5.1.dev123.dist-info}/LICENSE +0 -0
- {jaxsim-0.5.1.dev99.dist-info → jaxsim-0.5.1.dev123.dist-info}/WHEEL +0 -0
- {jaxsim-0.5.1.dev99.dist-info → jaxsim-0.5.1.dev123.dist-info}/top_level.txt +0 -0
jaxsim/__init__.py
CHANGED
@@ -8,19 +8,27 @@ def _jnp_options() -> None:
|
|
8
8
|
|
9
9
|
import jax
|
10
10
|
|
11
|
-
# Check if running on TPU
|
11
|
+
# Check if running on TPU.
|
12
12
|
is_tpu = jax.devices()[0].platform == "tpu"
|
13
13
|
|
14
|
+
# Check if running on Metal.
|
15
|
+
is_metal = jax.devices()[0].platform == "METAL"
|
16
|
+
|
14
17
|
# Enable by default 64-bit precision to get accurate physics.
|
15
18
|
# Users can enforce 32-bit precision by setting the following variable to 0.
|
16
19
|
use_x64 = os.environ.get("JAX_ENABLE_X64", "1") != "0"
|
17
20
|
|
18
21
|
# Notify the user if unsupported 64-bit precision was enforced on TPU.
|
19
|
-
if is_tpu and use_x64:
|
20
|
-
msg = "64-bit precision is not allowed on
|
22
|
+
if (is_tpu or is_metal) and use_x64:
|
23
|
+
msg = f"64-bit precision is not allowed on {jax.devices()[0].platform.upper}. Enforcing 32bit precision."
|
21
24
|
logging.warning(msg)
|
22
25
|
use_x64 = False
|
23
26
|
|
27
|
+
if is_metal:
|
28
|
+
logging.warning(
|
29
|
+
"JAX Metal backend is experimental. Some functionalities may not be available."
|
30
|
+
)
|
31
|
+
|
24
32
|
# Enable 64-bit precision in JAX.
|
25
33
|
if use_x64:
|
26
34
|
logging.info("Enabling JAX to use 64-bit precision")
|
jaxsim/_version.py
CHANGED
@@ -12,5 +12,5 @@ __version__: str
|
|
12
12
|
__version_tuple__: VERSION_TUPLE
|
13
13
|
version_tuple: VERSION_TUPLE
|
14
14
|
|
15
|
-
__version__ = version = '0.5.1.
|
16
|
-
__version_tuple__ = version_tuple = (0, 5, 1, '
|
15
|
+
__version__ = version = '0.5.1.dev123'
|
16
|
+
__version_tuple__ = version_tuple = (0, 5, 1, 'dev123')
|
jaxsim/exceptions.py
CHANGED
@@ -19,8 +19,9 @@ def raise_if(
|
|
19
19
|
format string (fmt), whose fields are filled with the args and kwargs.
|
20
20
|
"""
|
21
21
|
|
22
|
-
# Disable host callback if running on
|
23
|
-
|
22
|
+
# Disable host callback if running on unsupported hardware or if the user
|
23
|
+
# explicitly disabled it.
|
24
|
+
if jax.devices()[0].platform in {"tpu", "METAL"} or os.environ.get(
|
24
25
|
"JAXSIM_DISABLE_EXCEPTIONS", 0
|
25
26
|
):
|
26
27
|
return
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: jaxsim
|
3
|
-
Version: 0.5.1.
|
3
|
+
Version: 0.5.1.dev123
|
4
4
|
Summary: A differentiable physics engine and multibody dynamics library for control and robot learning.
|
5
5
|
Author-email: Diego Ferigo <dgferigo@gmail.com>, Filippo Luca Ferretti <filippoluca.ferretti@outlook.com>
|
6
6
|
Maintainer-email: Filippo Luca Ferretti <filippo.ferretti@iit.it>, Alessandro Croci <alessandro.croci@iit.it>
|
@@ -81,6 +81,7 @@ Requires-Dist: pytest>=6.0; extra == "testing"
|
|
81
81
|
Requires-Dist: pytest-benchmark; extra == "testing"
|
82
82
|
Requires-Dist: pytest-icdiff; extra == "testing"
|
83
83
|
Requires-Dist: robot-descriptions; extra == "testing"
|
84
|
+
Requires-Dist: icub-models; extra == "testing"
|
84
85
|
Provides-Extra: viz
|
85
86
|
Requires-Dist: lxml; extra == "viz"
|
86
87
|
Requires-Dist: mediapy; extra == "viz"
|
@@ -91,9 +92,7 @@ Requires-Dist: jaxsim[style,testing,viz]; extra == "all"
|
|
91
92
|
|
92
93
|
# JaxSim
|
93
94
|
|
94
|
-
JaxSim is a **differentiable physics engine** and **multibody dynamics library**
|
95
|
-
|
96
|
-
Its design facilitates research and accelerates prototyping in the intersection of robotics and artificial intelligence.
|
95
|
+
**JaxSim** is a **differentiable physics engine** and **multibody dynamics library** built with JAX, tailored for control and robotic learning applications.
|
97
96
|
|
98
97
|
<div align="center">
|
99
98
|
<br/>
|
@@ -108,41 +107,105 @@ Its design facilitates research and accelerates prototyping in the intersection
|
|
108
107
|
</div>
|
109
108
|
|
110
109
|
## Features
|
110
|
+
- Reduced-coordinate physics engine for **fixed-base** and **floating-base** robots.
|
111
|
+
- Multibody dynamics library for model-based control algorithms.
|
112
|
+
- Fully Python-based, leveraging [jax][jax] following a functional programming paradigm.
|
113
|
+
- Seamless execution on CPUs, GPUs, and TPUs.
|
114
|
+
- Supports JIT compilation and automatic vectorization for high performance.
|
115
|
+
- Compatible with SDF models and URDF (via [sdformat][sdformat] conversion).
|
116
|
+
|
117
|
+
## Usage
|
118
|
+
|
119
|
+
### Using JaxSim as simulator
|
120
|
+
|
121
|
+
|
122
|
+
```python
|
123
|
+
import jax.numpy as jnp
|
124
|
+
import jaxsim.api as js
|
125
|
+
import icub_models
|
126
|
+
import pathlib
|
127
|
+
|
128
|
+
# Load the iCub model
|
129
|
+
model_path = icub_models.get_model_file("iCubGazeboV2_5")
|
130
|
+
joints = ('torso_pitch', 'torso_roll', 'torso_yaw', 'l_shoulder_pitch',
|
131
|
+
'l_shoulder_roll', 'l_shoulder_yaw', 'l_elbow', 'r_shoulder_pitch',
|
132
|
+
'r_shoulder_roll', 'r_shoulder_yaw', 'r_elbow', 'l_hip_pitch',
|
133
|
+
'l_hip_roll', 'l_hip_yaw', 'l_knee', 'l_ankle_pitch', 'l_ankle_roll',
|
134
|
+
'r_hip_pitch', 'r_hip_roll', 'r_hip_yaw', 'r_knee', 'r_ankle_pitch',
|
135
|
+
'r_ankle_roll')
|
136
|
+
|
137
|
+
# Build and reduce the model
|
138
|
+
model_description = pathlib.Path(model_path)
|
139
|
+
full_model = js.model.JaxSimModel.build_from_model_description(
|
140
|
+
model_description=model_description, time_step=0.0001, is_urdf=True
|
141
|
+
)
|
142
|
+
model = js.model.reduce(model=full_model, considered_joints=joints)
|
143
|
+
|
144
|
+
ndof = model.dofs()
|
145
|
+
# Initialize data and simulation
|
146
|
+
data = js.data.JaxSimModelData.zero(model=model).reset_base_position(
|
147
|
+
base_position=jnp.array([0.0, 0.0, 1.0])
|
148
|
+
)
|
149
|
+
T = jnp.arange(start=0, stop=1.0, step=model.time_step)
|
150
|
+
tau = jnp.zeros(ndof)
|
151
|
+
|
152
|
+
# Simulate
|
153
|
+
for t in T:
|
154
|
+
data, _ = js.model.step(model=model, data=data, link_forces=None, joint_force_references=tau)
|
111
155
|
|
112
|
-
|
113
|
-
- Multibody dynamics library providing all the necessary components for developing model-based control algorithms.
|
114
|
-
- Completely developed in Python with [`google/jax`][jax] following a functional programming paradigm.
|
115
|
-
- Transparent support for running on CPUs, GPUs, and TPUs.
|
116
|
-
- Full support for JIT compilation for increased performance.
|
117
|
-
- Full support for automatic vectorization for massive parallelization of open-loop and closed-loop architectures.
|
118
|
-
- Support for SDF models and, upon conversion with [sdformat][sdformat], URDF models.
|
119
|
-
- Visualization based on the [passive viewer][passive_viewer_mujoco] of Mujoco.
|
120
|
-
|
121
|
-
### JaxSim as a simulator
|
122
|
-
|
123
|
-
- Wide range of fixed-step explicit Runge-Kutta integrators.
|
124
|
-
- Support for variable-step integrators implemented as embedded Runge-Kutta schemes.
|
125
|
-
- Improved stability by optionally integrating the base orientation on the $\text{SO}(3)$ manifold.
|
126
|
-
- Soft contacts model supporting full friction cone and sticking-slipping transition.
|
127
|
-
- Collision detection between points rigidly attached to bodies and uneven ground surfaces.
|
128
|
-
|
129
|
-
### JaxSim as a multibody dynamics library
|
156
|
+
```
|
130
157
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
158
|
+
### Using JaxSim as a multibody dynamics library
|
159
|
+
``` python
|
160
|
+
import jax.numpy as jnp
|
161
|
+
import jaxsim.api as js
|
162
|
+
import icub_models
|
163
|
+
import pathlib
|
164
|
+
|
165
|
+
# Load the iCub model
|
166
|
+
model_path = icub_models.get_model_file("iCubGazeboV2_5")
|
167
|
+
joints = ('torso_pitch', 'torso_roll', 'torso_yaw', 'l_shoulder_pitch',
|
168
|
+
'l_shoulder_roll', 'l_shoulder_yaw', 'l_elbow', 'r_shoulder_pitch',
|
169
|
+
'r_shoulder_roll', 'r_shoulder_yaw', 'r_elbow', 'l_hip_pitch',
|
170
|
+
'l_hip_roll', 'l_hip_yaw', 'l_knee', 'l_ankle_pitch', 'l_ankle_roll',
|
171
|
+
'r_hip_pitch', 'r_hip_roll', 'r_hip_yaw', 'r_knee', 'r_ankle_pitch',
|
172
|
+
'r_ankle_roll')
|
173
|
+
|
174
|
+
# Build and reduce the model
|
175
|
+
model_description = pathlib.Path(model_path)
|
176
|
+
full_model = js.model.JaxSimModel.build_from_model_description(
|
177
|
+
model_description=model_description, time_step=0.0001, is_urdf=True
|
178
|
+
)
|
179
|
+
model = js.model.reduce(model=full_model, considered_joints=joints)
|
180
|
+
|
181
|
+
# Initialize model data
|
182
|
+
data = js.data.JaxSimModelData.build(
|
183
|
+
model=model,
|
184
|
+
base_position=jnp.array([0.0, 0.0, 1.0],
|
185
|
+
)
|
186
|
+
|
187
|
+
# Frame and dynamics computations
|
188
|
+
frame_index = js.frame.name_to_idx(model=model, frame_name="l_foot")
|
189
|
+
W_H_F = js.frame.transform(model=model, data=data, frame_index=frame_index) # Frame transformation
|
190
|
+
W_J_F = js.frame.jacobian(model=model, data=data, frame_index=frame_index) # Frame Jacobian
|
191
|
+
|
192
|
+
# Dynamics properties
|
193
|
+
M = js.model.free_floating_mass_matrix(model=model, data=data) # Mass matrix
|
194
|
+
h = js.model.free_floating_bias_forces(model=model, data=data) # Bias forces
|
195
|
+
g = js.model.free_floating_gravity_forces(model=model, data=data) # Gravity forces
|
196
|
+
C = js.model.free_floating_coriolis_matrix(model=model, data=data) # Coriolis matrix
|
197
|
+
|
198
|
+
# Print dynamics results
|
199
|
+
print(f"M: shape={M.shape}, h: shape={h.shape}, g: shape={g.shape}, C: shape={C.shape}")
|
136
200
|
|
137
|
-
|
201
|
+
```
|
202
|
+
### Additional features
|
138
203
|
|
139
|
-
-
|
204
|
+
- Full support for automatic differentiation of RBDAs (forward and reverse modes) with JAX.
|
140
205
|
- Support for automatically differentiating against kinematics and dynamics parameters.
|
141
206
|
- All fixed-step integrators are forward and reverse differentiable.
|
142
207
|
- All variable-step integrators are forward differentiable.
|
143
|
-
-
|
144
|
-
- Ideal for designing physics-informed neural networks (PINNs) with loss functions requiring model-based quantities.
|
145
|
-
- Ideal for combining model-based control with learning-based components.
|
208
|
+
- Check the example folder for additional usecase !
|
146
209
|
|
147
210
|
[jax]: https://github.com/google/jax/
|
148
211
|
[sdformat]: https://github.com/gazebosim/sdformat
|
@@ -156,12 +219,6 @@ Its design facilitates research and accelerates prototyping in the intersection
|
|
156
219
|
> JaxSim currently focuses on locomotion applications.
|
157
220
|
> Only contacts between bodies and smooth ground surfaces are supported.
|
158
221
|
|
159
|
-
## Documentation
|
160
|
-
|
161
|
-
The JaxSim API documentation is available at [jaxsim.readthedocs.io][readthedocs].
|
162
|
-
|
163
|
-
[readthedocs]: https://jaxsim.readthedocs.io/
|
164
|
-
|
165
222
|
## Installation
|
166
223
|
|
167
224
|
<details>
|
@@ -233,6 +290,13 @@ pip install --no-deps -e .
|
|
233
290
|
[venv]: https://docs.python.org/3/tutorial/venv.html
|
234
291
|
[jax_gpu]: https://github.com/google/jax/#installation
|
235
292
|
|
293
|
+
## Documentation
|
294
|
+
|
295
|
+
The JaxSim API documentation is available at [jaxsim.readthedocs.io][readthedocs].
|
296
|
+
|
297
|
+
[readthedocs]: https://jaxsim.readthedocs.io/
|
298
|
+
|
299
|
+
|
236
300
|
## Overview
|
237
301
|
|
238
302
|
<details>
|
@@ -1,6 +1,6 @@
|
|
1
|
-
jaxsim/__init__.py,sha256=
|
2
|
-
jaxsim/_version.py,sha256=
|
3
|
-
jaxsim/exceptions.py,sha256=
|
1
|
+
jaxsim/__init__.py,sha256=OQcCxXn4BXiSvGjAatqvw5fAEVfXbxyavQZN25NEyBo,3675
|
2
|
+
jaxsim/_version.py,sha256=AbzPKnmppXR6QDpBgOm9asK8vnGvLhmkB5prR4HYWBc,428
|
3
|
+
jaxsim/exceptions.py,sha256=5rYd0kGrIaq1e0WK0qMVTCkoGJtMWz_uWlVtxHbjH_A,2322
|
4
4
|
jaxsim/logging.py,sha256=STI-D_upXZYX-ZezLrlJJ0UlD5YspST0vZ_DcIwkzO4,1553
|
5
5
|
jaxsim/typing.py,sha256=7msl8t5Jt09RNYfKdPJtpjLfWurldcycDappb045Eso,761
|
6
6
|
jaxsim/api/__init__.py,sha256=8eV22t2S3UwNyCg8karPetG1dmX1VDBXkyv28_FwNQA,210
|
@@ -67,8 +67,8 @@ jaxsim/utils/__init__.py,sha256=Y5zyoRevl3EMVQadhZ4EtSwTEkDt2vcnFoRhPJjKTZ0,215
|
|
67
67
|
jaxsim/utils/jaxsim_dataclass.py,sha256=TGmTQV2Lq7Q-2nLoAEaeNtkPa_qj0IKkdBm4COj46Os,11312
|
68
68
|
jaxsim/utils/tracing.py,sha256=eEY28MZW0Lm_jJNt1NkFqZz0ek01tvhR46OXZYCo7tc,532
|
69
69
|
jaxsim/utils/wrappers.py,sha256=ZY7olSORzZRvSzkdeNLj8yjwUIAt9L0Douwl7wItjpk,4008
|
70
|
-
jaxsim-0.5.1.
|
71
|
-
jaxsim-0.5.1.
|
72
|
-
jaxsim-0.5.1.
|
73
|
-
jaxsim-0.5.1.
|
74
|
-
jaxsim-0.5.1.
|
70
|
+
jaxsim-0.5.1.dev123.dist-info/LICENSE,sha256=eaYdFmdeMbiIoIiPzEK0MjP1S9wtFXjXNR5er49uLR0,1546
|
71
|
+
jaxsim-0.5.1.dev123.dist-info/METADATA,sha256=KK8J1WX2yaEQYKLBIPqryr6Fem8CKXGg5jGHOcLdvWc,19484
|
72
|
+
jaxsim-0.5.1.dev123.dist-info/WHEEL,sha256=A3WOREP4zgxI0fKrHUG8DC8013e3dK3n7a6HDbcEIwE,91
|
73
|
+
jaxsim-0.5.1.dev123.dist-info/top_level.txt,sha256=LxGMA8FLtXjQ6oI7N5gd_R_oSUHxpXxUEOfT1xS_ni0,7
|
74
|
+
jaxsim-0.5.1.dev123.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|