jaxsim 0.9.1.dev33__tar.gz → 0.9.1.dev37__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.
Files changed (140) hide show
  1. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/PKG-INFO +1 -1
  2. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/_version.py +2 -2
  3. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/api/data.py +6 -2
  4. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/api/model.py +7 -43
  5. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/math/joint_model.py +3 -12
  6. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/parsers/rod/parser.py +24 -20
  7. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/rbda/__init__.py +1 -0
  8. jaxsim-0.9.1.dev37/src/jaxsim/rbda/coriolis.py +204 -0
  9. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/tests/test_api_data.py +22 -0
  10. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/tests/test_api_model.py +25 -0
  11. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/tests/test_automatic_differentiation.py +34 -0
  12. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/.devcontainer/Dockerfile +0 -0
  13. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/.devcontainer/devcontainer.json +0 -0
  14. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/.gitattributes +0 -0
  15. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/.github/CODEOWNERS +0 -0
  16. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/.github/dependabot.yml +0 -0
  17. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/.github/release.yml +0 -0
  18. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/.github/workflows/ci_cd.yml +0 -0
  19. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/.github/workflows/gpu_benchmark.yml +0 -0
  20. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/.github/workflows/pixi.yml +0 -0
  21. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/.github/workflows/read_the_docs.yml +0 -0
  22. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/.gitignore +0 -0
  23. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/.pre-commit-config.yaml +0 -0
  24. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/.readthedocs.yaml +0 -0
  25. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/CITATION.cff +0 -0
  26. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/CONTRIBUTING.md +0 -0
  27. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/LICENSE +0 -0
  28. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/README.md +0 -0
  29. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/docs/Makefile +0 -0
  30. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/docs/conf.py +0 -0
  31. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/docs/examples.rst +0 -0
  32. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/docs/guide/configuration.rst +0 -0
  33. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/docs/guide/install.rst +0 -0
  34. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/docs/index.rst +0 -0
  35. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/docs/make.bat +0 -0
  36. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/docs/modules/api.rst +0 -0
  37. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/docs/modules/math.rst +0 -0
  38. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/docs/modules/mujoco.rst +0 -0
  39. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/docs/modules/parsers.rst +0 -0
  40. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/docs/modules/rbda.rst +0 -0
  41. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/docs/modules/typing.rst +0 -0
  42. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/docs/modules/utils.rst +0 -0
  43. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/environment.yml +0 -0
  44. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/examples/.gitattributes +0 -0
  45. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/examples/.gitignore +0 -0
  46. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/examples/README.md +0 -0
  47. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/examples/assets/build_cartpole_urdf.py +0 -0
  48. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/examples/assets/cartpole.urdf +0 -0
  49. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/examples/jaxsim_as_multibody_dynamics_library.ipynb +0 -0
  50. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/examples/jaxsim_as_physics_engine.ipynb +0 -0
  51. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/examples/jaxsim_as_physics_engine_advanced.ipynb +0 -0
  52. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/examples/jaxsim_for_robot_controllers.ipynb +0 -0
  53. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/pixi.lock +0 -0
  54. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/pyproject.toml +0 -0
  55. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/__init__.py +0 -0
  56. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/api/__init__.py +0 -0
  57. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/api/actuation_model.py +0 -0
  58. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/api/com.py +0 -0
  59. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/api/common.py +0 -0
  60. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/api/contact.py +0 -0
  61. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/api/frame.py +0 -0
  62. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/api/integrators.py +0 -0
  63. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/api/joint.py +0 -0
  64. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/api/kin_dyn_parameters.py +0 -0
  65. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/api/link.py +0 -0
  66. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/api/ode.py +0 -0
  67. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/api/references.py +0 -0
  68. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/exceptions.py +0 -0
  69. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/logging.py +0 -0
  70. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/math/__init__.py +0 -0
  71. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/math/adjoint.py +0 -0
  72. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/math/cross.py +0 -0
  73. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/math/inertia.py +0 -0
  74. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/math/quaternion.py +0 -0
  75. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/math/rotation.py +0 -0
  76. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/math/skew.py +0 -0
  77. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/math/transform.py +0 -0
  78. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/math/utils.py +0 -0
  79. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/mujoco/__init__.py +0 -0
  80. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/mujoco/__main__.py +0 -0
  81. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/mujoco/loaders.py +0 -0
  82. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/mujoco/model.py +0 -0
  83. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/mujoco/utils.py +0 -0
  84. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/mujoco/visualizer.py +0 -0
  85. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/parsers/__init__.py +0 -0
  86. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/parsers/descriptions/__init__.py +0 -0
  87. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/parsers/descriptions/collision.py +0 -0
  88. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/parsers/descriptions/joint.py +0 -0
  89. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/parsers/descriptions/link.py +0 -0
  90. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/parsers/descriptions/model.py +0 -0
  91. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/parsers/kinematic_graph.py +0 -0
  92. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/parsers/rod/__init__.py +0 -0
  93. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/parsers/rod/meshes.py +0 -0
  94. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/parsers/rod/utils.py +0 -0
  95. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/rbda/aba.py +0 -0
  96. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/rbda/aba_parallel.py +0 -0
  97. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/rbda/actuation/__init__.py +0 -0
  98. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/rbda/actuation/common.py +0 -0
  99. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/rbda/collidable_points.py +0 -0
  100. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/rbda/contacts/__init__.py +0 -0
  101. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/rbda/contacts/common.py +0 -0
  102. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/rbda/contacts/relaxed_rigid.py +0 -0
  103. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/rbda/contacts/rigid.py +0 -0
  104. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/rbda/contacts/soft.py +0 -0
  105. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/rbda/crba.py +0 -0
  106. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/rbda/forward_kinematics.py +0 -0
  107. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/rbda/forward_kinematics_parallel.py +0 -0
  108. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/rbda/jacobian.py +0 -0
  109. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/rbda/kinematic_constraints.py +0 -0
  110. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/rbda/mass_inverse.py +0 -0
  111. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/rbda/rnea.py +0 -0
  112. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/rbda/utils.py +0 -0
  113. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/terrain/__init__.py +0 -0
  114. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/terrain/terrain.py +0 -0
  115. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/typing.py +0 -0
  116. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/utils/__init__.py +0 -0
  117. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/utils/jaxsim_dataclass.py +0 -0
  118. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/utils/tracing.py +0 -0
  119. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/src/jaxsim/utils/wrappers.py +0 -0
  120. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/tests/__init__.py +0 -0
  121. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/tests/assets/4_bar_opened.urdf +0 -0
  122. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/tests/assets/cube.stl +0 -0
  123. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/tests/assets/double_pendulum.sdf +0 -0
  124. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/tests/assets/mixed_shapes_robot.urdf +0 -0
  125. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/tests/assets/test_cube.urdf +0 -0
  126. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/tests/conftest.py +0 -0
  127. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/tests/test_actuation.py +0 -0
  128. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/tests/test_api_com.py +0 -0
  129. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/tests/test_api_contact.py +0 -0
  130. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/tests/test_api_frame.py +0 -0
  131. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/tests/test_api_joint.py +0 -0
  132. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/tests/test_api_link.py +0 -0
  133. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/tests/test_api_model_hw_parametrization.py +0 -0
  134. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/tests/test_benchmark.py +0 -0
  135. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/tests/test_exceptions.py +0 -0
  136. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/tests/test_meshes.py +0 -0
  137. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/tests/test_pytree.py +0 -0
  138. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/tests/test_simulations.py +0 -0
  139. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/tests/test_visualizer.py +0 -0
  140. {jaxsim-0.9.1.dev33 → jaxsim-0.9.1.dev37}/tests/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: jaxsim
3
- Version: 0.9.1.dev33
3
+ Version: 0.9.1.dev37
4
4
  Summary: A differentiable physics engine and multibody dynamics library for control and robot learning.
5
5
  Project-URL: Changelog, https://github.com/gbionics/jaxsim/releases
6
6
  Project-URL: Documentation, https://jaxsim.readthedocs.io
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '0.9.1.dev33'
22
- __version_tuple__ = version_tuple = (0, 9, 1, 'dev33')
21
+ __version__ = version = '0.9.1.dev37'
22
+ __version_tuple__ = version_tuple = (0, 9, 1, 'dev37')
23
23
 
24
24
  __commit_id__ = commit_id = None
@@ -95,7 +95,11 @@ class JaxSimModelData(common.ModelDataWithVelocityRepresentation):
95
95
  """
96
96
 
97
97
  base_position = jnp.array(
98
- base_position if base_position is not None else jnp.zeros(3),
98
+ (
99
+ base_position
100
+ if base_position is not None
101
+ else model.description.root_pose.root_position
102
+ ),
99
103
  dtype=float,
100
104
  ).squeeze()
101
105
 
@@ -103,7 +107,7 @@ class JaxSimModelData(common.ModelDataWithVelocityRepresentation):
103
107
  (
104
108
  base_quaternion
105
109
  if base_quaternion is not None
106
- else jnp.array([1.0, 0, 0, 0])
110
+ else model.description.root_pose.root_quaternion
107
111
  ),
108
112
  dtype=float,
109
113
  ).squeeze()
@@ -1953,55 +1953,19 @@ def free_floating_coriolis_matrix(
1953
1953
 
1954
1954
  Returns:
1955
1955
  The free-floating Coriolis matrix of the model.
1956
-
1957
- Note:
1958
- This function, contrarily to other quantities of the equations of motion,
1959
- does not exploit any iterative algorithm. Therefore, the computation of
1960
- the Coriolis matrix may be much slower than other quantities.
1961
1956
  """
1962
1957
 
1963
- # We perform all the calculation in body-fixed.
1964
- # The Coriolis matrix computed in this representation is converted later
1965
- # to the active representation stored in data.
1966
1958
  with data.switch_velocity_representation(VelRepr.Body):
1967
- B_ν = data.generalized_velocity
1968
-
1969
- # Doubly-left free-floating Jacobian.
1970
- L_J_WL_B = generalized_free_floating_jacobian(model=model, data=data)
1971
-
1972
- # Doubly-left free-floating Jacobian derivative.
1973
- L_J̇_WL_B = generalized_free_floating_jacobian_derivative(
1974
- model=model, data=data
1975
- )
1976
-
1977
- L_M_L = link_spatial_inertia_matrices(model=model)
1978
-
1979
- # Body-fixed link velocities.
1980
- # Note: we could have called link.velocity() instead of computing it ourselves,
1981
- # but since we need the link Jacobians later, we can save a double calculation.
1982
- L_v_WL = jax.vmap(lambda J: J @ B_ν)(L_J_WL_B)
1983
-
1984
- # Compute the contribution of each link to the Coriolis matrix.
1985
- def compute_link_contribution(M, v, J, J̇) -> jtp.Array:
1986
- return J.T @ ((Cross.vx_star(v) @ M + M @ Cross.vx(v)) @ J + M @ J̇)
1959
+ B_v_WB = data.base_velocity
1987
1960
 
1988
- C_B_links = jax.vmap(compute_link_contribution)(
1989
- L_M_L,
1990
- L_v_WL,
1991
- L_J_WL_B,
1992
- L_J̇_WL_B,
1961
+ C_B = jaxsim.rbda.coriolis(
1962
+ model=model,
1963
+ joint_positions=data.joint_positions,
1964
+ joint_velocities=data.joint_velocities,
1965
+ base_linear_velocity=B_v_WB[0:3],
1966
+ base_angular_velocity=B_v_WB[3:6],
1993
1967
  )
1994
1968
 
1995
- # We need to adjust the Coriolis matrix for fixed-base models.
1996
- # In this case, the base link does not contribute to the matrix, and we need to zero
1997
- # the off-diagonal terms mapping joint quantities onto the base configuration.
1998
- if model.floating_base():
1999
- C_B = C_B_links.sum(axis=0)
2000
- else:
2001
- C_B = C_B_links[1:].sum(axis=0)
2002
- C_B = C_B.at[0:6, 6:].set(0.0)
2003
- C_B = C_B.at[6:, 0:6].set(0.0)
2004
-
2005
1969
  # Adjust the representation of the Coriolis matrix.
2006
1970
  # Refer to https://github.com/traversaro/traversaro-phd-thesis, Section 3.6.
2007
1971
  match data.velocity_representation:
@@ -54,12 +54,6 @@ class JointModel(JaxsimDataclass):
54
54
  The joint model of the considered model description.
55
55
  """
56
56
 
57
- # The link index is equal to its body index: [0, number_of_bodies - 1].
58
- ordered_links = sorted(
59
- list(description.links_dict.values()),
60
- key=lambda l: l.index,
61
- )
62
-
63
57
  # Note: the joint index is equal to its child link index, therefore it
64
58
  # starts from 1.
65
59
  ordered_joints = sorted(
@@ -75,12 +69,9 @@ class JointModel(JaxsimDataclass):
75
69
  # between the world frame W and the base link B.
76
70
  λ_H_pre = λ_H_pre.at[0].set(jnp.eye(4))
77
71
 
78
- # Initialize the successor-to-child transform of the joint between the
79
- # world frame W and the base link B.
80
- # We store here the optional transform between the root frame of the model
81
- # and the base link frame (this is needed only if the pose of the link frame
82
- # w.r.t. the implicit __model__ SDF frame is not the identity).
83
- suc_H_i = suc_H_i.at[0].set(ordered_links[0].pose)
72
+ # Initialize an identical successor-to-child transform for the joint
73
+ # between the world frame W and the base link B.
74
+ suc_H_i = suc_H_i.at[0].set(jnp.eye(4))
84
75
 
85
76
  # Create the object to compute forward kinematics.
86
77
  fk = KinematicGraphTransforms(graph=description)
@@ -91,17 +91,6 @@ def extract_model_data(
91
91
  # Log detected base link.
92
92
  logging.debug(msg=f"Considering '{sdf_model.get_canonical_link()}' as base link")
93
93
 
94
- # Pose of the model
95
- if sdf_model.pose is None:
96
- model_pose = kinematic_graph.RootPose()
97
-
98
- else:
99
- W_H_M = sdf_model.pose.transform()
100
- model_pose = kinematic_graph.RootPose(
101
- root_position=W_H_M[0:3, 3],
102
- root_quaternion=Quaternion.from_dcm(dcm=W_H_M[0:3, 0:3]),
103
- )
104
-
105
94
  # ===========
106
95
  # Parse links
107
96
  # ===========
@@ -186,15 +175,30 @@ def extract_model_data(
186
175
 
187
176
  base_link_name = joints_with_world_parent[0].child.name
188
177
 
189
- msg = "Combining the pose of base link '{}' with the pose of joint '{}'"
190
- logging.debug(msg.format(base_link_name, joints_with_world_parent[0].name))
178
+ if base_link_name != sdf_model.get_canonical_link():
179
+ msg = "Combining the pose of base link '{}' with the pose of joint '{}'"
180
+ logging.debug(msg.format(base_link_name, joints_with_world_parent[0].name))
181
+
182
+ # Combine the pose of the base link (child of the found fixed joint)
183
+ # with the pose of the fixed joint connecting with the world.
184
+ # Note: when base_link_name == sdf_model.get_canonical_link(),
185
+ # switch_frame_convention(Urdf) has already resolved the base link pose
186
+ # relative to "world".
187
+ links_dict[base_link_name].mutable(validate=False).pose = (
188
+ joints_with_world_parent[0].pose @ links_dict[base_link_name].pose
189
+ )
190
+
191
+ W_H_B = links_dict[base_link_name].pose
191
192
 
192
- # Combine the pose of the base link (child of the found fixed joint)
193
- # with the pose of the fixed joint connecting with the world.
194
- # Note: we assume it's a fixed joint and ignore any joint angle.
195
- links_dict[base_link_name].mutable(validate=False).pose = (
196
- joints_with_world_parent[0].pose @ links_dict[base_link_name].pose
197
- )
193
+ else:
194
+ base_link_name = sdf_model.get_canonical_link()
195
+ W_H_M = sdf_model.pose.transform() if sdf_model.pose is not None else np.eye(4)
196
+ W_H_B = W_H_M @ links_dict[base_link_name].pose
197
+
198
+ model_pose = kinematic_graph.RootPose(
199
+ root_position=W_H_B[0:3, 3],
200
+ root_quaternion=Quaternion.from_dcm(dcm=W_H_B[0:3, 0:3]),
201
+ )
198
202
 
199
203
  # ============
200
204
  # Parse joints
@@ -363,7 +367,7 @@ def extract_model_data(
363
367
  frame_descriptions=frames,
364
368
  collision_shapes=collisions,
365
369
  fixed_base=sdf_model.is_fixed_base(),
366
- base_link_name=sdf_model.get_canonical_link(),
370
+ base_link_name=base_link_name,
367
371
  model_pose=model_pose,
368
372
  sdf_model=sdf_model,
369
373
  )
@@ -2,6 +2,7 @@ from . import actuation, contacts
2
2
  from .aba import aba
3
3
  from .aba_parallel import aba_parallel
4
4
  from .collidable_points import collidable_points_pos_vel
5
+ from .coriolis import coriolis
5
6
  from .crba import crba
6
7
  from .forward_kinematics import forward_kinematics_model
7
8
  from .forward_kinematics_parallel import forward_kinematics_model_parallel
@@ -0,0 +1,204 @@
1
+ import jax
2
+ import jax.numpy as jnp
3
+
4
+ import jaxsim.api as js
5
+ import jaxsim.typing as jtp
6
+ from jaxsim.math import Cross
7
+
8
+ from . import utils
9
+
10
+
11
+ def coriolis(
12
+ model: js.model.JaxSimModel,
13
+ *,
14
+ joint_positions: jtp.VectorLike,
15
+ joint_velocities: jtp.VectorLike,
16
+ base_linear_velocity: jtp.VectorLike,
17
+ base_angular_velocity: jtp.VectorLike,
18
+ ) -> jtp.Matrix:
19
+ """
20
+ Compute the free-floating Coriolis matrix in body-fixed representation.
21
+
22
+ Args:
23
+ model: The model to consider.
24
+ joint_positions: The positions of the joints.
25
+ joint_velocities: The velocities of the joints.
26
+ base_linear_velocity:
27
+ The linear velocity of the base link in body-fixed representation.
28
+ base_angular_velocity:
29
+ The angular velocity of the base link in body-fixed representation.
30
+
31
+ Returns:
32
+ The free-floating Coriolis matrix in body-fixed representation.
33
+ """
34
+
35
+ _, _, s, B_v_WB, ṡ, _, _, _, _, _ = utils.process_inputs(
36
+ model=model,
37
+ joint_positions=joint_positions,
38
+ joint_velocities=joint_velocities,
39
+ base_linear_velocity=base_linear_velocity,
40
+ base_angular_velocity=base_angular_velocity,
41
+ )
42
+
43
+ # Get the 6D spatial inertia matrices of all links.
44
+ M = js.model.link_spatial_inertia_matrices(model=model)
45
+
46
+ # Get the parent array λ(i).
47
+ λ = model.kin_dyn_parameters.parent_array
48
+
49
+ # Compute the parent-to-child adjoints of the joints.
50
+ i_X_λi = model.kin_dyn_parameters.joint_transforms(
51
+ joint_positions=s, base_transform=jnp.eye(4)
52
+ )
53
+
54
+ # Extract the joint motion subspaces.
55
+ S = model.kin_dyn_parameters.motion_subspaces
56
+
57
+ # Allocate the buffers.
58
+ v = jnp.zeros(shape=(model.number_of_links(), 6))
59
+ Ṡ = jnp.zeros_like(S)
60
+ Mc = M
61
+ Bc = jnp.zeros_like(M)
62
+
63
+ # Initialize the base quantities.
64
+ B_v_WB = B_v_WB if model.floating_base() else jnp.zeros(6)
65
+ v = v.at[0].set(B_v_WB)
66
+ Bc = Bc.at[0].set(Cross.vx_star(v[0]) @ M[0])
67
+
68
+ # ====================
69
+ # Propagate kinematics
70
+ # ====================
71
+
72
+ ForwardPassCarry = tuple[jtp.Matrix, jtp.Array, jtp.Array]
73
+ forward_pass_carry: ForwardPassCarry = (v, Ṡ, Bc)
74
+
75
+ def propagate_kinematics(
76
+ carry: ForwardPassCarry, i: jtp.Int
77
+ ) -> tuple[ForwardPassCarry, None]:
78
+
79
+ ii = i - 1
80
+ v, Ṡ, Bc = carry
81
+
82
+ v_i = i_X_λi[i] @ v[λ[i]] + S[i].squeeze() * ṡ[ii]
83
+ v = v.at[i].set(v_i)
84
+
85
+ Ṡ_i = Cross.vx(v[i]) @ S[i]
86
+ Ṡ = Ṡ.at[i].set(Ṡ_i)
87
+
88
+ Bc_i = Cross.vx_star(v[i]) @ M[i]
89
+ Bc = Bc.at[i].set(Bc_i)
90
+
91
+ return (v, Ṡ, Bc), None
92
+
93
+ (v, Ṡ, Bc), _ = (
94
+ jax.lax.scan(
95
+ f=propagate_kinematics,
96
+ init=forward_pass_carry,
97
+ xs=jnp.arange(start=1, stop=model.number_of_links()),
98
+ )
99
+ if model.number_of_links() > 1
100
+ else [(v, Ṡ, Bc), None]
101
+ )
102
+
103
+ # =======================
104
+ # Compute Coriolis matrix
105
+ # =======================
106
+
107
+ C = jnp.zeros(shape=(6 + model.dofs(), 6 + model.dofs()))
108
+
109
+ BackwardPassCarry = tuple[jtp.Array, jtp.Array, jtp.Matrix]
110
+ backward_pass_carry: BackwardPassCarry = (Mc, Bc, C)
111
+
112
+ def backward_pass(
113
+ carry: BackwardPassCarry, i: jtp.Int
114
+ ) -> tuple[BackwardPassCarry, None]:
115
+
116
+ ii = i - 1
117
+ Mc, Bc, C = carry
118
+
119
+ F1 = Mc[i] @ Ṡ[i] + Bc[i] @ S[i]
120
+ F2 = Mc[i] @ S[i]
121
+ F3 = Bc[i].T @ S[i]
122
+
123
+ C_ii = S[i].T @ F1
124
+ C = C.at[6 + ii, 6 + ii].set(C_ii.squeeze())
125
+
126
+ Mc_λi = Mc[λ[i]] + i_X_λi[i].T @ Mc[i] @ i_X_λi[i]
127
+ Mc = Mc.at[λ[i]].set(Mc_λi)
128
+
129
+ Bc_λi = Bc[λ[i]] + i_X_λi[i].T @ Bc[i] @ i_X_λi[i]
130
+ Bc = Bc.at[λ[i]].set(Bc_λi)
131
+
132
+ j = i
133
+
134
+ FakeWhileCarry = tuple[jtp.Int, jtp.Vector, jtp.Vector, jtp.Vector, jtp.Matrix]
135
+ fake_while_carry: FakeWhileCarry = (j, F1, F2, F3, C)
136
+
137
+ def fake_while_loop(
138
+ carry: FakeWhileCarry, k: jtp.Int
139
+ ) -> tuple[FakeWhileCarry, None]:
140
+
141
+ def compute(carry: FakeWhileCarry) -> FakeWhileCarry:
142
+
143
+ j, F1, F2, F3, C = carry
144
+
145
+ F1 = i_X_λi[j].T @ F1
146
+ F2 = i_X_λi[j].T @ F2
147
+ F3 = i_X_λi[j].T @ F3
148
+
149
+ j = λ[j]
150
+ jj = j - 1
151
+
152
+ C_ji = S[j].T @ F1
153
+ C = C.at[6 + jj, 6 + ii].set(C_ji.squeeze())
154
+
155
+ C_ij = Ṡ[j].T @ F2 + S[j].T @ F3
156
+ C = C.at[6 + ii, 6 + jj].set(C_ij.squeeze())
157
+
158
+ return j, F1, F2, F3, C
159
+
160
+ j, _, _, _, _ = carry
161
+
162
+ j, F1, F2, F3, C = jax.lax.cond(
163
+ pred=jnp.logical_and(k == λ[j], λ[j] > 0),
164
+ true_fun=compute,
165
+ false_fun=lambda carry: carry,
166
+ operand=carry,
167
+ )
168
+
169
+ return (j, F1, F2, F3, C), None
170
+
171
+ (j, F1, F2, F3, C), _ = (
172
+ jax.lax.scan(
173
+ f=fake_while_loop,
174
+ init=fake_while_carry,
175
+ xs=jnp.flip(jnp.arange(start=1, stop=model.number_of_links())),
176
+ )
177
+ if model.number_of_links() > 1
178
+ else [(j, F1, F2, F3, C), None]
179
+ )
180
+
181
+ if model.floating_base():
182
+ F1 = i_X_λi[j].T @ F1
183
+ F2 = i_X_λi[j].T @ F2
184
+ F3 = i_X_λi[j].T @ F3
185
+
186
+ C = C.at[0:6, 6 + ii].set(F1.squeeze())
187
+ C = C.at[6 + ii, 0:6].set((Cross.vx(v[0]).T @ F2 + F3).squeeze())
188
+
189
+ return (Mc, Bc, C), None
190
+
191
+ (Mc, Bc, C), _ = (
192
+ jax.lax.scan(
193
+ f=backward_pass,
194
+ init=backward_pass_carry,
195
+ xs=jnp.flip(jnp.arange(start=1, stop=model.number_of_links())),
196
+ )
197
+ if model.number_of_links() > 1
198
+ else [(Mc, Bc, C), None]
199
+ )
200
+
201
+ C_00 = Mc[0] @ Cross.vx(v[0]) + Bc[0]
202
+ C = C.at[0:6, 0:6].set(C_00)
203
+
204
+ return C
@@ -143,3 +143,25 @@ def test_data_change_velocity_representation(
143
143
  data.base_velocity[3:6],
144
144
  data._base_angular_velocity,
145
145
  )
146
+
147
+
148
+ def test_fixed_base_root_transform(
149
+ jaxsim_model_single_pendulum: js.model.JaxSimModel,
150
+ ):
151
+
152
+ model = jaxsim_model_single_pendulum
153
+ data = js.data.JaxSimModelData.build(model=model)
154
+
155
+ kin_dyn = utils.build_kindyncomputations_from_jaxsim_model(model=model, data=data)
156
+
157
+ W_H_LL = js.model.forward_kinematics(model=model, data=data)
158
+
159
+ assert_allclose(data.base_position, jnp.array([0.0, 0.0, 2.15 / 2]))
160
+ assert_allclose(data.base_transform, W_H_LL[0])
161
+
162
+ for W_H_L, link_name in zip(W_H_LL, model.link_names(), strict=True):
163
+ assert_allclose(
164
+ W_H_L,
165
+ kin_dyn.frame_transform(frame_name=link_name),
166
+ err_msg=f"Mismatch in {link_name}",
167
+ )
@@ -429,6 +429,31 @@ def test_coriolis_matrix(
429
429
 
430
430
  assert_allclose(C @ I_ν, Cν)
431
431
 
432
+ if velocity_representation == VelRepr.Body:
433
+ L_J_WL_B = js.model.generalized_free_floating_jacobian(model=model, data=data)
434
+ L_J̇_WL_B = js.model.generalized_free_floating_jacobian_derivative(
435
+ model=model, data=data
436
+ )
437
+ L_M_L = js.model.link_spatial_inertia_matrices(model=model)
438
+ L_v_WL = jax.vmap(lambda J: J @ I_ν)(L_J_WL_B)
439
+
440
+ C_B_links = jax.vmap(
441
+ lambda M, v, J, J̇: J.T
442
+ @ (
443
+ (jaxsim.math.Cross.vx_star(v) @ M + M @ jaxsim.math.Cross.vx(v)) @ J
444
+ + M @ J̇
445
+ )
446
+ )(L_M_L, L_v_WL, L_J_WL_B, L_J̇_WL_B)
447
+
448
+ if model.floating_base():
449
+ C_B_ref = C_B_links.sum(axis=0)
450
+ else:
451
+ C_B_ref = C_B_links[1:].sum(axis=0)
452
+ C_B_ref = C_B_ref.at[0:6, 6:].set(0.0)
453
+ C_B_ref = C_B_ref.at[6:, 0:6].set(0.0)
454
+
455
+ assert_allclose(C, C_B_ref)
456
+
432
457
  # Compute the free-floating mass matrix.
433
458
  # This function will be used to compute the Ṁ with AD.
434
459
  # Given q, computing Ṁ by AD-ing this function should work out-of-the-box with
@@ -301,6 +301,40 @@ def test_ad_crba(
301
301
  )
302
302
 
303
303
 
304
+ def test_ad_coriolis(
305
+ jaxsim_models_types: js.model.JaxSimModel,
306
+ prng_key: jax.Array,
307
+ ):
308
+
309
+ model = jaxsim_models_types
310
+
311
+ _, subkey = jax.random.split(prng_key, num=2)
312
+ data, _ = get_random_data_and_references(
313
+ model=model, velocity_representation=VelRepr.Body, key=subkey
314
+ )
315
+
316
+ s = data.joint_positions
317
+ ṡ = data.joint_velocities
318
+ B_v_WB = data.base_velocity
319
+
320
+ coriolis = lambda s, ṡ, B_v_WB: jaxsim.rbda.coriolis(
321
+ model=model,
322
+ joint_positions=s,
323
+ joint_velocities=ṡ,
324
+ base_linear_velocity=B_v_WB[0:3],
325
+ base_angular_velocity=B_v_WB[3:6],
326
+ )
327
+
328
+ check_grads(
329
+ f=coriolis,
330
+ args=(s, ṡ, B_v_WB),
331
+ order=AD_ORDER,
332
+ modes=["rev", "fwd"],
333
+ eps=ε,
334
+ rtol=None if jax.config.jax_enable_x64 else 1e-2,
335
+ )
336
+
337
+
304
338
  def test_ad_fk(
305
339
  jaxsim_models_types: js.model.JaxSimModel,
306
340
  prng_key: jax.Array,
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes