jaxsim 0.8.3.dev33__tar.gz → 0.8.3.dev35__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 (134) hide show
  1. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/PKG-INFO +1 -1
  2. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/_version.py +2 -2
  3. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/api/frame.py +62 -109
  4. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/api/model.py +200 -203
  5. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/.devcontainer/Dockerfile +0 -0
  6. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/.devcontainer/devcontainer.json +0 -0
  7. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/.gitattributes +0 -0
  8. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/.github/CODEOWNERS +0 -0
  9. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/.github/dependabot.yml +0 -0
  10. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/.github/release.yml +0 -0
  11. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/.github/workflows/ci_cd.yml +0 -0
  12. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/.github/workflows/gpu_benchmark.yml +0 -0
  13. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/.github/workflows/pixi.yml +0 -0
  14. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/.github/workflows/read_the_docs.yml +0 -0
  15. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/.gitignore +0 -0
  16. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/.pre-commit-config.yaml +0 -0
  17. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/.readthedocs.yaml +0 -0
  18. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/CITATION.cff +0 -0
  19. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/CONTRIBUTING.md +0 -0
  20. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/LICENSE +0 -0
  21. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/README.md +0 -0
  22. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/docs/Makefile +0 -0
  23. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/docs/conf.py +0 -0
  24. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/docs/examples.rst +0 -0
  25. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/docs/guide/configuration.rst +0 -0
  26. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/docs/guide/install.rst +0 -0
  27. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/docs/index.rst +0 -0
  28. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/docs/make.bat +0 -0
  29. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/docs/modules/api.rst +0 -0
  30. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/docs/modules/math.rst +0 -0
  31. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/docs/modules/mujoco.rst +0 -0
  32. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/docs/modules/parsers.rst +0 -0
  33. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/docs/modules/rbda.rst +0 -0
  34. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/docs/modules/typing.rst +0 -0
  35. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/docs/modules/utils.rst +0 -0
  36. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/environment.yml +0 -0
  37. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/examples/.gitattributes +0 -0
  38. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/examples/.gitignore +0 -0
  39. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/examples/README.md +0 -0
  40. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/examples/assets/build_cartpole_urdf.py +0 -0
  41. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/examples/assets/cartpole.urdf +0 -0
  42. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/examples/jaxsim_as_multibody_dynamics_library.ipynb +0 -0
  43. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/examples/jaxsim_as_physics_engine.ipynb +0 -0
  44. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/examples/jaxsim_as_physics_engine_advanced.ipynb +0 -0
  45. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/examples/jaxsim_for_robot_controllers.ipynb +0 -0
  46. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/pixi.lock +0 -0
  47. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/pyproject.toml +0 -0
  48. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/__init__.py +0 -0
  49. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/api/__init__.py +0 -0
  50. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/api/actuation_model.py +0 -0
  51. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/api/com.py +0 -0
  52. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/api/common.py +0 -0
  53. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/api/contact.py +0 -0
  54. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/api/data.py +0 -0
  55. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/api/integrators.py +0 -0
  56. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/api/joint.py +0 -0
  57. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/api/kin_dyn_parameters.py +0 -0
  58. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/api/link.py +0 -0
  59. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/api/ode.py +0 -0
  60. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/api/references.py +0 -0
  61. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/exceptions.py +0 -0
  62. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/logging.py +0 -0
  63. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/math/__init__.py +0 -0
  64. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/math/adjoint.py +0 -0
  65. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/math/cross.py +0 -0
  66. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/math/inertia.py +0 -0
  67. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/math/joint_model.py +0 -0
  68. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/math/quaternion.py +0 -0
  69. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/math/rotation.py +0 -0
  70. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/math/skew.py +0 -0
  71. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/math/transform.py +0 -0
  72. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/math/utils.py +0 -0
  73. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/mujoco/__init__.py +0 -0
  74. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/mujoco/__main__.py +0 -0
  75. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/mujoco/loaders.py +0 -0
  76. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/mujoco/model.py +0 -0
  77. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/mujoco/utils.py +0 -0
  78. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/mujoco/visualizer.py +0 -0
  79. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/parsers/__init__.py +0 -0
  80. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/parsers/descriptions/__init__.py +0 -0
  81. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/parsers/descriptions/collision.py +0 -0
  82. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/parsers/descriptions/joint.py +0 -0
  83. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/parsers/descriptions/link.py +0 -0
  84. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/parsers/descriptions/model.py +0 -0
  85. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/parsers/kinematic_graph.py +0 -0
  86. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/parsers/rod/__init__.py +0 -0
  87. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/parsers/rod/meshes.py +0 -0
  88. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/parsers/rod/parser.py +0 -0
  89. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/parsers/rod/utils.py +0 -0
  90. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/rbda/__init__.py +0 -0
  91. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/rbda/aba.py +0 -0
  92. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/rbda/actuation/__init__.py +0 -0
  93. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/rbda/actuation/common.py +0 -0
  94. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/rbda/collidable_points.py +0 -0
  95. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/rbda/contacts/__init__.py +0 -0
  96. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/rbda/contacts/common.py +0 -0
  97. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/rbda/contacts/relaxed_rigid.py +0 -0
  98. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/rbda/contacts/rigid.py +0 -0
  99. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/rbda/contacts/soft.py +0 -0
  100. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/rbda/crba.py +0 -0
  101. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/rbda/forward_kinematics.py +0 -0
  102. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/rbda/jacobian.py +0 -0
  103. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/rbda/kinematic_constraints.py +0 -0
  104. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/rbda/mass_inverse.py +0 -0
  105. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/rbda/rnea.py +0 -0
  106. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/rbda/utils.py +0 -0
  107. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/terrain/__init__.py +0 -0
  108. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/terrain/terrain.py +0 -0
  109. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/typing.py +0 -0
  110. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/utils/__init__.py +0 -0
  111. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/utils/jaxsim_dataclass.py +0 -0
  112. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/utils/tracing.py +0 -0
  113. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/src/jaxsim/utils/wrappers.py +0 -0
  114. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/tests/__init__.py +0 -0
  115. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/tests/assets/4_bar_opened.urdf +0 -0
  116. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/tests/assets/double_pendulum.sdf +0 -0
  117. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/tests/conftest.py +0 -0
  118. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/tests/test_actuation.py +0 -0
  119. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/tests/test_api_com.py +0 -0
  120. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/tests/test_api_contact.py +0 -0
  121. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/tests/test_api_data.py +0 -0
  122. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/tests/test_api_frame.py +0 -0
  123. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/tests/test_api_joint.py +0 -0
  124. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/tests/test_api_link.py +0 -0
  125. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/tests/test_api_model.py +0 -0
  126. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/tests/test_api_model_hw_parametrization.py +0 -0
  127. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/tests/test_automatic_differentiation.py +0 -0
  128. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/tests/test_benchmark.py +0 -0
  129. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/tests/test_exceptions.py +0 -0
  130. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/tests/test_meshes.py +0 -0
  131. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/tests/test_pytree.py +0 -0
  132. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/tests/test_simulations.py +0 -0
  133. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/tests/test_visualizer.py +0 -0
  134. {jaxsim-0.8.3.dev33 → jaxsim-0.8.3.dev35}/tests/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: jaxsim
3
- Version: 0.8.3.dev33
3
+ Version: 0.8.3.dev35
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.8.3.dev33'
22
- __version_tuple__ = version_tuple = (0, 8, 3, 'dev33')
21
+ __version__ = version = '0.8.3.dev35'
22
+ __version_tuple__ = version_tuple = (0, 8, 3, 'dev35')
23
23
 
24
24
  __commit_id__ = commit_id = None
@@ -7,7 +7,7 @@ import jax.numpy as jnp
7
7
  import jaxsim.api as js
8
8
  import jaxsim.typing as jtp
9
9
  from jaxsim import exceptions
10
- from jaxsim.math import Adjoint, Cross, Transform
10
+ from jaxsim.math import Adjoint, Cross
11
11
 
12
12
  from .common import VelRepr
13
13
 
@@ -278,34 +278,44 @@ def jacobian(
278
278
  # Get the index of the parent link.
279
279
  L = idx_of_parent_link(model=model, frame_index=frame_index)
280
280
 
281
- # Compute the Jacobian of the parent link using body-fixed output representation.
281
+ # Compute only the parent-link body Jacobian.
282
282
  L_J_WL = js.link.jacobian(
283
- model=model, data=data, link_index=L, output_vel_repr=VelRepr.Body
283
+ model=model,
284
+ data=data,
285
+ link_index=L,
286
+ output_vel_repr=VelRepr.Body,
284
287
  )
288
+ W_H_L = data._link_transforms[L]
289
+ L_H_F = model.kin_dyn_parameters.frame_parameters.transform[
290
+ frame_index - model.number_of_links()
291
+ ]
292
+ L_p_F = L_H_F[0:3, 3]
285
293
 
286
294
  # Adjust the output representation.
287
295
  match output_vel_repr:
288
296
  case VelRepr.Inertial:
289
- W_H_L = js.link.transform(model=model, data=data, link_index=L)
290
- W_X_L = Adjoint.from_transform(transform=W_H_L)
297
+ W_X_L = Adjoint.from_rotation_and_translation(
298
+ rotation=W_H_L[0:3, 0:3],
299
+ translation=W_H_L[0:3, 3],
300
+ )
291
301
  W_J_WL = W_X_L @ L_J_WL
292
302
  O_J_WL_I = W_J_WL
293
303
 
294
304
  case VelRepr.Body:
295
- W_H_L = js.link.transform(model=model, data=data, link_index=L)
296
- W_H_F = transform(model=model, data=data, frame_index=frame_index)
297
- F_H_L = Transform.inverse(W_H_F) @ W_H_L
298
- F_X_L = Adjoint.from_transform(transform=F_H_L)
305
+ F_X_L = Adjoint.from_rotation_and_translation(
306
+ rotation=L_H_F[0:3, 0:3],
307
+ translation=L_p_F,
308
+ inverse=True,
309
+ )
299
310
  F_J_WL = F_X_L @ L_J_WL
300
311
  O_J_WL_I = F_J_WL
301
312
 
302
313
  case VelRepr.Mixed:
303
- W_H_L = js.link.transform(model=model, data=data, link_index=L)
304
- W_H_F = transform(model=model, data=data, frame_index=frame_index)
305
- F_H_L = Transform.inverse(W_H_F) @ W_H_L
306
- FW_H_F = W_H_F.at[0:3, 3].set(jnp.zeros(3))
307
- FW_H_L = FW_H_F @ F_H_L
308
- FW_X_L = Adjoint.from_transform(transform=FW_H_L)
314
+ W_R_L = W_H_L[0:3, 0:3]
315
+ FW_X_L = Adjoint.from_rotation_and_translation(
316
+ rotation=W_R_L,
317
+ translation=-W_R_L @ L_p_F,
318
+ )
309
319
  FW_J_WL = FW_X_L @ L_J_WL
310
320
  O_J_WL_I = FW_J_WL
311
321
 
@@ -357,115 +367,58 @@ def jacobian_derivative(
357
367
 
358
368
  # Get the index of the parent link.
359
369
  L = idx_of_parent_link(model=model, frame_index=frame_index)
370
+ W_J_WL_I = js.link.jacobian(
371
+ model=model,
372
+ data=data,
373
+ link_index=L,
374
+ output_vel_repr=VelRepr.Inertial,
375
+ )
376
+ W_J̇_WL_I = js.link.jacobian_derivative(
377
+ model=model,
378
+ data=data,
379
+ link_index=L,
380
+ output_vel_repr=VelRepr.Inertial,
381
+ )
360
382
 
361
- with data.switch_velocity_representation(VelRepr.Inertial):
362
- # Compute the Jacobian of the parent link in inertial representation.
363
- W_J_WL_W = js.link.jacobian(
364
- model=model,
365
- data=data,
366
- link_index=L,
367
- output_vel_repr=VelRepr.Inertial,
368
- )
369
-
370
- # Compute the Jacobian derivative of the parent link in inertial representation.
371
- W_J̇_WL_W = js.link.jacobian_derivative(
372
- model=model,
373
- data=data,
374
- link_index=L,
375
- output_vel_repr=VelRepr.Inertial,
376
- )
377
-
378
- # =====================================================
379
- # Compute quantities to adjust the input representation
380
- # =====================================================
381
-
382
- def compute_T(model: js.model.JaxSimModel, X: jtp.Matrix) -> jtp.Matrix:
383
- In = jnp.eye(model.dofs())
384
- T = jax.scipy.linalg.block_diag(X, In)
385
- return T
386
-
387
- def compute_Ṫ(model: js.model.JaxSimModel, Ẋ: jtp.Matrix) -> jtp.Matrix:
388
- On = jnp.zeros(shape=(model.dofs(), model.dofs()))
389
- Ṫ = jax.scipy.linalg.block_diag(Ẋ, On)
390
- return Ṫ
391
-
392
- # Compute the operator to change the representation of ν, and its
393
- # time derivative.
394
- match data.velocity_representation:
395
- case VelRepr.Inertial:
396
- W_H_W = jnp.eye(4)
397
- W_X_W = Adjoint.from_transform(transform=W_H_W)
398
- W_Ẋ_W = jnp.zeros((6, 6))
399
-
400
- T = compute_T(model=model, X=W_X_W)
401
- Ṫ = compute_Ṫ(model=model, Ẋ=W_Ẋ_W)
402
-
403
- case VelRepr.Body:
404
- W_H_B = data._base_transform
405
- W_X_B = Adjoint.from_transform(transform=W_H_B)
406
- B_v_WB = data.base_velocity
407
- B_vx_WB = Cross.vx(B_v_WB)
408
- W_Ẋ_B = W_X_B @ B_vx_WB
409
-
410
- T = compute_T(model=model, X=W_X_B)
411
- Ṫ = compute_Ṫ(model=model, Ẋ=W_Ẋ_B)
412
-
413
- case VelRepr.Mixed:
414
- W_H_B = data._base_transform
415
- W_H_BW = W_H_B.at[0:3, 0:3].set(jnp.eye(3))
416
- W_X_BW = Adjoint.from_transform(transform=W_H_BW)
417
- BW_v_WB = data.base_velocity
418
- BW_v_W_BW = BW_v_WB.at[3:6].set(jnp.zeros(3))
419
- BW_vx_W_BW = Cross.vx(BW_v_W_BW)
420
- W_Ẋ_BW = W_X_BW @ BW_vx_W_BW
421
-
422
- T = compute_T(model=model, X=W_X_BW)
423
- Ṫ = compute_Ṫ(model=model, Ẋ=W_Ẋ_BW)
424
-
425
- case _:
426
- raise ValueError(data.velocity_representation)
383
+ W_H_L = data._link_transforms[L]
384
+ L_H_F = model.kin_dyn_parameters.frame_parameters.transform[
385
+ frame_index - model.number_of_links()
386
+ ]
387
+ W_H_F = W_H_L @ L_H_F
427
388
 
428
389
  # =====================================================
429
390
  # Compute quantities to adjust the output representation
430
391
  # =====================================================
431
392
 
393
+ W_v_WF = W_J_WL_I @ data.generalized_velocity
394
+
432
395
  match output_vel_repr:
433
396
  case VelRepr.Inertial:
434
- O_X_W = W_X_W = Adjoint.from_transform(transform=jnp.eye(4))
435
- O_Ẋ_W = W_Ẋ_W = jnp.zeros((6, 6))
397
+ O_X_W = jnp.eye(6, dtype=W_H_F.dtype)
398
+ O_Ẋ_W = jnp.zeros((6, 6), dtype=W_H_F.dtype)
436
399
 
437
400
  case VelRepr.Body:
438
- W_H_F = transform(model=model, data=data, frame_index=frame_index)
439
- O_X_W = F_X_W = Adjoint.from_transform(transform=W_H_F, inverse=True)
440
- with data.switch_velocity_representation(VelRepr.Inertial):
441
- W_nu = data.generalized_velocity
442
- W_v_WF = W_J_WL_W @ W_nu
443
- W_vx_WF = Cross.vx(W_v_WF)
444
- O_Ẋ_W = F_Ẋ_W = -F_X_W @ W_vx_WF # noqa: F841
401
+ O_X_W = Adjoint.from_rotation_and_translation(
402
+ rotation=W_H_F[0:3, 0:3],
403
+ translation=W_H_F[0:3, 3],
404
+ inverse=True,
405
+ )
406
+ O_Ẋ_W = -O_X_W @ Cross.vx(W_v_WF)
445
407
 
446
408
  case VelRepr.Mixed:
447
- W_H_F = transform(model=model, data=data, frame_index=frame_index)
448
- W_H_FW = W_H_F.at[0:3, 0:3].set(jnp.eye(3))
449
- FW_H_W = Transform.inverse(W_H_FW)
450
- O_X_W = FW_X_W = Adjoint.from_transform(transform=FW_H_W)
451
- with data.switch_velocity_representation(VelRepr.Mixed):
452
- FW_J_WF_FW = jacobian(
453
- model=model,
454
- data=data,
455
- frame_index=frame_index,
456
- output_vel_repr=VelRepr.Mixed,
457
- )
458
- FW_v_WF = FW_J_WF_FW @ data.generalized_velocity
459
- W_v_W_FW = jnp.zeros(6).at[0:3].set(FW_v_WF[0:3])
460
- W_vx_W_FW = Cross.vx(W_v_W_FW)
461
- O_Ẋ_W = FW_Ẋ_W = -FW_X_W @ W_vx_W_FW # noqa: F841
409
+ O_X_W = Adjoint.from_rotation_and_translation(
410
+ rotation=jnp.eye(3, dtype=W_H_F.dtype),
411
+ translation=W_H_F[0:3, 3],
412
+ inverse=True,
413
+ )
414
+ FW_v_WF = O_X_W @ W_v_WF
415
+ W_v_W_FW = FW_v_WF.at[3:6].set(jnp.zeros_like(FW_v_WF[3:6]))
416
+ O_Ẋ_W = -O_X_W @ Cross.vx(W_v_W_FW)
462
417
 
463
418
  case _:
464
419
  raise ValueError(output_vel_repr)
465
420
 
466
- O_J̇_WF_I = jnp.zeros(shape=(6, 6 + model.dofs()))
467
- O_J̇_WF_I += O_Ẋ_W @ W_J_WL_W @ T
468
- O_J̇_WF_I += O_X_W @ W_J̇_WL_W @ T
469
- O_J̇_WF_I += O_X_W @ W_J_WL_W @ Ṫ
421
+ O_J̇_WF_I = O_Ẋ_W @ W_J_WL_I
422
+ O_J̇_WF_I += O_X_W @ W_J̇_WL_I
470
423
 
471
424
  return O_J̇_WF_I
@@ -26,7 +26,7 @@ from jaxsim.api.kin_dyn_parameters import (
26
26
  LinkParametrizableShape,
27
27
  ScalingFactors,
28
28
  )
29
- from jaxsim.math import Adjoint, Cross
29
+ from jaxsim.math import Adjoint, Cross, Skew
30
30
  from jaxsim.parsers.descriptions import ModelDescription
31
31
  from jaxsim.parsers.descriptions.joint import JointDescription
32
32
  from jaxsim.parsers.descriptions.link import LinkDescription
@@ -926,6 +926,149 @@ def link_spatial_inertia_matrices(model: JaxSimModel) -> jtp.Array:
926
926
  # ==============================
927
927
 
928
928
 
929
+ def _adjoint_from_rotation_translation(
930
+ rotation: jtp.Matrix,
931
+ translation: jtp.Vector,
932
+ ) -> jtp.Matrix:
933
+ zeros = jnp.zeros_like(rotation)
934
+ top_right = jnp.einsum("...ij,...jk->...ik", Skew.wedge(translation), rotation)
935
+ return jnp.concatenate(
936
+ [
937
+ jnp.concatenate([rotation, top_right], axis=-1),
938
+ jnp.concatenate([zeros, rotation], axis=-1),
939
+ ],
940
+ axis=-2,
941
+ )
942
+
943
+
944
+ def _inverse_adjoint_from_rotation_translation(
945
+ rotation: jtp.Matrix,
946
+ translation: jtp.Vector,
947
+ ) -> jtp.Matrix:
948
+ rotation_t = jnp.swapaxes(rotation, -1, -2)
949
+ zeros = jnp.zeros_like(rotation_t)
950
+ top_right = -jnp.einsum("...ij,...jk->...ik", rotation_t, Skew.wedge(translation))
951
+ return jnp.concatenate(
952
+ [
953
+ jnp.concatenate([rotation_t, top_right], axis=-1),
954
+ jnp.concatenate([zeros, rotation_t], axis=-1),
955
+ ],
956
+ axis=-2,
957
+ )
958
+
959
+
960
+ def _apply_input_representation_to_jacobian(
961
+ jacobian: jtp.Matrix,
962
+ base_transform: jtp.Matrix,
963
+ ) -> jtp.Matrix:
964
+ transformed_base = jnp.einsum(
965
+ "...ij,jk->...ik",
966
+ jacobian[..., :, 0:6],
967
+ base_transform,
968
+ )
969
+ return jnp.concatenate([transformed_base, jacobian[..., :, 6:]], axis=-1)
970
+
971
+
972
+ def _apply_input_representation_derivative_to_jacobian(
973
+ jacobian: jtp.Matrix,
974
+ base_transform_derivative: jtp.Matrix,
975
+ ) -> jtp.Matrix:
976
+ transformed_base = jnp.einsum(
977
+ "...ij,jk->...ik",
978
+ jacobian[..., :, 0:6],
979
+ base_transform_derivative,
980
+ )
981
+ return jnp.concatenate(
982
+ [transformed_base, jnp.zeros_like(jacobian[..., :, 6:])],
983
+ axis=-1,
984
+ )
985
+
986
+
987
+ def _link_jacobian_support_mask(
988
+ model: JaxSimModel,
989
+ *,
990
+ dtype: jnp.dtype,
991
+ ) -> jtp.Matrix:
992
+ κb = model.kin_dyn_parameters.support_body_array_bool
993
+ return jnp.concatenate(
994
+ [
995
+ jnp.ones((model.number_of_links(), 5), dtype=dtype),
996
+ jnp.asarray(κb, dtype=dtype),
997
+ ],
998
+ axis=1,
999
+ )
1000
+
1001
+
1002
+ def _body_input_transform(
1003
+ data: js.data.JaxSimModelData,
1004
+ ) -> tuple[jtp.Matrix, jtp.Matrix]:
1005
+ base_transform = data._base_transform
1006
+ base_rotation = base_transform[0:3, 0:3]
1007
+
1008
+ match data.velocity_representation:
1009
+ case VelRepr.Inertial:
1010
+ B_X_I = _inverse_adjoint_from_rotation_translation(
1011
+ rotation=base_rotation,
1012
+ translation=base_transform[0:3, 3],
1013
+ )
1014
+ B_Ẋ_I = -B_X_I @ Cross.vx(data.base_velocity)
1015
+
1016
+ case VelRepr.Body:
1017
+ B_X_I = jnp.eye(6, dtype=base_transform.dtype)
1018
+ B_Ẋ_I = jnp.zeros((6, 6), dtype=base_transform.dtype)
1019
+
1020
+ case VelRepr.Mixed:
1021
+ B_X_I = _inverse_adjoint_from_rotation_translation(
1022
+ rotation=base_rotation,
1023
+ translation=jnp.zeros(3, dtype=base_transform.dtype),
1024
+ )
1025
+ BW_v_BW_B = data.base_velocity.at[0:3].set(
1026
+ jnp.zeros(3, dtype=base_transform.dtype)
1027
+ )
1028
+ B_Ẋ_I = -B_X_I @ Cross.vx(BW_v_BW_B)
1029
+
1030
+ case _:
1031
+ raise ValueError(data.velocity_representation)
1032
+
1033
+ return B_X_I, B_Ẋ_I
1034
+
1035
+
1036
+ def _link_output_adjoint_from_body(
1037
+ data: js.data.JaxSimModelData,
1038
+ B_H_L: jtp.Matrix,
1039
+ *,
1040
+ output_vel_repr: VelRepr,
1041
+ ) -> jtp.Matrix:
1042
+ base_transform = data._base_transform
1043
+ base_rotation = base_transform[0:3, 0:3]
1044
+ B_R_L = B_H_L[..., 0:3, 0:3]
1045
+ B_p_L = B_H_L[..., 0:3, 3]
1046
+
1047
+ match output_vel_repr:
1048
+ case VelRepr.Inertial:
1049
+ return _adjoint_from_rotation_translation(
1050
+ rotation=base_rotation,
1051
+ translation=base_transform[0:3, 3],
1052
+ )
1053
+
1054
+ case VelRepr.Body:
1055
+ return _inverse_adjoint_from_rotation_translation(
1056
+ rotation=B_R_L,
1057
+ translation=B_p_L,
1058
+ )
1059
+
1060
+ case VelRepr.Mixed:
1061
+ W_p_B_in_LW = -jnp.einsum("ij,...j->...i", base_rotation, B_p_L)
1062
+ W_R_B = jnp.broadcast_to(base_rotation, B_R_L.shape)
1063
+ return _adjoint_from_rotation_translation(
1064
+ rotation=W_R_B,
1065
+ translation=W_p_B_in_LW,
1066
+ )
1067
+
1068
+ case _:
1069
+ raise ValueError(output_vel_repr)
1070
+
1071
+
929
1072
  @functools.partial(jax.jit, static_argnames=["output_vel_repr"])
930
1073
  def generalized_free_floating_jacobian(
931
1074
  model: JaxSimModel,
@@ -962,91 +1105,22 @@ def generalized_free_floating_jacobian(
962
1105
  joint_positions=data.joint_positions,
963
1106
  )
964
1107
 
965
- # ======================================================================
966
- # Update the input velocity representation such that v_WL = J_WL_I @ I_ν
967
- # ======================================================================
968
-
969
- match data.velocity_representation:
970
- case VelRepr.Inertial:
971
- W_H_B = data._base_transform
972
- B_X_W = Adjoint.from_transform(transform=W_H_B, inverse=True)
973
-
974
- B_J_full_WX_I = B_J_full_WX_W = ( # noqa: F841
975
- B_J_full_WX_B
976
- @ jax.scipy.linalg.block_diag(B_X_W, jnp.eye(model.dofs()))
977
- )
978
-
979
- case VelRepr.Body:
980
- B_J_full_WX_I = B_J_full_WX_B
981
-
982
- case VelRepr.Mixed:
983
- W_R_B = jaxsim.math.Quaternion.to_dcm(data.base_orientation)
984
- BW_H_B = jnp.eye(4).at[0:3, 0:3].set(W_R_B)
985
- B_X_BW = Adjoint.from_transform(transform=BW_H_B, inverse=True)
1108
+ support_mask = _link_jacobian_support_mask(model=model, dtype=B_J_full_WX_B.dtype)
1109
+ B_J_WL_B = support_mask[:, jnp.newaxis, :] * B_J_full_WX_B[jnp.newaxis, ...]
986
1110
 
987
- B_J_full_WX_I = B_J_full_WX_BW = ( # noqa: F841
988
- B_J_full_WX_B
989
- @ jax.scipy.linalg.block_diag(B_X_BW, jnp.eye(model.dofs()))
990
- )
991
-
992
- case _:
993
- raise ValueError(data.velocity_representation)
994
-
995
- # ====================================================================
996
- # Create stacked Jacobian for each link by filtering the full Jacobian
997
- # ====================================================================
998
-
999
- κ_bool = model.kin_dyn_parameters.support_body_array_bool
1000
-
1001
- # Keep only the columns of the full Jacobian corresponding to the support
1002
- # body array of each link.
1003
- B_J_WL_I = jax.vmap(
1004
- lambda κ: jnp.where(
1005
- jnp.hstack([jnp.ones(5), κ]), B_J_full_WX_I, jnp.zeros_like(B_J_full_WX_I)
1006
- )
1007
- )(κ_bool)
1008
-
1009
- # =======================================================================
1010
- # Update the output velocity representation such that O_v_WL = O_J_WL @ ν
1011
- # =======================================================================
1012
-
1013
- match output_vel_repr:
1014
- case VelRepr.Inertial:
1015
- W_H_B = data._base_transform
1016
- W_X_B = jaxsim.math.Adjoint.from_transform(W_H_B)
1017
-
1018
- O_J_WL_I = W_J_WL_I = jax.vmap( # noqa: F841
1019
- lambda B_J_WL_I: W_X_B @ B_J_WL_I
1020
- )(B_J_WL_I)
1021
-
1022
- case VelRepr.Body:
1023
- O_J_WL_I = L_J_WL_I = jax.vmap( # noqa: F841
1024
- lambda B_H_L, B_J_WL_I: jaxsim.math.Adjoint.from_transform(
1025
- B_H_L, inverse=True
1026
- )
1027
- @ B_J_WL_I
1028
- )(B_H_L, B_J_WL_I)
1029
-
1030
- case VelRepr.Mixed:
1031
- W_H_B = data._base_transform
1032
-
1033
- LW_H_L = jax.vmap(
1034
- lambda B_H_L: (W_H_B @ B_H_L).at[0:3, 3].set(jnp.zeros(3))
1035
- )(B_H_L)
1036
-
1037
- LW_H_B = jax.vmap(
1038
- lambda LW_H_L, B_H_L: LW_H_L @ jaxsim.math.Transform.inverse(B_H_L)
1039
- )(LW_H_L, B_H_L)
1040
-
1041
- O_J_WL_I = LW_J_WL_I = jax.vmap( # noqa: F841
1042
- lambda LW_H_B, B_J_WL_I: jaxsim.math.Adjoint.from_transform(LW_H_B)
1043
- @ B_J_WL_I
1044
- )(LW_H_B, B_J_WL_I)
1111
+ B_X_I, _ = _body_input_transform(data=data)
1112
+ B_J_WL_I = _apply_input_representation_to_jacobian(
1113
+ jacobian=B_J_WL_B,
1114
+ base_transform=B_X_I,
1115
+ )
1045
1116
 
1046
- case _:
1047
- raise ValueError(output_vel_repr)
1117
+ O_X_B = _link_output_adjoint_from_body(
1118
+ data=data,
1119
+ B_H_L=B_H_L,
1120
+ output_vel_repr=output_vel_repr,
1121
+ )
1048
1122
 
1049
- return O_J_WL_I
1123
+ return jnp.einsum("...ij,...jk->...ik", O_X_B, B_J_WL_I)
1050
1124
 
1051
1125
 
1052
1126
  @functools.partial(jax.jit, static_argnames=["output_vel_repr"])
@@ -1088,146 +1162,69 @@ def generalized_free_floating_jacobian_derivative(
1088
1162
  joint_positions=data.joint_positions,
1089
1163
  )
1090
1164
 
1091
- # Compute the actual doubly-left free-floating jacobian derivative of the link
1092
- # by zeroing the columns not in the path π_B(L) using the boolean κ(i).
1093
- κb = model.kin_dyn_parameters.support_body_array_bool
1094
-
1095
- # Compute the base transform.
1096
- W_H_B = data._base_transform
1165
+ support_mask = _link_jacobian_support_mask(model=model, dtype=B_J̇_full_WX_B.dtype)
1166
+ B_J̇_WL_B = support_mask[:, jnp.newaxis, :] * B_J̇_full_WX_B[jnp.newaxis, ...]
1167
+ B_J_WL_B = support_mask[:, jnp.newaxis, :] * B_J_full_WL_B[jnp.newaxis, ...]
1097
1168
 
1098
- # We add the 5 columns of ones to the Jacobian derivative to account for the
1099
- # base velocity and acceleration (5 + number of links = 6 + number of joints).
1100
- B_J̇_WL_B = (
1101
- jnp.hstack([jnp.ones((κb.shape[0], 5)), κb])[:, jnp.newaxis] * B_J̇_full_WX_B
1169
+ B_X_I, B_Ẋ_I = _body_input_transform(data=data)
1170
+ B_J_WL_I = _apply_input_representation_to_jacobian(
1171
+ jacobian=B_J_WL_B,
1172
+ base_transform=B_X_I,
1102
1173
  )
1103
- B_J_WL_B = (
1104
- jnp.hstack([jnp.ones((κb.shape[0], 5)), κb])[:, jnp.newaxis] * B_J_full_WL_B
1174
+ B_J̇_WL_input = _apply_input_representation_to_jacobian(
1175
+ jacobian=B_J̇_WL_B,
1176
+ base_transform=B_X_I,
1177
+ )
1178
+ B_J̇_WL_repr = _apply_input_representation_derivative_to_jacobian(
1179
+ jacobian=B_J_WL_B,
1180
+ base_transform_derivative=B_Ẋ_I,
1105
1181
  )
1106
1182
 
1107
- # =====================================================
1108
- # Compute quantities to adjust the input representation
1109
- # =====================================================
1110
-
1111
- In = jnp.eye(model.dofs())
1112
- On = jnp.zeros(shape=(model.dofs(), model.dofs()))
1113
-
1114
- match data.velocity_representation:
1115
- case VelRepr.Inertial:
1116
- B_X_W = jaxsim.math.Adjoint.from_transform(transform=W_H_B, inverse=True)
1117
-
1118
- W_v_WB = data.base_velocity
1119
- B_Ẋ_W = -B_X_W @ jaxsim.math.Cross.vx(W_v_WB)
1120
-
1121
- # Compute the operator to change the representation of ν, and its
1122
- # time derivative.
1123
- T = jax.scipy.linalg.block_diag(B_X_W, In)
1124
- Ṫ = jax.scipy.linalg.block_diag(B_Ẋ_W, On)
1125
-
1126
- case VelRepr.Body:
1127
- B_X_B = jaxsim.math.Adjoint.from_rotation_and_translation(
1128
- translation=jnp.zeros(3), rotation=jnp.eye(3)
1129
- )
1130
-
1131
- B_Ẋ_B = jnp.zeros(shape=(6, 6))
1132
-
1133
- # Compute the operator to change the representation of ν, and its
1134
- # time derivative.
1135
- T = jax.scipy.linalg.block_diag(B_X_B, In)
1136
- Ṫ = jax.scipy.linalg.block_diag(B_Ẋ_B, On)
1137
-
1138
- case VelRepr.Mixed:
1139
- BW_H_B = W_H_B.at[0:3, 3].set(jnp.zeros(3))
1140
- B_X_BW = jaxsim.math.Adjoint.from_transform(transform=BW_H_B, inverse=True)
1141
-
1142
- BW_v_WB = data.base_velocity
1143
- BW_v_W_BW = BW_v_WB.at[3:6].set(jnp.zeros(3))
1144
-
1145
- BW_v_BW_B = BW_v_WB - BW_v_W_BW
1146
- B_Ẋ_BW = -B_X_BW @ jaxsim.math.Cross.vx(BW_v_BW_B)
1147
-
1148
- # Compute the operator to change the representation of ν, and its
1149
- # time derivative.
1150
- T = jax.scipy.linalg.block_diag(B_X_BW, In)
1151
- Ṫ = jax.scipy.linalg.block_diag(B_Ẋ_BW, On)
1152
-
1153
- case _:
1154
- raise ValueError(data.velocity_representation)
1183
+ B_v_WB = B_X_I @ data.base_velocity
1184
+ B_ν = jnp.concatenate([B_v_WB, data.joint_velocities])
1185
+ B_v_WL = jnp.einsum("bij,j->bi", B_J_WL_B, B_ν)
1155
1186
 
1156
- # ======================================================
1157
- # Compute quantities to adjust the output representation
1158
- # ======================================================
1187
+ O_X_B = _link_output_adjoint_from_body(
1188
+ data=data,
1189
+ B_H_L=B_H_L,
1190
+ output_vel_repr=output_vel_repr,
1191
+ )
1159
1192
 
1160
1193
  match output_vel_repr:
1161
1194
  case VelRepr.Inertial:
1162
- O_X_B = W_X_B = jaxsim.math.Adjoint.from_transform(transform=W_H_B)
1163
-
1164
- with data.switch_velocity_representation(VelRepr.Body):
1165
- B_v_WB = data.base_velocity
1166
-
1167
- O_Ẋ_B = W_Ẋ_B = W_X_B @ jaxsim.math.Cross.vx(B_v_WB) # noqa: F841
1195
+ O_Ẋ_B = O_X_B @ Cross.vx(B_v_WB)
1168
1196
 
1169
1197
  case VelRepr.Body:
1170
- O_X_B = L_X_B = jaxsim.math.Adjoint.from_transform(
1171
- transform=B_H_L, inverse=True
1172
- )
1173
-
1174
- B_X_L = jaxsim.math.Adjoint.inverse(adjoint=L_X_B)
1175
-
1176
- with data.switch_velocity_representation(VelRepr.Body):
1177
- B_v_WB = data.base_velocity
1178
- L_v_WL = jnp.einsum(
1179
- "b6j,j->b6", L_X_B @ B_J_WL_B, data.generalized_velocity
1180
- )
1181
-
1182
- O_Ẋ_B = L_Ẋ_B = -L_X_B @ jaxsim.math.Cross.vx( # noqa: F841
1183
- jnp.einsum("bij,bj->bi", B_X_L, L_v_WL) - B_v_WB
1184
- )
1198
+ B_v_B_L = B_v_WL - B_v_WB
1199
+ O_Ẋ_B = -jnp.einsum("...ij,...jk->...ik", O_X_B, Cross.vx(B_v_B_L))
1185
1200
 
1186
1201
  case VelRepr.Mixed:
1187
- W_H_L = W_H_B @ B_H_L
1188
- LW_H_L = W_H_L.at[:, 0:3, 3].set(jnp.zeros_like(W_H_L[:, 0:3, 3]))
1189
- LW_H_B = LW_H_L @ jaxsim.math.Transform.inverse(B_H_L)
1190
-
1191
- O_X_B = LW_X_B = jaxsim.math.Adjoint.from_transform(transform=LW_H_B)
1192
-
1193
- B_X_LW = jaxsim.math.Adjoint.inverse(adjoint=LW_X_B)
1194
-
1195
- with data.switch_velocity_representation(VelRepr.Body):
1196
- B_v_WB = data.base_velocity
1197
-
1198
- with data.switch_velocity_representation(VelRepr.Mixed):
1199
- BW_H_B = W_H_B.at[0:3, 3].set(jnp.zeros(3))
1200
- B_X_BW = Adjoint.from_transform(transform=BW_H_B, inverse=True)
1201
- LW_v_WL = jnp.einsum(
1202
- "bij,bj->bi",
1203
- LW_X_B,
1204
- B_J_WL_B
1205
- @ jax.scipy.linalg.block_diag(B_X_BW, jnp.eye(model.dofs()))
1206
- @ data.generalized_velocity,
1207
- )
1208
-
1209
- LW_v_W_LW = LW_v_WL.at[:, 3:6].set(jnp.zeros_like(LW_v_WL[:, 3:6]))
1202
+ base_rotation = data._base_transform[0:3, 0:3]
1203
+ B_p_L = B_H_L[..., 0:3, 3]
1204
+ W_p_B_in_LW = -jnp.einsum("ij,...j->...i", base_rotation, B_p_L)
1205
+ W_R_B = jnp.broadcast_to(base_rotation, B_H_L[..., 0:3, 0:3].shape)
1206
+ B_X_LW = _inverse_adjoint_from_rotation_translation(
1207
+ rotation=W_R_B,
1208
+ translation=W_p_B_in_LW,
1209
+ )
1210
1210
 
1211
+ LW_v_WL = jnp.einsum("...ij,...j->...i", O_X_B, B_v_WL)
1212
+ LW_v_W_LW = LW_v_WL.at[..., 3:6].set(jnp.zeros_like(LW_v_WL[..., 3:6]))
1211
1213
  LW_v_LW_L = LW_v_WL - LW_v_W_LW
1212
- LW_v_B_LW = LW_v_WL - jnp.einsum("bij,j->bi", LW_X_B, B_v_WB) - LW_v_LW_L
1214
+ LW_v_B_LW = LW_v_WL - jnp.einsum("...ij,j->...i", O_X_B, B_v_WB) - LW_v_LW_L
1213
1215
 
1214
- O_Ẋ_B = LW_Ẋ_B = -LW_X_B @ jaxsim.math.Cross.vx( # noqa: F841
1215
- jnp.einsum("bij,bj->bi", B_X_LW, LW_v_B_LW)
1216
+ O_Ẋ_B = -jnp.einsum(
1217
+ "...ij,...jk->...ik",
1218
+ O_X_B,
1219
+ Cross.vx(jnp.einsum("...ij,...j->...i", B_X_LW, LW_v_B_LW)),
1216
1220
  )
1217
1221
 
1218
1222
  case _:
1219
1223
  raise ValueError(output_vel_repr)
1220
1224
 
1221
- # =============================================================
1222
- # Express the Jacobian derivative in the target representations
1223
- # =============================================================
1224
-
1225
- # Sum all the components that form the Jacobian derivative in the target
1226
- # input/output velocity representations.
1227
- O_J̇_WL_I = jnp.zeros_like(B_J̇_WL_B)
1228
- O_J̇_WL_I += O_Ẋ_B @ B_J_WL_B @ T
1229
- O_J̇_WL_I += O_X_B @ B_J̇_WL_B @ T
1230
- O_J̇_WL_I += O_X_B @ B_J_WL_B @ Ṫ
1225
+ O_J̇_WL_I = jnp.einsum("...ij,...jk->...ik", O_Ẋ_B, B_J_WL_I)
1226
+ O_J̇_WL_I += jnp.einsum("...ij,...jk->...ik", O_X_B, B_J̇_WL_input)
1227
+ O_J̇_WL_I += jnp.einsum("...ij,...jk->...ik", O_X_B, B_J̇_WL_repr)
1231
1228
 
1232
1229
  return O_J̇_WL_I
1233
1230
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes