jaxsim 0.4.1.dev26__py3-none-any.whl → 0.4.2.dev12__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/frame.py +156 -1
- jaxsim/api/model.py +2 -2
- {jaxsim-0.4.1.dev26.dist-info → jaxsim-0.4.2.dev12.dist-info}/METADATA +1 -1
- {jaxsim-0.4.1.dev26.dist-info → jaxsim-0.4.2.dev12.dist-info}/RECORD +8 -8
- {jaxsim-0.4.1.dev26.dist-info → jaxsim-0.4.2.dev12.dist-info}/WHEEL +1 -1
- {jaxsim-0.4.1.dev26.dist-info → jaxsim-0.4.2.dev12.dist-info}/LICENSE +0 -0
- {jaxsim-0.4.1.dev26.dist-info → jaxsim-0.4.2.dev12.dist-info}/top_level.txt +0 -0
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.
|
16
|
-
__version_tuple__ = version_tuple = (0, 4,
|
15
|
+
__version__ = version = '0.4.2.dev12'
|
16
|
+
__version_tuple__ = version_tuple = (0, 4, 2, 'dev12')
|
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, Transform
|
10
|
+
from jaxsim.math import Adjoint, Cross, Transform
|
11
11
|
|
12
12
|
from .common import VelRepr
|
13
13
|
|
@@ -257,3 +257,158 @@ def jacobian(
|
|
257
257
|
raise ValueError(output_vel_repr)
|
258
258
|
|
259
259
|
return O_J_WL_I
|
260
|
+
|
261
|
+
|
262
|
+
@functools.partial(jax.jit, static_argnames=["output_vel_repr"])
|
263
|
+
def jacobian_derivative(
|
264
|
+
model: js.model.JaxSimModel,
|
265
|
+
data: js.data.JaxSimModelData,
|
266
|
+
*,
|
267
|
+
frame_index: jtp.IntLike,
|
268
|
+
output_vel_repr: VelRepr | None = None,
|
269
|
+
) -> jtp.Matrix:
|
270
|
+
r"""
|
271
|
+
Compute the derivative of the free-floating jacobian of the frame.
|
272
|
+
|
273
|
+
Args:
|
274
|
+
model: The model to consider.
|
275
|
+
data: The data of the considered model.
|
276
|
+
frame_index: The index of the frame.
|
277
|
+
output_vel_repr:
|
278
|
+
The output velocity representation of the free-floating jacobian derivative.
|
279
|
+
|
280
|
+
Returns:
|
281
|
+
The derivative of the :math:`6 \times (6+n)` free-floating jacobian of the frame.
|
282
|
+
|
283
|
+
Note:
|
284
|
+
The input representation of the free-floating jacobian derivative is the active
|
285
|
+
velocity representation.
|
286
|
+
"""
|
287
|
+
|
288
|
+
n_l = model.number_of_links()
|
289
|
+
n_f = len(model.frame_names())
|
290
|
+
|
291
|
+
exceptions.raise_value_error_if(
|
292
|
+
condition=jnp.array([frame_index < n_l, frame_index >= n_l + n_f]).any(),
|
293
|
+
msg="Invalid frame index '{idx}'",
|
294
|
+
idx=frame_index,
|
295
|
+
)
|
296
|
+
|
297
|
+
output_vel_repr = (
|
298
|
+
output_vel_repr if output_vel_repr is not None else data.velocity_representation
|
299
|
+
)
|
300
|
+
|
301
|
+
# Get the index of the parent link.
|
302
|
+
L = idx_of_parent_link(model=model, frame_index=frame_index)
|
303
|
+
|
304
|
+
with data.switch_velocity_representation(VelRepr.Inertial):
|
305
|
+
# Compute the Jacobian of the parent link in inertial representation.
|
306
|
+
W_J_WL_W = js.link.jacobian(
|
307
|
+
model=model,
|
308
|
+
data=data,
|
309
|
+
link_index=L,
|
310
|
+
output_vel_repr=VelRepr.Inertial,
|
311
|
+
)
|
312
|
+
|
313
|
+
# Compute the Jacobian derivative of the parent link in inertial representation.
|
314
|
+
W_J̇_WL_W = js.link.jacobian_derivative(
|
315
|
+
model=model,
|
316
|
+
data=data,
|
317
|
+
link_index=L,
|
318
|
+
output_vel_repr=VelRepr.Inertial,
|
319
|
+
)
|
320
|
+
|
321
|
+
# =====================================================
|
322
|
+
# Compute quantities to adjust the input representation
|
323
|
+
# =====================================================
|
324
|
+
|
325
|
+
def compute_T(model: js.model.JaxSimModel, X: jtp.Matrix) -> jtp.Matrix:
|
326
|
+
In = jnp.eye(model.dofs())
|
327
|
+
T = jax.scipy.linalg.block_diag(X, In)
|
328
|
+
return T
|
329
|
+
|
330
|
+
def compute_Ṫ(model: js.model.JaxSimModel, Ẋ: jtp.Matrix) -> jtp.Matrix:
|
331
|
+
On = jnp.zeros(shape=(model.dofs(), model.dofs()))
|
332
|
+
Ṫ = jax.scipy.linalg.block_diag(Ẋ, On)
|
333
|
+
return Ṫ
|
334
|
+
|
335
|
+
# Compute the operator to change the representation of ν, and its
|
336
|
+
# time derivative.
|
337
|
+
match data.velocity_representation:
|
338
|
+
case VelRepr.Inertial:
|
339
|
+
W_H_W = jnp.eye(4)
|
340
|
+
W_X_W = Adjoint.from_transform(transform=W_H_W)
|
341
|
+
W_Ẋ_W = jnp.zeros((6, 6))
|
342
|
+
|
343
|
+
T = compute_T(model=model, X=W_X_W)
|
344
|
+
Ṫ = compute_Ṫ(model=model, Ẋ=W_Ẋ_W)
|
345
|
+
|
346
|
+
case VelRepr.Body:
|
347
|
+
W_H_B = data.base_transform()
|
348
|
+
W_X_B = Adjoint.from_transform(transform=W_H_B)
|
349
|
+
B_v_WB = data.base_velocity()
|
350
|
+
B_vx_WB = Cross.vx(B_v_WB)
|
351
|
+
W_Ẋ_B = W_X_B @ B_vx_WB
|
352
|
+
|
353
|
+
T = compute_T(model=model, X=W_X_B)
|
354
|
+
Ṫ = compute_Ṫ(model=model, Ẋ=W_Ẋ_B)
|
355
|
+
|
356
|
+
case VelRepr.Mixed:
|
357
|
+
W_H_B = data.base_transform()
|
358
|
+
W_H_BW = W_H_B.at[0:3, 0:3].set(jnp.eye(3))
|
359
|
+
W_X_BW = Adjoint.from_transform(transform=W_H_BW)
|
360
|
+
BW_v_WB = data.base_velocity()
|
361
|
+
BW_v_W_BW = BW_v_WB.at[3:6].set(jnp.zeros(3))
|
362
|
+
BW_vx_W_BW = Cross.vx(BW_v_W_BW)
|
363
|
+
W_Ẋ_BW = W_X_BW @ BW_vx_W_BW
|
364
|
+
|
365
|
+
T = compute_T(model=model, X=W_X_BW)
|
366
|
+
Ṫ = compute_Ṫ(model=model, Ẋ=W_Ẋ_BW)
|
367
|
+
|
368
|
+
case _:
|
369
|
+
raise ValueError(data.velocity_representation)
|
370
|
+
|
371
|
+
# =====================================================
|
372
|
+
# Compute quantities to adjust the output representation
|
373
|
+
# =====================================================
|
374
|
+
|
375
|
+
match output_vel_repr:
|
376
|
+
case VelRepr.Inertial:
|
377
|
+
O_X_W = W_X_W = Adjoint.from_transform(transform=jnp.eye(4))
|
378
|
+
O_Ẋ_W = W_Ẋ_W = jnp.zeros((6, 6))
|
379
|
+
|
380
|
+
case VelRepr.Body:
|
381
|
+
W_H_F = transform(model=model, data=data, frame_index=frame_index)
|
382
|
+
O_X_W = F_X_W = Adjoint.from_transform(transform=W_H_F, inverse=True)
|
383
|
+
with data.switch_velocity_representation(VelRepr.Inertial):
|
384
|
+
W_nu = data.generalized_velocity()
|
385
|
+
W_v_WF = W_J_WL_W @ W_nu
|
386
|
+
W_vx_WF = Cross.vx(W_v_WF)
|
387
|
+
O_Ẋ_W = F_Ẋ_W = -F_X_W @ W_vx_WF
|
388
|
+
|
389
|
+
case VelRepr.Mixed:
|
390
|
+
W_H_F = transform(model=model, data=data, frame_index=frame_index)
|
391
|
+
W_H_FW = W_H_F.at[0:3, 0:3].set(jnp.eye(3))
|
392
|
+
FW_H_W = Transform.inverse(W_H_FW)
|
393
|
+
O_X_W = FW_X_W = Adjoint.from_transform(transform=FW_H_W)
|
394
|
+
with data.switch_velocity_representation(VelRepr.Mixed):
|
395
|
+
FW_J_WF_FW = jacobian(
|
396
|
+
model=model,
|
397
|
+
data=data,
|
398
|
+
frame_index=frame_index,
|
399
|
+
output_vel_repr=VelRepr.Mixed,
|
400
|
+
)
|
401
|
+
FW_v_WF = FW_J_WF_FW @ data.generalized_velocity()
|
402
|
+
W_v_W_FW = jnp.zeros(6).at[0:3].set(FW_v_WF[0:3])
|
403
|
+
W_vx_W_FW = Cross.vx(W_v_W_FW)
|
404
|
+
O_Ẋ_W = FW_Ẋ_W = -FW_X_W @ W_vx_W_FW
|
405
|
+
|
406
|
+
case _:
|
407
|
+
raise ValueError(output_vel_repr)
|
408
|
+
|
409
|
+
O_J̇_WF_I = jnp.zeros(shape=(6, 6 + model.dofs()))
|
410
|
+
O_J̇_WF_I += O_Ẋ_W @ W_J_WL_W @ T
|
411
|
+
O_J̇_WF_I += O_X_W @ W_J̇_WL_W @ T
|
412
|
+
O_J̇_WF_I += O_X_W @ W_J_WL_W @ Ṫ
|
413
|
+
|
414
|
+
return O_J̇_WF_I
|
jaxsim/api/model.py
CHANGED
@@ -301,10 +301,10 @@ class JaxSimModel(JaxsimDataclass):
|
|
301
301
|
|
302
302
|
def frame_names(self) -> tuple[str, ...]:
|
303
303
|
"""
|
304
|
-
Return the names of the
|
304
|
+
Return the names of the frames in the model.
|
305
305
|
|
306
306
|
Returns:
|
307
|
-
The names of the
|
307
|
+
The names of the frames in the model.
|
308
308
|
"""
|
309
309
|
|
310
310
|
return self.kin_dyn_parameters.frame_parameters.name
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: jaxsim
|
3
|
-
Version: 0.4.
|
3
|
+
Version: 0.4.2.dev12
|
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=
|
2
|
+
jaxsim/_version.py,sha256=RAx3CWTs9fxrkfMFaLp1UMf3oZxbRvQW5m-ab2iNDcg,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
|
@@ -8,11 +8,11 @@ jaxsim/api/com.py,sha256=6TnYCvjmsJ2KLuw3NtZb0pay7ZwGKe9MKphYeQdjpQ0,13474
|
|
8
8
|
jaxsim/api/common.py,sha256=Ubi6uAw3o6qbdU0TFGzUyHg98EnoMzrnlihrvrs95Sk,6653
|
9
9
|
jaxsim/api/contact.py,sha256=EcOx_T94gZT3igtebmW9FJDpZYPEf-RwKfFN18JjOWM,13364
|
10
10
|
jaxsim/api/data.py,sha256=-xx4b11thP8oJEXB4xtgrh3RTY2-BxrT38b7s_GrzjA,27420
|
11
|
-
jaxsim/api/frame.py,sha256=
|
11
|
+
jaxsim/api/frame.py,sha256=yQmhh8fckXnqzs7dQvojOzbuSanNGLwUTWUQDXbVtF4,12874
|
12
12
|
jaxsim/api/joint.py,sha256=Pvg_It2iYA-jAQ2nOlFZxwmITiozO_f46G13BdQtHQ0,5106
|
13
13
|
jaxsim/api/kin_dyn_parameters.py,sha256=CcfSg5Mc8qb1mZeMQ4AK_ffZIsK5yOl7tu397pFhcDA,29369
|
14
14
|
jaxsim/api/link.py,sha256=hn7fbxaebHeXnvwEG9jZiWwzRcfdS8m-18LVsIG3S24,18479
|
15
|
-
jaxsim/api/model.py,sha256=
|
15
|
+
jaxsim/api/model.py,sha256=PMTSz00AIVopwiJ3zGBoYPTtkLH_beJCcQsX9wBE38I,61502
|
16
16
|
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
|
@@ -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.
|
65
|
-
jaxsim-0.4.
|
66
|
-
jaxsim-0.4.
|
67
|
-
jaxsim-0.4.
|
68
|
-
jaxsim-0.4.
|
64
|
+
jaxsim-0.4.2.dev12.dist-info/LICENSE,sha256=eaYdFmdeMbiIoIiPzEK0MjP1S9wtFXjXNR5er49uLR0,1546
|
65
|
+
jaxsim-0.4.2.dev12.dist-info/METADATA,sha256=bxPCWzVduanZPJ4ZuYkXTKkRCyyu-rjDSRd64c4oKpw,16826
|
66
|
+
jaxsim-0.4.2.dev12.dist-info/WHEEL,sha256=-oYQCr74JF3a37z2nRlQays_SX2MqOANoqVjBBAP2yE,91
|
67
|
+
jaxsim-0.4.2.dev12.dist-info/top_level.txt,sha256=LxGMA8FLtXjQ6oI7N5gd_R_oSUHxpXxUEOfT1xS_ni0,7
|
68
|
+
jaxsim-0.4.2.dev12.dist-info/RECORD,,
|
File without changes
|
File without changes
|