jaxsim 0.4.3.dev94__py3-none-any.whl → 0.4.3.dev100__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
jaxsim/_version.py CHANGED
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.4.3.dev94'
16
- __version_tuple__ = version_tuple = (0, 4, 3, 'dev94')
15
+ __version__ = version = '0.4.3.dev100'
16
+ __version_tuple__ = version_tuple = (0, 4, 3, 'dev100')
jaxsim/api/contact.py CHANGED
@@ -93,7 +93,10 @@ def collidable_point_velocities(
93
93
 
94
94
  @jax.jit
95
95
  def collidable_point_forces(
96
- model: js.model.JaxSimModel, data: js.data.JaxSimModelData
96
+ model: js.model.JaxSimModel,
97
+ data: js.data.JaxSimModelData,
98
+ link_forces: jtp.MatrixLike | None = None,
99
+ joint_force_references: jtp.VectorLike | None = None,
97
100
  ) -> jtp.Matrix:
98
101
  """
99
102
  Compute the 6D forces applied to each collidable point.
@@ -101,13 +104,23 @@ def collidable_point_forces(
101
104
  Args:
102
105
  model: The model to consider.
103
106
  data: The data of the considered model.
107
+ link_forces:
108
+ The 6D external forces to apply to the links expressed in the same
109
+ representation of data.
110
+ joint_force_references:
111
+ The joint force references to apply to the joints.
104
112
 
105
113
  Returns:
106
114
  The 6D forces applied to each collidable point expressed in the frame
107
115
  corresponding to the active representation.
108
116
  """
109
117
 
110
- f_Ci, _ = collidable_point_dynamics(model=model, data=data)
118
+ f_Ci, _ = collidable_point_dynamics(
119
+ model=model,
120
+ data=data,
121
+ link_forces=link_forces,
122
+ joint_force_references=joint_force_references,
123
+ )
111
124
 
112
125
  return f_Ci
113
126
 
@@ -195,6 +208,7 @@ def collidable_point_dynamics(
195
208
  data=data,
196
209
  link_forces=link_forces,
197
210
  joint_force_references=joint_force_references,
211
+ solver_tol=1e-3,
198
212
  )
199
213
 
200
214
  aux_data = dict()
jaxsim/api/model.py CHANGED
@@ -1731,7 +1731,10 @@ def link_bias_accelerations(
1731
1731
 
1732
1732
  @jax.jit
1733
1733
  def link_contact_forces(
1734
- model: js.model.JaxSimModel, data: js.data.JaxSimModelData
1734
+ model: js.model.JaxSimModel,
1735
+ data: js.data.JaxSimModelData,
1736
+ link_forces: jtp.MatrixLike | None = None,
1737
+ joint_force_references: jtp.VectorLike | None = None,
1735
1738
  ) -> jtp.Matrix:
1736
1739
  """
1737
1740
  Compute the 6D contact forces of all links of the model.
@@ -1739,6 +1742,11 @@ def link_contact_forces(
1739
1742
  Args:
1740
1743
  model: The model to consider.
1741
1744
  data: The data of the considered model.
1745
+ link_forces:
1746
+ The 6D external forces to apply to the links expressed in the same
1747
+ representation of data.
1748
+ joint_force_references:
1749
+ The joint force references to apply to the joints.
1742
1750
 
1743
1751
  Returns:
1744
1752
  A `(nL, 6)` array containing the stacked 6D contact forces of the links,
@@ -1749,10 +1757,44 @@ def link_contact_forces(
1749
1757
  # `jaxsim.api.ode.system_velocity_dynamics`. We cannot merge them since
1750
1758
  # there we need to get also aux_data.
1751
1759
 
1760
+ # Build link forces if not provided.
1761
+ # These forces are expressed in the frame corresponding to the velocity
1762
+ # representation of data.
1763
+ O_f_L = (
1764
+ jnp.atleast_2d(link_forces.squeeze())
1765
+ if link_forces is not None
1766
+ else jnp.zeros((model.number_of_links(), 6))
1767
+ ).astype(float)
1768
+
1769
+ # Build joint force references if not provided.
1770
+ joint_force_references = (
1771
+ jnp.atleast_1d(joint_force_references)
1772
+ if joint_force_references is not None
1773
+ else jnp.zeros(model.dofs())
1774
+ )
1775
+
1776
+ # We expect that the 6D forces included in the `link_forces` argument are expressed
1777
+ # in the frame corresponding to the velocity representation of `data`.
1778
+ input_references = js.references.JaxSimModelReferences.build(
1779
+ model=model,
1780
+ data=data,
1781
+ velocity_representation=data.velocity_representation,
1782
+ link_forces=O_f_L,
1783
+ joint_force_references=joint_force_references,
1784
+ )
1785
+
1752
1786
  # Compute the 6D forces applied to each collidable point expressed in the
1753
1787
  # inertial frame.
1754
- with data.switch_velocity_representation(VelRepr.Inertial):
1755
- W_f_C = js.contact.collidable_point_forces(model=model, data=data)
1788
+ with (
1789
+ data.switch_velocity_representation(VelRepr.Inertial),
1790
+ input_references.switch_velocity_representation(VelRepr.Inertial),
1791
+ ):
1792
+ W_f_C = js.contact.collidable_point_forces(
1793
+ model=model,
1794
+ data=data,
1795
+ link_forces=input_references.link_forces(),
1796
+ joint_force_references=input_references.joint_force_references(),
1797
+ )
1756
1798
 
1757
1799
  # Construct the vector defining the parent link index of each collidable point.
1758
1800
  # We use this vector to sum the 6D forces of all collidable points rigidly
@@ -215,6 +215,7 @@ class RigidContacts(ContactModel):
215
215
  link_forces: jtp.MatrixLike | None = None,
216
216
  joint_force_references: jtp.VectorLike | None = None,
217
217
  regularization_term: jtp.FloatLike = 1e-6,
218
+ solver_tol: jtp.FloatLike = 1e-3,
218
219
  ) -> tuple[jtp.Vector, tuple[Any, ...]]:
219
220
  """
220
221
  Compute the contact forces.
@@ -257,6 +258,9 @@ class RigidContacts(ContactModel):
257
258
  M = js.model.free_floating_mass_matrix(model=model, data=data)
258
259
  J_WC = js.contact.jacobian(model=model, data=data)
259
260
  W_H_C = js.contact.transforms(model=model, data=data)
261
+ J̇_WC_BW = js.contact.jacobian_derivative(model=model, data=data)
262
+ BW_ν = data.generalized_velocity()
263
+
260
264
  terrain_height = jax.vmap(self.terrain.height)(position[:, 0], position[:, 1])
261
265
  n_collidable_points = model.kin_dyn_parameters.contact_parameters.point.shape[0]
262
266
 
@@ -295,9 +299,10 @@ class RigidContacts(ContactModel):
295
299
  )
296
300
 
297
301
  free_contact_acc = RigidContacts._linear_acceleration_of_collidable_points(
298
- model,
299
- data,
300
- BW_ν̇_free,
302
+ BW_nu=BW_ν,
303
+ BW_nu_dot=BW_ν̇_free,
304
+ CW_J_WC_BW=J_WC,
305
+ CW_J_dot_WC_BW=J̇_WC_BW,
301
306
  ).flatten()
302
307
 
303
308
  # Compute stabilization term
@@ -325,7 +330,9 @@ class RigidContacts(ContactModel):
325
330
  b = jnp.zeros((0,))
326
331
 
327
332
  # Solve the optimization problem
328
- solution, *_ = qpax.solve_qp(Q=Q, q=q, A=A, b=b, G=G, h=h_bounds)
333
+ solution, *_ = qpax.solve_qp(
334
+ Q=Q, q=q, A=A, b=b, G=G, h=h_bounds, solver_tol=solver_tol
335
+ )
329
336
 
330
337
  f_C_lin = solution.reshape(-1, 3)
331
338
 
@@ -399,24 +406,14 @@ class RigidContacts(ContactModel):
399
406
 
400
407
  @staticmethod
401
408
  def _linear_acceleration_of_collidable_points(
402
- model: js.model.JaxSimModel,
403
- data: js.data.JaxSimModelData,
404
- mixed_nu_dot: jtp.ArrayLike,
409
+ BW_nu: jtp.ArrayLike,
410
+ BW_nu_dot: jtp.ArrayLike,
411
+ CW_J_WC_BW: jtp.MatrixLike,
412
+ CW_J_dot_WC_BW: jtp.MatrixLike,
405
413
  ) -> jtp.Matrix:
406
- with data.switch_velocity_representation(VelRepr.Mixed):
407
- CW_J_WC_BW = js.contact.jacobian(
408
- model=model,
409
- data=data,
410
- output_vel_repr=VelRepr.Mixed,
411
- )
412
- CW_J̇_WC_BW = js.contact.jacobian_derivative(
413
- model=model,
414
- data=data,
415
- output_vel_repr=VelRepr.Mixed,
416
- )
417
-
418
- BW_ν = data.generalized_velocity()
419
- BW_ν̇ = mixed_nu_dot
414
+ CW_J̇_WC_BW = CW_J_dot_WC_BW
415
+ BW_ν = BW_nu
416
+ BW_ν̇ = BW_nu_dot
420
417
 
421
418
  CW_a_WC = jnp.vstack(CW_J̇_WC_BW) @ BW_ν + jnp.vstack(CW_J_WC_BW) @ BW_ν̇
422
419
  CW_a_WC = CW_a_WC.reshape(-1, 6)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: jaxsim
3
- Version: 0.4.3.dev94
3
+ Version: 0.4.3.dev100
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>
6
6
  Maintainer-email: Diego Ferigo <dgferigo@gmail.com>, Filippo Luca Ferretti <filippo.ferretti@iit.it>
@@ -1,18 +1,18 @@
1
1
  jaxsim/__init__.py,sha256=bSbpggIz5aG6QuGZLa0V2EfHjAOeucMxi-vIYxzLmN8,2788
2
- jaxsim/_version.py,sha256=f0-5Va8ZSzGXVRJ_ApiuY6zOurBuqFLN7dmOX5CxUAA,426
2
+ jaxsim/_version.py,sha256=6tbBNOYxIl9wn0NrYbEUl4HAOBZXlIyTW1wpZtsJZEA,428
3
3
  jaxsim/exceptions.py,sha256=8_h8iqL8DgNR754dR8SZiQ7361GR5V1sUk3ZuZCHw1Q,2069
4
4
  jaxsim/logging.py,sha256=STI-D_upXZYX-ZezLrlJJ0UlD5YspST0vZ_DcIwkzO4,1553
5
5
  jaxsim/typing.py,sha256=2HXy9hgazPXjofi1vLQ09ZubPtgVmg80U9NKmZ6NYiI,761
6
6
  jaxsim/api/__init__.py,sha256=8eV22t2S3UwNyCg8karPetG1dmX1VDBXkyv28_FwNQA,210
7
7
  jaxsim/api/com.py,sha256=m-p3EJDhpnMTlXKplfbZE_aH9NqX_VyLlAE3vUhc6l4,13642
8
8
  jaxsim/api/common.py,sha256=SNgxq42r6eF_-aPszvOjUYkGwXOzz4hKmhDwEUkscFQ,6650
9
- jaxsim/api/contact.py,sha256=YwiG44giPxFgIaZq24rYxBx6McNgXXFwwiG9tA8801I,22528
9
+ jaxsim/api/contact.py,sha256=BQMIMHBFYiHe_LVx_bwxKCpy20uiy0V-NljHfYXWhI0,23013
10
10
  jaxsim/api/data.py,sha256=QldUHniJqKrdNtAcXuRaS9UyeslJ0Rjvb17UA0Ca5Tw,29008
11
11
  jaxsim/api/frame.py,sha256=KS8A5wRfjxhe9NgcVo2QA516iP5zky7UVnWxG7nTa7c,12911
12
12
  jaxsim/api/joint.py,sha256=lksT1Doxz2jknHyhb4ls20z6f6dofpZSzBJtVacZXAE,7129
13
13
  jaxsim/api/kin_dyn_parameters.py,sha256=ElahFk_RCcLvjTidH2qDOsY-m1gN1hXitCv4SvfgGYY,29260
14
14
  jaxsim/api/link.py,sha256=LAA6ZMQXkWomXeptURBtc7z3_xDZ2BBnBMhVrohh0bE,18621
15
- jaxsim/api/model.py,sha256=WL31JA2jK5L79TJ05ZouIYGe02rQvFItVDqizkzC1UE,66100
15
+ jaxsim/api/model.py,sha256=CAxGDjSSP5coKQXM53pejnF1UmSo851UwZ3fz7JN8RE,67658
16
16
  jaxsim/api/ode.py,sha256=gYSbtHWGCDP-IkUzQlH3t0fBKnK8qmxwhIvsbLG9lwU,13616
17
17
  jaxsim/api/ode_data.py,sha256=7RSoBhfCJdP6P9InQbDwdBVpClPMMuetewI-6AWm-_0,20276
18
18
  jaxsim/api/references.py,sha256=XOVKuQXRmjPoP-T5JWGSbqIGX5DzOkeGafqRpj0ZQEM,20771
@@ -55,7 +55,7 @@ jaxsim/rbda/utils.py,sha256=eeT21Y4DiiyhrdF0lUE_VvRuwru5-rR7yOlOlWzCCWE,5381
55
55
  jaxsim/rbda/contacts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
56
56
  jaxsim/rbda/contacts/common.py,sha256=VwAs742futAmLnDgbaOuLzNDBFiKDfYItdEZ4UcFgzE,2467
57
57
  jaxsim/rbda/contacts/relaxed_rigid.py,sha256=deTC0M2a_RER7iwVpxLCfuSlgBLqkTmHQdOJ4169IR4,13646
58
- jaxsim/rbda/contacts/rigid.py,sha256=zbSM0miwpgC1rp1d0RoQ1q8pYiKdIkHV8iZimeEPC94,15153
58
+ jaxsim/rbda/contacts/rigid.py,sha256=BYvQgoaG5yKo2N1SLlXgjP6cb1OrJ1BawGXkJf0Hhi0,15060
59
59
  jaxsim/rbda/contacts/soft.py,sha256=_wvb5iZDjGcVg6rNQelN4LZN7qSC2NIp0HdKvZmlGfk,15647
60
60
  jaxsim/terrain/__init__.py,sha256=f7lVX-iNpH_wkkjef9Qpjh19TTAUOQw76EiLYJDVizc,78
61
61
  jaxsim/terrain/terrain.py,sha256=xUQg47yGxIOcTkLPbnO3sruEGBhoCd16j1evTGlmNjI,5010
@@ -63,8 +63,8 @@ jaxsim/utils/__init__.py,sha256=Y5zyoRevl3EMVQadhZ4EtSwTEkDt2vcnFoRhPJjKTZ0,215
63
63
  jaxsim/utils/jaxsim_dataclass.py,sha256=TGmTQV2Lq7Q-2nLoAEaeNtkPa_qj0IKkdBm4COj46Os,11312
64
64
  jaxsim/utils/tracing.py,sha256=KDMoyVPlu2NJvFkhtZwq5AkqMMgajt3munvJom-vEjQ,650
65
65
  jaxsim/utils/wrappers.py,sha256=Fh82ZcaFi5fUnByyFLnmumaobsu1hJIvFdopUVzJ1ps,4052
66
- jaxsim-0.4.3.dev94.dist-info/LICENSE,sha256=eaYdFmdeMbiIoIiPzEK0MjP1S9wtFXjXNR5er49uLR0,1546
67
- jaxsim-0.4.3.dev94.dist-info/METADATA,sha256=wEoRAFF3f-3u2hBbHzyOPBQ_mgcwFGcBaPmC-wYuAhE,17276
68
- jaxsim-0.4.3.dev94.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
69
- jaxsim-0.4.3.dev94.dist-info/top_level.txt,sha256=LxGMA8FLtXjQ6oI7N5gd_R_oSUHxpXxUEOfT1xS_ni0,7
70
- jaxsim-0.4.3.dev94.dist-info/RECORD,,
66
+ jaxsim-0.4.3.dev100.dist-info/LICENSE,sha256=eaYdFmdeMbiIoIiPzEK0MjP1S9wtFXjXNR5er49uLR0,1546
67
+ jaxsim-0.4.3.dev100.dist-info/METADATA,sha256=VcqRqSnrI9gZktcAwUSPlwy_OQl-5dWn9ZY9-BjMGyQ,17277
68
+ jaxsim-0.4.3.dev100.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
69
+ jaxsim-0.4.3.dev100.dist-info/top_level.txt,sha256=LxGMA8FLtXjQ6oI7N5gd_R_oSUHxpXxUEOfT1xS_ni0,7
70
+ jaxsim-0.4.3.dev100.dist-info/RECORD,,