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}
WORKER_OPS
module-attribute
¶
WORKER_OPS = {'retarget': SIM_WORKER, 'check': SIM_WORKER, 'validate': SIM_WORKER, 'clip': MEDIA_WORKER, 'compose': MEDIA_WORKER, 'rig': MEDIA_WORKER}
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.
joint_names
class-attribute
instance-attribute
¶
ToolBackend ¶
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 ¶
Another hylo tool (hands, depth, segment, ...) through its Python API; returns its outputs and files.
sim ¶
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.
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.
text_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 ¶
Reference video -> human motion (the human tool: MediaPipe Pose 3D keypoints; approximate world
grounding, static camera). start / seconds select a window.
pose_from_image ¶
A still image of a person -> a one-frame pose (use it with keyframe(...) or hold(...)).
motion_from_array ¶
Your own motion: joints (T, 17, 3) in NAMES order, metres, z up.
retarget ¶
Skeleton motion -> character motion: robots by keypoint IK (MuJoCo), rigged characters by bone driving (Blender); see motion_characters for the characters.
report ¶
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 ¶
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 ¶
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 ¶
Frames of a video (n, evenly spaced) or an image, as one contact sheet attached to the next feedback.
finish ¶
The final motion (skeleton or robot motion); ends the session.
robot_spec ¶
What motion_sim needs to know about an MJCF character (see its docstring and motion_characters).
render_tool_dir ¶
The hylo-tools render tool's worker scripts (its Blender locator, video writer and Blender look).
contact_sheet ¶
An RGB image of n evenly spaced frames of a video (time stamps drawn), or the image at path itself.
parse_characters ¶
--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).