jaxsim 0.5.1.dev84__tar.gz → 0.5.1.dev91__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.5.1.dev84 → jaxsim-0.5.1.dev91}/PKG-INFO +1 -1
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/_version.py +2 -2
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/integrators/common.py +8 -11
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/integrators/variable_step.py +29 -36
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim.egg-info/PKG-INFO +1 -1
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/tests/conftest.py +1 -1
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/tests/test_simulations.py +16 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/.devcontainer/Dockerfile +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/.devcontainer/devcontainer.json +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/.gitattributes +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/.github/CODEOWNERS +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/.github/dependabot.yml +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/.github/workflows/ci_cd.yml +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/.github/workflows/pixi.yml +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/.github/workflows/read_the_docs.yml +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/.gitignore +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/.pre-commit-config.yaml +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/.readthedocs.yaml +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/CONTRIBUTING.md +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/LICENSE +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/README.md +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/docs/Makefile +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/docs/conf.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/docs/examples.rst +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/docs/guide/configuration.rst +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/docs/guide/install.rst +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/docs/index.rst +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/docs/make.bat +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/docs/modules/api.rst +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/docs/modules/integrators.rst +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/docs/modules/math.rst +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/docs/modules/mujoco.rst +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/docs/modules/parsers.rst +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/docs/modules/rbda.rst +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/docs/modules/typing.rst +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/docs/modules/utils.rst +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/environment.yml +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/examples/.gitattributes +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/examples/.gitignore +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/examples/README.md +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/examples/assets/build_cartpole_urdf.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/examples/assets/cartpole.urdf +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/examples/jaxsim_as_multibody_dynamics_library.ipynb +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/examples/jaxsim_as_physics_engine.ipynb +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/examples/jaxsim_for_robot_controllers.ipynb +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/pixi.lock +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/pyproject.toml +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/setup.cfg +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/setup.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/__init__.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/api/__init__.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/api/com.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/api/common.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/api/contact.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/api/data.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/api/frame.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/api/joint.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/api/kin_dyn_parameters.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/api/link.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/api/model.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/api/ode.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/api/ode_data.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/api/references.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/exceptions.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/integrators/__init__.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/integrators/fixed_step.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/logging.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/math/__init__.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/math/adjoint.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/math/cross.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/math/inertia.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/math/joint_model.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/math/quaternion.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/math/rotation.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/math/skew.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/math/transform.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/mujoco/__init__.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/mujoco/__main__.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/mujoco/loaders.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/mujoco/model.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/mujoco/utils.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/mujoco/visualizer.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/parsers/__init__.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/parsers/descriptions/__init__.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/parsers/descriptions/collision.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/parsers/descriptions/joint.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/parsers/descriptions/link.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/parsers/descriptions/model.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/parsers/kinematic_graph.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/parsers/rod/__init__.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/parsers/rod/meshes.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/parsers/rod/parser.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/parsers/rod/utils.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/rbda/__init__.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/rbda/aba.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/rbda/collidable_points.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/rbda/contacts/__init__.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/rbda/contacts/common.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/rbda/contacts/relaxed_rigid.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/rbda/contacts/rigid.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/rbda/contacts/soft.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/rbda/contacts/visco_elastic.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/rbda/crba.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/rbda/forward_kinematics.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/rbda/jacobian.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/rbda/rnea.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/rbda/utils.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/terrain/__init__.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/terrain/terrain.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/typing.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/utils/__init__.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/utils/jaxsim_dataclass.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/utils/tracing.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim/utils/wrappers.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim.egg-info/SOURCES.txt +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim.egg-info/dependency_links.txt +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim.egg-info/requires.txt +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/src/jaxsim.egg-info/top_level.txt +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/tests/__init__.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/tests/test_api_com.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/tests/test_api_contact.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/tests/test_api_data.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/tests/test_api_frame.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/tests/test_api_joint.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/tests/test_api_link.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/tests/test_api_model.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/tests/test_automatic_differentiation.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/tests/test_benchmark.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/tests/test_contact.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/tests/test_exceptions.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/tests/test_meshes.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/tests/test_pytree.py +0 -0
- {jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/tests/utils_idyntree.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: jaxsim
|
3
|
-
Version: 0.5.1.
|
3
|
+
Version: 0.5.1.dev91
|
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>
|
@@ -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.dev91'
|
16
|
+
__version_tuple__ = version_tuple = (0, 5, 1, 'dev91')
|
@@ -53,10 +53,6 @@ class Integrator(JaxsimDataclass, abc.ABC, Generic[State, StateDerivative]):
|
|
53
53
|
repr=False, hash=False, compare=False, kw_only=True
|
54
54
|
)
|
55
55
|
|
56
|
-
metadata: dict[str, Any] = dataclasses.field(
|
57
|
-
default_factory=dict, repr=False, hash=False, compare=False, kw_only=True
|
58
|
-
)
|
59
|
-
|
60
56
|
@classmethod
|
61
57
|
def build(
|
62
58
|
cls: type[Self],
|
@@ -102,10 +98,7 @@ class Integrator(JaxsimDataclass, abc.ABC, Generic[State, StateDerivative]):
|
|
102
98
|
|
103
99
|
metadata = metadata if metadata is not None else {}
|
104
100
|
|
105
|
-
with self.
|
106
|
-
integrator.metadata = metadata
|
107
|
-
|
108
|
-
with integrator.mutable_context(mutability=Mutability.MUTABLE):
|
101
|
+
with self.mutable_context(mutability=Mutability.MUTABLE) as integrator:
|
109
102
|
xf, metadata_step = integrator(x0, t0, dt, **kwargs)
|
110
103
|
|
111
104
|
return (
|
@@ -315,6 +308,9 @@ class ExplicitRungeKutta(Integrator[PyTreeType, PyTreeType], Generic[PyTreeType]
|
|
315
308
|
b = self.b
|
316
309
|
A = self.A
|
317
310
|
|
311
|
+
# Extract metadata from the kwargs.
|
312
|
+
metadata = kwargs.pop("metadata", {})
|
313
|
+
|
318
314
|
# Close f over optional kwargs.
|
319
315
|
f = lambda x, t: self.dynamics(x=x, t=t, **kwargs)
|
320
316
|
|
@@ -327,7 +323,7 @@ class ExplicitRungeKutta(Integrator[PyTreeType, PyTreeType], Generic[PyTreeType]
|
|
327
323
|
# or to use the previous state derivative (only integrators supporting FSAL).
|
328
324
|
def get_ẋ0_and_aux_dict() -> tuple[StateDerivative, dict[str, Any]]:
|
329
325
|
ẋ0, aux_dict = f(x0, t0)
|
330
|
-
return
|
326
|
+
return metadata.get("dxdt0", ẋ0), aux_dict
|
331
327
|
|
332
328
|
# We use a `jax.lax.scan` to compile the `f` function only once.
|
333
329
|
# Otherwise, if we compute e.g. for RK4 sequentially, the jit-compiled code
|
@@ -381,7 +377,8 @@ class ExplicitRungeKutta(Integrator[PyTreeType, PyTreeType], Generic[PyTreeType]
|
|
381
377
|
|
382
378
|
# Update the FSAL property for the next iteration.
|
383
379
|
if self.has_fsal:
|
384
|
-
|
380
|
+
# Store the first derivative of the next step in the metadata.
|
381
|
+
metadata["dxdt0"] = jax.tree.map(lambda l: l[self.index_of_fsal], K)
|
385
382
|
|
386
383
|
# Compute the output state.
|
387
384
|
# Note that z contains as many new states as the rows of `b.T`.
|
@@ -394,7 +391,7 @@ class ExplicitRungeKutta(Integrator[PyTreeType, PyTreeType], Generic[PyTreeType]
|
|
394
391
|
lambda xf: self.post_process_state(x0=x0, t0=t0, xf=xf, dt=dt)
|
395
392
|
)(z)
|
396
393
|
|
397
|
-
return z_transformed, aux_dict
|
394
|
+
return z_transformed, aux_dict | {"metadata": metadata}
|
398
395
|
|
399
396
|
@staticmethod
|
400
397
|
def butcher_tableau_is_valid(
|
@@ -14,7 +14,6 @@ from jax_dataclasses import Static
|
|
14
14
|
|
15
15
|
import jaxsim.utils.tracing
|
16
16
|
from jaxsim import typing as jtp
|
17
|
-
from jaxsim.utils import Mutability
|
18
17
|
|
19
18
|
from .common import (
|
20
19
|
ExplicitRungeKutta,
|
@@ -271,30 +270,27 @@ class EmbeddedRungeKutta(ExplicitRungeKutta[PyTreeType], Generic[PyTreeType]):
|
|
271
270
|
# Inject this key to signal that the integrator is initializing.
|
272
271
|
# This is used to allocate the arrays of the metadata dictionary,
|
273
272
|
# that are then filled with NaNs.
|
274
|
-
|
273
|
+
metadata = {EmbeddedRungeKutta.InitializingKey: jnp.array(True)}
|
275
274
|
|
276
275
|
# Run a dummy call of the integrator.
|
277
276
|
# It is used only to get the metadata so that we know the structure
|
278
277
|
# of the corresponding pytree.
|
279
278
|
_ = integrator(
|
280
|
-
x0,
|
279
|
+
x0,
|
280
|
+
jnp.array(t0, dtype=float),
|
281
|
+
jnp.array(dt, dtype=float),
|
282
|
+
**(kwargs | {"metadata": metadata}),
|
281
283
|
)
|
282
284
|
|
283
285
|
# Remove the injected key.
|
284
|
-
_ =
|
286
|
+
_ = metadata.pop(EmbeddedRungeKutta.InitializingKey)
|
285
287
|
|
286
288
|
# Make sure that all leafs of the dictionary are JAX arrays.
|
287
289
|
# Also, since these are dummy parameters, set them all to NaN.
|
288
290
|
metadata_after_init = jax.tree.map(
|
289
|
-
lambda l: jnp.nan * jnp.zeros_like(l),
|
291
|
+
lambda l: jnp.nan * jnp.zeros_like(l), metadata
|
290
292
|
)
|
291
293
|
|
292
|
-
# Store the zero parameters in the integrator.
|
293
|
-
# When the integrator is stepped, this is used to check if the passed
|
294
|
-
# parameters are valid.
|
295
|
-
with self.mutable_context(mutability=Mutability.MUTABLE_NO_VALIDATION):
|
296
|
-
self.metadata = metadata_after_init
|
297
|
-
|
298
294
|
return metadata_after_init
|
299
295
|
|
300
296
|
def __call__(
|
@@ -307,7 +303,7 @@ class EmbeddedRungeKutta(ExplicitRungeKutta[PyTreeType], Generic[PyTreeType]):
|
|
307
303
|
# The metadata is a dictionary of float JAX arrays, that are initialized
|
308
304
|
# with the right shape and filled with NaNs.
|
309
305
|
# 2. During the first step, this method operates on the Nan-filled
|
310
|
-
# `
|
306
|
+
# `metadata` argument, and it populates with the actual metadata.
|
311
307
|
# 3. After the first step, this method operates on the actual metadata.
|
312
308
|
#
|
313
309
|
# In particular, we store the following information in the metadata:
|
@@ -318,8 +314,10 @@ class EmbeddedRungeKutta(ExplicitRungeKutta[PyTreeType], Generic[PyTreeType]):
|
|
318
314
|
# evaluate the dynamics at the final state of the previous step, that matches
|
319
315
|
# the initial state of the current step.
|
320
316
|
#
|
317
|
+
metadata = kwargs.pop("metadata", {})
|
318
|
+
|
321
319
|
integrator_init = jnp.array(
|
322
|
-
|
320
|
+
metadata.get(self.InitializingKey, False), dtype=bool
|
323
321
|
)
|
324
322
|
|
325
323
|
# Close f over optional kwargs.
|
@@ -335,24 +333,23 @@ class EmbeddedRungeKutta(ExplicitRungeKutta[PyTreeType], Generic[PyTreeType]):
|
|
335
333
|
|
336
334
|
# The value of dt0 is NaN (or, at least, it should be) only after initialization
|
337
335
|
# and before the first step.
|
338
|
-
|
339
|
-
pred=("dt0" in
|
340
|
-
& ~jnp.isnan(self.metadata.get("dt0", 0.0)).any(),
|
336
|
+
metadata["dt0"], metadata["dxdt0"] = jax.lax.cond(
|
337
|
+
pred=("dt0" in metadata) & ~jnp.isnan(metadata.get("dt0", 0.0)).any(),
|
341
338
|
true_fun=lambda metadata: (
|
342
339
|
metadata.get("dt0", jnp.array(0.0, dtype=float)),
|
343
|
-
|
340
|
+
metadata.get("dxdt0", f(x0, t0)[0]),
|
344
341
|
),
|
345
342
|
false_fun=lambda aux: estimate_step_size(
|
346
343
|
x0=x0, t0=t0, f=f, order=p, atol=self.atol, rtol=self.rtol
|
347
344
|
),
|
348
|
-
operand=
|
345
|
+
operand=metadata,
|
349
346
|
)
|
350
347
|
|
351
348
|
# Clip the estimated initial step size to the given bounds, if necessary.
|
352
|
-
|
353
|
-
|
354
|
-
jnp.minimum(self.dt_min,
|
355
|
-
jnp.minimum(self.dt_max,
|
349
|
+
metadata["dt0"] = jnp.clip(
|
350
|
+
metadata["dt0"],
|
351
|
+
jnp.minimum(self.dt_min, metadata["dt0"]),
|
352
|
+
jnp.minimum(self.dt_max, metadata["dt0"]),
|
356
353
|
)
|
357
354
|
|
358
355
|
# =========================================================
|
@@ -364,7 +361,7 @@ class EmbeddedRungeKutta(ExplicitRungeKutta[PyTreeType], Generic[PyTreeType]):
|
|
364
361
|
carry0: Carry = (
|
365
362
|
x0,
|
366
363
|
jnp.array(t0).astype(float),
|
367
|
-
|
364
|
+
metadata,
|
368
365
|
jnp.array(0, dtype=int),
|
369
366
|
jnp.array(False).astype(bool),
|
370
367
|
)
|
@@ -392,9 +389,10 @@ class EmbeddedRungeKutta(ExplicitRungeKutta[PyTreeType], Generic[PyTreeType]):
|
|
392
389
|
# Run the underlying explicit RK integrator.
|
393
390
|
# The output z contains multiple solutions (depending on the rows of b.T).
|
394
391
|
with self.editable(validate=True) as integrator:
|
395
|
-
|
396
|
-
|
397
|
-
|
392
|
+
z, aux_dict = integrator._compute_next_state(
|
393
|
+
x0=x0, t0=t0, dt=Δt0, **kwargs
|
394
|
+
)
|
395
|
+
metadata_next = aux_dict["metadata"]
|
398
396
|
|
399
397
|
# Extract the high-order solution xf and the low-order estimate x̂f.
|
400
398
|
xf = jax.tree.map(lambda l: l[self.row_index_of_solution], z)
|
@@ -481,10 +479,10 @@ class EmbeddedRungeKutta(ExplicitRungeKutta[PyTreeType], Generic[PyTreeType]):
|
|
481
479
|
metadata_next,
|
482
480
|
discarded_steps,
|
483
481
|
) = jax.lax.cond(
|
484
|
-
pred=discarded_steps
|
485
|
-
|
486
|
-
|
487
|
-
|
482
|
+
pred=(discarded_steps >= self.max_step_rejections)
|
483
|
+
| (local_error <= 1.0)
|
484
|
+
| (Δt_next < self.dt_min)
|
485
|
+
| integrator_init,
|
488
486
|
true_fun=accept_step,
|
489
487
|
false_fun=reject_step,
|
490
488
|
)
|
@@ -510,12 +508,7 @@ class EmbeddedRungeKutta(ExplicitRungeKutta[PyTreeType], Generic[PyTreeType]):
|
|
510
508
|
init_val=carry0,
|
511
509
|
)
|
512
510
|
|
513
|
-
|
514
|
-
# They will be returned to the caller in a functional way in the step method.
|
515
|
-
with self.mutable_context(mutability=Mutability.MUTABLE):
|
516
|
-
self.metadata = metadata_tf
|
517
|
-
|
518
|
-
return xf, {}
|
511
|
+
return xf, {"metadata": metadata_tf}
|
519
512
|
|
520
513
|
@property
|
521
514
|
def order_of_solution(self) -> int:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: jaxsim
|
3
|
-
Version: 0.5.1.
|
3
|
+
Version: 0.5.1.dev91
|
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>
|
@@ -426,7 +426,7 @@ def jaxsim_model_single_pendulum() -> js.model.JaxSimModel:
|
|
426
426
|
|
427
427
|
rod_model.model.resolve_frames()
|
428
428
|
|
429
|
-
urdf_string = rod.urdf.exporter.UrdfExporter.
|
429
|
+
urdf_string = rod.urdf.exporter.UrdfExporter(pretty=True).to_urdf_string(
|
430
430
|
sdf=rod_model.models()[0]
|
431
431
|
)
|
432
432
|
|
@@ -201,8 +201,19 @@ def run_simulation(
|
|
201
201
|
return data
|
202
202
|
|
203
203
|
|
204
|
+
@pytest.mark.parametrize(
|
205
|
+
"integrator",
|
206
|
+
[
|
207
|
+
jaxsim.integrators.fixed_step.ForwardEuler,
|
208
|
+
jaxsim.integrators.fixed_step.ForwardEulerSO3,
|
209
|
+
jaxsim.integrators.fixed_step.RungeKutta4,
|
210
|
+
jaxsim.integrators.fixed_step.RungeKutta4SO3,
|
211
|
+
jaxsim.integrators.variable_step.BogackiShampineSO3,
|
212
|
+
],
|
213
|
+
)
|
204
214
|
def test_simulation_with_soft_contacts(
|
205
215
|
jaxsim_model_box: js.model.JaxSimModel,
|
216
|
+
integrator: jaxsim.integrators.Integrator,
|
206
217
|
):
|
207
218
|
|
208
219
|
model = jaxsim_model_box
|
@@ -218,6 +229,11 @@ def test_simulation_with_soft_contacts(
|
|
218
229
|
model.kin_dyn_parameters.contact_parameters.enabled = tuple(
|
219
230
|
enabled_collidable_points_mask.tolist()
|
220
231
|
)
|
232
|
+
model.integrator = integrator.build(
|
233
|
+
dynamics=js.ode.wrap_system_dynamics_for_integration(
|
234
|
+
system_dynamics=js.ode.system_dynamics
|
235
|
+
)
|
236
|
+
)
|
221
237
|
|
222
238
|
assert np.sum(model.kin_dyn_parameters.contact_parameters.enabled) == 4
|
223
239
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{jaxsim-0.5.1.dev84 → jaxsim-0.5.1.dev91}/examples/jaxsim_as_multibody_dynamics_library.ipynb
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|