jaxsim 0.2.1.dev56__tar.gz → 0.2.1.dev69__tar.gz
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-0.2.1.dev56 → jaxsim-0.2.1.dev69}/PKG-INFO +1 -1
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/examples/PD_controller.ipynb +64 -17
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/examples/Parallel_computing.ipynb +9 -0
- jaxsim-0.2.1.dev69/examples/README.md +41 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/_version.py +2 -2
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/parsers/descriptions/model.py +49 -54
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/parsers/kinematic_graph.py +288 -156
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/parsers/rod/parser.py +2 -42
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim.egg-info/PKG-INFO +1 -1
- jaxsim-0.2.1.dev56/examples/README.md +0 -29
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/.devcontainer/Dockerfile +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/.devcontainer/devcontainer.json +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/.gitattributes +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/.github/CODEOWNERS +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/.github/workflows/ci_cd.yml +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/.github/workflows/read_the_docs.yml +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/.github/workflows/style.yml +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/.gitignore +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/.pre-commit-config.yaml +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/.readthedocs.yaml +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/CONTRIBUTING.md +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/LICENSE +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/README.md +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/docs/Makefile +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/docs/conf.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/docs/guide/install.rst +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/docs/index.rst +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/docs/make.bat +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/docs/modules/api.rst +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/docs/modules/index.rst +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/docs/modules/integrators.rst +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/docs/modules/math.rst +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/docs/modules/mujoco.rst +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/docs/modules/parsers.rst +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/docs/modules/rbda.rst +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/docs/modules/typing.rst +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/docs/modules/utils.rst +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/environment.yml +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/examples/.gitattributes +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/examples/.gitignore +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/examples/assets/cartpole.urdf +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/pixi.lock +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/pyproject.toml +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/setup.cfg +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/setup.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/__init__.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/api/__init__.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/api/com.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/api/common.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/api/contact.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/api/data.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/api/joint.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/api/kin_dyn_parameters.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/api/link.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/api/model.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/api/ode.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/api/ode_data.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/api/references.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/integrators/__init__.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/integrators/common.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/integrators/fixed_step.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/integrators/variable_step.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/logging.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/math/__init__.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/math/adjoint.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/math/cross.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/math/inertia.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/math/joint_model.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/math/quaternion.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/math/rotation.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/math/skew.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/math/transform.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/mujoco/__init__.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/mujoco/__main__.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/mujoco/loaders.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/mujoco/model.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/mujoco/visualizer.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/parsers/__init__.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/parsers/descriptions/__init__.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/parsers/descriptions/collision.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/parsers/descriptions/joint.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/parsers/descriptions/link.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/parsers/rod/__init__.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/parsers/rod/utils.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/rbda/__init__.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/rbda/aba.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/rbda/collidable_points.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/rbda/crba.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/rbda/forward_kinematics.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/rbda/jacobian.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/rbda/rnea.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/rbda/soft_contacts.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/rbda/utils.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/terrain/__init__.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/terrain/terrain.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/typing.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/utils/__init__.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/utils/hashless.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/utils/jaxsim_dataclass.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim/utils/tracing.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim.egg-info/SOURCES.txt +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim.egg-info/dependency_links.txt +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim.egg-info/not-zip-safe +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim.egg-info/requires.txt +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/src/jaxsim.egg-info/top_level.txt +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/tests/__init__.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/tests/conftest.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/tests/test_api_com.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/tests/test_api_data.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/tests/test_api_joint.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/tests/test_api_link.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/tests/test_api_model.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/tests/test_automatic_differentiation.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/tests/test_pytree.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/tests/test_simulations.py +0 -0
- {jaxsim-0.2.1.dev56 → jaxsim-0.2.1.dev69}/tests/utils_idyntree.py +0 -0
@@ -6,7 +6,11 @@
|
|
6
6
|
"source": [
|
7
7
|
"# `JAXsim` Showcase: PD Controller\n",
|
8
8
|
"\n",
|
9
|
-
"First, we install the necessary packages and import them
|
9
|
+
"First, we install the necessary packages and import them.\n",
|
10
|
+
"\n",
|
11
|
+
"<a target=\"_blank\" href=\"https://colab.research.google.com/github/ami-iit/jaxsim/blob/main/examples/PD_controller.ipynb\">\n",
|
12
|
+
" <img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/>\n",
|
13
|
+
"</a>"
|
10
14
|
]
|
11
15
|
},
|
12
16
|
{
|
@@ -19,6 +23,28 @@
|
|
19
23
|
"from IPython.display import clear_output, HTML, display\n",
|
20
24
|
"import sys\n",
|
21
25
|
"\n",
|
26
|
+
"IS_COLAB = \"google.colab\" in sys.modules\n",
|
27
|
+
"\n",
|
28
|
+
"# Install JAX and Gazebo SDF\n",
|
29
|
+
"if IS_COLAB:\n",
|
30
|
+
" !{sys.executable} -m pip install -qU jaxsim[viz]\n",
|
31
|
+
" !apt install -qq lsb-release wget gnupg\n",
|
32
|
+
" !wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg\n",
|
33
|
+
" !echo \"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main\" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null\n",
|
34
|
+
" !apt -qq update\n",
|
35
|
+
" !apt install -qq --no-install-recommends libsdformat13 gz-tools2\n",
|
36
|
+
"\n",
|
37
|
+
" # Optional dependency for visualization\n",
|
38
|
+
" !{sys.executable} -m pip install pyvirtualdisplay\n",
|
39
|
+
" !apt install xvfb\n",
|
40
|
+
"\n",
|
41
|
+
" # Start Xvfb and set \"DISPLAY\" environment variable\n",
|
42
|
+
" import pyvirtualdisplay\n",
|
43
|
+
" d = pyvirtualdisplay.Display()\n",
|
44
|
+
" d.start()\n",
|
45
|
+
"\n",
|
46
|
+
" clear_output()\n",
|
47
|
+
"\n",
|
22
48
|
"import jax\n",
|
23
49
|
"import jax.numpy as jnp\n",
|
24
50
|
"from jaxsim import logging\n",
|
@@ -124,29 +150,50 @@
|
|
124
150
|
"source": [
|
125
151
|
"# @title Set up MuJoCo renderer\n",
|
126
152
|
"\n",
|
127
|
-
"from jaxsim.mujoco.visualizer import MujocoVisualizer\n",
|
128
153
|
"from jaxsim.mujoco import RodModelToMjcf, MujocoModelHelper, MujocoVideoRecorder\n",
|
129
154
|
"from jaxsim.mujoco.loaders import UrdfToMjcf\n",
|
130
155
|
"\n",
|
156
|
+
"import os\n",
|
157
|
+
"import subprocess\n",
|
158
|
+
"\n",
|
159
|
+
"\n",
|
160
|
+
"if IS_COLAB:\n",
|
161
|
+
" if subprocess.run(\"ffmpeg -version\", shell=True).returncode:\n",
|
162
|
+
" !command -v ffmpeg >/dev/null || (apt update && apt install -y ffmpeg)\n",
|
163
|
+
" clear_output()\n",
|
164
|
+
"\n",
|
165
|
+
" if subprocess.run(\"nvidia-smi\").returncode:\n",
|
166
|
+
" raise RuntimeError(\n",
|
167
|
+
" \"Cannot communicate with GPU. \"\n",
|
168
|
+
" \"Make sure you are using a GPU Colab runtime. \"\n",
|
169
|
+
" \"Go to the Runtime menu and select Choose runtime type.\"\n",
|
170
|
+
" )\n",
|
171
|
+
"\n",
|
172
|
+
" # Add an ICD config so that glvnd can pick up the Nvidia EGL driver.\n",
|
173
|
+
" # This is usually installed as part of an Nvidia driver package, but the Colab\n",
|
174
|
+
" # kernel doesn't install its driver via APT, and as a result the ICD is missing.\n",
|
175
|
+
" # (https://github.com/NVIDIA/libglvnd/blob/master/src/EGL/icd_enumeration.md)\n",
|
176
|
+
" NVIDIA_ICD_CONFIG_PATH = \"/usr/share/glvnd/egl_vendor.d/10_nvidia.json\"\n",
|
177
|
+
" if not os.path.exists(NVIDIA_ICD_CONFIG_PATH):\n",
|
178
|
+
" with open(NVIDIA_ICD_CONFIG_PATH, \"w\") as f:\n",
|
179
|
+
" f.write(\n",
|
180
|
+
" \"\"\"{\n",
|
181
|
+
" \"file_format_version\" : \"1.0.0\",\n",
|
182
|
+
" \"ICD\" : {\n",
|
183
|
+
" \"library_path\" : \"libEGL_nvidia.so.0\"\n",
|
184
|
+
" }\n",
|
185
|
+
" }\n",
|
186
|
+
" \"\"\"\n",
|
187
|
+
" )\n",
|
131
188
|
"\n",
|
132
189
|
"%env MUJOCO_GL=egl\n",
|
133
190
|
"\n",
|
134
|
-
"try:\n",
|
135
|
-
" import mujoco\n",
|
136
|
-
"except Exception as e:\n",
|
137
|
-
" raise e from RuntimeError(\n",
|
138
|
-
" \"Something went wrong during installation. Check the shell output above \"\n",
|
139
|
-
" \"for more information.\\n\"\n",
|
140
|
-
" \"If using a hosted Colab runtime, make sure you enable GPU acceleration \"\n",
|
141
|
-
" 'by going to the Runtime menu and selecting \"Choose runtime type\".'\n",
|
142
|
-
" )\n",
|
143
|
-
"\n",
|
144
191
|
"camera = {\n",
|
145
|
-
" \"name\"
|
146
|
-
" \"mode\"
|
147
|
-
" \"pos\"
|
148
|
-
" \"xyaxes\"
|
149
|
-
" \"fovy\"
|
192
|
+
" \"name\": \"cartpole_camera\",\n",
|
193
|
+
" \"mode\": \"fixed\",\n",
|
194
|
+
" \"pos\": \"3.954 3.533 2.343\",\n",
|
195
|
+
" \"xyaxes\": \"-0.594 0.804 -0.000 -0.163 -0.120 0.979\",\n",
|
196
|
+
" \"fovy\": \"60\",\n",
|
150
197
|
"}\n",
|
151
198
|
"\n",
|
152
199
|
"mjcf_string, assets = UrdfToMjcf.convert(urdf=model.built_from, cameras=camera)\n",
|
@@ -25,7 +25,16 @@
|
|
25
25
|
"\n",
|
26
26
|
"from IPython.display import HTML, clear_output, display\n",
|
27
27
|
"\n",
|
28
|
+
"IS_COLAB = \"google.colab\" in sys.modules\n",
|
29
|
+
"\n",
|
28
30
|
"# Install JAX and Gazebo\n",
|
31
|
+
"if IS_COLAB:\n",
|
32
|
+
" !{sys.executable} -m pip install -qU jaxsim\n",
|
33
|
+
" !apt install -qq lsb-release wget gnupg\n",
|
34
|
+
" !wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg\n",
|
35
|
+
" !echo \"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main\" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null\n",
|
36
|
+
" !apt -qq update\n",
|
37
|
+
" !apt install -qq --no-install-recommends libsdformat13 gz-tools2\n",
|
29
38
|
"\n",
|
30
39
|
"# Set environment variable to avoid GPU out of memory errors\n",
|
31
40
|
"%env XLA_PYTHON_CLIENT_MEM_PREALLOCATE=false\n",
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# JAXsim Notebook Examples
|
2
|
+
|
3
|
+
This folder includes a Jupyter Notebook demonstrating the practical usage of JAXsim for system simulations.
|
4
|
+
|
5
|
+
### Examples
|
6
|
+
|
7
|
+
- [PD_controller](./PD_controller.ipynb) <a target="_blank" href="https://colab.research.google.com/github/ami-iit/jaxsim/blob/main/examples/PD_controller.ipynb">
|
8
|
+
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
|
9
|
+
</a> - A simple example demonstrating the use of JAXsim to simulate a PD controller with gravity compensation for a 2-DOF cartpole.
|
10
|
+
- [Parallel_computing](./Parallel_computing.ipynb) <a target="_blank" href="https://colab.research.google.com/github/ami-iit/jaxsim/blob/main/examples/Parallel_computing.ipynb">
|
11
|
+
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
|
12
|
+
</a> - An example demonstrating how to simulate vectorized models in parallel using JAXsim.
|
13
|
+
|
14
|
+
> [!TIP]
|
15
|
+
> Stay tuned for more examples!
|
16
|
+
|
17
|
+
## Running the Examples
|
18
|
+
|
19
|
+
To execute these examples utilizing JAXsim with hardware acceleration, there are a couple of options available:
|
20
|
+
|
21
|
+
### Option 1: Google Colab (Recommended)
|
22
|
+
|
23
|
+
The simplest way to run the examples is by accessing the provided Google Colab notebook link mentioned above. This will enable you to execute the examples in a hosted environment.
|
24
|
+
|
25
|
+
### Option 2: Local Execution with `pixi`
|
26
|
+
|
27
|
+
For local execution, follow these steps:
|
28
|
+
|
29
|
+
1. **Install `pixi`:**
|
30
|
+
|
31
|
+
As per the [official documentation](https://pixi.sh/#installation):
|
32
|
+
|
33
|
+
```bash
|
34
|
+
curl -fsSL https://pixi.sh/install.sh | bash
|
35
|
+
```
|
36
|
+
|
37
|
+
2. **Run the Example Notebook:**
|
38
|
+
|
39
|
+
Use `pixi run examples` from the project source directory to execute the example notebook locally.
|
40
|
+
|
41
|
+
This command will automatically handle the installation of necessary dependencies and execute the examples within a self-contained environment
|
@@ -12,5 +12,5 @@ __version__: str
|
|
12
12
|
__version_tuple__: VERSION_TUPLE
|
13
13
|
version_tuple: VERSION_TUPLE
|
14
14
|
|
15
|
-
__version__ = version = '0.2.1.
|
16
|
-
__version_tuple__ = version_tuple = (0, 2, 1, '
|
15
|
+
__version__ = version = '0.2.1.dev69'
|
16
|
+
__version_tuple__ = version_tuple = (0, 2, 1, 'dev69')
|
@@ -1,6 +1,8 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
1
3
|
import dataclasses
|
2
4
|
import itertools
|
3
|
-
from typing import
|
5
|
+
from typing import Sequence
|
4
6
|
|
5
7
|
from jaxsim import logging
|
6
8
|
|
@@ -13,63 +15,62 @@ from .link import LinkDescription
|
|
13
15
|
@dataclasses.dataclass(frozen=True)
|
14
16
|
class ModelDescription(KinematicGraph):
|
15
17
|
"""
|
16
|
-
|
17
|
-
|
18
|
-
Args:
|
19
|
-
name (str): The name of the model.
|
20
|
-
fixed_base (bool): Indicates whether the model has a fixed base.
|
21
|
-
collision_shapes (List[CollisionShape]): List of collision shapes associated with the model.
|
18
|
+
Intermediate representation representing the kinematic graph of a robot model.
|
22
19
|
|
23
20
|
Attributes:
|
24
|
-
name
|
25
|
-
fixed_base
|
26
|
-
collision_shapes
|
21
|
+
name: The name of the model.
|
22
|
+
fixed_base: Whether the model is either fixed-base or floating-base.
|
23
|
+
collision_shapes: List of collision shapes associated with the model.
|
27
24
|
"""
|
28
25
|
|
29
26
|
name: str = None
|
27
|
+
|
30
28
|
fixed_base: bool = True
|
31
|
-
|
29
|
+
|
30
|
+
collision_shapes: list[CollisionShape] = dataclasses.field(
|
31
|
+
default_factory=list, repr=False, hash=False
|
32
|
+
)
|
32
33
|
|
33
34
|
@staticmethod
|
34
35
|
def build_model_from(
|
35
36
|
name: str,
|
36
|
-
links:
|
37
|
-
joints:
|
38
|
-
|
37
|
+
links: list[LinkDescription],
|
38
|
+
joints: list[JointDescription],
|
39
|
+
frames: list[LinkDescription] | None = None,
|
40
|
+
collisions: list[CollisionShape] = (),
|
39
41
|
fixed_base: bool = False,
|
40
42
|
base_link_name: str | None = None,
|
41
|
-
considered_joints:
|
43
|
+
considered_joints: Sequence[str] | None = None,
|
42
44
|
model_pose: RootPose = RootPose(),
|
43
|
-
) ->
|
45
|
+
) -> ModelDescription:
|
44
46
|
"""
|
45
47
|
Build a model description from provided components.
|
46
48
|
|
47
49
|
Args:
|
48
|
-
name
|
49
|
-
links
|
50
|
-
joints
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
50
|
+
name: The name of the model.
|
51
|
+
links: List of link descriptions.
|
52
|
+
joints: List of joint descriptions.
|
53
|
+
frames: List of frame descriptions.
|
54
|
+
collisions: List of collision shapes associated with the model.
|
55
|
+
fixed_base: Indicates whether the model has a fixed base.
|
56
|
+
base_link_name: Name of the base link (i.e. the root of the kinematic tree).
|
57
|
+
considered_joints: List of joint names to consider (by default all joints).
|
58
|
+
model_pose: Pose of the model's root (by default an identity transform).
|
56
59
|
|
57
60
|
Returns:
|
58
|
-
|
59
|
-
|
60
|
-
Raises:
|
61
|
-
ValueError: If invalid or missing input data.
|
61
|
+
A ModelDescription instance representing the model.
|
62
62
|
"""
|
63
63
|
|
64
|
-
# Create the full kinematic graph
|
64
|
+
# Create the full kinematic graph.
|
65
65
|
kinematic_graph = KinematicGraph.build_from(
|
66
66
|
links=links,
|
67
67
|
joints=joints,
|
68
|
+
frames=frames,
|
68
69
|
root_link_name=base_link_name,
|
69
70
|
root_pose=model_pose,
|
70
71
|
)
|
71
72
|
|
72
|
-
# Reduce the graph if needed
|
73
|
+
# Reduce the graph if needed.
|
73
74
|
if considered_joints is not None:
|
74
75
|
kinematic_graph = kinematic_graph.reduce(
|
75
76
|
considered_joints=considered_joints
|
@@ -78,11 +79,13 @@ class ModelDescription(KinematicGraph):
|
|
78
79
|
# Create the object to compute forward kinematics.
|
79
80
|
fk = KinematicGraphTransforms(graph=kinematic_graph)
|
80
81
|
|
81
|
-
#
|
82
|
-
final_collisions:
|
82
|
+
# Container of the final model's collision shapes.
|
83
|
+
final_collisions: list[CollisionShape] = []
|
83
84
|
|
84
|
-
# Move and express the collision shapes of
|
85
|
+
# Move and express the collision shapes of removed links to the resulting
|
86
|
+
# lumped link that replace the combination of the removed link and its parent.
|
85
87
|
for collision_shape in collisions:
|
88
|
+
|
86
89
|
# Get all the collidable points of the shape
|
87
90
|
coll_points = list(collision_shape.collidable_points)
|
88
91
|
|
@@ -112,7 +115,7 @@ class ModelDescription(KinematicGraph):
|
|
112
115
|
final_collisions.append(new_collision_shape)
|
113
116
|
|
114
117
|
# If the frame was found, update the collidable points' pose and add them
|
115
|
-
#
|
118
|
+
# to the new collision shape.
|
116
119
|
for cp in collision_shape.collidable_points:
|
117
120
|
# Find the link that is part of the (reduced) model in which the
|
118
121
|
# collision shape's parent was lumped into
|
@@ -145,22 +148,20 @@ class ModelDescription(KinematicGraph):
|
|
145
148
|
_joints_removed=kinematic_graph._joints_removed,
|
146
149
|
)
|
147
150
|
|
151
|
+
# Check that the root link of kinematic graph is the desired base link.
|
148
152
|
assert kinematic_graph.root.name == base_link_name, kinematic_graph.root.name
|
149
153
|
|
150
154
|
return model
|
151
155
|
|
152
|
-
def reduce(self, considered_joints:
|
156
|
+
def reduce(self, considered_joints: Sequence[str]) -> ModelDescription:
|
153
157
|
"""
|
154
158
|
Reduce the model by removing specified joints.
|
155
159
|
|
156
160
|
Args:
|
157
|
-
|
161
|
+
The joint names to consider.
|
158
162
|
|
159
163
|
Returns:
|
160
|
-
ModelDescription
|
161
|
-
|
162
|
-
Raises:
|
163
|
-
ValueError: If the specified joints are not part of the model.
|
164
|
+
A `ModelDescription` instance that only includes the considered joints.
|
164
165
|
"""
|
165
166
|
|
166
167
|
if len(set(considered_joints) - set(self.joint_names())) != 0:
|
@@ -172,6 +173,7 @@ class ModelDescription(KinematicGraph):
|
|
172
173
|
name=self.name,
|
173
174
|
links=list(self.links_dict.values()),
|
174
175
|
joints=self.joints,
|
176
|
+
frames=self.frames,
|
175
177
|
collisions=self.collision_shapes,
|
176
178
|
fixed_base=self.fixed_base,
|
177
179
|
base_link_name=list(iter(self))[0].name,
|
@@ -190,12 +192,8 @@ class ModelDescription(KinematicGraph):
|
|
190
192
|
Enable or disable collision shapes associated with a link.
|
191
193
|
|
192
194
|
Args:
|
193
|
-
link_name
|
194
|
-
enabled
|
195
|
-
|
196
|
-
Raises:
|
197
|
-
ValueError: If the link name is not found in the model.
|
198
|
-
|
195
|
+
link_name: The name of the link.
|
196
|
+
enabled: Enable or disable collision shapes associated with the link.
|
199
197
|
"""
|
200
198
|
|
201
199
|
if link_name not in self.link_names():
|
@@ -211,14 +209,10 @@ class ModelDescription(KinematicGraph):
|
|
211
209
|
Get the collision shape associated with a specific link.
|
212
210
|
|
213
211
|
Args:
|
214
|
-
link_name
|
212
|
+
link_name: The name of the link.
|
215
213
|
|
216
214
|
Returns:
|
217
|
-
|
218
|
-
|
219
|
-
Raises:
|
220
|
-
ValueError: If the link name is not found in the model.
|
221
|
-
|
215
|
+
The collision shape associated with the link.
|
222
216
|
"""
|
223
217
|
|
224
218
|
if link_name not in self.link_names():
|
@@ -233,14 +227,15 @@ class ModelDescription(KinematicGraph):
|
|
233
227
|
]
|
234
228
|
)
|
235
229
|
|
236
|
-
def all_enabled_collidable_points(self) ->
|
230
|
+
def all_enabled_collidable_points(self) -> list[CollidablePoint]:
|
237
231
|
"""
|
238
232
|
Get all enabled collidable points in the model.
|
239
233
|
|
240
234
|
Returns:
|
241
|
-
|
235
|
+
The list of all enabled collidable points.
|
242
236
|
|
243
237
|
"""
|
238
|
+
|
244
239
|
# Get iterator of all collidable points
|
245
240
|
all_collidable_points = itertools.chain.from_iterable(
|
246
241
|
[shape.collidable_points for shape in self.collision_shapes]
|