Skip to content

hylo.codeagents.motion_characters

Package: hylo-code-agents · Core contracts

motion_characters

Target characters of the motion studio: humanoid robots (MJCF) and rigged human characters (Blender), each described by a short mapping file in motion_characters/.json.

A mapping names, for every role of the studio's skeleton (pelvis, chest, head and, per side, hip, knee, ankle, toe, shoulder, elbow, wrist), where that point is on the character:

  • kind "mjcf" (a robot or a simulated humanoid): bodies maps a role to a body, or to [body, [x, y, z]] (an offset in the body frame, e.g. the toe in front of the ankle); feet are the two foot bodies (contact, sole flat); clearance keeps hands and elbows that far from the body's midline (metres); the asset is a MuJoCo Menagerie folder at a pinned commit (menagerie: a manifest beside this module with a digest per file) or a builtin model.
  • kind "rig" (a skinned character, driven in Blender): joints maps a role to a bone end ("Bone.head" or "Bone.tail"); drive says which bones move: pelvis (placed and turned with the hips), spine (bones that share the turn from the hips to the chest), neck, and per side upper_arm, forearm, thigh, shin, foot (turned so the segment between their joints points like the source's); attach pins a bone's head to another bone's end (an IK foot of the original rig); colours overrides material base colours (sRGB, by material name). height_m scales the character to that height. The asset is an archive fetched from its original page (archive: url, sha256, members to extract).

Every mapping records licence and credit. Robots are fetched from MuJoCo Menagerie and characters from their authors' uploads, verified by digest, into the asset cache; nothing is vendored.

CHAR_DIR module-attribute

CHAR_DIR = Path(__file__).with_name('motion_characters')

SIDE_ROLES module-attribute

SIDE_ROLES = ('hip', 'knee', 'ankle', 'toe', 'shoulder', 'elbow', 'wrist')

ROLES module-attribute

ROLES = ('pelvis', 'chest', 'head', *[f'{s}_{r}' for s in ('left', 'right') for r in SIDE_ROLES])

ROLE_KP module-attribute

ROLE_KP = {'pelvis': 'Hips', 'chest': 'Chest', 'head': 'Head', **{f'{s}_{r}': f'{S}{k}' for s, S in (('left', 'Left'), ('right', 'Right')) for r, k in (('hip', 'Leg'), ('knee', 'Shin'), ('ankle', 'Foot'), ('toe', 'ToeBase'), ('shoulder', 'Arm'), ('elbow', 'ForeArm'), ('wrist', 'Hand'))}}

WEIGHTS module-attribute

WEIGHTS = {'pelvis': 3.0, 'chest': 1.5, 'head': 1.0, 'hip': 1.0, 'knee': 1.5, 'ankle': 2.0, 'toe': 1.0, 'shoulder': 1.0, 'elbow': 1.5, 'wrist': 2.0}

DRIVE_SIDE module-attribute

DRIVE_SIDE = {'upper_arm': ('shoulder', 'elbow'), 'forearm': ('elbow', 'wrist'), 'thigh': ('hip', 'knee'), 'shin': ('knee', 'ankle'), 'foot': ('ankle', 'toe')}

BONE_END module-attribute

BONE_END = re.compile('^.+\\.(head|tail)$')

USER_AGENT module-attribute

USER_AGENT = 'Mozilla/5.0 (X11; Linux x86_64) hylo-motion-studio'

ROBOTS_DEFAULT module-attribute

ROBOTS_DEFAULT = ('g1', 'h1', 't1', 'apollo', 'n1')

names

names(kind: str | None = None) -> list[str]

The characters with a mapping file (optionally only one kind: "mjcf" or "rig").

load

load(name: str) -> dict[str, Any]

A character's mapping (validated; raises ValueError listing the problems).

validate

validate(data: dict[str, Any]) -> list[str]

Problems with a mapping's structure (an empty list when it is fine). Whether the bodies or bones exist in the model is checked when the model is loaded (motion_sim validate, the Blender script).

asset_root

asset_root() -> Path

The asset cache ($HYLO_ASSETS, default ~/.cache/hylo/assets).

menagerie_dir

menagerie_dir(manifest: str | Path) -> Path

Where a Menagerie folder of manifest lives in the asset cache.

menagerie_assets

menagerie_assets(manifest: str | Path) -> Path

A MuJoCo Menagerie model folder (its LICENSE kept) at the commit pinned in manifest (repo, commit, folder, sha256 per file), fetched on first use from the original repository into the asset cache and verified file by file; never vendored. Offline: copy that folder (the files listed in the manifest) to menagerie_dir() by hand.

archive_dir

archive_dir(asset: dict[str, Any]) -> Path

archive_assets

archive_assets(asset: dict[str, Any]) -> Path

Fetch a character archive from its original page (verified by sha256), extract the listed members into the asset cache and return that folder.

mjcf_spec

mjcf_spec(name: str, work: Path) -> dict[str, Any]

The robot description motion_sim needs (see its docstring) for an MJCF character.

rig_spec

rig_spec(name: str) -> dict[str, Any]

What the Blender script needs to drive a rigged character.

kind

kind(name: str) -> str

title

title(name: str) -> str

camera_distance

camera_distance(name: str) -> float

credits

credits(chars: list[str]) -> dict[str, dict[str, Any]]

Source and licence of each character (for sources.json).