|
5 | 5 |
|
6 | 6 | from __future__ import annotations |
7 | 7 |
|
8 | | -from dataclasses import dataclass, field |
| 8 | +from dataclasses import dataclass |
9 | 9 |
|
10 | 10 | import warp as wp |
11 | 11 |
|
12 | | -from .....core.types import override |
13 | 12 | from .....sim import BodyFlags |
14 | | -from .types import Descriptor |
15 | 13 |
|
16 | 14 | ### |
17 | 15 | # Module interface |
|
20 | 18 | __all__ = [ |
21 | 19 | "RigidBodiesData", |
22 | 20 | "RigidBodiesModel", |
23 | | - "RigidBodyDescriptor", |
24 | 21 | "convert_base_origin_to_com", |
25 | 22 | "convert_body_com_to_origin", |
26 | 23 | "convert_body_origin_to_com", |
|
44 | 41 | ### |
45 | 42 |
|
46 | 43 |
|
47 | | -@dataclass |
48 | | -class RigidBodyDescriptor(Descriptor): |
49 | | - """ |
50 | | - A container to describe a single rigid body in the model builder. |
51 | | -
|
52 | | - Attributes: |
53 | | - name: The name of the body. |
54 | | - uid: The unique identifier of the body. |
55 | | - m_i: Mass of the body [kg]. |
56 | | - i_r_com_i: Translational offset of the body center of mass [m]. |
57 | | - i_I_i: Moment of inertia matrix in local coordinates [kg·m²]. |
58 | | - q_i_0: Initial absolute pose of the body in world coordinates. |
59 | | - u_i_0: Initial absolute twist of the body in world coordinates. |
60 | | - wid: Index of the world to which the body belongs. |
61 | | - bid: Index of the body w.r.t. its world. |
62 | | - """ |
63 | | - |
64 | | - ### |
65 | | - # Attributes |
66 | | - ### |
67 | | - |
68 | | - m_i: float = 0.0 |
69 | | - """Mass of the body.""" |
70 | | - |
71 | | - i_r_com_i: wp.vec3f = field(default_factory=wp.vec3f) |
72 | | - """Translational offset of the body center of mass w.r.t the reference frame expressed in local coordinates.""" |
73 | | - |
74 | | - i_I_i: wp.mat33f = field(default_factory=wp.mat33f) |
75 | | - """Moment of inertia matrix of the body expressed in local coordinates.""" |
76 | | - |
77 | | - q_i_0: wp.transformf = field(default_factory=wp.transformf) |
78 | | - """Initial absolute pose of the body expressed in world coordinates.""" |
79 | | - |
80 | | - u_i_0: wp.spatial_vectorf = field(default_factory=wp.spatial_vectorf) |
81 | | - """Initial absolute twist of the body expressed in world coordinates.""" |
82 | | - |
83 | | - ### |
84 | | - # Metadata - to be set by the WorldDescriptor when added |
85 | | - ### |
86 | | - |
87 | | - wid: int = -1 |
88 | | - """ |
89 | | - Index of the world to which the body belongs. |
90 | | - Defaults to `-1`, indicating that the body has not yet been added to a world. |
91 | | - """ |
92 | | - |
93 | | - bid: int = -1 |
94 | | - """ |
95 | | - Index of the body w.r.t. its world. |
96 | | - Defaults to `-1`, indicating that the body has not yet been added to a world. |
97 | | - """ |
98 | | - |
99 | | - @override |
100 | | - def __repr__(self) -> str: |
101 | | - """Returns a human-readable string representation of the RigidBodyDescriptor.""" |
102 | | - return ( |
103 | | - f"RigidBodyDescriptor(\n" |
104 | | - f"name: {self.name},\n" |
105 | | - f"uid: {self.uid},\n" |
106 | | - f"m_i: {self.m_i},\n" |
107 | | - f"i_I_i:\n{self.i_I_i},\n" |
108 | | - f"q_i_0: {self.q_i_0},\n" |
109 | | - f"u_i_0: {self.u_i_0}\n" |
110 | | - f"wid: {self.wid},\n" |
111 | | - f"bid: {self.bid},\n" |
112 | | - f")" |
113 | | - ) |
114 | | - |
115 | | - |
116 | 44 | @dataclass |
117 | 45 | class RigidBodiesModel: |
118 | 46 | """ |
|
0 commit comments