jaxsim 0.4.3.dev280__py3-none-any.whl → 0.4.3.dev282__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.dev280'
16
- __version_tuple__ = version_tuple = (0, 4, 3, 'dev280')
15
+ __version__ = version = '0.4.3.dev282'
16
+ __version_tuple__ = version_tuple = (0, 4, 3, 'dev282')
jaxsim/math/rotation.py CHANGED
@@ -1,4 +1,3 @@
1
- import jax
2
1
  import jax.numpy as jnp
3
2
  import jaxlie
4
3
 
@@ -8,6 +7,7 @@ from .skew import Skew
8
7
 
9
8
 
10
9
  class Rotation:
10
+
11
11
  @staticmethod
12
12
  def x(theta: jtp.Float) -> jtp.Matrix:
13
13
  """
@@ -19,6 +19,7 @@ class Rotation:
19
19
  Returns:
20
20
  jtp.Matrix: 3D rotation matrix.
21
21
  """
22
+
22
23
  return jaxlie.SO3.from_x_radians(theta=theta).as_matrix()
23
24
 
24
25
  @staticmethod
@@ -32,6 +33,7 @@ class Rotation:
32
33
  Returns:
33
34
  jtp.Matrix: 3D rotation matrix.
34
35
  """
36
+
35
37
  return jaxlie.SO3.from_y_radians(theta=theta).as_matrix()
36
38
 
37
39
  @staticmethod
@@ -45,6 +47,7 @@ class Rotation:
45
47
  Returns:
46
48
  jtp.Matrix: 3D rotation matrix.
47
49
  """
50
+
48
51
  return jaxlie.SO3.from_z_radians(theta=theta).as_matrix()
49
52
 
50
53
  @staticmethod
@@ -53,17 +56,18 @@ class Rotation:
53
56
  Generate a 3D rotation matrix from an axis-angle representation.
54
57
 
55
58
  Args:
56
- vector (jtp.Vector): Axis-angle representation as a 3D vector.
59
+ vector: Axis-angle representation or the rotation as a 3D vector.
57
60
 
58
61
  Returns:
59
- jtp.Matrix: 3D rotation matrix.
60
-
62
+ The SO(3) rotation matrix.
61
63
  """
64
+
62
65
  vector = vector.squeeze()
63
- theta = jnp.linalg.norm(vector)
64
66
 
65
- def theta_is_not_zero(theta_and_v: tuple[jtp.Float, jtp.Vector]) -> jtp.Matrix:
66
- theta, v = theta_and_v
67
+ def theta_is_not_zero(axis: jtp.Vector) -> jtp.Matrix:
68
+
69
+ v = axis
70
+ theta = jnp.linalg.norm(v)
67
71
 
68
72
  s = jnp.sin(theta)
69
73
  c = jnp.cos(theta)
@@ -77,9 +81,19 @@ class Rotation:
77
81
 
78
82
  return R.transpose()
79
83
 
80
- return jax.lax.cond(
81
- pred=(theta == 0.0),
82
- true_fun=lambda operand: jnp.eye(3),
83
- false_fun=theta_is_not_zero,
84
- operand=(theta, vector),
84
+ # Use the double-where trick to prevent JAX problems when the
85
+ # jax.jit and jax.grad transforms are applied.
86
+ return jnp.where(
87
+ jnp.linalg.norm(vector) > 0,
88
+ theta_is_not_zero(
89
+ axis=jnp.where(
90
+ jnp.linalg.norm(vector) > 0,
91
+ vector,
92
+ # The following line is a workaround to prevent division by 0.
93
+ # Considering the outer where, this branch is never executed.
94
+ jnp.ones(3),
95
+ )
96
+ ),
97
+ # Return an identity rotation matrix when the input vector is zero.
98
+ jnp.eye(3),
85
99
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: jaxsim
3
- Version: 0.4.3.dev280
3
+ Version: 0.4.3.dev282
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=opgtbhhd1kDsHI4H1vOd3loMPDRi884yQ3tohfFGfNc,3382
2
- jaxsim/_version.py,sha256=U12VcDXh7Zu7La30KnfhDG0g-i5JqVyuLLRlI8iTnrI,428
2
+ jaxsim/_version.py,sha256=8Lzzuj01bYiR6tHmTBRLQW2sSRCWlBO6B-razI_HdjU,428
3
3
  jaxsim/exceptions.py,sha256=vSoScaRD4nvh6jltgK9Ry5pKnE0O5hb4_yI_pk_fvR8,2175
4
4
  jaxsim/logging.py,sha256=STI-D_upXZYX-ZezLrlJJ0UlD5YspST0vZ_DcIwkzO4,1553
5
5
  jaxsim/typing.py,sha256=2HXy9hgazPXjofi1vLQ09ZubPtgVmg80U9NKmZ6NYiI,761
@@ -26,7 +26,7 @@ jaxsim/math/cross.py,sha256=U7yEx_l75mSy5g6O-jsjBztApvxC3WaV4MpkS5tThu4,1330
26
26
  jaxsim/math/inertia.py,sha256=01hz6wMFreN2jBA0rVoBS1YMVh77KvwuzXSOpI3pxNk,1614
27
27
  jaxsim/math/joint_model.py,sha256=EzAveaG5B6ZnCFNUzN30KEQUVesd83lfWXJarYR-kUw,9989
28
28
  jaxsim/math/quaternion.py,sha256=_WA7W3iv7px83sWO1V1n0-J78hqAlO4SL1-jofE-UZ4,4754
29
- jaxsim/math/rotation.py,sha256=k-nwT79zmWrys3NNAB-lGWxat7Kqm_6JnFRoimJ8rBg,2156
29
+ jaxsim/math/rotation.py,sha256=P34sx28Rh1MhNwxUxqXjxP-ZN1_5tvoflMoAIpy2LbE,2586
30
30
  jaxsim/math/skew.py,sha256=oOGSSR8PUGROl6IJFlrmu6K3gPH-u16hUPfKIkcVv9o,1177
31
31
  jaxsim/math/transform.py,sha256=KXzQgOnCfAtbXCwxhplpJ3F0JT3oEyeLVby1_uRAryQ,2892
32
32
  jaxsim/mujoco/__init__.py,sha256=fZyRWre49pIhOrYdf6yJk_hOax8qWGe8OCmoq-dMVq8,201
@@ -65,8 +65,8 @@ jaxsim/utils/__init__.py,sha256=Y5zyoRevl3EMVQadhZ4EtSwTEkDt2vcnFoRhPJjKTZ0,215
65
65
  jaxsim/utils/jaxsim_dataclass.py,sha256=TGmTQV2Lq7Q-2nLoAEaeNtkPa_qj0IKkdBm4COj46Os,11312
66
66
  jaxsim/utils/tracing.py,sha256=KDMoyVPlu2NJvFkhtZwq5AkqMMgajt3munvJom-vEjQ,650
67
67
  jaxsim/utils/wrappers.py,sha256=Fh82ZcaFi5fUnByyFLnmumaobsu1hJIvFdopUVzJ1ps,4052
68
- jaxsim-0.4.3.dev280.dist-info/LICENSE,sha256=eaYdFmdeMbiIoIiPzEK0MjP1S9wtFXjXNR5er49uLR0,1546
69
- jaxsim-0.4.3.dev280.dist-info/METADATA,sha256=3Ad6_an0aEBTc9JVFxZbdbT-0PnAWLKgEVRW37ztcxo,17276
70
- jaxsim-0.4.3.dev280.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
71
- jaxsim-0.4.3.dev280.dist-info/top_level.txt,sha256=LxGMA8FLtXjQ6oI7N5gd_R_oSUHxpXxUEOfT1xS_ni0,7
72
- jaxsim-0.4.3.dev280.dist-info/RECORD,,
68
+ jaxsim-0.4.3.dev282.dist-info/LICENSE,sha256=eaYdFmdeMbiIoIiPzEK0MjP1S9wtFXjXNR5er49uLR0,1546
69
+ jaxsim-0.4.3.dev282.dist-info/METADATA,sha256=Llp_WIbsROSnrBpSMJUdFnAOOkLDobo5f87CO8xvOuA,17276
70
+ jaxsim-0.4.3.dev282.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
71
+ jaxsim-0.4.3.dev282.dist-info/top_level.txt,sha256=LxGMA8FLtXjQ6oI7N5gd_R_oSUHxpXxUEOfT1xS_ni0,7
72
+ jaxsim-0.4.3.dev282.dist-info/RECORD,,