jaxsim 0.4.3.dev61__py3-none-any.whl → 0.4.3.dev64__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.dev61'
16
- __version_tuple__ = version_tuple = (0, 4, 3, 'dev61')
15
+ __version__ = version = '0.4.3.dev64'
16
+ __version_tuple__ = version_tuple = (0, 4, 3, 'dev64')
jaxsim/api/data.py CHANGED
@@ -746,6 +746,13 @@ def random_model_data(
746
746
  jtp.FloatLike | Sequence[jtp.FloatLike],
747
747
  jtp.FloatLike | Sequence[jtp.FloatLike],
748
748
  ] = ((-1, -1, 0.5), 1.0),
749
+ joint_pos_bounds: (
750
+ tuple[
751
+ jtp.FloatLike | Sequence[jtp.FloatLike],
752
+ jtp.FloatLike | Sequence[jtp.FloatLike],
753
+ ]
754
+ | None
755
+ ) = None,
749
756
  base_vel_lin_bounds: tuple[
750
757
  jtp.FloatLike | Sequence[jtp.FloatLike],
751
758
  jtp.FloatLike | Sequence[jtp.FloatLike],
@@ -771,6 +778,8 @@ def random_model_data(
771
778
  key: The random key.
772
779
  velocity_representation: The velocity representation to use.
773
780
  base_pos_bounds: The bounds for the base position.
781
+ joint_pos_bounds:
782
+ The bounds for the joint positions (reading the joint limits if None).
774
783
  base_vel_lin_bounds: The bounds for the base linear velocity.
775
784
  base_vel_ang_bounds: The bounds for the base angular velocity.
776
785
  joint_vel_bounds: The bounds for the joint velocities.
@@ -815,8 +824,19 @@ def random_model_data(
815
824
  ).wxyz
816
825
 
817
826
  if model.number_of_joints() > 0:
818
- physics_model_state.joint_positions = js.joint.random_joint_positions(
819
- model=model, key=k3
827
+
828
+ s_min, s_max = (
829
+ jnp.array(joint_pos_bounds, dtype=float)
830
+ if joint_pos_bounds is not None
831
+ else (None, None)
832
+ )
833
+
834
+ physics_model_state.joint_positions = (
835
+ js.joint.random_joint_positions(model=model, key=k3)
836
+ if (s_min is None or s_max is None)
837
+ else jax.random.uniform(
838
+ key=k3, shape=(model.dofs(),), minval=s_min, maxval=s_max
839
+ )
820
840
  )
821
841
 
822
842
  physics_model_state.joint_velocities = jax.random.uniform(
jaxsim/api/joint.py CHANGED
@@ -180,17 +180,77 @@ def random_joint_positions(
180
180
 
181
181
  Args:
182
182
  model: The model to consider.
183
- joint_names: The names of the joints.
184
- key: The random key.
183
+ joint_names: The names of the considered joints (all if None).
184
+ key: The random key (initialized from seed 0 if None).
185
+
186
+ Note:
187
+ If the joint range or revolute joints is larger than 2π, their joint positions
188
+ will be sampled from an interval of size 2π.
185
189
 
186
190
  Returns:
187
191
  The random joint positions.
188
192
  """
189
193
 
194
+ # Consider the key corresponding to a zero seed if it was not passed.
190
195
  key = key if key is not None else jax.random.PRNGKey(seed=0)
191
196
 
197
+ # Get the joint limits parsed from the model description.
192
198
  s_min, s_max = position_limits(model=model, joint_names=joint_names)
193
199
 
200
+ # Get the joint indices.
201
+ # Note that it will trigger an exception if the given `joint_names` are not valid.
202
+ joint_names = joint_names if joint_names is not None else model.joint_names()
203
+ joint_indices = names_to_idxs(model=model, joint_names=joint_names)
204
+
205
+ from jaxsim.parsers.descriptions.joint import JointType
206
+
207
+ # Filter for revolute joints.
208
+ is_revolute = jnp.where(
209
+ jnp.array(model.kin_dyn_parameters.joint_model.joint_types[1:])[joint_indices]
210
+ == JointType.Revolute,
211
+ True,
212
+ False,
213
+ )
214
+
215
+ # Shorthand for π.
216
+ π = jnp.pi
217
+
218
+ # Filter for revolute with full range (or continuous).
219
+ is_revolute_full_range = jnp.logical_and(is_revolute, s_max - s_min >= 2 * π)
220
+
221
+ # Clip the lower limit to -π if the joint range is larger than [-π, π].
222
+ s_min = jnp.where(
223
+ jnp.logical_and(
224
+ is_revolute_full_range, jnp.logical_and(s_min <= -π, s_max >= π)
225
+ ),
226
+ -π,
227
+ s_min,
228
+ )
229
+
230
+ # Clip the upper limit to +π if the joint range is larger than [-π, π].
231
+ s_max = jnp.where(
232
+ jnp.logical_and(
233
+ is_revolute_full_range, jnp.logical_and(s_min <= -π, s_max >= π)
234
+ ),
235
+ π,
236
+ s_max,
237
+ )
238
+
239
+ # Shift the lower limit if the upper limit is smaller than +π.
240
+ s_min = jnp.where(
241
+ jnp.logical_and(is_revolute_full_range, s_max < π),
242
+ s_max - 2 * π,
243
+ s_min,
244
+ )
245
+
246
+ # Shift the upper limit if the lower limit is larger than -π.
247
+ s_max = jnp.where(
248
+ jnp.logical_and(is_revolute_full_range, s_min > -π),
249
+ s_min + 2 * π,
250
+ s_max,
251
+ )
252
+
253
+ # Sample the joint positions.
194
254
  s_random = jax.random.uniform(
195
255
  minval=s_min,
196
256
  maxval=s_max,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: jaxsim
3
- Version: 0.4.3.dev61
3
+ Version: 0.4.3.dev64
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=bSbpggIz5aG6QuGZLa0V2EfHjAOeucMxi-vIYxzLmN8,2788
2
- jaxsim/_version.py,sha256=-X1WOrm5bVGXKgqXhQ2hfs9nX5G3KTlE1ShNm2Qfmi0,426
2
+ jaxsim/_version.py,sha256=lLNskxtfHW1HqvnLRuhux3LlK89fMiZFUWknSYopw7k,426
3
3
  jaxsim/exceptions.py,sha256=8_h8iqL8DgNR754dR8SZiQ7361GR5V1sUk3ZuZCHw1Q,2069
4
4
  jaxsim/logging.py,sha256=STI-D_upXZYX-ZezLrlJJ0UlD5YspST0vZ_DcIwkzO4,1553
5
5
  jaxsim/typing.py,sha256=2HXy9hgazPXjofi1vLQ09ZubPtgVmg80U9NKmZ6NYiI,761
@@ -7,9 +7,9 @@ jaxsim/api/__init__.py,sha256=8eV22t2S3UwNyCg8karPetG1dmX1VDBXkyv28_FwNQA,210
7
7
  jaxsim/api/com.py,sha256=m-p3EJDhpnMTlXKplfbZE_aH9NqX_VyLlAE3vUhc6l4,13642
8
8
  jaxsim/api/common.py,sha256=SNgxq42r6eF_-aPszvOjUYkGwXOzz4hKmhDwEUkscFQ,6650
9
9
  jaxsim/api/contact.py,sha256=C_PgMjWYYiqpA7Oz3IxHeFgrp855-xG6AQr6Ze98CtI,21863
10
- jaxsim/api/data.py,sha256=xu1KFL7YLaj6J52DfefTIp5pumoaspPNk1XYQRijYNQ,27538
10
+ jaxsim/api/data.py,sha256=mFUw2mj8AIXduW6HnkGN7eooZHfJhwnWbtYZfLF6gk4,28206
11
11
  jaxsim/api/frame.py,sha256=KS8A5wRfjxhe9NgcVo2QA516iP5zky7UVnWxG7nTa7c,12911
12
- jaxsim/api/joint.py,sha256=L81bQe-noPT6_54KOSF7KBjRmEPAS433ULn2EcXI8vI,5115
12
+ jaxsim/api/joint.py,sha256=lksT1Doxz2jknHyhb4ls20z6f6dofpZSzBJtVacZXAE,7129
13
13
  jaxsim/api/kin_dyn_parameters.py,sha256=CcfSg5Mc8qb1mZeMQ4AK_ffZIsK5yOl7tu397pFhcDA,29369
14
14
  jaxsim/api/link.py,sha256=qPRtc8qqMRjZxUCZYXJMygbB6huDXBfIT1b1b8Durkw,18631
15
15
  jaxsim/api/model.py,sha256=K0q8-j-04f6B3MEXsctDGtWiuWlN3HbDrsS7zoPYStk,65871
@@ -63,8 +63,8 @@ jaxsim/utils/__init__.py,sha256=Y5zyoRevl3EMVQadhZ4EtSwTEkDt2vcnFoRhPJjKTZ0,215
63
63
  jaxsim/utils/jaxsim_dataclass.py,sha256=FSiUvdnq4Y1T9Jaa_mw4ZBQJe8H7deLr3Kupxtlh4iI,11322
64
64
  jaxsim/utils/tracing.py,sha256=KDMoyVPlu2NJvFkhtZwq5AkqMMgajt3munvJom-vEjQ,650
65
65
  jaxsim/utils/wrappers.py,sha256=Fh82ZcaFi5fUnByyFLnmumaobsu1hJIvFdopUVzJ1ps,4052
66
- jaxsim-0.4.3.dev61.dist-info/LICENSE,sha256=eaYdFmdeMbiIoIiPzEK0MjP1S9wtFXjXNR5er49uLR0,1546
67
- jaxsim-0.4.3.dev61.dist-info/METADATA,sha256=I4iQjmhyhZrn98uoXHGLKM_o3k_NVNGhrugZ4ZTlhkI,17276
68
- jaxsim-0.4.3.dev61.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
69
- jaxsim-0.4.3.dev61.dist-info/top_level.txt,sha256=LxGMA8FLtXjQ6oI7N5gd_R_oSUHxpXxUEOfT1xS_ni0,7
70
- jaxsim-0.4.3.dev61.dist-info/RECORD,,
66
+ jaxsim-0.4.3.dev64.dist-info/LICENSE,sha256=eaYdFmdeMbiIoIiPzEK0MjP1S9wtFXjXNR5er49uLR0,1546
67
+ jaxsim-0.4.3.dev64.dist-info/METADATA,sha256=0-JS1eJjFMSaMzwqbCSpWYU2GcrZkxT1LBDo7lhWICo,17276
68
+ jaxsim-0.4.3.dev64.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
69
+ jaxsim-0.4.3.dev64.dist-info/top_level.txt,sha256=LxGMA8FLtXjQ6oI7N5gd_R_oSUHxpXxUEOfT1xS_ni0,7
70
+ jaxsim-0.4.3.dev64.dist-info/RECORD,,