Create specs for attachment frames. Attachment frames are specialized without an identifier. The only allowed children are joints which also don't have identifiers. Args: is_world_attachment: Whether we are creating a spec for attachments to worldbody. If `True`, allow <free
(is_world_attachment)
| 197 | |
| 198 | |
| 199 | def _attachment_frame_spec(is_world_attachment): |
| 200 | """Create specs for attachment frames. |
| 201 | |
| 202 | Attachment frames are specialized <body> without an identifier. |
| 203 | The only allowed children are joints which also don't have identifiers. |
| 204 | |
| 205 | Args: |
| 206 | is_world_attachment: Whether we are creating a spec for attachments to |
| 207 | worldbody. If `True`, allow <freejoint> as child. |
| 208 | |
| 209 | Returns: |
| 210 | An `ElementSpec`. |
| 211 | """ |
| 212 | frame_spec = ElementSpec( |
| 213 | 'body', repeated=True, on_demand=False, identifier=None, namespace='body', |
| 214 | attributes=collections.OrderedDict(), |
| 215 | children=collections.OrderedDict()) |
| 216 | |
| 217 | body_spec = MUJOCO.children['worldbody'].children['body'] |
| 218 | # 'name' and 'childclass' attributes are excluded. |
| 219 | for attrib_name in ( |
| 220 | 'mocap', 'pos', 'quat', 'axisangle', 'xyaxes', 'zaxis', 'euler', 'user'): |
| 221 | frame_spec.attributes[attrib_name] = copy.deepcopy( |
| 222 | body_spec.attributes[attrib_name]) |
| 223 | |
| 224 | inertial_spec = body_spec.children['inertial'] |
| 225 | frame_spec.children['inertial'] = copy.deepcopy(inertial_spec) |
| 226 | joint_spec = body_spec.children['joint'] |
| 227 | frame_spec.children['joint'] = ElementSpec( |
| 228 | 'joint', repeated=True, on_demand=False, |
| 229 | identifier=None, namespace='joint', |
| 230 | attributes=copy.deepcopy(joint_spec.attributes), |
| 231 | children=collections.OrderedDict()) |
| 232 | |
| 233 | if is_world_attachment: |
| 234 | freejoint_spec = (MUJOCO.children['worldbody'] |
| 235 | .children['body'].children['freejoint']) |
| 236 | frame_spec.children['freejoint'] = ElementSpec( |
| 237 | 'freejoint', repeated=False, on_demand=True, |
| 238 | identifier=None, namespace='joint', |
| 239 | attributes=copy.deepcopy(freejoint_spec.attributes), |
| 240 | children=collections.OrderedDict()) |
| 241 | |
| 242 | return frame_spec |
| 243 | |
| 244 | ATTACHMENT_FRAME = _attachment_frame_spec(is_world_attachment=False) |
| 245 | WORLD_ATTACHMENT_FRAME = _attachment_frame_spec(is_world_attachment=True) |
no outgoing calls
no test coverage detected
searching dependent graphs…