12
12
import jaxsim .typing as jtp
13
13
from jaxsim .math import Adjoint , Inertia , JointModel , supported_joint_motion
14
14
from jaxsim .parsers .descriptions import JointDescription , JointType , ModelDescription
15
- from jaxsim .utils import HashedNumpyArray , JaxsimDataclass
15
+ from jaxsim .utils import JaxsimDataclass
16
16
17
17
18
18
@jax_dataclasses .pytree_dataclass (eq = False , unsafe_hash = False )
@@ -34,9 +34,9 @@ class KinDynParameters(JaxsimDataclass):
34
34
35
35
# Static
36
36
link_names : Static [tuple [str ]]
37
- _parent_array : Static [HashedNumpyArray ]
38
- _support_body_array_bool : Static [HashedNumpyArray ]
39
- _motion_subspaces : Static [HashedNumpyArray ]
37
+ _parent_array : Static [tuple [ int ] ]
38
+ _support_body_array_bool : Static [tuple [ int ] ]
39
+ _motion_subspaces : Static [tuple [ float ] ]
40
40
41
41
# Links
42
42
link_parameters : LinkParameters
@@ -56,21 +56,21 @@ def motion_subspaces(self) -> jtp.Matrix:
56
56
r"""
57
57
Return the motion subspaces :math:`\mathbf{S}(s)` of the joints.
58
58
"""
59
- return self ._motion_subspaces . get ( )
59
+ return jnp . array ( self ._motion_subspaces , dtype = float )
60
60
61
61
@property
62
62
def parent_array (self ) -> jtp .Vector :
63
63
r"""
64
64
Return the parent array :math:`\lambda(i)` of the model.
65
65
"""
66
- return self ._parent_array . get ( )
66
+ return jnp . array ( self ._parent_array , dtype = int )
67
67
68
68
@property
69
69
def support_body_array_bool (self ) -> jtp .Matrix :
70
70
r"""
71
71
Return the boolean support parent array :math:`\kappa_{b}(i)` of the model.
72
72
"""
73
- return self ._support_body_array_bool . get ( )
73
+ return jnp . array ( self ._support_body_array_bool , dtype = int )
74
74
75
75
@staticmethod
76
76
def build (model_description : ModelDescription ) -> KinDynParameters :
@@ -227,8 +227,8 @@ def motion_subspace(joint_type: int, axis: npt.ArrayLike) -> npt.ArrayLike:
227
227
228
228
S = {
229
229
JointType .Fixed : np .zeros (shape = (6 , 1 )),
230
- JointType .Revolute : np .vstack (np .hstack ([np .zeros (3 ), axis . axis ])),
231
- JointType .Prismatic : np .vstack (np .hstack ([axis . axis , np .zeros (3 )])),
230
+ JointType .Revolute : np .vstack (np .hstack ([np .zeros (3 ), axis ])),
231
+ JointType .Prismatic : np .vstack (np .hstack ([axis , np .zeros (3 )])),
232
232
}
233
233
234
234
return S [joint_type ]
@@ -254,36 +254,16 @@ def motion_subspace(joint_type: int, axis: npt.ArrayLike) -> npt.ArrayLike:
254
254
255
255
return KinDynParameters (
256
256
link_names = tuple (l .name for l in ordered_links ),
257
- _parent_array = HashedNumpyArray ( array = parent_array ),
258
- _support_body_array_bool = HashedNumpyArray ( array = support_body_array_bool ),
259
- _motion_subspaces = HashedNumpyArray ( array = motion_subspaces ),
257
+ _parent_array = tuple ( parent_array . tolist () ),
258
+ _support_body_array_bool = tuple ( support_body_array_bool . tolist () ),
259
+ _motion_subspaces = tuple ( motion_subspaces . tolist () ),
260
260
link_parameters = link_parameters ,
261
261
joint_model = joint_model ,
262
262
joint_parameters = joint_parameters ,
263
263
contact_parameters = contact_parameters ,
264
264
frame_parameters = frame_parameters ,
265
265
)
266
266
267
- def __eq__ (self , other : KinDynParameters ) -> bool :
268
-
269
- if not isinstance (other , KinDynParameters ):
270
- return False
271
-
272
- return hash (self ) == hash (other )
273
-
274
- def __hash__ (self ) -> int :
275
-
276
- return hash (
277
- (
278
- hash (self .number_of_links ()),
279
- hash (self .number_of_joints ()),
280
- hash (self .frame_parameters .name ),
281
- hash (self .frame_parameters .body ),
282
- hash (self ._parent_array ),
283
- hash (self ._support_body_array_bool ),
284
- )
285
- )
286
-
287
267
# =============================
288
268
# Helpers to extract parameters
289
269
# =============================
@@ -409,7 +389,7 @@ def joint_transforms(
409
389
pre_H_suc_J = jax .vmap (supported_joint_motion )(
410
390
joint_types = jnp .array (self .joint_model .joint_types [1 :]).astype (int ),
411
391
joint_positions = jnp .array (joint_positions ),
412
- joint_axes = jnp .array ([ j . axis for j in self .joint_model .joint_axis ] ),
392
+ joint_axes = jnp .array (self .joint_model .joint_axis ),
413
393
)
414
394
415
395
# Extract the transforms and motion subspaces of the joints.
0 commit comments