jaxsim 0.2.1.dev123__py3-none-any.whl → 0.2.1.dev128__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.2.1.dev123'
16
- __version_tuple__ = version_tuple = (0, 2, 1, 'dev123')
15
+ __version__ = version = '0.2.1.dev128'
16
+ __version_tuple__ = version_tuple = (0, 2, 1, 'dev128')
jaxsim/api/model.py CHANGED
@@ -16,6 +16,7 @@ from jax_dataclasses import Static
16
16
  import jaxsim.api as js
17
17
  import jaxsim.parsers.descriptions
18
18
  import jaxsim.typing as jtp
19
+ from jaxsim.math import Cross
19
20
  from jaxsim.utils import HashlessObject, JaxsimDataclass, Mutability
20
21
 
21
22
  from .common import VelRepr
@@ -871,6 +872,126 @@ def free_floating_mass_matrix(
871
872
  raise ValueError(data.velocity_representation)
872
873
 
873
874
 
875
+ @jax.jit
876
+ def free_floating_coriolis_matrix(
877
+ model: JaxSimModel, data: js.data.JaxSimModelData
878
+ ) -> jtp.Matrix:
879
+ """
880
+ Compute the free-floating Coriolis matrix of the model.
881
+
882
+ Args:
883
+ model: The model to consider.
884
+ data: The data of the considered model.
885
+
886
+ Returns:
887
+ The free-floating Coriolis matrix of the model.
888
+
889
+ Note:
890
+ This function, contrarily to other quantities of the equations of motion,
891
+ does not exploit any iterative algorithm. Therefore, the computation of
892
+ the Coriolis matrix may be much slower than other quantities.
893
+ """
894
+
895
+ # We perform all the calculation in body-fixed.
896
+ # The Coriolis matrix computed in this representation is converted later
897
+ # to the active representation stored in data.
898
+ with data.switch_velocity_representation(VelRepr.Body):
899
+
900
+ B_ν = data.generalized_velocity()
901
+
902
+ # Doubly-left free-floating Jacobian.
903
+ L_J_WL_B = generalized_free_floating_jacobian(model=model, data=data)
904
+
905
+ # Doubly-left free-floating Jacobian derivative.
906
+ L_J̇_WL_B = jax.vmap(
907
+ lambda link_index: js.link.jacobian_derivative(
908
+ model=model, data=data, link_index=link_index
909
+ )
910
+ )(js.link.names_to_idxs(model=model, link_names=model.link_names()))
911
+
912
+ L_M_L = link_spatial_inertia_matrices(model=model)
913
+
914
+ # Body-fixed link velocities.
915
+ # Note: we could have called link.velocity() instead of computing it ourselves,
916
+ # but since we need the link Jacobians later, we can save a double calculation.
917
+ L_v_WL = jax.vmap(lambda J: J @ B_ν)(L_J_WL_B)
918
+
919
+ # Compute the contribution of each link to the Coriolis matrix.
920
+ def compute_link_contribution(M, v, J, J̇) -> jtp.Array:
921
+
922
+ return J.T @ ((Cross.vx_star(v) @ M + M @ Cross.vx(v)) @ J + M @ J̇)
923
+
924
+ C_B_links = jax.vmap(compute_link_contribution)(
925
+ L_M_L,
926
+ L_v_WL,
927
+ L_J_WL_B,
928
+ L_J̇_WL_B,
929
+ )
930
+
931
+ # We need to adjust the Coriolis matrix for fixed-base models.
932
+ # In this case, the base link does not contribute to the matrix, and we need to zero
933
+ # the off-diagonal terms mapping joint quantities onto the base configuration.
934
+ if model.floating_base():
935
+ C_B = C_B_links.sum(axis=0)
936
+ else:
937
+ C_B = C_B_links[1:].sum(axis=0)
938
+ C_B = C_B.at[0:6, 6:].set(0.0)
939
+ C_B = C_B.at[6:, 0:6].set(0.0)
940
+
941
+ # Adjust the representation of the Coriolis matrix.
942
+ # Refer to https://github.com/traversaro/traversaro-phd-thesis, Section 3.6.
943
+ match data.velocity_representation:
944
+
945
+ case VelRepr.Body:
946
+ return C_B
947
+
948
+ case VelRepr.Inertial:
949
+
950
+ n = model.dofs()
951
+ W_H_B = data.base_transform()
952
+ B_X_W = jaxsim.math.Adjoint.from_transform(W_H_B, inverse=True)
953
+ B_T_W = jax.scipy.linalg.block_diag(B_X_W, jnp.eye(n))
954
+
955
+ with data.switch_velocity_representation(VelRepr.Inertial):
956
+ W_v_WB = data.base_velocity()
957
+ B_Ẋ_W = -B_X_W @ jaxsim.math.Cross.vx(W_v_WB)
958
+
959
+ B_Ṫ_W = jax.scipy.linalg.block_diag(B_Ẋ_W, jnp.zeros(shape=(n, n)))
960
+
961
+ with data.switch_velocity_representation(VelRepr.Body):
962
+ M = free_floating_mass_matrix(model=model, data=data)
963
+
964
+ C = B_T_W.T @ (M @ B_Ṫ_W + C_B @ B_T_W)
965
+
966
+ return C
967
+
968
+ case VelRepr.Mixed:
969
+
970
+ n = model.dofs()
971
+ BW_H_B = data.base_transform().at[0:3, 3].set(jnp.zeros(3))
972
+ B_X_BW = jaxsim.math.Adjoint.from_transform(transform=BW_H_B, inverse=True)
973
+ B_T_BW = jax.scipy.linalg.block_diag(B_X_BW, jnp.eye(n))
974
+
975
+ with data.switch_velocity_representation(VelRepr.Mixed):
976
+ BW_v_WB = data.base_velocity()
977
+ BW_v_W_BW = BW_v_WB.at[3:6].set(jnp.zeros(3))
978
+
979
+ BW_v_BW_B = BW_v_WB - BW_v_W_BW
980
+ B_Ẋ_BW = -B_X_BW @ jaxsim.math.Cross.vx(BW_v_BW_B)
981
+
982
+ B_Ṫ_BW = jax.scipy.linalg.block_diag(B_Ẋ_BW, jnp.zeros(shape=(n, n)))
983
+
984
+ with data.switch_velocity_representation(VelRepr.Body):
985
+ M = free_floating_mass_matrix(model=model, data=data)
986
+
987
+ C = B_T_BW.T @ (M @ B_Ṫ_BW + C_B @ B_T_BW)
988
+
989
+ return C
990
+
991
+ case _:
992
+ raise ValueError(data.velocity_representation)
993
+
994
+
874
995
  @jax.jit
875
996
  def inverse_dynamics(
876
997
  model: JaxSimModel,
@@ -931,8 +1052,6 @@ def inverse_dynamics(
931
1052
  expressed in a generic frame C to the inertial-fixed representation W_v̇_WB.
932
1053
  """
933
1054
 
934
- from jaxsim.math import Cross
935
-
936
1055
  W_X_C = jaxlie.SE3.from_matrix(W_H_C).adjoint()
937
1056
  C_X_W = jaxlie.SE3.from_matrix(W_H_C).inverse().adjoint()
938
1057
  C_v_WC = C_X_W @ W_v_WC
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: jaxsim
3
- Version: 0.2.1.dev123
3
+ Version: 0.2.1.dev128
4
4
  Home-page: https://github.com/ami-iit/jaxsim
5
5
  Author: Diego Ferigo
6
6
  Author-email: diego.ferigo@iit.it
@@ -1,5 +1,5 @@
1
1
  jaxsim/__init__.py,sha256=OcrfoYS1DGcmAGqu2AqlCTiUVxcpi-IsVwcr_16x74Q,1789
2
- jaxsim/_version.py,sha256=jAmAP2ZYBVoFw5W8EyAYOEpIKED5Jy8XK259JnSs0Fk,428
2
+ jaxsim/_version.py,sha256=yQXGZi_4HTKCz6q_0MIAO7BEL6qzqzrqL23narMccVE,428
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
@@ -11,7 +11,7 @@ jaxsim/api/frame.py,sha256=0YXOrGmx3cSQqa4_Ky-n6zyup3I3xvXNEgub-Bc5xUw,6222
11
11
  jaxsim/api/joint.py,sha256=-5DogPg4g4mmLckyVIVNjwv-Rxz0IWS7_md9nDlhPWA,4581
12
12
  jaxsim/api/kin_dyn_parameters.py,sha256=zMca7OmCsCWK_cavLTSZSeYh9Qu1-409cdsyWvWPAUQ,26090
13
13
  jaxsim/api/link.py,sha256=oW5-DShmmeCRk3JOJIwzo3HbWuNGmpm_wBJ4fkmrROM,16645
14
- jaxsim/api/model.py,sha256=1HlQ5FMzeJAk-cE1pmELgVjzMYUX9-iipw3N4WssAL4,55435
14
+ jaxsim/api/model.py,sha256=bUwC4ODd2E4bCLoWaKpRiAUWYFxyc-dhSR6sACnFeiQ,59744
15
15
  jaxsim/api/ode.py,sha256=BfvV_14uu0szWecoDiV8rTu-dvSFLK7eyrO38ZqHB_w,10157
16
16
  jaxsim/api/ode_data.py,sha256=D6FzMkvY_qNuoFEImyp7sxAk-0pJOd3oZeSr9bBTcLk,23089
17
17
  jaxsim/api/references.py,sha256=UA6kSQVBoq-bXSo99EOELf-_MD5MTy2zS0GtG3wQ410,16618
@@ -58,8 +58,8 @@ jaxsim/utils/__init__.py,sha256=Y5zyoRevl3EMVQadhZ4EtSwTEkDt2vcnFoRhPJjKTZ0,215
58
58
  jaxsim/utils/jaxsim_dataclass.py,sha256=h26timZ_XrBL_Q_oymv-DkQd-EcUiHn8QexAaZXBY9c,11396
59
59
  jaxsim/utils/tracing.py,sha256=KDMoyVPlu2NJvFkhtZwq5AkqMMgajt3munvJom-vEjQ,650
60
60
  jaxsim/utils/wrappers.py,sha256=EJMcblYKUjxw9HJShVf81Ig3pHUJno6Dx6h-RnY--wM,2040
61
- jaxsim-0.2.1.dev123.dist-info/LICENSE,sha256=eaYdFmdeMbiIoIiPzEK0MjP1S9wtFXjXNR5er49uLR0,1546
62
- jaxsim-0.2.1.dev123.dist-info/METADATA,sha256=hOUnUjhHwGvdZVMR_-z5pKFsd681swunNdYkqgC338I,9745
63
- jaxsim-0.2.1.dev123.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
64
- jaxsim-0.2.1.dev123.dist-info/top_level.txt,sha256=LxGMA8FLtXjQ6oI7N5gd_R_oSUHxpXxUEOfT1xS_ni0,7
65
- jaxsim-0.2.1.dev123.dist-info/RECORD,,
61
+ jaxsim-0.2.1.dev128.dist-info/LICENSE,sha256=eaYdFmdeMbiIoIiPzEK0MjP1S9wtFXjXNR5er49uLR0,1546
62
+ jaxsim-0.2.1.dev128.dist-info/METADATA,sha256=uVUMKKPoXJY-BJNVKZPj9PE49nPDRzyiQC0ZkaU_LOs,9745
63
+ jaxsim-0.2.1.dev128.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
64
+ jaxsim-0.2.1.dev128.dist-info/top_level.txt,sha256=LxGMA8FLtXjQ6oI7N5gd_R_oSUHxpXxUEOfT1xS_ni0,7
65
+ jaxsim-0.2.1.dev128.dist-info/RECORD,,