The wire
The behaviour model does not draw. Sixty times a second it says a whole pose: how much of each muscle of the face, and how each joint is turned. Whatever takes those messages and shows them is a puppet. This page is the contract between the two. Wire number 1.
How it travels
- One JSON object a message, one message a UDP datagram, to
127.0.0.1:9000by default. - 60 a second by default. No answer is expected.
- A message is the whole pose. Nothing is kept from one message to the next, so a lost message costs one frame, a puppet may start listening at any moment, and two puppets may listen to copies of one stream.
- The same messages, a line each, can be kept in a file and played back.
A message
{
"wire": 1,
"blend": { "jawOpen": 0.12, "mouthSmileLeft": 0.31, "eyeBlinkLeft": 0.0 },
"bones": { "head": [3.1, -8.0, 1.2], "leftEye": [-2.0, 6.5, 0],
"chest": [1.0, 2.2, -0.4], "armL": [4, -30, 2] },
"pupil": 0.31,
"flush": 0.0,
"smooth": 0
}
| Field | What it is | Range |
|---|---|---|
wire | which wire this is | 1 |
blend | the face: how much of each of its 52 shapes, by ARKit's names | 0 to 1 each |
bones | each joint's turn from its rest, by name: [pitch, yaw, roll] in degrees | see below |
pupil | the pupil's width as a share of the iris's | about 0.22 to 0.36 |
flush | how much she blushes | 0 to 1 |
smooth | seconds the puppet should smooth by; the model sends 0, because how things move is its to say | 0 |
A puppet ignores a field, a face shape or a bone it does not have. That is what makes a small body possible.
Turns
- Axes are the character's own: x to its left, y up, z forward.
- A turn is [pitch, yaw, roll] in degrees: +pitch nods down, +yaw turns to its own left, +roll tilts to its own right, applied yaw, then pitch, then roll.
- A bone's turn is from its rest pose, in its parent's frame; a bone carries everything that hangs from it.
The bones
| Bone | Hangs from | What turns it |
|---|---|---|
chest | the waist | leaning, turning and tilting of the trunk |
head | neck | where the head points, less the chest's turn |
leftEye, rightEye | head | each eye from where the head points |
collarL, collarR | chest | a shoulder lifting and coming forward |
armL, armR | its collar | the upper arm, from straight and 75° below level at the side |
forearmL, forearmR | its upper arm | the elbow, from straight |
twistL, twistR | its forearm | the forearm turning about its own line |
handL, handR | its twist | the wrist's bend |
index, middle, ring, pinky, thumb + L/R + 1, 2, 3 | the hand, then the joint before | a finger joint, from a flat hand |
What the sender promises
- Every number is finite; face values are within 0 to 1.
- Joints stay within how far recorded people's went, and the forearms and hands are kept out of each other.
- Not promised: how fast. A blink shuts the lids in about a twentieth of a second; an eye jumps at several hundred degrees a second, as people's do. A body that cannot go that fast limits it itself.
- Not promised: that the trunk, the arms and a table meet properly. Nothing here is physics.
A body of few motors
A robot's head does not have 52 face shapes. A body's description says, for each motor, what of a message moves it, how far it goes and how fast:
{ "name": "neckYaw", "unit": "degrees", "range": [-70, 70], "speed": 240, "rest": 0,
"from": [{ "bone": "head", "axis": 1, "gain": 1 },
{ "bone": "chest", "axis": 1, "gain": 1 }] }
A motor is a sum of parts of the message, each by a weight: a face value, a bone's turn about one axis, or another number of the message. It is held within its range and its speed, and how often more was asked is counted: that says whether a body is quick and free enough for how people move.
Writing a puppet
Listen on a UDP port, or read lines of a file. For each message, set the face shapes and the bones you have, with the axes and rest pose above, and ignore the rest. The hair, the light and anything else that is not behaviour are the puppet's own. A browser cannot hear UDP: bring the messages to it over a WebSocket or server-sent events with a small relay.