hylo.codeagents.motion¶
Package: hylo-code-agents · Core contracts
motion ¶
The motion studio (RFC-0006 part 8): a request (text, an image of a pose, or a reference video) -> a humanoid or robot motion, checked and rendered, by a chat model writing Python against motion tools.
hylo motion "wave with the right hand, then bow" --robot g1 --out runs/motion/wave
hylo motion "do this pose" --image pose.jpg --robot g1 --out DIR [--model SPEC] [--budget turns=12,cost=1]
hylo motion "copy the person" --video clip.mp4 --robot human --out DIR [--side-by-side] [--style mujoco]
hylo motion "jump and wave" --characters all --out DIR the final motion on every character, one video
hylo motion --free "a looping dance from the clip" --video clip.mp4 --out DIR (free mode: motion_free)
One agent loop (the code-agents sandbox and CodeLoop): each turn the model writes one Python block; the tools in
its namespace are text_motion (NVIDIA Kimodo), video_motion and pose_from_image (the human tool), the motion edits
of motion_ops, retarget (any character of motion_characters: humanoid robots from MuJoCo Menagerie, Hylo's capsule
figure, rigged human characters driven in Blender), check (plausibility and a physics rollout), render (Blender
Cycles on the CPU, MuJoCo fallback), lineup (one render per character, composed into a labelled grid) and look;
finish(motion) ends it. Slow tool calls do not count against the block time limit. The run directory gets log.jsonl
(turns and tool calls), motion.npz, check.json, motion.mp4 (+ split.mp4 with --side-by-side) and summary.json
(turns, cost, wall time, time per tool). With --characters the final motion is also retargeted to, checked on and
rendered with each of those characters: characters.json and lineup.mp4 (with --video and --side-by-side, split.mp4
puts the source clip next to each character) instead of motion.mp4.
This module is the agent loop and the CLI; the tools, their backend and the final report are in motion_tools, the characters in motion_characters (mapping files) and the retargeting in motion_retarget / motion_sim / motion_blender. Tests pass a fake backend. SPEC is a chat-model spec (JSON or shorthand, hylo.reasoners.llm.chat); default Ollama qwen3.5:35b-a3b with vision.
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}
SYSTEM
module-attribute
¶
SYSTEM = 'You are a motion director. You turn a request into a humanoid motion for a robot by writing Python that\ncalls motion tools, then check it and render it.\n\nTools (already in your namespace; motions are objects, print them to see a summary):\n- text_motion(prompt, seconds=4.0, seed=0) -> Motion. A text-to-motion model (NVIDIA Kimodo, ~1 min per call).\n Describe one person\'s movement plainly ("a person waves with the right hand"). For a sequence, pass a list of\n prompts and a list of seconds (one per segment): it makes one continuous motion.\n- video_motion(path="video", start=0.0, seconds=None) -> Motion from the reference video (pose estimation).\n- pose_from_image(path="image") -> a one-frame Motion: the pose of the person in the image.\n- Edits (return new motions): concat(m1, m2, ..., blend=0.3), blend(a, b, seconds=0.5), loop(m, times=2),\n mirror(m) (left <-> right), retime(m, speed=None, seconds=None), trim(m, start=0.0, end=None),\n hold(pose, seconds=1.0) (stand still in the last frame of pose), keyframe(m, pose, at, width=0.8) (make m pass\n through pose at time `at` seconds), motion_from_array(joints, fps) (your own (T, 17, 3) keypoints, names NAMES).\n- A Motion has .seconds, .frames, .fps, .joints (T, 17, 3 metres, z up, ground z = 0, facing +x at the start),\n .summary() (path length, turn, pelvis and hand heights), .pose(t), .joint(name).\n- retarget(m, robot=None) -> RobotMotion for a character (CHARACTERS lists them: robots g1, h1, t1, apollo, n1,\n "human" (a capsule figure) and rigged human characters); the run\'s robot by default.\n- check(m) -> {"problems": [...], "kinematics": {...}}. problems lists real defects (floor penetration,\n sliding feet, self-collision, joint limits, poor retargeting); kinematics has the metrics\n (com_outside_support_frac is static balance and is high for any dynamic motion: not a defect). The studio\n adds a physics rollout to the final report; you do not need it. Never change or drop part of the request to\n make the motion calmer or more stable.\n- render(m, camera="track", style=None) -> path of an MP4 (minutes; optional). A still frame is shown to you\n if you can see images.\n- lineup(m, characters=None) -> path of an MP4 with the motion on several characters side by side (minutes).\n- look(path, n=4) shows you n frames of a video in your next feedback.\n- finish(m, note="") -> the final motion. The studio then checks and renders it (you do not have to).\n\nHow to work:\n- Reply with a short thought, then exactly ONE fenced block ```python ... ```. It runs at once; you see what it\n printed and any error, then you write the next block. Variables persist between blocks.\n- Only math and numpy can be imported; no files, no classes, no names starting with an underscore.\n- print() what you need to see. Look at the summary: does the motion do what was asked (duration, path length,\n turn angle, hand heights)? If not, try a clearer prompt, another seed, or edit it.\n- Be economical: on this busy CPU every text_motion call takes 5-20 minutes and a render a few minutes. A good\n plan uses 2-3 blocks: generate (and edit), check, finish.\nEnding: call finish(motion) as soon as the motion does everything the request asks.'
EXAMPLE
module-attribute
¶
EXAMPLE = 'Example (another request: "step to the left, then clap twice"):\n```python\nm = text_motion(["a person steps to the left", "a person claps twice"], seconds=[2.5, 3.0])\nprint(m, m.summary())\nprint(check(m))\n```\nthen, if it looks right: ```python\nfinish(m, "steps left, then claps")\n```'
first_message ¶
first_message(request: str, robot: str, inputs: dict[str, str], budget: Budget, characters: list[str] | None = None) -> str
run_studio ¶
run_studio(request: str, out: str | Path, *, robot: str = 'g1', image: str | None = None, video: str | None = None, model: Any = None, budget: Budget | str | None = None, backend: Any = None, style: str = 'auto', side_by_side: bool = False, max_wall_s: float | None = None, block_timeout_s: float = 60.0, characters: list[str] | None = None, samples: int = 16, log: Callable[[str], None] = lambda s: None) -> dict[str, Any]
One motion-studio run; returns summary.json's content.
motion_command ¶
motion studio: text, an image of a pose or a reference video -> a motion on robots and human characters