jaxsim 0.8.3.dev33__py3-none-any.whl → 0.8.3.dev38__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/data.py +2 -0
- jaxsim/api/frame.py +62 -109
- jaxsim/api/integrators.py +1 -2
- jaxsim/api/model.py +230 -209
- jaxsim/rbda/aba.py +4 -4
- jaxsim/rbda/crba.py +5 -1
- jaxsim/rbda/forward_kinematics.py +5 -12
- jaxsim/rbda/mass_inverse.py +4 -27
- jaxsim/rbda/rnea.py +5 -4
- {jaxsim-0.8.3.dev33.dist-info → jaxsim-0.8.3.dev38.dist-info}/METADATA +1 -1
- {jaxsim-0.8.3.dev33.dist-info → jaxsim-0.8.3.dev38.dist-info}/RECORD +14 -14
- {jaxsim-0.8.3.dev33.dist-info → jaxsim-0.8.3.dev38.dist-info}/WHEEL +0 -0
- {jaxsim-0.8.3.dev33.dist-info → jaxsim-0.8.3.dev38.dist-info}/licenses/LICENSE +0 -0
jaxsim/_version.py
CHANGED
|
@@ -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.
|
|
22
|
-
__version_tuple__ = version_tuple = (0, 8, 3, '
|
|
21
|
+
__version__ = version = '0.8.3.dev38'
|
|
22
|
+
__version_tuple__ = version_tuple = (0, 8, 3, 'dev38')
|
|
23
23
|
|
|
24
24
|
__commit_id__ = commit_id = None
|
jaxsim/api/data.py
CHANGED
|
@@ -168,6 +168,7 @@ class JaxSimModelData(common.ModelDataWithVelocityRepresentation):
|
|
|
168
168
|
base_linear_velocity_inertial=W_v_WB[0:3],
|
|
169
169
|
base_angular_velocity_inertial=W_v_WB[3:6],
|
|
170
170
|
joint_velocities=joint_velocities,
|
|
171
|
+
joint_transforms=joint_transforms,
|
|
171
172
|
)
|
|
172
173
|
)
|
|
173
174
|
|
|
@@ -489,6 +490,7 @@ class JaxSimModelData(common.ModelDataWithVelocityRepresentation):
|
|
|
489
490
|
base_angular_velocity_inertial=jnp.atleast_2d(
|
|
490
491
|
base_angular_velocity_inertial
|
|
491
492
|
),
|
|
493
|
+
joint_transforms=joint_transforms,
|
|
492
494
|
)
|
|
493
495
|
|
|
494
496
|
# Adjust the output shapes.
|
jaxsim/api/frame.py
CHANGED
|
@@ -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
|
|
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
|
|
281
|
+
# Compute only the parent-link body Jacobian.
|
|
282
282
|
L_J_WL = js.link.jacobian(
|
|
283
|
-
model=model,
|
|
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
|
-
|
|
290
|
-
|
|
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
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
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
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
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
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
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 =
|
|
435
|
-
O_Ẋ_W =
|
|
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
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
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
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
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 =
|
|
467
|
-
O_J̇_WF_I +=
|
|
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
|
jaxsim/api/integrators.py
CHANGED
|
@@ -70,7 +70,6 @@ def semi_implicit_euler_integration(
|
|
|
70
70
|
contact_state_derivative,
|
|
71
71
|
)
|
|
72
72
|
|
|
73
|
-
# TODO: Avoid double replace, e.g. by computing cached value here
|
|
74
73
|
data = dataclasses.replace(
|
|
75
74
|
data,
|
|
76
75
|
_base_quaternion=W_Q_B,
|
|
@@ -82,7 +81,7 @@ def semi_implicit_euler_integration(
|
|
|
82
81
|
contact_state=integrated_contact_state,
|
|
83
82
|
)
|
|
84
83
|
|
|
85
|
-
#
|
|
84
|
+
# Recompute kinematic caches for the new state.
|
|
86
85
|
data = data.replace(model=model)
|
|
87
86
|
|
|
88
87
|
return data
|
jaxsim/api/model.py
CHANGED
|
@@ -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
|
-
|
|
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)
|
|
986
|
-
|
|
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)
|
|
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, ...]
|
|
1036
1110
|
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
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
|
-
|
|
1047
|
-
|
|
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
|
|
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
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
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
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
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
|
-
|
|
1104
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1171
|
-
|
|
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
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
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("
|
|
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 =
|
|
1215
|
-
|
|
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
|
-
|
|
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
|
|
|
@@ -1348,6 +1345,7 @@ def forward_dynamics_aba(
|
|
|
1348
1345
|
base_linear_velocity=W_v_WB[0:3],
|
|
1349
1346
|
base_angular_velocity=W_v_WB[3:6],
|
|
1350
1347
|
joint_velocities=ṡ,
|
|
1348
|
+
joint_transforms=data._joint_transforms,
|
|
1351
1349
|
joint_forces=τ,
|
|
1352
1350
|
link_forces=W_f_L,
|
|
1353
1351
|
standard_gravity=model.gravity,
|
|
@@ -1525,6 +1523,7 @@ def forward_kinematics(model: JaxSimModel, data: js.data.JaxSimModelData) -> jtp
|
|
|
1525
1523
|
joint_velocities=data.joint_velocities,
|
|
1526
1524
|
base_linear_velocity_inertial=data._base_linear_velocity,
|
|
1527
1525
|
base_angular_velocity_inertial=data._base_angular_velocity,
|
|
1526
|
+
joint_transforms=data._joint_transforms,
|
|
1528
1527
|
)
|
|
1529
1528
|
|
|
1530
1529
|
return W_H_LL
|
|
@@ -1614,9 +1613,7 @@ def free_floating_mass_matrix_inverse(
|
|
|
1614
1613
|
"""
|
|
1615
1614
|
M_inv_body = jaxsim.rbda.mass_inverse(
|
|
1616
1615
|
model=model,
|
|
1617
|
-
|
|
1618
|
-
base_quaternion=data.base_orientation,
|
|
1619
|
-
joint_positions=data.joint_positions,
|
|
1616
|
+
joint_transforms=data._joint_transforms,
|
|
1620
1617
|
)
|
|
1621
1618
|
|
|
1622
1619
|
match data.velocity_representation:
|
|
@@ -1881,6 +1878,7 @@ def inverse_dynamics(
|
|
|
1881
1878
|
base_linear_acceleration=W_v̇_WB[0:3],
|
|
1882
1879
|
base_angular_acceleration=W_v̇_WB[3:6],
|
|
1883
1880
|
joint_accelerations=s̈,
|
|
1881
|
+
joint_transforms=data._joint_transforms,
|
|
1884
1882
|
link_forces=W_f_L,
|
|
1885
1883
|
standard_gravity=model.gravity,
|
|
1886
1884
|
)
|
|
@@ -2276,9 +2274,8 @@ def link_bias_accelerations(
|
|
|
2276
2274
|
# Compute the parent-to-child adjoints and the motion subspaces of the joints.
|
|
2277
2275
|
# These transforms define the relative kinematics of the entire model, including
|
|
2278
2276
|
# the base transform for both floating-base and fixed-base models.
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
)
|
|
2277
|
+
# Ensure cached transforms stay on device when indexed with traced `i`.
|
|
2278
|
+
i_X_λi = jnp.asarray(data._joint_transforms)
|
|
2282
2279
|
|
|
2283
2280
|
# Extract the joint motion subspaces.
|
|
2284
2281
|
S = model.kin_dyn_parameters.motion_subspaces
|
|
@@ -2393,6 +2390,30 @@ def link_bias_accelerations(
|
|
|
2393
2390
|
return O_v̇_WL
|
|
2394
2391
|
|
|
2395
2392
|
|
|
2393
|
+
@jax.jit
|
|
2394
|
+
def joint_transforms(
|
|
2395
|
+
model: JaxSimModel, joint_positions: jtp.VectorLike, base_transform: jtp.MatrixLike
|
|
2396
|
+
) -> jtp.Array:
|
|
2397
|
+
r"""
|
|
2398
|
+
Return the transforms of the joints.
|
|
2399
|
+
|
|
2400
|
+
Args:
|
|
2401
|
+
model: The model to consider.
|
|
2402
|
+
joint_positions: The joint positions.
|
|
2403
|
+
base_transform: The homogeneous matrix defining the base pose.
|
|
2404
|
+
|
|
2405
|
+
Returns:
|
|
2406
|
+
The stacked transforms
|
|
2407
|
+
:math:`{}^{i} \mathbf{H}_{\lambda(i)}(s)`
|
|
2408
|
+
of each joint.
|
|
2409
|
+
"""
|
|
2410
|
+
|
|
2411
|
+
return model.kin_dyn_parameters.joint_transforms(
|
|
2412
|
+
joint_positions=joint_positions,
|
|
2413
|
+
base_transform=base_transform,
|
|
2414
|
+
)
|
|
2415
|
+
|
|
2416
|
+
|
|
2396
2417
|
# ======
|
|
2397
2418
|
# Energy
|
|
2398
2419
|
# ======
|
jaxsim/rbda/aba.py
CHANGED
|
@@ -18,6 +18,7 @@ def aba(
|
|
|
18
18
|
base_linear_velocity: jtp.VectorLike,
|
|
19
19
|
base_angular_velocity: jtp.VectorLike,
|
|
20
20
|
joint_velocities: jtp.VectorLike,
|
|
21
|
+
joint_transforms: jtp.MatrixLike,
|
|
21
22
|
joint_forces: jtp.VectorLike | None = None,
|
|
22
23
|
link_forces: jtp.MatrixLike | None = None,
|
|
23
24
|
standard_gravity: jtp.FloatLike = STANDARD_GRAVITY,
|
|
@@ -35,6 +36,7 @@ def aba(
|
|
|
35
36
|
base_angular_velocity:
|
|
36
37
|
The angular velocity of the base link in inertial-fixed representation.
|
|
37
38
|
joint_velocities: The velocities of the joints.
|
|
39
|
+
joint_transforms: The parent-to-child transforms of the joints.
|
|
38
40
|
joint_forces: The forces applied to the joints.
|
|
39
41
|
link_forces:
|
|
40
42
|
The forces applied to the links expressed in the world frame.
|
|
@@ -85,12 +87,10 @@ def aba(
|
|
|
85
87
|
W_X_B = W_H_B.adjoint()
|
|
86
88
|
B_X_W = W_H_B.inverse().adjoint()
|
|
87
89
|
|
|
88
|
-
#
|
|
90
|
+
# Extract the parent-to-child adjoints of the joints.
|
|
89
91
|
# These transforms define the relative kinematics of the entire model, including
|
|
90
92
|
# the base transform for both floating-base and fixed-base models.
|
|
91
|
-
i_X_λi =
|
|
92
|
-
joint_positions=s, base_transform=W_H_B.as_matrix()
|
|
93
|
-
)
|
|
93
|
+
i_X_λi = jnp.asarray(joint_transforms)
|
|
94
94
|
|
|
95
95
|
# Extract the joint motion subspaces.
|
|
96
96
|
S = model.kin_dyn_parameters.motion_subspaces
|
jaxsim/rbda/crba.py
CHANGED
|
@@ -7,7 +7,11 @@ import jaxsim.typing as jtp
|
|
|
7
7
|
from . import utils
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
def crba(
|
|
10
|
+
def crba(
|
|
11
|
+
model: js.model.JaxSimModel,
|
|
12
|
+
*,
|
|
13
|
+
joint_positions: jtp.Vector,
|
|
14
|
+
) -> jtp.Matrix:
|
|
11
15
|
"""
|
|
12
16
|
Compute the free-floating mass matrix using the Composite Rigid-Body Algorithm (CRBA).
|
|
13
17
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import jax
|
|
2
2
|
import jax.numpy as jnp
|
|
3
|
-
import jaxlie
|
|
4
3
|
|
|
5
4
|
import jaxsim.api as js
|
|
6
5
|
import jaxsim.typing as jtp
|
|
@@ -18,6 +17,7 @@ def forward_kinematics_model(
|
|
|
18
17
|
base_linear_velocity_inertial: jtp.VectorLike,
|
|
19
18
|
base_angular_velocity_inertial: jtp.VectorLike,
|
|
20
19
|
joint_velocities: jtp.VectorLike,
|
|
20
|
+
joint_transforms: jtp.MatrixLike,
|
|
21
21
|
) -> jtp.Array:
|
|
22
22
|
"""
|
|
23
23
|
Compute the forward kinematics.
|
|
@@ -30,12 +30,13 @@ def forward_kinematics_model(
|
|
|
30
30
|
base_linear_velocity_inertial: The linear velocity of the base link in inertial-fixed representation.
|
|
31
31
|
base_angular_velocity_inertial: The angular velocity of the base link in inertial-fixed representation.
|
|
32
32
|
joint_velocities: The velocities of the joints.
|
|
33
|
+
joint_transforms: The parent-to-child transforms of the joints.
|
|
33
34
|
|
|
34
35
|
Returns:
|
|
35
36
|
A 3D array containing the SE(3) transforms of all links belonging to the model.
|
|
36
37
|
"""
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
_, _, _, W_v_WB, ṡ, _, _, _, _, _ = utils.process_inputs(
|
|
39
40
|
model=model,
|
|
40
41
|
base_position=base_position,
|
|
41
42
|
base_quaternion=base_quaternion,
|
|
@@ -49,18 +50,10 @@ def forward_kinematics_model(
|
|
|
49
50
|
# Note: λ(0) must not be used, it's initialized to -1.
|
|
50
51
|
λ = model.kin_dyn_parameters.parent_array
|
|
51
52
|
|
|
52
|
-
#
|
|
53
|
-
W_H_B = jaxlie.SE3.from_rotation_and_translation(
|
|
54
|
-
rotation=jaxlie.SO3(wxyz=W_Q_B),
|
|
55
|
-
translation=W_p_B,
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
# Compute the parent-to-child adjoints of the joints.
|
|
53
|
+
# Extract the parent-to-child adjoints of the joints.
|
|
59
54
|
# These transforms define the relative kinematics of the entire model, including
|
|
60
55
|
# the base transform for both floating-base and fixed-base models.
|
|
61
|
-
i_X_λi =
|
|
62
|
-
joint_positions=s, base_transform=W_H_B.as_matrix()
|
|
63
|
-
)
|
|
56
|
+
i_X_λi = jnp.asarray(joint_transforms)
|
|
64
57
|
|
|
65
58
|
# Allocate the buffer of transforms world -> link and initialize the base pose.
|
|
66
59
|
W_X_i = jnp.zeros(shape=(model.number_of_links(), 6, 6))
|
jaxsim/rbda/mass_inverse.py
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
import jax
|
|
2
2
|
import jax.numpy as jnp
|
|
3
|
-
import jaxlie
|
|
4
3
|
|
|
5
4
|
import jaxsim.api as js
|
|
6
5
|
import jaxsim.typing as jtp
|
|
7
6
|
|
|
8
|
-
from . import utils
|
|
9
|
-
|
|
10
7
|
|
|
11
8
|
def mass_inverse(
|
|
12
9
|
model: js.model.JaxSimModel,
|
|
13
10
|
*,
|
|
14
|
-
|
|
15
|
-
base_quaternion: jtp.VectorLike,
|
|
16
|
-
joint_positions: jtp.VectorLike,
|
|
11
|
+
joint_transforms: jtp.MatrixLike,
|
|
17
12
|
) -> jtp.Matrix:
|
|
18
13
|
"""
|
|
19
14
|
Compute the inverse of the mass matrix using an ABA-like algorithm.
|
|
@@ -21,21 +16,12 @@ def mass_inverse(
|
|
|
21
16
|
|
|
22
17
|
Args:
|
|
23
18
|
model: The model to consider.
|
|
24
|
-
|
|
25
|
-
base_quaternion: The orientation of the base link (w, x, y, z).
|
|
26
|
-
joint_positions: The positions of the joints.
|
|
19
|
+
joint_transforms: The parent-to-child transforms of the joints.
|
|
27
20
|
|
|
28
21
|
Returns:
|
|
29
22
|
The inverse of the mass matrix.
|
|
30
23
|
"""
|
|
31
24
|
|
|
32
|
-
W_p_B, W_Q_B, s, _, _, _, _, _, _, _ = utils.process_inputs(
|
|
33
|
-
model=model,
|
|
34
|
-
base_position=base_position,
|
|
35
|
-
base_quaternion=base_quaternion,
|
|
36
|
-
joint_positions=joint_positions,
|
|
37
|
-
)
|
|
38
|
-
|
|
39
25
|
# Get the 6D spatial inertia matrices of all links.
|
|
40
26
|
I_A = js.model.link_spatial_inertia_matrices(model=model)
|
|
41
27
|
|
|
@@ -44,19 +30,10 @@ def mass_inverse(
|
|
|
44
30
|
# λ[i] = parent link index for link i.
|
|
45
31
|
λ = model.kin_dyn_parameters.parent_array
|
|
46
32
|
|
|
47
|
-
#
|
|
48
|
-
W_H_B = jaxlie.SE3.from_rotation_and_translation(
|
|
49
|
-
rotation=jaxlie.SO3(wxyz=W_Q_B),
|
|
50
|
-
translation=W_p_B,
|
|
51
|
-
)
|
|
52
|
-
|
|
53
|
-
# Compute the parent-to-child adjoints of the joints.
|
|
33
|
+
# Extract the parent-to-child adjoints of the joints.
|
|
54
34
|
# These transforms define the relative kinematics of the entire model, including
|
|
55
35
|
# the base transform for both floating-base and fixed-base models.
|
|
56
|
-
i_X_λi =
|
|
57
|
-
joint_positions=s,
|
|
58
|
-
base_transform=W_H_B.as_matrix(),
|
|
59
|
-
)
|
|
36
|
+
i_X_λi = jnp.asarray(joint_transforms)
|
|
60
37
|
|
|
61
38
|
# Extract the joint motion subspaces.
|
|
62
39
|
S = model.kin_dyn_parameters.motion_subspaces
|
jaxsim/rbda/rnea.py
CHANGED
|
@@ -21,6 +21,7 @@ def rnea(
|
|
|
21
21
|
base_linear_acceleration: jtp.Vector | None = None,
|
|
22
22
|
base_angular_acceleration: jtp.Vector | None = None,
|
|
23
23
|
joint_accelerations: jtp.Vector | None = None,
|
|
24
|
+
joint_transforms: jtp.MatrixLike,
|
|
24
25
|
link_forces: jtp.Matrix | None = None,
|
|
25
26
|
standard_gravity: jtp.FloatLike = STANDARD_GRAVITY,
|
|
26
27
|
) -> tuple[jtp.Vector, jtp.Vector]:
|
|
@@ -42,6 +43,7 @@ def rnea(
|
|
|
42
43
|
base_angular_acceleration:
|
|
43
44
|
The angular acceleration of the base link in inertial-fixed representation.
|
|
44
45
|
joint_accelerations: The accelerations of the joints.
|
|
46
|
+
joint_transforms: The parent-to-child transforms of the joints.
|
|
45
47
|
link_forces:
|
|
46
48
|
The forces applied to the links expressed in the world frame.
|
|
47
49
|
standard_gravity: The standard gravity constant.
|
|
@@ -88,12 +90,11 @@ def rnea(
|
|
|
88
90
|
W_X_B = W_H_B.adjoint()
|
|
89
91
|
B_X_W = W_H_B.inverse().adjoint()
|
|
90
92
|
|
|
91
|
-
#
|
|
93
|
+
# Extract the parent-to-child adjoints of the joints.
|
|
92
94
|
# These transforms define the relative kinematics of the entire model, including
|
|
93
95
|
# the base transform for both floating-base and fixed-base models.
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
)
|
|
96
|
+
# Ensure cached transforms are JAX arrays so they work with traced indices.
|
|
97
|
+
i_X_λi = jnp.asarray(joint_transforms)
|
|
97
98
|
|
|
98
99
|
# Extract the joint motion subspaces.
|
|
99
100
|
S = model.kin_dyn_parameters.motion_subspaces
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: jaxsim
|
|
3
|
-
Version: 0.8.3.
|
|
3
|
+
Version: 0.8.3.dev38
|
|
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
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
jaxsim/__init__.py,sha256=EKeysKN-7UswwJLCl7n6qIBKQIVUtYsCMYu_tCoFn7g,3628
|
|
2
|
-
jaxsim/_version.py,sha256=
|
|
2
|
+
jaxsim/_version.py,sha256=sXQLPCg1QrwqhCKxogazqFz_iGp1l06sXOqkHvjNHvc,535
|
|
3
3
|
jaxsim/exceptions.py,sha256=MQ3LRMfVMX2-g3qYj7mUVNV9OLlIA48TANJegbcQyXI,2641
|
|
4
4
|
jaxsim/logging.py,sha256=iLZ_zNvZfz5IvQEjxcCi8QUwPsZD5_9dcD0zotpxT78,2573
|
|
5
5
|
jaxsim/typing.py,sha256=7msl8t5Jt09RNYfKdPJtpjLfWurldcycDappb045Eso,761
|
|
@@ -8,13 +8,13 @@ jaxsim/api/actuation_model.py,sha256=0tjFjBfDQlJ3Mw1VqZxXVLJq1xPxiUy5TLP5uh-IM8A
|
|
|
8
8
|
jaxsim/api/com.py,sha256=47a9SSaXY540RCkVnHodwLNUrodIfJIkguIYdSEQVwQ,13697
|
|
9
9
|
jaxsim/api/common.py,sha256=yTaRXDYkXmISBOhZ93f9TssR0p4wq7qj7B6OsvYzRME,6942
|
|
10
10
|
jaxsim/api/contact.py,sha256=fiWQYh1y5zD7z4FBvcahMSPNZfRaWrqu5lZIV9KEIE8,20628
|
|
11
|
-
jaxsim/api/data.py,sha256=
|
|
12
|
-
jaxsim/api/frame.py,sha256=
|
|
13
|
-
jaxsim/api/integrators.py,sha256=
|
|
11
|
+
jaxsim/api/data.py,sha256=9L5mhfFF7F3QpDlicGfzp6lqZFVrZjnj6IuJ7yKIjhI,23347
|
|
12
|
+
jaxsim/api/frame.py,sha256=0WRPgBaB7jAa5xMST6ERIBhyuc-Li2FmuKpOQDVOC5Q,11852
|
|
13
|
+
jaxsim/api/integrators.py,sha256=0mH11GMb12982Y71_vqGdSntNCCSSJwWm8DRaiRR19k,8915
|
|
14
14
|
jaxsim/api/joint.py,sha256=AnqlNWmBOay-gsoo0y4AbfFQ2OCJm-8T1E0IMhZeLoY,7457
|
|
15
15
|
jaxsim/api/kin_dyn_parameters.py,sha256=DcCth7d4Mx8i4uyJYMOmdWMRqvcovFl5mPm6ZEsHWHc,45504
|
|
16
16
|
jaxsim/api/link.py,sha256=bSZOYJDY9HJMgY25VzevTTsdFZTJc6yRRpslc5FhGHE,12782
|
|
17
|
-
jaxsim/api/model.py,sha256=
|
|
17
|
+
jaxsim/api/model.py,sha256=eWU03yi8tu6MC9N6tMMf5pdBH_uHwRzYqg44kyEM8Yg,92223
|
|
18
18
|
jaxsim/api/ode.py,sha256=RRCgHxFAonZQJoevY9PVjoO4jP6KQ-rX4JIqF7Ftt6g,7688
|
|
19
19
|
jaxsim/api/references.py,sha256=6x2OnWS3eKUvxVRvSZhKla59Fqku2T0SBB33THGbQ28,20267
|
|
20
20
|
jaxsim/math/__init__.py,sha256=0Jcu8EjkHRwfcX-m6wndcQRRTn6nx-onkYYuxLTe4bk,382
|
|
@@ -45,14 +45,14 @@ jaxsim/parsers/rod/meshes.py,sha256=yAXefG73_zqbVKRUdlcz9yFmypjDIpiP9cO96PeAozE,
|
|
|
45
45
|
jaxsim/parsers/rod/parser.py,sha256=Qty8QR1ZGunNI0gC3upYECUSVHHlamdbDcAaVZyHVJk,15043
|
|
46
46
|
jaxsim/parsers/rod/utils.py,sha256=wmD-wCF1lLO8pknX7A3a8CGt9wDlTS_xCqQulcZ_XlM,8242
|
|
47
47
|
jaxsim/rbda/__init__.py,sha256=z-FwUW1od-JW5rtu6E8q5nKa7rC2tOdOli79vcs4WVE,430
|
|
48
|
-
jaxsim/rbda/aba.py,sha256=
|
|
48
|
+
jaxsim/rbda/aba.py,sha256=kZpDiEL4HJ9jWljOXdFrav8kNG1bl8eiL3CzOq2NzgU,9061
|
|
49
49
|
jaxsim/rbda/collidable_points.py,sha256=XyeV1I43GL22j03rkNVocaIPOGYirt3PiDHrFMndziQ,2070
|
|
50
|
-
jaxsim/rbda/crba.py,sha256=
|
|
51
|
-
jaxsim/rbda/forward_kinematics.py,sha256=
|
|
50
|
+
jaxsim/rbda/crba.py,sha256=uzWmrNx5jDkOT5G3TioVRkd6LEA36wdpwYfGMJ1Y4cM,5108
|
|
51
|
+
jaxsim/rbda/forward_kinematics.py,sha256=l4C07lKfQh2kgqAT8j3tmAu-6M2MHoOgrp-oGoIbYr0,3684
|
|
52
52
|
jaxsim/rbda/jacobian.py,sha256=EaMvf073UnLWJGXm4UZIlYd4erulFAGgj_pp89k6xic,11113
|
|
53
53
|
jaxsim/rbda/kinematic_constraints.py,sha256=lpc2xbpjOjTXdaWHyOK7mT8QQSWdWjYoOqQVx3aWfFE,12139
|
|
54
|
-
jaxsim/rbda/mass_inverse.py,sha256=
|
|
55
|
-
jaxsim/rbda/rnea.py,sha256=
|
|
54
|
+
jaxsim/rbda/mass_inverse.py,sha256=QAiF5lEXRd_XB7DsXn2c1RsqPi2uebQ9xSQTyObKLiM,5634
|
|
55
|
+
jaxsim/rbda/rnea.py,sha256=YLZ2vFCXA3Yo3ipIekI-6sshcR0YWYEpM6XQLu9oVuk,7699
|
|
56
56
|
jaxsim/rbda/utils.py,sha256=j4-fsFc23dZwvUI0dE9ELkEd4BwIEZLOscPl35O2DYg,5603
|
|
57
57
|
jaxsim/rbda/actuation/__init__.py,sha256=zWqB8VBHadbyf8FAuhQtcfWdetGjfVxuNDwIeUqNOS4,36
|
|
58
58
|
jaxsim/rbda/actuation/common.py,sha256=DhOAdppQlubWGMA40A6UmDkXE8pkexuyQcOE9ALANhs,565
|
|
@@ -67,7 +67,7 @@ jaxsim/utils/__init__.py,sha256=Y5zyoRevl3EMVQadhZ4EtSwTEkDt2vcnFoRhPJjKTZ0,215
|
|
|
67
67
|
jaxsim/utils/jaxsim_dataclass.py,sha256=GsoGQVJBbu9kgEXsZOF6Cv5So3386R9zudrRtnvXJAo,11373
|
|
68
68
|
jaxsim/utils/tracing.py,sha256=Btwxdfhb7fJLk3r5PlQkGYj60Y2KbFT1gANGIA697FU,530
|
|
69
69
|
jaxsim/utils/wrappers.py,sha256=3IMwydqFgmSPqeuUQ3PRmdhDc1IoT6XC23jPC_LjWXs,4175
|
|
70
|
-
jaxsim-0.8.3.
|
|
71
|
-
jaxsim-0.8.3.
|
|
72
|
-
jaxsim-0.8.3.
|
|
73
|
-
jaxsim-0.8.3.
|
|
70
|
+
jaxsim-0.8.3.dev38.dist-info/METADATA,sha256=pyh_GyKSAx37qCZHpDU-YUlbkApcBYPi-k2eFj-q2Q0,14644
|
|
71
|
+
jaxsim-0.8.3.dev38.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
72
|
+
jaxsim-0.8.3.dev38.dist-info/licenses/LICENSE,sha256=eaYdFmdeMbiIoIiPzEK0MjP1S9wtFXjXNR5er49uLR0,1546
|
|
73
|
+
jaxsim-0.8.3.dev38.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|