jaxsim 0.2.1.dev70__py3-none-any.whl → 0.2.1.dev80__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 +2 -2
- jaxsim/api/com.py +176 -0
- jaxsim/api/contact.py +128 -2
- {jaxsim-0.2.1.dev70.dist-info → jaxsim-0.2.1.dev80.dist-info}/METADATA +1 -1
- {jaxsim-0.2.1.dev70.dist-info → jaxsim-0.2.1.dev80.dist-info}/RECORD +8 -8
- {jaxsim-0.2.1.dev70.dist-info → jaxsim-0.2.1.dev80.dist-info}/LICENSE +0 -0
- {jaxsim-0.2.1.dev70.dist-info → jaxsim-0.2.1.dev80.dist-info}/WHEEL +0 -0
- {jaxsim-0.2.1.dev70.dist-info → jaxsim-0.2.1.dev80.dist-info}/top_level.txt +0 -0
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.2.1.
|
16
|
-
__version_tuple__ = version_tuple = (0, 2, 1, '
|
15
|
+
__version__ = version = '0.2.1.dev80'
|
16
|
+
__version_tuple__ = version_tuple = (0, 2, 1, 'dev80')
|
jaxsim/api/com.py
CHANGED
@@ -238,3 +238,179 @@ def average_centroidal_velocity_jacobian(
|
|
238
238
|
G_Mbb = locked_centroidal_spatial_inertia(model=model, data=data)
|
239
239
|
|
240
240
|
return jnp.linalg.inv(G_Mbb) @ G_J
|
241
|
+
|
242
|
+
|
243
|
+
@jax.jit
|
244
|
+
def bias_acceleration(
|
245
|
+
model: js.model.JaxSimModel, data: js.data.JaxSimModelData
|
246
|
+
) -> jtp.Vector:
|
247
|
+
r"""
|
248
|
+
Compute the bias linear acceleration of the center of mass.
|
249
|
+
|
250
|
+
Args:
|
251
|
+
model: The model to consider.
|
252
|
+
data: The data of the considered model.
|
253
|
+
|
254
|
+
Returns:
|
255
|
+
The bias linear acceleration of the center of mass in the active representation.
|
256
|
+
|
257
|
+
Note:
|
258
|
+
The bias acceleration is expressed in the mixed frame
|
259
|
+
:math:`G = ({}^W \mathbf{p}_{\text{CoM}}, [C])`, where :math:`[C] = [W]` if the
|
260
|
+
active velocity representation is either inertial-fixed or mixed,
|
261
|
+
and :math:`[C] = [B]` if the active velocity representation is body-fixed.
|
262
|
+
"""
|
263
|
+
|
264
|
+
# Compute the pose of all links with forward kinematics.
|
265
|
+
W_H_L = js.model.forward_kinematics(model=model, data=data)
|
266
|
+
|
267
|
+
# Compute the bias acceleration of all links by zeroing the generalized velocity
|
268
|
+
# in the active representation.
|
269
|
+
v̇_bias_WL = js.model.link_bias_accelerations(model=model, data=data)
|
270
|
+
|
271
|
+
def other_representation_to_body(
|
272
|
+
C_v̇_WL: jtp.Vector, C_v_WC: jtp.Vector, L_H_C: jtp.Matrix, L_v_LC: jtp.Vector
|
273
|
+
) -> jtp.Vector:
|
274
|
+
"""
|
275
|
+
Helper to convert the body-fixed representation of the link bias acceleration
|
276
|
+
C_v̇_WL expressed in a generic frame C to the body-fixed representation L_v̇_WL.
|
277
|
+
"""
|
278
|
+
|
279
|
+
L_X_C = jaxsim.math.Adjoint.from_transform(transform=L_H_C)
|
280
|
+
C_X_L = jaxsim.math.Adjoint.inverse(L_X_C)
|
281
|
+
|
282
|
+
L_v̇_WL = L_X_C @ (C_v̇_WL + jaxsim.math.Cross.vx(C_X_L @ L_v_LC) @ C_v_WC)
|
283
|
+
return L_v̇_WL
|
284
|
+
|
285
|
+
# We need here to get the body-fixed bias acceleration of the links.
|
286
|
+
# Since it's computed in the active representation, we need to convert it to body.
|
287
|
+
match data.velocity_representation:
|
288
|
+
|
289
|
+
case VelRepr.Body:
|
290
|
+
L_a_bias_WL = v̇_bias_WL
|
291
|
+
|
292
|
+
case VelRepr.Inertial:
|
293
|
+
|
294
|
+
C_v̇_WL = W_v̇_bias_WL = v̇_bias_WL
|
295
|
+
C_v_WC = W_v_WW = jnp.zeros(6)
|
296
|
+
|
297
|
+
L_H_C = L_H_W = jax.vmap(
|
298
|
+
lambda W_H_L: jaxsim.math.Transform.inverse(W_H_L)
|
299
|
+
)(W_H_L)
|
300
|
+
|
301
|
+
L_v_LC = L_v_LW = jax.vmap(
|
302
|
+
lambda i: -js.link.velocity(
|
303
|
+
model=model, data=data, link_index=i, output_vel_repr=VelRepr.Body
|
304
|
+
)
|
305
|
+
)(jnp.arange(model.number_of_links()))
|
306
|
+
|
307
|
+
L_a_bias_WL = jax.vmap(
|
308
|
+
lambda i: other_representation_to_body(
|
309
|
+
C_v̇_WL=C_v̇_WL[i],
|
310
|
+
C_v_WC=C_v_WC,
|
311
|
+
L_H_C=L_H_C[i],
|
312
|
+
L_v_LC=L_v_LC[i],
|
313
|
+
)
|
314
|
+
)(jnp.arange(model.number_of_links()))
|
315
|
+
|
316
|
+
case VelRepr.Mixed:
|
317
|
+
|
318
|
+
C_v̇_WL = LW_v̇_bias_WL = v̇_bias_WL
|
319
|
+
|
320
|
+
C_v_WC = LW_v_W_LW = jax.vmap(
|
321
|
+
lambda i: js.link.velocity(
|
322
|
+
model=model, data=data, link_index=i, output_vel_repr=VelRepr.Mixed
|
323
|
+
)
|
324
|
+
.at[3:6]
|
325
|
+
.set(jnp.zeros(3))
|
326
|
+
)(jnp.arange(model.number_of_links()))
|
327
|
+
|
328
|
+
L_H_C = L_H_LW = jax.vmap(
|
329
|
+
lambda W_H_L: jaxsim.math.Transform.inverse(
|
330
|
+
W_H_L.at[0:3, 3].set(jnp.zeros(3))
|
331
|
+
)
|
332
|
+
)(W_H_L)
|
333
|
+
|
334
|
+
L_v_LC = L_v_L_LW = jax.vmap(
|
335
|
+
lambda i: -js.link.velocity(
|
336
|
+
model=model, data=data, link_index=i, output_vel_repr=VelRepr.Body
|
337
|
+
)
|
338
|
+
.at[0:3]
|
339
|
+
.set(jnp.zeros(3))
|
340
|
+
)(jnp.arange(model.number_of_links()))
|
341
|
+
|
342
|
+
L_a_bias_WL = jax.vmap(
|
343
|
+
lambda i: other_representation_to_body(
|
344
|
+
C_v̇_WL=C_v̇_WL[i],
|
345
|
+
C_v_WC=C_v_WC[i],
|
346
|
+
L_H_C=L_H_C[i],
|
347
|
+
L_v_LC=L_v_LC[i],
|
348
|
+
)
|
349
|
+
)(jnp.arange(model.number_of_links()))
|
350
|
+
|
351
|
+
case _:
|
352
|
+
raise ValueError(data.velocity_representation)
|
353
|
+
|
354
|
+
# Compute the bias of the 6D momentum derivative.
|
355
|
+
def bias_momentum_derivative_term(
|
356
|
+
link_index: jtp.Int, L_a_bias_WL: jtp.Vector
|
357
|
+
) -> jtp.Vector:
|
358
|
+
|
359
|
+
# Get the body-fixed 6D inertia matrix.
|
360
|
+
L_M_L = js.link.spatial_inertia(model=model, link_index=link_index)
|
361
|
+
|
362
|
+
# Compute the body-fixed 6D velocity.
|
363
|
+
L_v_WL = js.link.velocity(
|
364
|
+
model=model, data=data, link_index=link_index, output_vel_repr=VelRepr.Body
|
365
|
+
)
|
366
|
+
|
367
|
+
# Compute the world-to-link transformations for 6D forces.
|
368
|
+
W_Xf_L = jaxsim.math.Adjoint.from_transform(
|
369
|
+
transform=W_H_L[link_index], inverse=True
|
370
|
+
).T
|
371
|
+
|
372
|
+
# Compute the contribution of the link to the bias acceleration of the CoM.
|
373
|
+
W_ḣ_bias_link_contribution = W_Xf_L @ (
|
374
|
+
L_M_L @ L_a_bias_WL + jaxsim.math.Cross.vx_star(L_v_WL) @ L_M_L @ L_v_WL
|
375
|
+
)
|
376
|
+
|
377
|
+
return W_ḣ_bias_link_contribution
|
378
|
+
|
379
|
+
# Sum the contributions of all links to the bias acceleration of the CoM.
|
380
|
+
W_ḣ_bias = jax.vmap(bias_momentum_derivative_term)(
|
381
|
+
jnp.arange(model.number_of_links()), L_a_bias_WL
|
382
|
+
).sum(axis=0)
|
383
|
+
|
384
|
+
# Compute the total mass of the model.
|
385
|
+
m = js.model.total_mass(model=model)
|
386
|
+
|
387
|
+
# Compute the position of the CoM.
|
388
|
+
W_p_CoM = com_position(model=model, data=data)
|
389
|
+
|
390
|
+
match data.velocity_representation:
|
391
|
+
|
392
|
+
# G := G[W] = (W_p_CoM, [W])
|
393
|
+
case VelRepr.Inertial | VelRepr.Mixed:
|
394
|
+
|
395
|
+
W_H_GW = jnp.eye(4).at[0:3, 3].set(W_p_CoM)
|
396
|
+
GW_Xf_W = jaxsim.math.Adjoint.from_transform(W_H_GW).T
|
397
|
+
|
398
|
+
GW_ḣ_bias = GW_Xf_W @ W_ḣ_bias
|
399
|
+
GW_v̇l_com_bias = GW_ḣ_bias[0:3] / m
|
400
|
+
|
401
|
+
return GW_v̇l_com_bias
|
402
|
+
|
403
|
+
# G := G[B] = (W_p_CoM, [B])
|
404
|
+
case VelRepr.Body:
|
405
|
+
|
406
|
+
GB_Xf_W = jaxsim.math.Adjoint.from_transform(
|
407
|
+
transform=data.base_transform().at[0:3].set(W_p_CoM)
|
408
|
+
).T
|
409
|
+
|
410
|
+
GB_ḣ_bias = GB_Xf_W @ W_ḣ_bias
|
411
|
+
GB_v̇l_com_bias = GB_ḣ_bias[0:3] / m
|
412
|
+
|
413
|
+
return GB_v̇l_com_bias
|
414
|
+
|
415
|
+
case _:
|
416
|
+
raise ValueError(data.velocity_representation)
|
jaxsim/api/contact.py
CHANGED
@@ -32,6 +32,7 @@ def collidable_point_kinematics(
|
|
32
32
|
|
33
33
|
from jaxsim.rbda import collidable_points
|
34
34
|
|
35
|
+
# Switch to inertial-fixed since the RBDAs expect velocities in this representation.
|
35
36
|
with data.switch_velocity_representation(VelRepr.Inertial):
|
36
37
|
W_p_Ci, W_ṗ_Ci = collidable_points.collidable_points_pos_vel(
|
37
38
|
model=model,
|
@@ -61,7 +62,9 @@ def collidable_point_positions(
|
|
61
62
|
The position of the collidable points in the world frame.
|
62
63
|
"""
|
63
64
|
|
64
|
-
|
65
|
+
W_p_Ci, _ = collidable_point_kinematics(model=model, data=data)
|
66
|
+
|
67
|
+
return W_p_Ci
|
65
68
|
|
66
69
|
|
67
70
|
@jax.jit
|
@@ -79,7 +82,9 @@ def collidable_point_velocities(
|
|
79
82
|
The 3D velocity of the collidable points.
|
80
83
|
"""
|
81
84
|
|
82
|
-
|
85
|
+
_, W_ṗ_Ci = collidable_point_kinematics(model=model, data=data)
|
86
|
+
|
87
|
+
return W_ṗ_Ci
|
83
88
|
|
84
89
|
|
85
90
|
@jax.jit
|
@@ -269,3 +274,124 @@ def estimate_good_soft_contacts_parameters(
|
|
269
274
|
)
|
270
275
|
|
271
276
|
return sc_parameters
|
277
|
+
|
278
|
+
|
279
|
+
@jax.jit
|
280
|
+
def transforms(model: js.model.JaxSimModel, data: js.data.JaxSimModelData) -> jtp.Array:
|
281
|
+
r"""
|
282
|
+
Return the pose of the collidable points.
|
283
|
+
|
284
|
+
Args:
|
285
|
+
model: The model to consider.
|
286
|
+
data: The data of the considered model.
|
287
|
+
|
288
|
+
Returns:
|
289
|
+
The stacked SE(3) matrices of all collidable points.
|
290
|
+
|
291
|
+
Note:
|
292
|
+
Each collidable point is implicitly associated with a frame
|
293
|
+
:math:`C = ({}^W p_C, [L])`, where :math:`{}^W p_C` is the position of the
|
294
|
+
collidable point and :math:`[L]` is the orientation frame of the link it is
|
295
|
+
rigidly attached to.
|
296
|
+
"""
|
297
|
+
|
298
|
+
# Get the transforms of the parent link of all collidable points.
|
299
|
+
W_H_L = jax.vmap(
|
300
|
+
lambda parent_link_idx: js.link.transform(
|
301
|
+
model=model, data=data, link_index=parent_link_idx
|
302
|
+
)
|
303
|
+
)(jnp.array(model.kin_dyn_parameters.contact_parameters.body, dtype=int))
|
304
|
+
|
305
|
+
# Build the link-to-point transform from the displacement between the link frame L
|
306
|
+
# and the implicit contact frame C.
|
307
|
+
L_H_C = jax.vmap(lambda L_p_C: jnp.eye(4).at[0:3, 3].set(L_p_C))(
|
308
|
+
model.kin_dyn_parameters.contact_parameters.point
|
309
|
+
)
|
310
|
+
|
311
|
+
# Compose the work-to-link and link-to-point transforms.
|
312
|
+
return jax.vmap(lambda W_H_Li, L_H_Ci: W_H_Li @ L_H_Ci)(W_H_L, L_H_C)
|
313
|
+
|
314
|
+
|
315
|
+
@functools.partial(jax.jit, static_argnames=["output_vel_repr"])
|
316
|
+
def jacobian(
|
317
|
+
model: js.model.JaxSimModel,
|
318
|
+
data: js.data.JaxSimModelData,
|
319
|
+
*,
|
320
|
+
output_vel_repr: VelRepr | None = None,
|
321
|
+
) -> jtp.Array:
|
322
|
+
r"""
|
323
|
+
Return the free-floating Jacobian of the collidable points.
|
324
|
+
|
325
|
+
Args:
|
326
|
+
model: The model to consider.
|
327
|
+
data: The data of the considered model.
|
328
|
+
output_vel_repr:
|
329
|
+
The output velocity representation of the free-floating jacobian.
|
330
|
+
|
331
|
+
Returns:
|
332
|
+
The stacked 6×(6+n) free-floating jacobians of the frames associated to the
|
333
|
+
collidable points.
|
334
|
+
|
335
|
+
Note:
|
336
|
+
Each collidable point is implicitly associated with a frame
|
337
|
+
:math:`C = ({}^W p_C, [L])`, where :math:`{}^W p_C` is the position of the
|
338
|
+
collidable point and :math:`[L]` is the orientation frame of the link it is
|
339
|
+
rigidly attached to.
|
340
|
+
"""
|
341
|
+
|
342
|
+
output_vel_repr = (
|
343
|
+
output_vel_repr if output_vel_repr is not None else data.velocity_representation
|
344
|
+
)
|
345
|
+
|
346
|
+
# For each collidable point, get the Jacobians of their parent link.
|
347
|
+
# In inertial-fixed output representation, the Jacobian of the parent link is also
|
348
|
+
# the Jacobian of the frame C implicitly associated with the collidable point.
|
349
|
+
W_J_WC = W_J_WL = jax.vmap(
|
350
|
+
lambda parent_link_idx: js.link.jacobian(
|
351
|
+
model=model,
|
352
|
+
data=data,
|
353
|
+
link_index=parent_link_idx,
|
354
|
+
output_vel_repr=VelRepr.Inertial,
|
355
|
+
)
|
356
|
+
)(jnp.array(model.kin_dyn_parameters.contact_parameters.body, dtype=int))
|
357
|
+
|
358
|
+
# Adjust the output representation.
|
359
|
+
match output_vel_repr:
|
360
|
+
|
361
|
+
case VelRepr.Inertial:
|
362
|
+
O_J_WC = W_J_WC
|
363
|
+
|
364
|
+
case VelRepr.Body:
|
365
|
+
|
366
|
+
W_H_C = transforms(model=model, data=data)
|
367
|
+
|
368
|
+
def jacobian(W_H_C: jtp.Matrix, W_J_WC: jtp.Matrix) -> jtp.Matrix:
|
369
|
+
C_X_W = jaxsim.math.Adjoint.from_transform(
|
370
|
+
transform=W_H_C, inverse=True
|
371
|
+
)
|
372
|
+
C_J_WC = C_X_W @ W_J_WC
|
373
|
+
return C_J_WC
|
374
|
+
|
375
|
+
O_J_WC = jax.vmap(jacobian)(W_H_C, W_J_WC)
|
376
|
+
|
377
|
+
case VelRepr.Mixed:
|
378
|
+
|
379
|
+
W_H_C = transforms(model=model, data=data)
|
380
|
+
|
381
|
+
def jacobian(W_H_C: jtp.Matrix, W_J_WC: jtp.Matrix) -> jtp.Matrix:
|
382
|
+
|
383
|
+
W_H_CW = W_H_C.at[0:3, 0:3].set(jnp.eye(3))
|
384
|
+
|
385
|
+
CW_X_W = jaxsim.math.Adjoint.from_transform(
|
386
|
+
transform=W_H_CW, inverse=True
|
387
|
+
)
|
388
|
+
|
389
|
+
CW_J_WC = CW_X_W @ W_J_WC
|
390
|
+
return CW_J_WC
|
391
|
+
|
392
|
+
O_J_WC = jax.vmap(jacobian)(W_H_C, W_J_WC)
|
393
|
+
|
394
|
+
case _:
|
395
|
+
raise ValueError(output_vel_repr)
|
396
|
+
|
397
|
+
return O_J_WC
|
@@ -1,11 +1,11 @@
|
|
1
1
|
jaxsim/__init__.py,sha256=OcrfoYS1DGcmAGqu2AqlCTiUVxcpi-IsVwcr_16x74Q,1789
|
2
|
-
jaxsim/_version.py,sha256=
|
2
|
+
jaxsim/_version.py,sha256=6bZIeO5gVEXbcUw14r0OEvahs0AZBEq5fAmJ16fr2fU,426
|
3
3
|
jaxsim/logging.py,sha256=c4zhwBKf9eAYAHVp62kTEllqdsZgh0K-kPKVy8L3elU,1584
|
4
4
|
jaxsim/typing.py,sha256=MeuOCQtLAr-sPkvB_sU8FtwGNRirz1auCwIgRC-QZl8,646
|
5
5
|
jaxsim/api/__init__.py,sha256=8eV22t2S3UwNyCg8karPetG1dmX1VDBXkyv28_FwNQA,210
|
6
|
-
jaxsim/api/com.py,sha256=
|
6
|
+
jaxsim/api/com.py,sha256=Yof6otFi-mLWAs1rqjmeNJTOWIH9gn7BdU5EIjiL6Ts,13481
|
7
7
|
jaxsim/api/common.py,sha256=DV-WZG28sikXopNv458aYvpLjmiAtFr5LRscOwXusuk,6640
|
8
|
-
jaxsim/api/contact.py,sha256=
|
8
|
+
jaxsim/api/contact.py,sha256=Cvr-EfQtHP3nymtWdo-9WWU24Bkta-2Pp3nKsdjo6uc,12778
|
9
9
|
jaxsim/api/data.py,sha256=GXSCfq4_PsRZuUwsmcl18e2Ppdtu4ykYs0oWih8J2ZI,26775
|
10
10
|
jaxsim/api/frame.py,sha256=68liCmwFDikuP0GQOpo-nF7aVeHJ173e1USSOwskTP0,6246
|
11
11
|
jaxsim/api/joint.py,sha256=-5DogPg4g4mmLckyVIVNjwv-Rxz0IWS7_md9nDlhPWA,4581
|
@@ -58,8 +58,8 @@ jaxsim/utils/__init__.py,sha256=tnQq1_CavdfeKaLYt3pmO7Jk4MU2RwwQU_qICkjyoTY,197
|
|
58
58
|
jaxsim/utils/hashless.py,sha256=bFIwKeo9KiWwsY8QM55duEGGQOyyJ4jQyPcuqTLEp5k,297
|
59
59
|
jaxsim/utils/jaxsim_dataclass.py,sha256=h26timZ_XrBL_Q_oymv-DkQd-EcUiHn8QexAaZXBY9c,11396
|
60
60
|
jaxsim/utils/tracing.py,sha256=KDMoyVPlu2NJvFkhtZwq5AkqMMgajt3munvJom-vEjQ,650
|
61
|
-
jaxsim-0.2.1.
|
62
|
-
jaxsim-0.2.1.
|
63
|
-
jaxsim-0.2.1.
|
64
|
-
jaxsim-0.2.1.
|
65
|
-
jaxsim-0.2.1.
|
61
|
+
jaxsim-0.2.1.dev80.dist-info/LICENSE,sha256=eaYdFmdeMbiIoIiPzEK0MjP1S9wtFXjXNR5er49uLR0,1546
|
62
|
+
jaxsim-0.2.1.dev80.dist-info/METADATA,sha256=yFYgYOpZwSa-j1g4zj-4mp2B3z4TkL_9kbF-Rd5Q3hI,9744
|
63
|
+
jaxsim-0.2.1.dev80.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
64
|
+
jaxsim-0.2.1.dev80.dist-info/top_level.txt,sha256=LxGMA8FLtXjQ6oI7N5gd_R_oSUHxpXxUEOfT1xS_ni0,7
|
65
|
+
jaxsim-0.2.1.dev80.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|