hylo.codeagents.motion_ops¶
Package: hylo-code-agents · Core contracts
motion_ops ¶
Motion data and edits for the motion studio (pure numpy): one keypoint skeleton, converters from the motion tools and edits on joint trajectories.
Skeleton: 17 keypoints (NAMES, SOMA joint names), metres, z up, ground z = 0. canonical puts a motion on the
ground, at the origin, facing +x at its first frame, so edits can align clips by root position and heading.
Edits (concat, blend, loop, mirror, retime, trim, hold, keyframe) work on positions: clips are
aligned (the next clip starts where and facing where the last one ended) and cross-faded over a short window.
NAMES
module-attribute
¶
NAMES = ['Hips', 'Chest', 'Head', 'LeftLeg', 'LeftShin', 'LeftFoot', 'LeftToeBase', 'RightLeg', 'RightShin', 'RightFoot', 'RightToeBase', 'LeftArm', 'LeftForeArm', 'LeftHand', 'RightArm', 'RightForeArm', 'RightHand']
FEET
module-attribute
¶
MEDIAPIPE
module-attribute
¶
MEDIAPIPE = {'Hips': (23, 24), 'LeftLeg': (23,), 'LeftShin': (25,), 'LeftFoot': (27,), 'LeftToeBase': (31,), 'RightLeg': (24,), 'RightShin': (26,), 'RightFoot': (28,), 'RightToeBase': (32,), 'LeftArm': (11,), 'LeftForeArm': (13,), 'LeftHand': (15,), 'RightArm': (12,), 'RightForeArm': (14,), 'RightHand': (16,), 'Head': (7, 8)}
EDITS
module-attribute
¶
EDITS = {'concat': concat, 'blend': blend, 'loop': loop, 'mirror': mirror, 'retime': retime, 'trim': trim, 'hold': hold, 'keyframe': keyframe}
Motion
dataclass
¶
A skeleton motion: joints (T, 17, 3) in NAMES order, at fps. source says where it came from.
from_soma ¶
from_mediapipe ¶
MediaPipe Pose world keypoints (T, 33, 3; z up) -> the skeleton; frames without a person are interpolated.
level ¶
Remove a sideways tilt of the ground (a camera roll the pose estimator did not know): the standing heights of the left and right foot keypoints should match.
heading ¶
Yaw (rad) per frame of the hips' forward direction (left hip - right hip, turned -90 deg about z).
canonical ¶
Ground at z = 0 (low percentile of the feet), first root at x = y = 0, facing +x at the first frame.
concat ¶
Play clips one after another; each starts where (and facing where) the previous ended, cross-faded over
blend seconds (the overlap shortens the result by that much per join).
blend ¶
A smooth transition from a into b over seconds (same as concat with a longer cross-fade).
loop ¶
Repeat a clip times times; each repeat continues from where the previous one ended.
mirror ¶
Swap left and right (mirror across the vertical plane along the initial heading).
retime ¶
Play faster (speed > 1) or slower, or stretch to a duration in seconds.
trim ¶
The part between start and end (seconds; end None = to the end).
hold ¶
Stand still in a pose (the last frame of pose) for seconds.
keyframe ¶
Constrain m to pass through pose at time at (seconds): the body offset (relative to the root and
heading, so the pose is matched where the motion is at that time) is added with a smooth bump of width
seconds on each side, full at at; from at on it is held when at is the last frame. root: also match the
pelvis height.