jaxsim 0.2.dev101__py3-none-any.whl → 0.2.dev166__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/__init__.py +1 -0
- jaxsim/api/contact.py +194 -0
- jaxsim/api/data.py +951 -0
- jaxsim/api/joint.py +148 -0
- jaxsim/api/link.py +262 -0
- jaxsim/api/model.py +1099 -0
- jaxsim/api/ode.py +280 -0
- jaxsim/integrators/__init__.py +2 -0
- jaxsim/integrators/common.py +508 -0
- jaxsim/integrators/fixed_step.py +158 -0
- jaxsim/mujoco/__init__.py +1 -1
- jaxsim/mujoco/loaders.py +30 -18
- jaxsim/mujoco/visualizer.py +3 -1
- jaxsim/physics/algos/soft_contacts.py +97 -28
- jaxsim/physics/model/physics_model.py +30 -0
- jaxsim/physics/model/physics_model_state.py +110 -11
- jaxsim/simulation/ode_data.py +43 -0
- {jaxsim-0.2.dev101.dist-info → jaxsim-0.2.dev166.dist-info}/METADATA +2 -1
- {jaxsim-0.2.dev101.dist-info → jaxsim-0.2.dev166.dist-info}/RECORD +23 -13
- {jaxsim-0.2.dev101.dist-info → jaxsim-0.2.dev166.dist-info}/LICENSE +0 -0
- {jaxsim-0.2.dev101.dist-info → jaxsim-0.2.dev166.dist-info}/WHEEL +0 -0
- {jaxsim-0.2.dev101.dist-info → jaxsim-0.2.dev166.dist-info}/top_level.txt +0 -0
jaxsim/mujoco/loaders.py
CHANGED
@@ -387,30 +387,42 @@ class RodModelToMjcf:
|
|
387
387
|
dir="0 0 -1",
|
388
388
|
)
|
389
389
|
|
390
|
+
# -------------------------------------------------------
|
391
|
+
# Add a camera following the CoM of the worldbody element
|
392
|
+
# -------------------------------------------------------
|
393
|
+
|
394
|
+
worldbody_element = None
|
395
|
+
|
396
|
+
# Find the <worldbody> element of our model by searching the one that contains
|
397
|
+
# all the considered joints. This is needed because there might be multiple
|
398
|
+
# <worldbody> elements inside <mujoco>.
|
399
|
+
for wb in mujoco_element.findall(".//worldbody"):
|
400
|
+
if all(
|
401
|
+
wb.find(f".//joint[@name='{j}']") is not None for j in considered_joints
|
402
|
+
):
|
403
|
+
worldbody_element = wb
|
404
|
+
break
|
405
|
+
|
406
|
+
if worldbody_element is None:
|
407
|
+
raise RuntimeError("Failed to find the <worldbody> element of the model")
|
408
|
+
|
409
|
+
# Camera attached to the model
|
410
|
+
_ = ET.SubElement(
|
411
|
+
worldbody_element,
|
412
|
+
"camera",
|
413
|
+
name="track",
|
414
|
+
mode="trackcom",
|
415
|
+
pos="1 0 5",
|
416
|
+
zaxis="0 0 1",
|
417
|
+
fovy="60",
|
418
|
+
)
|
419
|
+
|
390
420
|
# ------------------------------------------------
|
391
421
|
# Add a light following the CoM of the first link
|
392
422
|
# ------------------------------------------------
|
393
423
|
|
394
424
|
if not rod_model.is_fixed_base():
|
395
425
|
|
396
|
-
worldbody_element = None
|
397
|
-
|
398
|
-
# Find the <worldbody> element of our model by searching the one that contains
|
399
|
-
# all the considered joints. This is needed because there might be multiple
|
400
|
-
# <worldbody> elements inside <mujoco>.
|
401
|
-
for wb in mujoco_element.findall(".//worldbody"):
|
402
|
-
if all(
|
403
|
-
wb.find(f".//joint[@name='{j}']") is not None
|
404
|
-
for j in considered_joints
|
405
|
-
):
|
406
|
-
worldbody_element = wb
|
407
|
-
break
|
408
|
-
|
409
|
-
if worldbody_element is None:
|
410
|
-
raise RuntimeError(
|
411
|
-
"Failed to find the <worldbody> element of the model"
|
412
|
-
)
|
413
|
-
|
414
426
|
# Light attached to the model
|
415
427
|
_ = ET.SubElement(
|
416
428
|
worldbody_element,
|
jaxsim/mujoco/visualizer.py
CHANGED
@@ -54,14 +54,16 @@ class MujocoVideoRecorder:
|
|
54
54
|
|
55
55
|
def render_frame(self, camera_name: str | None = None) -> npt.NDArray:
|
56
56
|
""""""
|
57
|
+
camera_name = camera_name or "track"
|
57
58
|
|
58
59
|
mujoco.mj_forward(self.model, self.data)
|
59
|
-
self.renderer.update_scene(data=self.data
|
60
|
+
self.renderer.update_scene(data=self.data, camera=camera_name)
|
60
61
|
|
61
62
|
return self.renderer.render()
|
62
63
|
|
63
64
|
def record_frame(self, camera_name: str | None = None) -> None:
|
64
65
|
""""""
|
66
|
+
camera_name = camera_name or "track"
|
65
67
|
|
66
68
|
frame = self.render_frame(camera_name=camera_name)
|
67
69
|
self.frames.append(frame)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
1
3
|
import dataclasses
|
2
4
|
from typing import Tuple
|
3
5
|
|
@@ -13,38 +15,67 @@ from jaxsim.math.adjoint import Adjoint
|
|
13
15
|
from jaxsim.math.skew import Skew
|
14
16
|
from jaxsim.physics.algos.terrain import FlatTerrain, Terrain
|
15
17
|
from jaxsim.physics.model.physics_model import PhysicsModel
|
18
|
+
from jaxsim.utils.jaxsim_dataclass import JaxsimDataclass
|
16
19
|
|
17
20
|
from . import utils
|
18
21
|
|
19
22
|
|
20
23
|
@jax_dataclasses.pytree_dataclass
|
21
|
-
class SoftContactsState:
|
24
|
+
class SoftContactsState(JaxsimDataclass):
|
22
25
|
"""
|
23
26
|
State of the soft contacts model.
|
24
27
|
|
25
28
|
Attributes:
|
26
|
-
tangential_deformation
|
29
|
+
tangential_deformation:
|
30
|
+
The tangential deformation of the material at each collidable point.
|
27
31
|
"""
|
28
32
|
|
29
33
|
tangential_deformation: jtp.Matrix
|
30
34
|
|
35
|
+
@staticmethod
|
36
|
+
def build(
|
37
|
+
tangential_deformation: jtp.Matrix | None = None,
|
38
|
+
number_of_collidable_points: int | None = None,
|
39
|
+
) -> SoftContactsState:
|
40
|
+
""""""
|
41
|
+
|
42
|
+
tangential_deformation = (
|
43
|
+
tangential_deformation
|
44
|
+
if tangential_deformation is not None
|
45
|
+
else jnp.zeros(shape=(3, number_of_collidable_points))
|
46
|
+
)
|
47
|
+
|
48
|
+
return SoftContactsState(
|
49
|
+
tangential_deformation=jnp.array(tangential_deformation, dtype=float)
|
50
|
+
)
|
51
|
+
|
52
|
+
@staticmethod
|
53
|
+
def build_from_physics_model(
|
54
|
+
tangential_deformation: jtp.Matrix | None = None,
|
55
|
+
physics_model: jaxsim.physics.model.physics_model.PhysicsModel | None = None,
|
56
|
+
) -> SoftContactsState:
|
57
|
+
""""""
|
58
|
+
|
59
|
+
return SoftContactsState.build(
|
60
|
+
tangential_deformation=tangential_deformation,
|
61
|
+
number_of_collidable_points=physics_model.gc.body.size,
|
62
|
+
)
|
63
|
+
|
31
64
|
@staticmethod
|
32
65
|
def zero(
|
33
66
|
physics_model: jaxsim.physics.model.physics_model.PhysicsModel,
|
34
|
-
) ->
|
67
|
+
) -> SoftContactsState:
|
35
68
|
"""
|
36
69
|
Modify the SoftContactsState instance imposing zero tangential deformation.
|
37
70
|
|
38
71
|
Args:
|
39
|
-
physics_model
|
72
|
+
physics_model: The physics model.
|
40
73
|
|
41
74
|
Returns:
|
42
|
-
|
75
|
+
A SoftContactsState instance with zero tangential deformation.
|
43
76
|
"""
|
44
77
|
|
45
|
-
return SoftContactsState(
|
46
|
-
tangential_deformation=jnp.zeros(shape=(3, physics_model.gc.body.size))
|
47
|
-
)
|
78
|
+
return SoftContactsState.build_from_physics_model(physics_model=physics_model)
|
48
79
|
|
49
80
|
def valid(
|
50
81
|
self, physics_model: jaxsim.physics.model.physics_model.PhysicsModel
|
@@ -53,10 +84,10 @@ class SoftContactsState:
|
|
53
84
|
Check if the soft contacts state has valid shape.
|
54
85
|
|
55
86
|
Args:
|
56
|
-
physics_model
|
87
|
+
physics_model: The physics model.
|
57
88
|
|
58
89
|
Returns:
|
59
|
-
|
90
|
+
True if the state has a valid shape, otherwise False.
|
60
91
|
"""
|
61
92
|
|
62
93
|
from jaxsim.simulation.utils import check_valid_shape
|
@@ -68,22 +99,6 @@ class SoftContactsState:
|
|
68
99
|
valid=True,
|
69
100
|
)
|
70
101
|
|
71
|
-
def replace(self, validate: bool = True, **kwargs) -> "SoftContactsState":
|
72
|
-
"""
|
73
|
-
Replace attributes of the soft contacts state.
|
74
|
-
|
75
|
-
Args:
|
76
|
-
validate (bool, optional): Whether to validate the state after replacement. Defaults to True.
|
77
|
-
|
78
|
-
Returns:
|
79
|
-
SoftContactsState: A new SoftContactsState instance with replaced attributes.
|
80
|
-
"""
|
81
|
-
|
82
|
-
with jax_dataclasses.copy_and_mutate(self, validate=validate) as updated_state:
|
83
|
-
_ = [updated_state.__setattr__(k, v) for k, v in kwargs.items()]
|
84
|
-
|
85
|
-
return updated_state
|
86
|
-
|
87
102
|
|
88
103
|
def collidable_points_pos_vel(
|
89
104
|
model: PhysicsModel,
|
@@ -238,8 +253,8 @@ class SoftContactsParams:
|
|
238
253
|
|
239
254
|
@staticmethod
|
240
255
|
def build(
|
241
|
-
K:
|
242
|
-
) ->
|
256
|
+
K: jtp.FloatLike = 1e6, D: jtp.FloatLike = 2_000, mu: jtp.FloatLike = 0.5
|
257
|
+
) -> SoftContactsParams:
|
243
258
|
"""
|
244
259
|
Create a SoftContactsParams instance with specified parameters.
|
245
260
|
|
@@ -258,6 +273,60 @@ class SoftContactsParams:
|
|
258
273
|
mu=jnp.array(mu, dtype=float),
|
259
274
|
)
|
260
275
|
|
276
|
+
@staticmethod
|
277
|
+
def build_default_from_physics_model(
|
278
|
+
physics_model: PhysicsModel,
|
279
|
+
static_friction_coefficient: jtp.FloatLike = 0.5,
|
280
|
+
max_penetration: jtp.FloatLike = 0.001,
|
281
|
+
number_of_active_collidable_points_steady_state: jtp.IntLike = 1,
|
282
|
+
damping_ratio: jtp.FloatLike = 1.0,
|
283
|
+
) -> SoftContactsParams:
|
284
|
+
"""
|
285
|
+
Create a SoftContactsParams instance with good default parameters.
|
286
|
+
|
287
|
+
Args:
|
288
|
+
physics_model: The target physics model.
|
289
|
+
static_friction_coefficient: The static friction coefficient.
|
290
|
+
max_penetration: The maximum penetration depth.
|
291
|
+
number_of_active_collidable_points_steady_state: The number of contacts
|
292
|
+
supporting the weight of the model in steady state.
|
293
|
+
damping_ratio: The ratio controlling the damping behavior.
|
294
|
+
|
295
|
+
Returns:
|
296
|
+
A SoftContactsParams instance with the specified parameters.
|
297
|
+
|
298
|
+
Note:
|
299
|
+
The `damping_ratio` parameter allows to operate on the following conditions:
|
300
|
+
- ξ > 1.0: over-damped
|
301
|
+
- ξ = 1.0: critically damped
|
302
|
+
- ξ < 1.0: under-damped
|
303
|
+
"""
|
304
|
+
|
305
|
+
# Use symbols for input parameters
|
306
|
+
ξ = damping_ratio
|
307
|
+
δ_max = max_penetration
|
308
|
+
μc = static_friction_coefficient
|
309
|
+
|
310
|
+
# Compute the total mass of the model
|
311
|
+
m = jnp.array(
|
312
|
+
[l.mass for l in physics_model.description.links_dict.values()]
|
313
|
+
).sum()
|
314
|
+
|
315
|
+
# Extract gravity
|
316
|
+
g = -physics_model.gravity[0:3][-1]
|
317
|
+
|
318
|
+
# Compute the average support force on each collidable point
|
319
|
+
f_average = m * g / number_of_active_collidable_points_steady_state
|
320
|
+
|
321
|
+
# Compute the stiffness to get the desired steady-state penetration
|
322
|
+
K = f_average / jnp.power(δ_max, 3 / 2)
|
323
|
+
|
324
|
+
# Compute the damping using the damping ratio
|
325
|
+
critical_damping = 2 * jnp.sqrt(K * m)
|
326
|
+
D = ξ * critical_damping
|
327
|
+
|
328
|
+
return SoftContactsParams.build(K=K, D=D, mu=μc)
|
329
|
+
|
261
330
|
|
262
331
|
@jax_dataclasses.pytree_dataclass
|
263
332
|
class SoftContacts:
|
@@ -70,11 +70,41 @@ class PhysicsModel(JaxsimDataclass):
|
|
70
70
|
default_factory=dict
|
71
71
|
)
|
72
72
|
|
73
|
+
_link_masses: jtp.Vector = dataclasses.field(init=False)
|
74
|
+
_link_spatial_inertias: jtp.Vector = dataclasses.field(init=False)
|
75
|
+
_joint_position_limits_min: jtp.Matrix = dataclasses.field(init=False)
|
76
|
+
_joint_position_limits_max: jtp.Matrix = dataclasses.field(init=False)
|
77
|
+
|
73
78
|
def __post_init__(self):
|
74
79
|
if self.initial_state is None:
|
75
80
|
initial_state = PhysicsModelState.zero(physics_model=self)
|
76
81
|
object.__setattr__(self, "initial_state", initial_state)
|
77
82
|
|
83
|
+
ordered_links = sorted(
|
84
|
+
list(self.description.links_dict.values()),
|
85
|
+
key=lambda l: l.index,
|
86
|
+
)
|
87
|
+
|
88
|
+
ordered_joints = sorted(
|
89
|
+
list(self.description.joints_dict.values()),
|
90
|
+
key=lambda j: j.index,
|
91
|
+
)
|
92
|
+
|
93
|
+
from jaxsim.utils import Mutability
|
94
|
+
|
95
|
+
with self.mutable_context(
|
96
|
+
mutability=Mutability.MUTABLE_NO_VALIDATION, restore_after_exception=False
|
97
|
+
):
|
98
|
+
self._link_masses = jnp.stack([link.mass for link in ordered_links])
|
99
|
+
self._link_spatial_inertias = jnp.stack(
|
100
|
+
[self._link_inertias_dict[l.index] for l in ordered_links]
|
101
|
+
)
|
102
|
+
|
103
|
+
s_min = jnp.hstack([j.position_limit[0] for j in ordered_joints])
|
104
|
+
s_max = jnp.hstack([j.position_limit[1] for j in ordered_joints])
|
105
|
+
self._joint_position_limits_min = jnp.vstack([s_min, s_max]).min(axis=0)
|
106
|
+
self._joint_position_limits_max = jnp.vstack([s_min, s_max]).max(axis=0)
|
107
|
+
|
78
108
|
@staticmethod
|
79
109
|
def build_from(
|
80
110
|
model_description: jaxsim.parsers.descriptions.model.ModelDescription,
|
@@ -1,3 +1,5 @@
|
|
1
|
+
from typing import Union
|
2
|
+
|
1
3
|
import jax.numpy as jnp
|
2
4
|
import jax_dataclasses
|
3
5
|
|
@@ -41,14 +43,86 @@ class PhysicsModelState(JaxsimDataclass):
|
|
41
43
|
default_factory=lambda: jnp.zeros(3)
|
42
44
|
)
|
43
45
|
|
46
|
+
@staticmethod
|
47
|
+
def build(
|
48
|
+
joint_positions: jtp.Vector | None = None,
|
49
|
+
joint_velocities: jtp.Vector | None = None,
|
50
|
+
base_position: jtp.Vector | None = None,
|
51
|
+
base_quaternion: jtp.Vector | None = None,
|
52
|
+
base_linear_velocity: jtp.Vector | None = None,
|
53
|
+
base_angular_velocity: jtp.Vector | None = None,
|
54
|
+
number_of_dofs: jtp.Int | None = None,
|
55
|
+
) -> "PhysicsModelState":
|
56
|
+
""""""
|
57
|
+
|
58
|
+
joint_positions = (
|
59
|
+
joint_positions
|
60
|
+
if joint_positions is not None
|
61
|
+
else jnp.zeros(number_of_dofs)
|
62
|
+
)
|
63
|
+
|
64
|
+
joint_velocities = (
|
65
|
+
joint_velocities
|
66
|
+
if joint_velocities is not None
|
67
|
+
else jnp.zeros(number_of_dofs)
|
68
|
+
)
|
69
|
+
|
70
|
+
base_position = base_position if base_position is not None else jnp.zeros(3)
|
71
|
+
|
72
|
+
base_quaternion = (
|
73
|
+
base_quaternion
|
74
|
+
if base_quaternion is not None
|
75
|
+
else jnp.array([1.0, 0, 0, 0])
|
76
|
+
)
|
77
|
+
|
78
|
+
base_linear_velocity = (
|
79
|
+
base_linear_velocity if base_linear_velocity is not None else jnp.zeros(3)
|
80
|
+
)
|
81
|
+
|
82
|
+
base_angular_velocity = (
|
83
|
+
base_angular_velocity if base_angular_velocity is not None else jnp.zeros(3)
|
84
|
+
)
|
85
|
+
|
86
|
+
physics_model_state = PhysicsModelState(
|
87
|
+
joint_positions=jnp.array(joint_positions, dtype=float),
|
88
|
+
joint_velocities=jnp.array(joint_velocities, dtype=float),
|
89
|
+
base_position=jnp.array(base_position, dtype=float),
|
90
|
+
base_quaternion=jnp.array(base_quaternion, dtype=float),
|
91
|
+
base_linear_velocity=jnp.array(base_linear_velocity, dtype=float),
|
92
|
+
base_angular_velocity=jnp.array(base_angular_velocity, dtype=float),
|
93
|
+
)
|
94
|
+
|
95
|
+
return physics_model_state
|
96
|
+
|
97
|
+
@staticmethod
|
98
|
+
def build_from_physics_model(
|
99
|
+
joint_positions: jtp.Vector | None = None,
|
100
|
+
joint_velocities: jtp.Vector | None = None,
|
101
|
+
base_position: jtp.Vector | None = None,
|
102
|
+
base_quaternion: jtp.Vector | None = None,
|
103
|
+
base_linear_velocity: jtp.Vector | None = None,
|
104
|
+
base_angular_velocity: jtp.Vector | None = None,
|
105
|
+
physics_model: Union[
|
106
|
+
"jaxsim.physics.model.physics_model.PhysicsModel", None
|
107
|
+
] = None,
|
108
|
+
) -> "PhysicsModelState":
|
109
|
+
""""""
|
110
|
+
|
111
|
+
return PhysicsModelState.build(
|
112
|
+
joint_positions=joint_positions,
|
113
|
+
joint_velocities=joint_velocities,
|
114
|
+
base_position=base_position,
|
115
|
+
base_quaternion=base_quaternion,
|
116
|
+
base_linear_velocity=base_linear_velocity,
|
117
|
+
base_angular_velocity=base_angular_velocity,
|
118
|
+
number_of_dofs=physics_model.dofs(),
|
119
|
+
)
|
120
|
+
|
44
121
|
@staticmethod
|
45
122
|
def zero(
|
46
123
|
physics_model: "jaxsim.physics.model.physics_model.PhysicsModel",
|
47
124
|
) -> "PhysicsModelState":
|
48
|
-
return PhysicsModelState(
|
49
|
-
joint_positions=jnp.zeros(physics_model.dofs()),
|
50
|
-
joint_velocities=jnp.zeros(physics_model.dofs()),
|
51
|
-
)
|
125
|
+
return PhysicsModelState.build_from_physics_model(physics_model=physics_model)
|
52
126
|
|
53
127
|
def position(self) -> jtp.Vector:
|
54
128
|
return jnp.hstack(
|
@@ -143,16 +217,41 @@ class PhysicsModelInput(JaxsimDataclass):
|
|
143
217
|
f_ext: jtp.MatrixJax
|
144
218
|
|
145
219
|
@staticmethod
|
146
|
-
def
|
147
|
-
|
220
|
+
def build(
|
221
|
+
tau: jtp.VectorJax | None = None,
|
222
|
+
f_ext: jtp.MatrixJax | None = None,
|
223
|
+
number_of_dofs: jtp.Int | None = None,
|
224
|
+
number_of_links: jtp.Int | None = None,
|
148
225
|
) -> "PhysicsModelInput":
|
149
|
-
|
150
|
-
|
151
|
-
|
226
|
+
""""""
|
227
|
+
|
228
|
+
tau = tau if tau is not None else jnp.zeros(number_of_dofs)
|
229
|
+
f_ext = f_ext if f_ext is not None else jnp.zeros(shape=(number_of_links, 6))
|
230
|
+
|
231
|
+
return PhysicsModelInput(
|
232
|
+
tau=jnp.array(tau, dtype=float), f_ext=jnp.array(f_ext, dtype=float)
|
152
233
|
)
|
153
234
|
|
154
|
-
|
155
|
-
|
235
|
+
@staticmethod
|
236
|
+
def build_from_physics_model(
|
237
|
+
tau: jtp.VectorJax | None = None,
|
238
|
+
f_ext: jtp.MatrixJax | None = None,
|
239
|
+
physics_model: Union[
|
240
|
+
"jaxsim.physics.model.physics_model.PhysicsModel", None
|
241
|
+
] = None,
|
242
|
+
) -> "PhysicsModelInput":
|
243
|
+
return PhysicsModelInput.build(
|
244
|
+
tau=tau,
|
245
|
+
f_ext=f_ext,
|
246
|
+
number_of_dofs=physics_model.dofs(),
|
247
|
+
number_of_links=physics_model.NB,
|
248
|
+
)
|
249
|
+
|
250
|
+
@staticmethod
|
251
|
+
def zero(
|
252
|
+
physics_model: "jaxsim.physics.model.physics_model.PhysicsModel",
|
253
|
+
) -> "PhysicsModelInput":
|
254
|
+
return PhysicsModelInput.build_from_physics_model(physics_model=physics_model)
|
156
255
|
|
157
256
|
def replace(self, validate: bool = True, **kwargs) -> "PhysicsModelInput":
|
158
257
|
with jax_dataclasses.copy_and_mutate(self, validate=validate) as updated_input:
|
jaxsim/simulation/ode_data.py
CHANGED
@@ -13,8 +13,25 @@ from jaxsim.utils import JaxsimDataclass
|
|
13
13
|
|
14
14
|
@jax_dataclasses.pytree_dataclass
|
15
15
|
class ODEInput(JaxsimDataclass):
|
16
|
+
""""""
|
17
|
+
|
16
18
|
physics_model: PhysicsModelInput
|
17
19
|
|
20
|
+
@staticmethod
|
21
|
+
def build(
|
22
|
+
physics_model_input: PhysicsModelInput | None = None,
|
23
|
+
physics_model: PhysicsModel | None = None,
|
24
|
+
) -> "ODEInput":
|
25
|
+
""""""
|
26
|
+
|
27
|
+
physics_model_input = (
|
28
|
+
physics_model_input
|
29
|
+
if physics_model_input is not None
|
30
|
+
else PhysicsModelInput.zero(physics_model=physics_model)
|
31
|
+
)
|
32
|
+
|
33
|
+
return ODEInput(physics_model=physics_model_input)
|
34
|
+
|
18
35
|
@staticmethod
|
19
36
|
def zero(physics_model: PhysicsModel) -> "ODEInput":
|
20
37
|
return ODEInput(
|
@@ -27,9 +44,35 @@ class ODEInput(JaxsimDataclass):
|
|
27
44
|
|
28
45
|
@jax_dataclasses.pytree_dataclass
|
29
46
|
class ODEState(JaxsimDataclass):
|
47
|
+
""""""
|
48
|
+
|
30
49
|
physics_model: PhysicsModelState
|
31
50
|
soft_contacts: SoftContactsState
|
32
51
|
|
52
|
+
@staticmethod
|
53
|
+
def build(
|
54
|
+
physics_model_state: PhysicsModelState | None = None,
|
55
|
+
soft_contacts_state: SoftContactsState | None = None,
|
56
|
+
physics_model: PhysicsModel | None = None,
|
57
|
+
) -> "ODEState":
|
58
|
+
""""""
|
59
|
+
|
60
|
+
physics_model_state = (
|
61
|
+
physics_model_state
|
62
|
+
if physics_model_state is not None
|
63
|
+
else PhysicsModelState.zero(physics_model=physics_model)
|
64
|
+
)
|
65
|
+
|
66
|
+
soft_contacts_state = (
|
67
|
+
soft_contacts_state
|
68
|
+
if soft_contacts_state is not None
|
69
|
+
else SoftContactsState.zero(physics_model=physics_model)
|
70
|
+
)
|
71
|
+
|
72
|
+
return ODEState(
|
73
|
+
physics_model=physics_model_state, soft_contacts=soft_contacts_state
|
74
|
+
)
|
75
|
+
|
33
76
|
@staticmethod
|
34
77
|
def deserialize(data: jtp.VectorJax, physics_model: PhysicsModel) -> "ODEState":
|
35
78
|
dummy_object = ODEState.zero(physics_model=physics_model)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: jaxsim
|
3
|
-
Version: 0.2.
|
3
|
+
Version: 0.2.dev166
|
4
4
|
Summary: A physics engine in reduced coordinates implemented with JAX.
|
5
5
|
Home-page: https://github.com/ami-iit/jaxsim
|
6
6
|
Author: Diego Ferigo
|
@@ -37,6 +37,7 @@ Requires-Dist: jaxlie >=1.3.0
|
|
37
37
|
Requires-Dist: jax-dataclasses >=1.4.0
|
38
38
|
Requires-Dist: pptree
|
39
39
|
Requires-Dist: rod
|
40
|
+
Requires-Dist: typing-extensions ; python_version < "3.12"
|
40
41
|
Provides-Extra: all
|
41
42
|
Requires-Dist: black[jupyter] ; extra == 'all'
|
42
43
|
Requires-Dist: isort ; extra == 'all'
|
@@ -1,12 +1,22 @@
|
|
1
1
|
jaxsim/__init__.py,sha256=acqCVEg71ekNOwazlwA06dXeaPJh3Sr_e5JB8pcI5lo,1862
|
2
|
-
jaxsim/_version.py,sha256=
|
2
|
+
jaxsim/_version.py,sha256=vMokvYrBBPOrgLnCCWan0F7wQryZEpd6JLhmzbRqgM4,423
|
3
3
|
jaxsim/logging.py,sha256=c4zhwBKf9eAYAHVp62kTEllqdsZgh0K-kPKVy8L3elU,1584
|
4
4
|
jaxsim/typing.py,sha256=ErTscpEljFyrhPCisZnLEUt6FWLAuEAh-72Teb8Nz98,626
|
5
|
+
jaxsim/api/__init__.py,sha256=UehgJtcV9BYlX6vec-f_IgnMcq-F9BU_STsR0RDjEjA,53
|
6
|
+
jaxsim/api/contact.py,sha256=CXRTALb-3j9rbFkLWjbqKWmIIvnhShGD708wc132GcE,5942
|
7
|
+
jaxsim/api/data.py,sha256=R0hQUa5Gvdv-mkeONGPxEezsMtRogh820SBOv4ibS90,31195
|
8
|
+
jaxsim/api/joint.py,sha256=J65MgjMzp2O980wIEf2TxG_VCgczUsexGgd4YJ6rxiE,3615
|
9
|
+
jaxsim/api/link.py,sha256=Fpbtr2JF9fAouOX-lGAmajF2ZEz6q8ttDYsCiqpLxEk,6939
|
10
|
+
jaxsim/api/model.py,sha256=8m90nydtDQhA3xVpV0iG23p3t5XgcVSwPzxh2cVCZEY,33143
|
11
|
+
jaxsim/api/ode.py,sha256=cbWrXe7s5O3UCpWpI77Lg8Pujr_SiaQfLc7ELBqnJQM,9492
|
5
12
|
jaxsim/high_level/__init__.py,sha256=aWYBCsYmEO76Qt4GEi91Hye_ifGFLvc_bpy9OQplz2o,69
|
6
13
|
jaxsim/high_level/common.py,sha256=6nyRlFsNOLEy5JvLH70VPWeHGSL_ZKNxX3Q62ccqSuY,196
|
7
14
|
jaxsim/high_level/joint.py,sha256=0WF0QWkZzP0SXw0QYpn3PAwdZq0_uXFr2_f1OATiOBA,4089
|
8
15
|
jaxsim/high_level/link.py,sha256=4kcBMh-3w9c-fkTYm3_sXfdwd3NwUm7jKf5BjwEge94,8010
|
9
16
|
jaxsim/high_level/model.py,sha256=q29hSs0gH_UQrUyVzuCyF9YRB79WEWyHcVvV_1B9LrA,57054
|
17
|
+
jaxsim/integrators/__init__.py,sha256=x4kYr7k-nC0X7HH2bTXzGOl_3B9TBN9blw5BBxQtyQ0,72
|
18
|
+
jaxsim/integrators/common.py,sha256=kL4EqUjWZUNPtDrCcrStx-ZTxEYDS-W2WPQ0g-QqHqs,17567
|
19
|
+
jaxsim/integrators/fixed_step.py,sha256=_gChRm0RHjDtst-aWjyQKUys6TyYhZqdWap7vLf5LaE,4291
|
10
20
|
jaxsim/math/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
11
21
|
jaxsim/math/adjoint.py,sha256=ImkOkWHQKMukBprLTsOPpSuqb1NNPA3_t447zRVo79s,3779
|
12
22
|
jaxsim/math/conv.py,sha256=jbr9MU_vGtTpLTQpbqwAT4huF51skCfORFUBmKSdlaI,3138
|
@@ -17,11 +27,11 @@ jaxsim/math/plucker.py,sha256=44NvKVbcZoG8ivFN1BeXxDpuSFdEre1Q6ZXvhnmIiPY,2282
|
|
17
27
|
jaxsim/math/quaternion.py,sha256=ToyRnAWU0JvKSSSX2vaJeSw2lMa5BGU72DjtonOUw0k,3685
|
18
28
|
jaxsim/math/rotation.py,sha256=MHOnrpS5Sf4rszhOpZ8w7qXFkEl7UMltYimqqsuYuuU,2187
|
19
29
|
jaxsim/math/skew.py,sha256=oOGSSR8PUGROl6IJFlrmu6K3gPH-u16hUPfKIkcVv9o,1177
|
20
|
-
jaxsim/mujoco/__init__.py,sha256=
|
30
|
+
jaxsim/mujoco/__init__.py,sha256=Zo5GAlN1DYKvX8s1hu1j6HntKIbBMLB9Puv9ouaNAZ8,158
|
21
31
|
jaxsim/mujoco/__main__.py,sha256=GBmB7J-zj75ZnFyuAAmpSOpbxi_HhHhWJeot3ljGDJY,5291
|
22
|
-
jaxsim/mujoco/loaders.py,sha256=
|
32
|
+
jaxsim/mujoco/loaders.py,sha256=8sXc_tsDFWBYl8nesgFarYd3hA-PESLMrXsnR3Siz1Y,16400
|
23
33
|
jaxsim/mujoco/model.py,sha256=0kG2GERxjVFqWZ1K3352rgUNfchB4kRtIrsvv4pS4oc,10766
|
24
|
-
jaxsim/mujoco/visualizer.py,sha256
|
34
|
+
jaxsim/mujoco/visualizer.py,sha256=-qg26t5tleTva6zzQmc5SdnlC8XZ1ZAwZ_lDjdwHJ0A,4400
|
25
35
|
jaxsim/parsers/__init__.py,sha256=sonYi-bBWAoB04kp1mxT4uIORxjb7SdZ0ukGPmVx98Y,44
|
26
36
|
jaxsim/parsers/kinematic_graph.py,sha256=5wQnbzu8JE0bbnLRxK4ZsD_gQ9kbBpYbhUSzCMiNWko,23610
|
27
37
|
jaxsim/parsers/descriptions/__init__.py,sha256=EbTfnrK3oCxA3pNv--YUwllJ6uICENvFgAdRbYtS9ts,238
|
@@ -41,17 +51,17 @@ jaxsim/physics/algos/forward_kinematics.py,sha256=myiqBGk5Nv-OIJpkNFVOby2FdHEJM3
|
|
41
51
|
jaxsim/physics/algos/jacobian.py,sha256=HQk7UBYwWr2_qIYZBil_t9nqoL-TQB8hi-JHdPcSA0g,3166
|
42
52
|
jaxsim/physics/algos/rnea.py,sha256=bIv6TTwdCZVj_s9Fd5i_ZTMib4W2_sn8gxCbMRrzRcg,5322
|
43
53
|
jaxsim/physics/algos/rnea_motors.py,sha256=gaiEAOfpw9kZBVImfNKKwpgIgM8eygVu--wszh3npJc,5684
|
44
|
-
jaxsim/physics/algos/soft_contacts.py,sha256=
|
54
|
+
jaxsim/physics/algos/soft_contacts.py,sha256=mPNs5a3JAZ5dRTWbNMhZNV57UyYxQTqjRQXGA5pk3II,18424
|
45
55
|
jaxsim/physics/algos/terrain.py,sha256=Gw9-1AjU4c4Yd2xzo0i-fgWwYlroj03TjScJsz_2m9o,2228
|
46
56
|
jaxsim/physics/algos/utils.py,sha256=0OiELbXtv5Jink3l-vMK_OGHgGkZ_wTAAclcd7vDKoc,2230
|
47
57
|
jaxsim/physics/model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
48
58
|
jaxsim/physics/model/ground_contact.py,sha256=mva-yDzYHREmgUu8jGJmIAsf66_SF6ZISmN-XQQ9Ktw,1924
|
49
|
-
jaxsim/physics/model/physics_model.py,sha256=
|
50
|
-
jaxsim/physics/model/physics_model_state.py,sha256=
|
59
|
+
jaxsim/physics/model/physics_model.py,sha256=Lys3VTy2ypUbN_71h0DjUzKbEz7netgRfd_mNuy5Z5Y,14531
|
60
|
+
jaxsim/physics/model/physics_model_state.py,sha256=Av42rJWgicqxDmZZu1T_clpnmeaX_daASYhA7cxHYxQ,9256
|
51
61
|
jaxsim/simulation/__init__.py,sha256=WOWkzq7rMGa4xWvjNqTYtD0Nl4yLQtULGW1xU7hD9m0,182
|
52
62
|
jaxsim/simulation/integrators.py,sha256=WIlL7xi4UocSlWg4Qms8-6puqRYnK5A4r7TJUNPg5g0,13022
|
53
63
|
jaxsim/simulation/ode.py,sha256=ntq_iQPIw3SHj64CZWD2mHAKmt05ZgRpw2UwyTxHDOQ,10380
|
54
|
-
jaxsim/simulation/ode_data.py,sha256=
|
64
|
+
jaxsim/simulation/ode_data.py,sha256=5nPynNSC5tRnhAVwOCkdv6FrDn148bC7zZaqVCKgowM,2952
|
55
65
|
jaxsim/simulation/ode_integration.py,sha256=VDprQYoHEE_iI7ia1Mm3RyYl-LRvHU8dJEvRoGA4TFA,1947
|
56
66
|
jaxsim/simulation/simulator.py,sha256=qCI5QG0WKkBC5GNqauSvI7rSlGD7CLttTzCgLED7iJM,18123
|
57
67
|
jaxsim/simulation/simulator_callbacks.py,sha256=QWdY7dilmjrxeieWCB6RQ-cWpwLuUOK8fYWXpnnBcyU,2217
|
@@ -62,8 +72,8 @@ jaxsim/utils/jaxsim_dataclass.py,sha256=FbjfEoCoYC_F-M3wUggXiEhQ7MMS-V_ciYQca-uS
|
|
62
72
|
jaxsim/utils/oop.py,sha256=LQhBXkSOD0zgYNJLO7Bl0FPRg-LvtvPzxyQa1WFP0rM,22616
|
63
73
|
jaxsim/utils/tracing.py,sha256=KDMoyVPlu2NJvFkhtZwq5AkqMMgajt3munvJom-vEjQ,650
|
64
74
|
jaxsim/utils/vmappable.py,sha256=NqGL9nGFRI5OorCfnjXsjR_yXigzDxL0lW1YhQ_nMTY,3655
|
65
|
-
jaxsim-0.2.
|
66
|
-
jaxsim-0.2.
|
67
|
-
jaxsim-0.2.
|
68
|
-
jaxsim-0.2.
|
69
|
-
jaxsim-0.2.
|
75
|
+
jaxsim-0.2.dev166.dist-info/LICENSE,sha256=EsU2z6_sWW4Zduzq3goVWjZoCZVKQsM4H_y0o7oRA7Q,1547
|
76
|
+
jaxsim-0.2.dev166.dist-info/METADATA,sha256=_mCvtJJrBw5yxQsl47_64GcmfxMObN_GrPJ3mt3nGEo,7734
|
77
|
+
jaxsim-0.2.dev166.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
78
|
+
jaxsim-0.2.dev166.dist-info/top_level.txt,sha256=LxGMA8FLtXjQ6oI7N5gd_R_oSUHxpXxUEOfT1xS_ni0,7
|
79
|
+
jaxsim-0.2.dev166.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|