Expand description
Wire-protocol definitions for the Zendo motion-tracking WebSocket stream.
This crate is the single source of truth for the binary protocol that the
Zendo desktop app emits and that zendo-sdk
consumes. It owns the port range, the message-type tags, the joint and
landmark vocabularies, and the pure decode/encode routines.
It has no dependencies, performs no I/O, never allocates, and is no_std
by default-disabling the std feature.
§Frame layout
Every frame is one binary WebSocket message: byte 0 is the type tag, the
rest is the payload. All numeric values are little-endian f64.
| Message | Tag | Payload |
|---|---|---|
| Hello | 0x01 | protocol version (u16 LE) |
| Body quaternions | 0x02 | 13 joints x (w, x, y, z) |
| Body landmarks | 0x03 | 19 landmarks x (x, y, z, confidence) |
| Hand quaternions | 0x04 | 1 side byte + 16 joints x (w, x, y, z) |
| Hand landmarks | 0x05 | 1 side byte + 21 landmarks x (x, y, z, confidence) |
| Body ISB angles | 0x06 | 21 scalar angles (radians) |
The server sends the hello frame first on every connection so clients can
detect a PROTOCOL_VERSION mismatch before decoding data frames.
§Example
use zendo_protocol::{decode, Message};
match decode(frame) {
Ok(Message::BodyQuaternions(q)) => println!("hips: {:?}", q.hips),
Ok(other) => println!("other message: {other:?}"),
Err(e) => eprintln!("bad frame: {e}"),
}Structs§
- Body
IsbAngles Frame - Body ISB joint angles for one frame (21 scalars, radians).
- Body
Landmark Frame - Body-landmark positions for one frame (19 MAIA landmarks).
- Body
Quaternion Frame - Body-joint orientations for one frame (13 joints).
- Hand
Landmark Frame - Hand-landmark positions for one frame (21 BlazePose hand landmarks).
- Hand
Quaternion Frame - Hand-joint orientations for one frame (16 joints).
- Landmark
- A 3D landmark position with a detection confidence in
[0, 1]. - Quaternion
- A unit quaternion describing a joint orientation:
w + xi + yj + zk.
Enums§
- Hand
Joint - A hand joint in a
HandQuaternionFrame. - Hand
Landmark Name - A hand landmark in a
HandLandmarkFrame. - Hand
Side - Which hand a hand frame describes.
- IsbAngle
Name - A scalar angle in a
BodyIsbAnglesFrame. - Joint
- A body joint in a
BodyQuaternionFrame. - Landmark
Name - A body landmark in a
BodyLandmarkFrame. - Message
- One decoded message from the Zendo stream.
- Protocol
Error - Why a binary frame could not be decoded.
Constants§
- BODY_
ISB_ ANGLE_ COUNT - Number of scalar angles in a body ISB-angles frame.
- BODY_
JOINT_ COUNT - Number of joints in a body-quaternion frame.
- BODY_
LANDMARK_ COUNT - Number of landmarks in a body-landmark frame (MAIA topology).
- ENCODED_
BODY_ ISB_ ANGLES_ LEN - Encoded size of a body ISB-angles frame, in bytes.
- ENCODED_
BODY_ LANDMARK_ LEN - Encoded size of a body-landmark frame, in bytes.
- ENCODED_
BODY_ QUATERNION_ LEN - Encoded size of a body-quaternion frame, in bytes.
- ENCODED_
HAND_ LANDMARK_ LEN - Encoded size of a hand-landmark frame, in bytes.
- ENCODED_
HAND_ QUATERNION_ LEN - Encoded size of a hand-quaternion frame, in bytes.
- ENCODED_
HELLO_ LEN - Encoded size of a hello frame, in bytes (tag +
u16version). - HAND_
JOINT_ COUNT - Number of joints in a hand-quaternion frame (wrist + 5 digits x MCP/PIP/DIP).
- HAND_
LANDMARK_ COUNT - Number of landmarks in a hand-landmark frame (BlazePose hand topology).
- HAND_
SIDE_ LEFT - Side byte identifying the left hand in hand frames.
- HAND_
SIDE_ RIGHT - Side byte identifying the right hand in hand frames.
- MSG_
BODY_ ISB_ ANGLES - Type tag for a body ISB-angles frame.
- MSG_
BODY_ LANDMARK - Type tag for a body-landmark frame.
- MSG_
BODY_ QUATERNION - Type tag for a body-quaternion frame.
- MSG_
HAND_ LANDMARK - Type tag for a hand-landmark frame.
- MSG_
HAND_ QUATERNION - Type tag for a hand-quaternion frame.
- MSG_
HELLO - Type tag for the hello frame the server sends first on every connection.
- PROTOCOL_
VERSION - The wire-protocol version this crate implements.
- WEBSOCKET_
PORT_ END - Last TCP port the Zendo WebSocket server tries to bind, inclusive.
- WEBSOCKET_
PORT_ START - First TCP port the Zendo WebSocket server tries to bind.
Functions§
- decode
- Decodes one binary WebSocket frame.
- decode_
hello - Decodes a hello frame, returning the server’s protocol version.
- encode_
body_ isb_ angles - Encodes a body ISB-angles frame (
0x06). - encode_
body_ landmarks - Encodes a body-landmark frame (
0x03). - encode_
body_ quaternions - Encodes a body-quaternion frame (
0x02). - encode_
hand_ landmarks - Encodes a hand-landmark frame (
0x05). - encode_
hand_ quaternions - Encodes a hand-quaternion frame (
0x04). - encode_
hello - Encodes a hello frame (
0x01) announcing the protocol version.