ADCS.helpers.animations.godot.protocol module¶
Framing for the ADCS visualization stream, protocol version 1.
Every message is a 20-byte little-endian header followed by a payload:
offset size field
0 4 magic b"ADVZ"
4 2 protocol major version (uint16) = 1
6 2 message type (uint16)
8 4 payload length in bytes (uint32)
12 8 sequence number (uint64), per sender, starting at 0
Rows and blocks carry the same float64 values, in the same channel order, as
the files of an adcs-vizlog (see docs/source/viz/protocol_v1.rst).
Only the standard library and numpy are used, so this module is also the
reference for ports to other languages.
- exception ADCS.helpers.animations.godot.protocol.ProtocolError[source]¶
Bases:
RuntimeErrorMalformed or unexpected message.
- class ADCS.helpers.animations.godot.protocol.MsgType(*values)[source]¶
Bases:
IntEnumMessage types. Server = the Python side, client = the viewer.
- ACK = 5¶
client -> server, acknowledges header seq (lockstep mode)
- ASSET = 8¶
server -> client, a file the scene refers to (e.g. spacecraft model), see encode_asset
- BLOCK = 2¶
server -> client, many rows of one run (playback)
- CONNECT = 6¶
client -> server, JSON {token, client, protocol}
- END = 4¶
id} or {} for end of session
- Type:
server -> client, JSON {“run_id”
- EPHEMERIS_QUERY = 9¶
client -> server, JSON {t_s}; TT seconds since log epoch
- EPHEMERIS_STATE = 10¶
server -> client, JSON celestial positions and orientations
- ERROR = 7¶
either direction, JSON {“message”}; the sender then closes
- HELLO = 1¶
server -> client, JSON {protocol, mode, manifest, scene}
- ROW = 3¶
server -> client, one row of one run (live)
- ADCS.helpers.animations.godot.protocol.decode_asset(payload)[source]¶
- Parameters:
payload (bytes)
- Return type:
Tuple[str, dict, bytes]
- ADCS.helpers.animations.godot.protocol.decode_block(payload, widths)[source]¶
- Parameters:
payload (bytes)
widths (Sequence[int])
- Return type:
Tuple[str, int, List[ndarray]]
- ADCS.helpers.animations.godot.protocol.decode_json(payload)[source]¶
- Parameters:
payload (bytes)
- Return type:
Any
- ADCS.helpers.animations.godot.protocol.decode_row(payload)[source]¶
- Parameters:
payload (bytes)
- Return type:
Tuple[str, ndarray]
- ADCS.helpers.animations.godot.protocol.encode_asset(name, meta, data)[source]¶
ASSET payload:
u16 n, name[n] (UTF-8), u32 m, meta[m] (JSON), data.Sent after HELLO for each file the scene refers to (the spacecraft model’s levels of detail), so a viewer never needs the Python side’s file paths.
metacarries at least{"kind", "sha256"}.- Parameters:
name (str)
meta (dict)
data (bytes)
- Return type:
bytes
- ADCS.helpers.animations.godot.protocol.encode_block(run_id, row_start, columns)[source]¶
BLOCK payload:
u16 len, run_id, u32 row_start, u32 n_rows, then each channel in manifest order asfloat64[n_rows, width](row-major), i.e. a slice of each channel file, concatenated.- Parameters:
run_id (str)
row_start (int)
columns (Sequence[ndarray])
- Return type:
bytes
- ADCS.helpers.animations.godot.protocol.encode_json(obj)[source]¶
- Parameters:
obj (Any)
- Return type:
bytes
- ADCS.helpers.animations.godot.protocol.encode_row(run_id, values)[source]¶
ROW payload:
u16 len, run_id (UTF-8), float64[row_width].valuesis one row with all channels concatenated in manifest order, i.e. byte-identical to the corresponding row of the vizlog files.- Parameters:
run_id (str)
values (ndarray)
- Return type:
bytes
- ADCS.helpers.animations.godot.protocol.pack_frame(msg_type, payload=b'', seq=0)[source]¶
- Parameters:
msg_type (MsgType)
payload (bytes)
seq (int)
- Return type:
bytes
- ADCS.helpers.animations.godot.protocol.read_frame(sock)[source]¶
Read one message.
- Returns:
(type, seq, payload).- Raises:
ConnectionError – If the peer closed the connection.
ProtocolError – On a bad magic, version or type.
- Parameters:
sock (socket)
- Return type:
Tuple[MsgType, int, bytes]
- ADCS.helpers.animations.godot.protocol.MAX_PAYLOAD = 67108864¶
Upper bound on a single payload; blocks are split to stay below it.