Skip to content

hylo.codeagents.motion_tools

Package: hylo-code-agents · Core contracts

motion_tools

The motion studio's tool layer (RFC-0006 part 8), shared by the guided studio (motion.py) and free mode (motion_free.py): the model-facing tools, the backend that runs them, and the final report of a run.

  • RobotMotion: a motion retargeted to one character (robot qpos, or a rigged character's posed keypoints).
  • ToolBackend: the real tools, each in its own environment: hylo-tools workers (text_motion kept loaded, human, render and the perception tools), the MuJoCo worker (motion_sim: retarget, check, validate) and the media worker (motion_media: clip, compose, rig). Tests pass a fake with the same methods.
  • StudioTools: what the model calls: text_motion, video_motion, pose_from_image, retarget (any character of motion_characters), check, render (robots through the hylo-tools render tool, rigged characters through Blender), lineup (the same motion on several characters, one labelled video grid), look (frames of a video for the model), finish. Every call is logged and timed; slow calls pause the sandbox's block clock.
  • finalize: the final motion -> motion.npz, check.json, a report per character (characters.json) and the videos.

DEFAULT_MODEL module-attribute

DEFAULT_MODEL: dict[str, Any] = {'backend': 'ollama', 'model': 'qwen3.5:35b-a3b', 'vision': True, 'reasoning_effort': 'none', 'max_tokens': 3000, 'timeout_s': 900}

SIM_WORKER module-attribute

SIM_WORKER = Path(__file__).with_name('motion_sim.py')

MEDIA_WORKER module-attribute

MEDIA_WORKER = Path(__file__).with_name('motion_media.py')

WORKER_OPS module-attribute

WORKER_OPS = {'retarget': SIM_WORKER, 'check': SIM_WORKER, 'validate': SIM_WORKER, 'clip': MEDIA_WORKER, 'compose': MEDIA_WORKER, 'rig': MEDIA_WORKER}

RENDER_VIEW module-attribute

RENDER_VIEW = {'azimuth': 150.0, 'elevation': -12.0}

ANKLE_GAIN module-attribute

ANKLE_GAIN = 1.0

RobotMotion dataclass

RobotMotion(qpos: ndarray, fps: float, robot: str, scene: str, source: Motion, info: dict[str, Any] = dict(), joint_names: list[str] = list(), kind: str = 'mjcf')

A motion retargeted to a robot: qpos (T, nq) for its scene (scene.xml), at fps.

qpos instance-attribute

qpos: ndarray

fps instance-attribute

fps: float

robot instance-attribute

robot: str

scene instance-attribute

scene: str

source instance-attribute

source: Motion

info class-attribute instance-attribute

info: dict[str, Any] = field(default_factory=dict)

joint_names class-attribute instance-attribute

joint_names: list[str] = field(default_factory=list)

kind class-attribute instance-attribute

kind: str = 'mjcf'

seconds property

seconds: float

summary

summary() -> dict[str, Any]

The source motion's summary plus the retargeting error.

ToolBackend

ToolBackend(threads: int = 64, steps: int = 100)

The real tools: hylo-tools workers (text_motion kept loaded in a ToolServer, human, render, perception tools) and the studio's workers (motion_sim, motion_media), each in its own uv environment.

text_motion

text_motion(prompt: Any, seconds: Any, seed: int, out: Path) -> tuple[np.ndarray, list[str], float, dict]

human

human(frames: Path, fps: float, out: Path) -> tuple[np.ndarray, np.ndarray, float, dict, str | None]

render

render(scene: str, qpos: ndarray, fps: float, out: Path, *, camera: str, style: str, distance: float) -> dict

tool

tool(name: str, kwargs: dict, out: Path) -> dict

Another hylo tool (hands, depth, segment, ...) through its Python API; returns its outputs and files.

sim

sim(op: str, params: dict, inputs: dict, out: Path) -> dict

One op of the studio's workers (motion_sim: retarget, check, validate; motion_media: clip, compose, rig), each run with uv run --script in its own environment.

close

close() -> None

StudioTools

StudioTools(backend: Any, out: Path, robot: str, inputs: dict[str, str], *, style: str = 'auto', log: Callable[[dict], None] = lambda r: None, characters: list[str] | None = None, samples: int = 16)

The model's tools for one run; every call is logged and timed; slow calls pause the block clock.

characters instance-attribute

characters = list(characters or [])

samples instance-attribute

samples = samples

clips instance-attribute

clips: list[dict[str, Any]] = []

sandbox instance-attribute

sandbox: Any = None

loop instance-attribute

loop: Any = None

final instance-attribute

final: Any = None

note instance-attribute

note = ''

timing instance-attribute

timing: dict[str, dict[str, float]] = {}

renders instance-attribute

renders: dict[int, dict] = {}

lineups instance-attribute

lineups: list[dict] = []

made instance-attribute

made = 0

text_motion

text_motion(prompt: Any, seconds: Any = 4.0, seed: int = 0) -> ops.Motion

Text -> motion (NVIDIA Kimodo). prompt: one text, or a list of texts for consecutive segments (then seconds is a list too). 2-10 s per segment.

video_motion

video_motion(path: str = 'video', start: float = 0.0, seconds: float | None = None) -> ops.Motion

Reference video -> human motion (the human tool: MediaPipe Pose 3D keypoints; approximate world grounding, static camera). start / seconds select a window.

pose_from_image

pose_from_image(path: str = 'image') -> ops.Motion

A still image of a person -> a one-frame pose (use it with keyframe(...) or hold(...)).

motion_from_array

motion_from_array(joints: Any, fps: float = 30.0) -> ops.Motion

Your own motion: joints (T, 17, 3) in NAMES order, metres, z up.

retarget

retarget(motion: Any, robot: str | None = None) -> RobotMotion

Skeleton motion -> character motion: robots by keypoint IK (MuJoCo), rigged characters by bone driving (Blender); see motion_characters for the characters.

report

report(motion: Any, robot: str | None = None, physics: bool = True) -> dict[str, Any]

The full plausibility report (check.json): retargeting, kinematic metrics, physics rollouts (robots with actuators); for a rigged character its retargeting and contact metrics from Blender.

check

check(motion: Any, robot: str | None = None, physics: bool = False) -> dict[str, Any]

Plausibility of the robot motion for the model: a list of real problems (floor penetration, sliding feet, self-collision, joint-limit violations, poor retargeting) and the kinematic metrics. The physics rollout (physics=True) is information only; the final report always has it. With a local model it is off by default: shown the falls, the model kept trading the request away for a motion that stays up.

render

render(motion: Any, camera: str = 'track', style: str | None = None, robot: str | None = None, physics: bool = False) -> str

Render to MP4 (style "blender": Cycles, slower, nicer; "mujoco": fast; "auto"); camera "track", "orbit" or "fixed". physics=True renders the physics rollout of the last check instead. Returns the path; a still frame is attached to your next feedback. Rigged characters render in Blender (track camera).

lineup

lineup(motion: Any, characters: list[str] | None = None, cols: int | None = None) -> str

The same motion on several characters: one render per character (each with its own proportions and the same camera angle), composed into one labelled video grid. Characters default to the run's list (or all). Returns the MP4 path; a still of each render is shown.

look

look(path: str, n: int = 4, note: str = '') -> str

Frames of a video (n, evenly spaced) or an image, as one contact sheet attached to the next feedback.

finish

finish(motion: Any, note: str = '') -> str

The final motion (skeleton or robot motion); ends the session.

namespace

namespace() -> dict[str, Any]

status

status() -> dict[str, Any]

robot_spec

robot_spec(robot: str, work: Path) -> dict[str, Any]

What motion_sim needs to know about an MJCF character (see its docstring and motion_characters).

render_tool_dir

render_tool_dir() -> Path

The hylo-tools render tool's worker scripts (its Blender locator, video writer and Blender look).

contact_sheet

contact_sheet(path: Path, n: int = 4, tile: tuple[int, int] = (480, 270)) -> np.ndarray

An RGB image of n evenly spaced frames of a video (time stamps drawn), or the image at path itself.

clean_record

clean_record(rec: dict[str, Any]) -> dict[str, Any]

parse_characters

parse_characters(spec: Any) -> list[str]

--characters: None, "all", "robots", "humans" or a comma-separated list (or a list).

character_table

character_table(tools: StudioTools, src: Motion, characters: list[str]) -> dict[str, dict[str, Any]]

Retargeting error, joint-limit hits and plausibility per character (characters.json).

finalize

finalize(tools: StudioTools, out: Path, *, side_by_side: bool = False, characters: list[str] | None = None) -> dict[str, Any]

Final motion -> retarget, check, render (unless the model rendered exactly it), files in the run dir; with characters, also a report per character and the lineup video (next to the source video with side_by_side).