jaxsim 0.4.1.dev11__py3-none-any.whl → 0.4.1.dev15__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.1.dev11'
16
- __version_tuple__ = version_tuple = (0, 4, 1, 'dev11')
15
+ __version__ = version = '0.4.1.dev15'
16
+ __version_tuple__ = version_tuple = (0, 4, 1, 'dev15')
@@ -5,11 +5,12 @@ from typing import Any, ClassVar, Generic, Protocol, Type, TypeVar
5
5
  import jax
6
6
  import jax.numpy as jnp
7
7
  import jax_dataclasses
8
- import jaxlie
9
8
  from jax_dataclasses import Static
10
9
 
11
10
  import jaxsim.api as js
11
+ import jaxsim.math
12
12
  import jaxsim.typing as jtp
13
+ from jaxsim import exceptions
13
14
  from jaxsim.utils.jaxsim_dataclass import JaxsimDataclass, Mutability
14
15
 
15
16
  try:
@@ -539,48 +540,38 @@ class ExplicitRungeKuttaSO3Mixin:
539
540
  `PyTreeType = ODEState` to integrate the quaternion on SO(3).
540
541
  """
541
542
 
542
- @classmethod
543
- def integrate_rk_stage(
544
- cls, x0: js.ode_data.ODEState, t0: Time, dt: TimeStep, k: js.ode_data.ODEState
545
- ) -> js.ode_data.ODEState:
546
-
547
- op = lambda x0_leaf, k_leaf: x0_leaf + dt * k_leaf
548
- xf: js.ode_data.ODEState = jax.tree_util.tree_map(op, x0, k)
549
-
550
- W_Q_B_tf = xf.physics_model.base_quaternion
551
-
552
- return xf.replace(
553
- physics_model=xf.physics_model.replace(
554
- base_quaternion=W_Q_B_tf / jnp.linalg.norm(W_Q_B_tf)
555
- )
556
- )
557
-
558
543
  @classmethod
559
544
  def post_process_state(
560
545
  cls, x0: js.ode_data.ODEState, t0: Time, xf: js.ode_data.ODEState, dt: TimeStep
561
546
  ) -> js.ode_data.ODEState:
562
547
 
563
- # Indices to convert quaternions between serializations.
564
- to_xyzw = jnp.array([1, 2, 3, 0])
548
+ # Extract the initial base quaternion.
549
+ W_Q_B_t0 = x0.physics_model.base_quaternion
565
550
 
566
- # Get the initial rotation.
567
- W_R_B_t0 = jaxlie.SO3.from_quaternion_xyzw(
568
- xyzw=x0.physics_model.base_quaternion[to_xyzw]
551
+ # We assume that the initial quaternion is already unary.
552
+ exceptions.raise_runtime_error_if(
553
+ condition=jnp.logical_not(jnp.allclose(W_Q_B_t0.dot(W_Q_B_t0), 1.0)),
554
+ msg="The SO(3) integrator received a quaternion at t0 that is not unary.",
569
555
  )
570
556
 
571
- # Get the final angular velocity.
572
- # This is already computed by averaging the kᵢ in RK-based schemes.
573
- # Therefore, by using the ω at tf, we obtain a RK scheme operating
574
- # on the SO(3) manifold.
575
- W_ω_WB_tf = xf.physics_model.base_angular_velocity
576
-
577
- # Integrate the orientation on SO(3).
578
- # Note that we left-multiply with the exponential map since the angular
579
- # velocity is expressed in the inertial frame.
580
- W_R_B_tf = jaxlie.SO3.exp(tangent=dt * W_ω_WB_tf) @ W_R_B_t0
557
+ # Get the angular velocity ω to integrate the quaternion.
558
+ # This velocity ω[t0] is computed in the previous timestep by averaging the kᵢ
559
+ # corresponding to the active RK-based scheme. Therefore, by using the ω[t0],
560
+ # we obtain an explicit RK scheme operating on the SO(3) manifold.
561
+ # Note that the current integrator is not a semi-implicit scheme, therefore
562
+ # using the final ω[tf] would be not correct.
563
+ W_ω_WB_t0 = x0.physics_model.base_angular_velocity
564
+
565
+ # Integrate the quaternion on SO(3).
566
+ W_Q_B_tf = jaxsim.math.Quaternion.integration(
567
+ quaternion=W_Q_B_t0,
568
+ dt=dt,
569
+ omega=W_ω_WB_t0,
570
+ omega_in_body_fixed=False,
571
+ )
581
572
 
582
573
  # Replace the quaternion in the final state.
583
574
  return xf.replace(
584
- physics_model=xf.physics_model.replace(base_quaternion=W_R_B_tf.wxyz),
575
+ physics_model=xf.physics_model.replace(base_quaternion=W_Q_B_tf),
585
576
  validate=True,
586
577
  )
jaxsim/rbda/utils.py CHANGED
@@ -2,6 +2,7 @@ import jax.numpy as jnp
2
2
 
3
3
  import jaxsim.api as js
4
4
  import jaxsim.typing as jtp
5
+ from jaxsim import exceptions
5
6
  from jaxsim.math import StandardGravity
6
7
 
7
8
 
@@ -131,6 +132,13 @@ def process_inputs(
131
132
  if W_Q_B.shape != (4,):
132
133
  raise ValueError(W_Q_B.shape, (4,))
133
134
 
135
+ # Check that the quaternion is unary since our RBDAs make this assumption in order
136
+ # to prevent introducing additional normalizations that would affect AD.
137
+ exceptions.raise_value_error_if(
138
+ condition=jnp.logical_not(jnp.allclose(W_Q_B.dot(W_Q_B), 1.0)),
139
+ msg="A RBDA received a quaternion that is not normalized.",
140
+ )
141
+
134
142
  # Pack the 6D base velocity and acceleration.
135
143
  W_v_WB = jnp.hstack([W_vl_WB, W_ω_WB])
136
144
  W_v̇_WB = jnp.hstack([W_v̇l_WB, W_ω̇_WB])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: jaxsim
3
- Version: 0.4.1.dev11
3
+ Version: 0.4.1.dev15
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,5 +1,5 @@
1
1
  jaxsim/__init__.py,sha256=ixsS4dYMPex2wOUUp_rkPnwrPhYzkRh1xO_YuMj3Cr4,2626
2
- jaxsim/_version.py,sha256=7ZFpPaz7M9u-cSnMJ8POHhkQ3_j7elMp-k9w58-1Rgw,426
2
+ jaxsim/_version.py,sha256=GGa2wlqOOTBXMs_fQ4BwE7QCLSYjgvCVY3t6lhcCcz4,426
3
3
  jaxsim/exceptions.py,sha256=8_h8iqL8DgNR754dR8SZiQ7361GR5V1sUk3ZuZCHw1Q,2069
4
4
  jaxsim/logging.py,sha256=c4zhwBKf9eAYAHVp62kTEllqdsZgh0K-kPKVy8L3elU,1584
5
5
  jaxsim/typing.py,sha256=IbFx3UkEXi-cm7UBqMPi58rJAFV_HbZ9E_K4JwfNvVM,753
@@ -17,7 +17,7 @@ jaxsim/api/ode.py,sha256=NnLTBvpaT4kXnbjAghXIzLv9DTMJ8bele2iOlUQDv3Q,11028
17
17
  jaxsim/api/ode_data.py,sha256=9YZX-SK_KJtoIqG-zYWZsQInb2NA_LtxDn-jtLqm_3U,19759
18
18
  jaxsim/api/references.py,sha256=UA6kSQVBoq-bXSo99EOELf-_MD5MTy2zS0GtG3wQ410,16618
19
19
  jaxsim/integrators/__init__.py,sha256=hxvOD-VK_mmd6v31wtC-nb28AYve1gLuZCNLV9wS-Kg,103
20
- jaxsim/integrators/common.py,sha256=JXJECMkE-ZSmRt0-5koAw1vnmzkFewZ0aBrnP0bTpZY,20260
20
+ jaxsim/integrators/common.py,sha256=iwFykYZxdchqJcmcx8MFWEVijS5Hx9wCNKLKAJdF4gE,20103
21
21
  jaxsim/integrators/fixed_step.py,sha256=KpjRd6hHtapxDoo6D1kyDrVDSHnke2TepI5grFH7_bM,2693
22
22
  jaxsim/integrators/variable_step.py,sha256=0FCmAZIFnhvQxVbAzNfZgCWN1yMRTGVdBm9UwwaXI1o,21280
23
23
  jaxsim/math/__init__.py,sha256=8oPITEoGwgRcOeG8KxtqxPQ8b5uku1HNRMokpCoi9Tc,352
@@ -51,7 +51,7 @@ jaxsim/rbda/crba.py,sha256=NhtZO48OUKKor7ddY7mB7h7a6idrmOyf0Vy4p7UCCgI,4724
51
51
  jaxsim/rbda/forward_kinematics.py,sha256=OEQYovnLKsWphUKhigmWa_384LwZW3Csp0MKufw4e1M,3415
52
52
  jaxsim/rbda/jacobian.py,sha256=I6mrlkk7Cpq3CE7k_tajOHCbT6vf2pW6vMS0TKNCnng,10725
53
53
  jaxsim/rbda/rnea.py,sha256=UrhcL93fp3pAKlGxOPS6X47L0ferH50bcSMzG55t4zY,7626
54
- jaxsim/rbda/utils.py,sha256=dPRWG8pV7rm3VivP09NE2ttX6wHCRNir4wuixGA_G2Y,5003
54
+ 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=iMKLP30Qft9eGTiHo2iY-UoACJjg1JphA9_pW8wRdjc,2410
57
57
  jaxsim/rbda/contacts/soft.py,sha256=3cDynim_tIgcbzRuqpHN82v4ELlxxK6lR-PG0haSK7Q,15660
@@ -61,8 +61,8 @@ jaxsim/utils/__init__.py,sha256=Y5zyoRevl3EMVQadhZ4EtSwTEkDt2vcnFoRhPJjKTZ0,215
61
61
  jaxsim/utils/jaxsim_dataclass.py,sha256=fLl1tY3DDb3lpIhG6BPqA5W34hM84oFzL-5cuz8k-68,11379
62
62
  jaxsim/utils/tracing.py,sha256=KDMoyVPlu2NJvFkhtZwq5AkqMMgajt3munvJom-vEjQ,650
63
63
  jaxsim/utils/wrappers.py,sha256=GOJQCJc5zwzoEGZB62wnWWGvUUQlXvDxz_A2Q-hFv7c,4027
64
- jaxsim-0.4.1.dev11.dist-info/LICENSE,sha256=eaYdFmdeMbiIoIiPzEK0MjP1S9wtFXjXNR5er49uLR0,1546
65
- jaxsim-0.4.1.dev11.dist-info/METADATA,sha256=RQcmfKhS454m3fgEmDhJP00XtQFwnxWeXaBkTWiUKaQ,16779
66
- jaxsim-0.4.1.dev11.dist-info/WHEEL,sha256=Z4pYXqR_rTB7OWNDYFOm1qRk0RX6GFP2o8LgvP453Hk,91
67
- jaxsim-0.4.1.dev11.dist-info/top_level.txt,sha256=LxGMA8FLtXjQ6oI7N5gd_R_oSUHxpXxUEOfT1xS_ni0,7
68
- jaxsim-0.4.1.dev11.dist-info/RECORD,,
64
+ jaxsim-0.4.1.dev15.dist-info/LICENSE,sha256=eaYdFmdeMbiIoIiPzEK0MjP1S9wtFXjXNR5er49uLR0,1546
65
+ jaxsim-0.4.1.dev15.dist-info/METADATA,sha256=IbvjxjjI0ys4OxT59PyJKmN5Y5xaTDKPT41Q3PTcmbY,16779
66
+ jaxsim-0.4.1.dev15.dist-info/WHEEL,sha256=Z4pYXqR_rTB7OWNDYFOm1qRk0RX6GFP2o8LgvP453Hk,91
67
+ jaxsim-0.4.1.dev15.dist-info/top_level.txt,sha256=LxGMA8FLtXjQ6oI7N5gd_R_oSUHxpXxUEOfT1xS_ni0,7
68
+ jaxsim-0.4.1.dev15.dist-info/RECORD,,