jaxsim 0.6.2.dev253__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.dev253'
21
- __version_tuple__ = version_tuple = (0, 6, 2, 'dev253')
20
+ __version__ = version = '0.6.2.dev259'
21
+ __version_tuple__ = version_tuple = (0, 6, 2, 'dev259')
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)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: jaxsim
3
- Version: 0.6.2.dev253
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,5 +1,5 @@
1
1
  jaxsim/__init__.py,sha256=b8dYoVXqtHxHcF56iM2xgKk78lsvmGrfDlvdwaGasgs,3388
2
- jaxsim/_version.py,sha256=tso8wO5VrX4RPYa0ZLA_aUJ6ylncC96kilEqh4mUO5U,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
@@ -8,13 +8,13 @@ jaxsim/api/actuation_model.py,sha256=GgLi-yhEpsczwhMNYIlMvet8tirmmED6S7AumbSbk4U
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=rZK8YigkM1pHxx0Aj9AJDpFma7I_pNgcs8lzPF8ukUk,69914
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
@@ -65,8 +65,8 @@ jaxsim/utils/__init__.py,sha256=Y5zyoRevl3EMVQadhZ4EtSwTEkDt2vcnFoRhPJjKTZ0,215
65
65
  jaxsim/utils/jaxsim_dataclass.py,sha256=XzmZeIibcaOzaxpprsGSxH3UrM66PAO456rFV91sNXg,11453
66
66
  jaxsim/utils/tracing.py,sha256=Btwxdfhb7fJLk3r5PlQkGYj60Y2KbFT1gANGIA697FU,530
67
67
  jaxsim/utils/wrappers.py,sha256=3IMwydqFgmSPqeuUQ3PRmdhDc1IoT6XC23jPC_LjWXs,4175
68
- jaxsim-0.6.2.dev253.dist-info/licenses/LICENSE,sha256=eaYdFmdeMbiIoIiPzEK0MjP1S9wtFXjXNR5er49uLR0,1546
69
- jaxsim-0.6.2.dev253.dist-info/METADATA,sha256=F_UAPp-S0HPegiLJOZ2yiiu8y1qQRmIIqzwYiiuiieM,19658
70
- jaxsim-0.6.2.dev253.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
71
- jaxsim-0.6.2.dev253.dist-info/top_level.txt,sha256=LxGMA8FLtXjQ6oI7N5gd_R_oSUHxpXxUEOfT1xS_ni0,7
72
- jaxsim-0.6.2.dev253.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,,