math
Rotation3D
dataclass
¶
3D rotation representation in quaternion, axis-angle, xy-axes, z-axis, or Euler angles as allowed by MuJoCo. For details, see MuJoCo documentation.
Source code in src/flygym/utils/math.py
as_kwargs()
¶
Convert to keyword arguments for MuJoCo MJCF elements as a dict.
One should typically use ** to expand the returned dict when passing to an
MJCF element constructor. For example::
rotation = Rotation3D("quat", (1, 0, 0, 0))
camera = self.mjcf_root.worldbody.add(
"camera", pos=pos_offset, **rotation.as_kwargs()
)
which expands to::
camera = self.mjcf_root.worldbody.add(
"camera", pos=pos_offset, quat=(1, 0, 0, 0)
)
Source code in src/flygym/utils/math.py
Tree
¶
Bases: Generic[T]
Minimal implementation of a tree data structure, made to parse and verify body skeletons without requiring extra dependency.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nodes
|
list[T]
|
List of unique body segment identifiers. |
required |
edges
|
list[tuple[T, T]]
|
List of (parent, child) tuples defining connections. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If graph is not a valid tree (has cycles, disconnected, duplicate nodes, self-loops, or parallel edges). |
Source code in src/flygym/utils/math.py
dfs_edges(root)
¶
Yield edges in depth-first search order from root.