jaxsim 0.6.2.dev242__py3-none-any.whl → 0.6.2.dev259__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
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '0.6.2.dev242'
21
- __version_tuple__ = version_tuple = (0, 6, 2, 'dev242')
20
+ __version__ = version = '0.6.2.dev259'
21
+ __version_tuple__ = version_tuple = (0, 6, 2, 'dev259')
@@ -92,5 +92,34 @@ def compute_resultant_torques(
92
92
  # ===============================
93
93
 
94
94
  τ_total = τ_references + τ_friction + τ_position_limit
95
-
95
+ τ_lim = tn_curve_fn(model=model, data=data)
96
+ τ_total = jnp.clip(τ_total, -τ_lim, τ_lim)
96
97
  return τ_total
98
+
99
+
100
+ def tn_curve_fn(
101
+ model: js.model.JaxSimModel, data: js.data.JaxSimModelData
102
+ ) -> jtp.Vector:
103
+ """
104
+ Compute the torque limits using the tn curve.
105
+
106
+ Args:
107
+ model: The model to consider.
108
+ data: The data of the considered model.
109
+
110
+ Returns:
111
+ The torque limits.
112
+ """
113
+
114
+ τ_max = model.actuation_params.torque_max # Max torque (Nm)
115
+ ω_th = model.actuation_params.omega_th # Threshold speed (rad/s)
116
+ ω_max = model.actuation_params.omega_max # Max speed for torque drop-off (rad/s)
117
+ abs_vel = jnp.abs(data.joint_velocities)
118
+ τ_lim = jnp.where(
119
+ abs_vel <= ω_th,
120
+ τ_max,
121
+ jnp.where(
122
+ abs_vel <= ω_max, τ_max * (1 - (abs_vel - ω_th) / (ω_max - ω_th)), 0.0
123
+ ),
124
+ )
125
+ return τ_lim
jaxsim/api/data.py CHANGED
@@ -431,13 +431,6 @@ class JaxSimModelData(common.ModelDataWithVelocityRepresentation):
431
431
  if contact_state is None:
432
432
  contact_state = self.contact_state
433
433
 
434
- if isinstance(model.contact_model, jaxsim.rbda.contacts.SoftContacts):
435
- contact_state = {
436
- "tangential_deformation": jnp.zeros_like(
437
- contact_state["tangential_deformation"]
438
- )
439
- }
440
-
441
434
  # Normalize the quaternion to avoid numerical issues.
442
435
  base_quaternion_norm = jaxsim.math.safe_norm(
443
436
  base_quaternion, axis=-1, keepdims=True
@@ -525,6 +518,7 @@ class JaxSimModelData(common.ModelDataWithVelocityRepresentation):
525
518
  _joint_transforms=joint_transforms,
526
519
  _link_transforms=link_transforms,
527
520
  _link_velocities=link_velocities,
521
+ contact_state=contact_state,
528
522
  validate=validate,
529
523
  )
530
524
 
jaxsim/api/integrators.py CHANGED
@@ -156,9 +156,117 @@ def rk4_integration(
156
156
  return data_tf.replace(model=model)
157
157
 
158
158
 
159
+ def rk4fast_integration(
160
+ model: js.model.JaxSimModel,
161
+ data: JaxSimModelData,
162
+ link_forces: jtp.Vector,
163
+ joint_torques: jtp.Vector,
164
+ ) -> JaxSimModelData:
165
+ """
166
+ Integrate the system state using the Runge-Kutta 4 fast method.
167
+
168
+ Note:
169
+ This method is a faster version of the RK4 method, but it may not be as accurate.
170
+ It computes the contact forces only once at the beginning of the integration step.
171
+ """
172
+
173
+ dt = model.time_step
174
+
175
+ if len(model.kin_dyn_parameters.contact_parameters.body) > 0:
176
+
177
+ # Compute the 6D forces W_f ∈ ℝ^{n_L × 6} applied to links due to contact
178
+ # with the terrain.
179
+ W_f_L_terrain, contact_state_derivative = js.contact.link_contact_forces(
180
+ model=model,
181
+ data=data,
182
+ link_forces=link_forces,
183
+ joint_torques=joint_torques,
184
+ )
185
+
186
+ W_f_L_total = link_forces + W_f_L_terrain
187
+
188
+ # Update the contact state data. This is necessary only for the contact models
189
+ # that require propagation and integration of contact state.
190
+ contact_state = model.contact_model.update_contact_state(contact_state_derivative)
191
+
192
+ def f(x) -> dict[str, jtp.Matrix]:
193
+
194
+ with data.switch_velocity_representation(jaxsim.VelRepr.Inertial):
195
+
196
+ data_ti = data.replace(model=model, **x)
197
+
198
+ W_v̇_WB, s̈ = js.model.forward_dynamics_aba(
199
+ model=model,
200
+ data=data_ti,
201
+ joint_forces=joint_torques,
202
+ link_forces=W_f_L_total,
203
+ )
204
+
205
+ W_ṗ_B, W_Q̇_B, ṡ = js.ode.system_position_dynamics(
206
+ data=data,
207
+ baumgarte_quaternion_regularization=1.0,
208
+ )
209
+
210
+ return dict(
211
+ base_position=W_ṗ_B,
212
+ base_quaternion=W_Q̇_B,
213
+ joint_positions=ṡ,
214
+ base_linear_velocity=W_v̇_WB[0:3],
215
+ base_angular_velocity=W_v̇_WB[3:6],
216
+ joint_velocities=s̈,
217
+ # The contact state is not updated here, as it is assumed to be constant.
218
+ contact_state=data_ti.contact_state,
219
+ )
220
+
221
+ base_quaternion_norm = jaxsim.math.safe_norm(data._base_quaternion, axis=-1)
222
+ base_quaternion = data._base_quaternion / jnp.where(
223
+ base_quaternion_norm == 0, 1.0, base_quaternion_norm
224
+ )
225
+
226
+ x_t0 = dict(
227
+ base_position=data._base_position,
228
+ base_quaternion=base_quaternion,
229
+ joint_positions=data._joint_positions,
230
+ base_linear_velocity=data._base_linear_velocity,
231
+ base_angular_velocity=data._base_angular_velocity,
232
+ joint_velocities=data._joint_velocities,
233
+ contact_state=contact_state,
234
+ )
235
+
236
+ euler_mid = lambda x, dxdt: x + (0.5 * dt) * dxdt
237
+ euler_fin = lambda x, dxdt: x + dt * dxdt
238
+
239
+ k1 = f(x_t0)
240
+ k2 = f(jax.tree.map(euler_mid, x_t0, k1))
241
+ k3 = f(jax.tree.map(euler_mid, x_t0, k2))
242
+ k4 = f(jax.tree.map(euler_fin, x_t0, k3))
243
+
244
+ # Average the slopes and compute the RK4 state derivative.
245
+ average = lambda k1, k2, k3, k4: (k1 + 2 * k2 + 2 * k3 + k4) / 6
246
+
247
+ dxdt = jax.tree_util.tree_map(average, k1, k2, k3, k4)
248
+
249
+ # Integrate the dynamics
250
+ x_tf = jax.tree_util.tree_map(euler_fin, x_t0, dxdt)
251
+
252
+ data_tf = dataclasses.replace(
253
+ data,
254
+ _base_position=x_tf["base_position"],
255
+ _base_quaternion=x_tf["base_quaternion"],
256
+ _joint_positions=x_tf["joint_positions"],
257
+ _base_linear_velocity=x_tf["base_linear_velocity"],
258
+ _base_angular_velocity=x_tf["base_angular_velocity"],
259
+ _joint_velocities=x_tf["joint_velocities"],
260
+ contact_state=x_tf["contact_state"],
261
+ )
262
+
263
+ return data_tf.replace(model=model)
264
+
265
+
159
266
  _INTEGRATORS_MAP: dict[
160
267
  js.model.IntegratorType, Callable[..., js.data.JaxSimModelData]
161
268
  ] = {
162
269
  js.model.IntegratorType.SemiImplicitEuler: semi_implicit_euler_integration,
163
270
  js.model.IntegratorType.RungeKutta4: rk4_integration,
271
+ js.model.IntegratorType.RungeKutta4Fast: rk4fast_integration,
164
272
  }
jaxsim/api/model.py CHANGED
@@ -29,6 +29,7 @@ class IntegratorType(enum.IntEnum):
29
29
 
30
30
  SemiImplicitEuler = enum.auto()
31
31
  RungeKutta4 = enum.auto()
32
+ RungeKutta4Fast = enum.auto()
32
33
 
33
34
 
34
35
  @jax_dataclasses.pytree_dataclass(eq=False, unsafe_hash=False)
@@ -57,6 +58,10 @@ class JaxSimModel(JaxsimDataclass):
57
58
  default=None, repr=False
58
59
  )
59
60
 
61
+ actuation_params: Static[jaxsim.rbda.actuation.ActuationParams] = dataclasses.field(
62
+ default=None, repr=False
63
+ )
64
+
60
65
  kin_dyn_parameters: js.kin_dyn_parameters.KinDynParameters | None = (
61
66
  dataclasses.field(default=None, repr=False)
62
67
  )
@@ -121,6 +126,7 @@ class JaxSimModel(JaxsimDataclass):
121
126
  terrain: jaxsim.terrain.Terrain | None = None,
122
127
  contact_model: jaxsim.rbda.contacts.ContactModel | None = None,
123
128
  contact_params: jaxsim.rbda.contacts.ContactsParams | None = None,
129
+ actuation_params: jaxsim.rbda.actuation.ActuationParams | None = None,
124
130
  integrator: IntegratorType | None = None,
125
131
  is_urdf: bool | None = None,
126
132
  considered_joints: Sequence[str] | None = None,
@@ -143,6 +149,7 @@ class JaxSimModel(JaxsimDataclass):
143
149
  The contact model to consider.
144
150
  If not specified, a soft contacts model is used.
145
151
  contact_params: The parameters of the contact model.
152
+ actuation_params: The parameters of the actuation model.
146
153
  integrator: The integrator to use for the simulation.
147
154
  is_urdf:
148
155
  The optional flag to force the model description to be parsed as a URDF.
@@ -177,6 +184,7 @@ class JaxSimModel(JaxsimDataclass):
177
184
  time_step=time_step,
178
185
  terrain=terrain,
179
186
  contact_model=contact_model,
187
+ actuation_params=actuation_params,
180
188
  contact_params=contact_params,
181
189
  integrator=integrator,
182
190
  gravity=-gravity,
@@ -198,6 +206,7 @@ class JaxSimModel(JaxsimDataclass):
198
206
  terrain: jaxsim.terrain.Terrain | None = None,
199
207
  contact_model: jaxsim.rbda.contacts.ContactModel | None = None,
200
208
  contact_params: jaxsim.rbda.contacts.ContactsParams | None = None,
209
+ actuation_params: jaxsim.rbda.actuation.ActuationParams | None = None,
201
210
  integrator: IntegratorType | None = None,
202
211
  gravity: jtp.FloatLike = jaxsim.math.STANDARD_GRAVITY,
203
212
  ) -> JaxSimModel:
@@ -219,6 +228,7 @@ class JaxSimModel(JaxsimDataclass):
219
228
  The contact model to consider.
220
229
  If not specified, a relaxed-constraints rigid contacts model is used.
221
230
  contact_params: The parameters of the contact model.
231
+ actuation_params: The parameters of the actuation model.
222
232
  integrator: The integrator to use for the simulation.
223
233
  gravity: The gravity constant.
224
234
 
@@ -255,6 +265,9 @@ class JaxSimModel(JaxsimDataclass):
255
265
  if contact_params is None:
256
266
  contact_params = contact_model._parameters_class()
257
267
 
268
+ if actuation_params is None:
269
+ actuation_params = jaxsim.rbda.actuation.ActuationParams()
270
+
258
271
  # Consider the default integrator if not specified.
259
272
  integrator = (
260
273
  integrator
@@ -272,6 +285,7 @@ class JaxSimModel(JaxsimDataclass):
272
285
  terrain=terrain,
273
286
  contact_model=contact_model,
274
287
  contact_params=contact_params,
288
+ actuation_params=actuation_params,
275
289
  integrator=integrator,
276
290
  gravity=gravity,
277
291
  # The following is wrapped as hashless since it's a static argument, and we
@@ -474,6 +488,7 @@ def reduce(
474
488
  terrain=model.terrain,
475
489
  contact_model=model.contact_model,
476
490
  contact_params=model.contact_params,
491
+ actuation_params=model.actuation_params,
477
492
  gravity=model.gravity,
478
493
  integrator=model.integrator,
479
494
  )
jaxsim/rbda/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
- from . import contacts
1
+ from . import actuation, contacts
2
2
  from .aba import aba
3
3
  from .collidable_points import collidable_points_pos_vel
4
4
  from .crba import crba
@@ -0,0 +1 @@
1
+ from .common import ActuationParams
@@ -0,0 +1,17 @@
1
+ import dataclasses
2
+
3
+ import jax_dataclasses
4
+
5
+ import jaxsim.typing as jtp
6
+ from jaxsim.utils import JaxsimDataclass
7
+
8
+
9
+ @jax_dataclasses.pytree_dataclass
10
+ class ActuationParams(JaxsimDataclass):
11
+ """
12
+ Parameters class for the actuation model.
13
+ """
14
+
15
+ torque_max: jtp.Float = dataclasses.field(default=3000.0) # (Nm)
16
+ omega_th: jtp.Float = dataclasses.field(default=30.0) # (rad/s)
17
+ omega_max: jtp.Float = dataclasses.field(default=100.0) # (rad/s)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: jaxsim
3
- Version: 0.6.2.dev242
3
+ Version: 0.6.2.dev259
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>, Filippo Luca Ferretti <filippoluca.ferretti@outlook.com>
6
6
  Maintainer-email: Filippo Luca Ferretti <filippo.ferretti@iit.it>, Alessandro Croci <alessandro.croci@iit.it>
@@ -1,20 +1,20 @@
1
1
  jaxsim/__init__.py,sha256=b8dYoVXqtHxHcF56iM2xgKk78lsvmGrfDlvdwaGasgs,3388
2
- jaxsim/_version.py,sha256=vZazis7OZ6eA6f7PvDT2Iy5DGWPVUNPck7GOrlZkMro,528
2
+ jaxsim/_version.py,sha256=1sA1P-zDJFr36_7sVys2Js5b7_L1PGjlSUIpxd4AKm4,528
3
3
  jaxsim/exceptions.py,sha256=MQ3LRMfVMX2-g3qYj7mUVNV9OLlIA48TANJegbcQyXI,2641
4
4
  jaxsim/logging.py,sha256=STI-D_upXZYX-ZezLrlJJ0UlD5YspST0vZ_DcIwkzO4,1553
5
5
  jaxsim/typing.py,sha256=7msl8t5Jt09RNYfKdPJtpjLfWurldcycDappb045Eso,761
6
6
  jaxsim/api/__init__.py,sha256=4skzcTTejLFfZ_JE6yEEyNxObpXnR5u-bYsn2lBEx-4,234
7
- jaxsim/api/actuation_model.py,sha256=L8AzxIiEquWeG8UGGJaYr2Alt4dkkOROlbsCn9hUYik,2825
7
+ jaxsim/api/actuation_model.py,sha256=GgLi-yhEpsczwhMNYIlMvet8tirmmED6S7AumbSbk4U,3705
8
8
  jaxsim/api/com.py,sha256=47a9SSaXY540RCkVnHodwLNUrodIfJIkguIYdSEQVwQ,13697
9
9
  jaxsim/api/common.py,sha256=yTaRXDYkXmISBOhZ93f9TssR0p4wq7qj7B6OsvYzRME,6942
10
10
  jaxsim/api/contact.py,sha256=dlKKDQUG-KQ5qQaYBv2NmZLDb1OnJdltZv8MWXkD_W0,20969
11
- jaxsim/api/data.py,sha256=KBDN7zFrNDSkry3Pow1LdBZ6kmfwk7dR5jaLA6DNAVc,23468
11
+ jaxsim/api/data.py,sha256=9pxug2gFIZPwqi9kNYXhEziA5IQBB9KNNwIfPfc_kAU,23249
12
12
  jaxsim/api/frame.py,sha256=4wg6GsyBQgYhSvc-ry_31JsaL66sZt3TtgwjB7NrHmk,14583
13
- jaxsim/api/integrators.py,sha256=DgOnzLepy45e-TM6Infk8qfPXn0r8GubCdJQZmNLP8w,5269
13
+ jaxsim/api/integrators.py,sha256=sHdTWw2Z-Q7jggA8zRkA1KYYd4HNIozXPwNvFwt0YBs,9011
14
14
  jaxsim/api/joint.py,sha256=AnqlNWmBOay-gsoo0y4AbfFQ2OCJm-8T1E0IMhZeLoY,7457
15
15
  jaxsim/api/kin_dyn_parameters.py,sha256=v1ZDb-Eqn552Zb344sJYy9e5sQT--_SYGIdtNC2JVSg,29828
16
16
  jaxsim/api/link.py,sha256=bSZOYJDY9HJMgY25VzevTTsdFZTJc6yRRpslc5FhGHE,12782
17
- jaxsim/api/model.py,sha256=LkhQaN4ZgoQUOTTtDaa4y689vTF14VCeVeaqCkjB_t8,69237
17
+ jaxsim/api/model.py,sha256=Do5q7vSyml854wFyN21qJtNfJfFo7TlEfxx_FoTxOW0,69948
18
18
  jaxsim/api/ode.py,sha256=fp20_LK9lXw2DfNkQgrfJmtd_iBXDNzZkOn0u5Pm8Qw,6190
19
19
  jaxsim/api/references.py,sha256=-vd50y3v-jkXAsILS432etIKV6e2EUE2oOeLHuUrfuQ,20399
20
20
  jaxsim/math/__init__.py,sha256=dNozvtm8WsB7nxw4uK29yQQKPcDUEczr2zcHoZfMItc,383
@@ -44,7 +44,7 @@ jaxsim/parsers/rod/__init__.py,sha256=G2vqlLajBLUc4gyzXwsEI2Wsi4TMOIF9bLDFeT6KrG
44
44
  jaxsim/parsers/rod/meshes.py,sha256=yAXefG73_zqbVKRUdlcz9yFmypjDIpiP9cO96PeAozE,2842
45
45
  jaxsim/parsers/rod/parser.py,sha256=vaOlvlvgQCEGbymFc21praHKEVq_LqqlKeRJNv7tZiE,14398
46
46
  jaxsim/parsers/rod/utils.py,sha256=wmD-wCF1lLO8pknX7A3a8CGt9wDlTS_xCqQulcZ_XlM,8242
47
- jaxsim/rbda/__init__.py,sha256=nQ01ALTXm8lJAb5flCOzxfjyDZPbDrP4H3v-xlfyCss,317
47
+ jaxsim/rbda/__init__.py,sha256=ksfupKZzeJyysxrbyMyEfszUdBH6LfCfkSz3KLfODhY,328
48
48
  jaxsim/rbda/aba.py,sha256=QiajR4Uv06u-BX5V2kWpmFmP_kIfTxxcycdJhIbid9A,9029
49
49
  jaxsim/rbda/collidable_points.py,sha256=XyeV1I43GL22j03rkNVocaIPOGYirt3PiDHrFMndziQ,2070
50
50
  jaxsim/rbda/crba.py,sha256=DC9kBXMG1qXaoAdo8K7OCnVHT_YUaL_t6Li56sRf8ro,5093
@@ -52,6 +52,8 @@ jaxsim/rbda/forward_kinematics.py,sha256=qem7Yp-B2oNVOsU3Q2CWV2tbfZKJOCAdDozFgaP
52
52
  jaxsim/rbda/jacobian.py,sha256=EaMvf073UnLWJGXm4UZIlYd4erulFAGgj_pp89k6xic,11113
53
53
  jaxsim/rbda/rnea.py,sha256=lMU7xxdPqGGzk0QwteB-IYjL4auHOpd78C1YqAXlp9s,7588
54
54
  jaxsim/rbda/utils.py,sha256=6JwEDQqLMsBX7CUmPYEhdPEscXmGbWVYg6xEriPOgvE,5587
55
+ jaxsim/rbda/actuation/__init__.py,sha256=zWqB8VBHadbyf8FAuhQtcfWdetGjfVxuNDwIeUqNOS4,36
56
+ jaxsim/rbda/actuation/common.py,sha256=aGFqO4VTgQLsTJyOtVuoa_otT_RbkckmG3rq7wjOyB4,462
55
57
  jaxsim/rbda/contacts/__init__.py,sha256=resrBkTdOA-1YMdcdUH2RATEhAf_Ye6MQNtjG3ClMYQ,371
56
58
  jaxsim/rbda/contacts/common.py,sha256=qVm3Ghoytg1HAeykNrYw5-4rQJ4Mv7h0Pk75ETzGXyc,9045
57
59
  jaxsim/rbda/contacts/relaxed_rigid.py,sha256=RjeLF06Pp19qio447U9z5EdhdM6nyMh-ISQX_2-vdaE,21349
@@ -63,8 +65,8 @@ jaxsim/utils/__init__.py,sha256=Y5zyoRevl3EMVQadhZ4EtSwTEkDt2vcnFoRhPJjKTZ0,215
63
65
  jaxsim/utils/jaxsim_dataclass.py,sha256=XzmZeIibcaOzaxpprsGSxH3UrM66PAO456rFV91sNXg,11453
64
66
  jaxsim/utils/tracing.py,sha256=Btwxdfhb7fJLk3r5PlQkGYj60Y2KbFT1gANGIA697FU,530
65
67
  jaxsim/utils/wrappers.py,sha256=3IMwydqFgmSPqeuUQ3PRmdhDc1IoT6XC23jPC_LjWXs,4175
66
- jaxsim-0.6.2.dev242.dist-info/licenses/LICENSE,sha256=eaYdFmdeMbiIoIiPzEK0MjP1S9wtFXjXNR5er49uLR0,1546
67
- jaxsim-0.6.2.dev242.dist-info/METADATA,sha256=8qj1EBcMxGgcBZjcpo10JBT2pOlB2OrG9AlQpS7KVcg,19658
68
- jaxsim-0.6.2.dev242.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
69
- jaxsim-0.6.2.dev242.dist-info/top_level.txt,sha256=LxGMA8FLtXjQ6oI7N5gd_R_oSUHxpXxUEOfT1xS_ni0,7
70
- jaxsim-0.6.2.dev242.dist-info/RECORD,,
68
+ jaxsim-0.6.2.dev259.dist-info/licenses/LICENSE,sha256=eaYdFmdeMbiIoIiPzEK0MjP1S9wtFXjXNR5er49uLR0,1546
69
+ jaxsim-0.6.2.dev259.dist-info/METADATA,sha256=CTrShzNClPaRmA6R8VKttAgDC49h7V_TuWOk_Ry73Zc,19658
70
+ jaxsim-0.6.2.dev259.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
71
+ jaxsim-0.6.2.dev259.dist-info/top_level.txt,sha256=LxGMA8FLtXjQ6oI7N5gd_R_oSUHxpXxUEOfT1xS_ni0,7
72
+ jaxsim-0.6.2.dev259.dist-info/RECORD,,