signal_metadata
¶
Shared metadata model and helpers for tagging SignalManager.post()/.track() calls with their physical
quantity, so callers don't need to hand-build Pint dimension/unit strings at every call site.
MetadataLike
module-attribute
¶
MetadataLike = ColumnMetadata | Mapping[str, Any]
What callers may pass wherever metadata is accepted: a ColumnMetadata or a plain dict.
MetadataOverrides
module-attribute
¶
MetadataOverrides = Mapping[str, MetadataLike | None]
Per-channel metadata overrides, keyed by channel name.
Dimension
¶
Bases: StrEnum
Pint dimension expressions for physical quantities whose concrete unit depends on the
user's modeling scale (MuJoCo has no inherent unit system). Use with dim(), which
builds a metadata={"dimension": ...} entry for SignalManager.post()/.track().
-
Reference
mujoco_mojoutilssignal_metadatadim
TransformType
¶
Bases: StrEnum
How a signal must be re-expressed under MojoDataFrame.mojo.change_frame().
POINT, VECTOR, and QUATERNION tag channels grouped into a :x/:y/:z (or :w/:x/:y/:z) family (see rotatable_bases/quaternion_bases), which change_frame refuses to touch untagged. SCALAR says the value does not depend on the frame at all. A lone scalar column needs no tag to be left alone, so tagging it is optional and states the intent; the tag matters for a group whose columns happen to be named :x/:y/:z (or :w/:x/:y/:z) without being a vector, which it keeps out of any rotation.
VECTOR
class-attribute
instance-attribute
¶
Rotate only (velocities, forces, accelerations, momenta, directions).
QUATERNION
class-attribute
instance-attribute
¶
Compose: q' = q_b^-1 (x) q.
SCALAR
class-attribute
instance-attribute
¶
Unchanged by a frame change (energies, distances, angles, magnitudes, joint values).
metadata
property
¶
metadata: ColumnMetadata
Builds a ColumnMetadata carrying only this transform_type, tagging how a signal's grouped vector/quaternion components transform under MojoDataFrame.mojo.change_frame().
ColumnMetadata
¶
Bases: BaseModel
Metadata describing one telemetry column, stored per column in the parquet footer.
The declared fields are the ones mujoco-mojo understands and validates. Any other key is kept as-is (extra="allow"), so callers can attach their own labels. Unset fields (None or an empty string) are omitted when dumping, so the serialized form only carries what was actually tagged.
- User Guide Features MojoDataFrame
unit
class-attribute
instance-attribute
¶
unit: str | None = None
Concrete Pint unit string, e.g. meter / second. When dimension is also set, both must have the same dimensionality.
dimension
class-attribute
instance-attribute
¶
dimension: str | None = None
Pint dimension expression for the physical quantity, e.g. [length] / [time]. Tags the quantity without committing to a concrete unit, which is the right choice for built-in signals since the modeling unit system isn't knowable.
quantity
class-attribute
instance-attribute
¶
quantity: str | None = None
Free-form hint that separates quantities Pint cannot tell apart, e.g. torque versus energy.
transform_type
class-attribute
instance-attribute
¶
transform_type: TransformType | None = None
How this signal's grouped :x/:y/:z or :w/:x/:y/:z components transform under change_frame(). Only set it for channels that are grouped into such a family.
enumeration_map
class-attribute
instance-attribute
¶
Labels for an integer-coded signal, mapping each label to its code, e.g. {"IDLE": 0, "RUNNING": 1}. The column still holds the codes (as floats, like all telemetry); convert_enums() swaps them for labels and the Dojo shows the labels on the plot. Codes must be unique. Build it from an enum class with ColumnMetadata.from_enum().
description
class-attribute
instance-attribute
¶
description: str = ''
Free-text explanation of what this column holds, e.g. Torque the PD controller commands at the elbow, before the actuator's gear ratio. It tells apart columns whose names look alike. An empty string means no description.
__hash__
¶
__hash__() -> int
Hashes the declared scalar fields only (equal objects still hash equal), so instances can key the per-timestep caches. enumeration_map is left out because a dict is not hashable; equality still compares it.
Source code in src/mujoco_mojo/utils/signal_metadata.py
__or__
¶
__or__(other: object) -> ColumnMetadata
Merges two metadata objects, with the right side winning where both set a value. Extras are kept. The result is not re-validated (both sides already were, or are validated where they are registered), which keeps per-timestep merges cheap.
Source code in src/mujoco_mojo/utils/signal_metadata.py
from_enum
classmethod
¶
from_enum(enum_cls: type[Enum]) -> ColumnMetadata
Builds the metadata for a signal that posts the integer values of enum_cls: an enumeration_map of every member's name to its value (iterating the class, so aliases are skipped), tagged dimensionless since a code has no unit. Raises TypeError if a member's value is not an integer, and ValueError if the class has no members.
- User Guide Workflow Runtime Script Request-Based Telemetry
Source code in src/mujoco_mojo/utils/signal_metadata.py
validated
classmethod
¶
validated(value: MetadataLike) -> ColumnMetadata
Validates a metadata object or a plain dict (always, unlike model_validate on an instance), raising a ValidationError naming the bad field.
Source code in src/mujoco_mojo/utils/signal_metadata.py
unchecked
classmethod
¶
unchecked(value: MetadataLike) -> ColumnMetadata
Wraps a plain dict without validating it, for per-timestep merges. The merged result is validated once, where the signal is registered.
Source code in src/mujoco_mojo/utils/signal_metadata.py
lenient
classmethod
¶
lenient(
raw: Mapping[str, Any], *, where: str = ""
) -> ColumnMetadata
Validates raw, but falls back to loading it unvalidated (with a warning) if it is invalid, so files written by other versions still open.
Source code in src/mujoco_mojo/utils/signal_metadata.py
resolve_dimension_metadata
¶
resolve_dimension_metadata(
meta: ColumnMetadata, unit_system: UnitSystem
) -> ColumnMetadata
Adds a concrete unit string to meta derived from its dimension and the given unit_system. The dimension is preserved so callers can still see both the physical quantity type and the concrete unit. Dimensionless signals (dimension="[]") are left unchanged. All other fields (e.g. quantity) are preserved. Cached, since merge_signal_metadata runs every timestep.
Source code in src/mujoco_mojo/utils/signal_metadata.py
dim
cached
¶
dim(dimension: Dimension | str) -> ColumnMetadata
Builds a dimension-tagged ColumnMetadata. Accepts either a Dimension enum member or a Pint unit name string (e.g. "inch"), in which case Pint looks up the matching Dimension member by dimensionality.
Source code in src/mujoco_mojo/utils/signal_metadata.py
unit
cached
¶
unit(unit: str) -> ColumnMetadata
dimensionless_metadata
¶
dimensionless_metadata() -> ColumnMetadata
Tags a signal as known to have no units (e.g. quaternions, rotation matrices, axis vectors, enum/index values), distinguishing "known to be unitless" from "nobody tagged this column".
Source code in src/mujoco_mojo/utils/signal_metadata.py
angle_metadata
¶
angle_metadata() -> ColumnMetadata
Tags a signal as an angle in radians. MuJoCo's compiled model always stores angles in radians regardless of the XML angle= attribute, so this is a concrete unit rather than a scale-ambiguous dimension.
Source code in src/mujoco_mojo/utils/signal_metadata.py
angular_rate_metadata
¶
angular_rate_metadata(
per: str = "second",
) -> ColumnMetadata
Tags a signal as an angular rate (e.g. angular velocity, angular acceleration) in radians per per.
torque_metadata
¶
torque_metadata() -> ColumnMetadata
Tags a signal as torque. Includes an extra quantity hint since torque and energy share the same Pint dimensionality and can't be told apart by dimension alone.
Source code in src/mujoco_mojo/utils/signal_metadata.py
force_or_torque
cached
¶
force_or_torque(jnt_type: int) -> ColumnMetadata
Returns force metadata for a slide joint's generalized force, or torque metadata for any rotational joint (hinge/ball/free).
Source code in src/mujoco_mojo/utils/signal_metadata.py
merge_signal_metadata
¶
merge_signal_metadata(
builtin: ColumnMetadata | None,
channel: str,
user_metadata: MetadataOverrides | None,
*,
unit_system: UnitSystem | None = None,
description: str = "",
) -> ColumnMetadata
Merges a built-in default with the caller-supplied override/extension for channel, with user-supplied fields winning on conflict. If unit_system is provided and builtin has a dimension, it is resolved to a concrete unit. description is the built-in text for the column, built by the caller from the name of the object it belongs to, and a description in user_metadata replaces it like any other field. Returns an empty ColumnMetadata if both are empty. Nothing here is validated: the result is validated when it is used to build a Column.