Body API Map
Parsed from stretch_body_ii/src/ with transport, RPC, endpoint, and ZMQ communication-chain details.
26
Modules
59
Classes
12,132
Lines (shown)
41
Class RPC Maps
Transport Layer
USB CDC transport stack including backend behavior, framing, checksum, line-coding notes, and PyO3 integration options for native extensions.
USB CDC transport
Python backend
TransportPySerial via aioserial.AioSerial; baud not explicitly set in Python path.
C backend
TransportCSerial via libtransport.so queue thread; open config uses raw serial mode.
Framing
Shared Hello transport framing with COBS encoding, CRC-16 Modbus, and 0x00 packet marker.
Notes
- Nominal USB CDC line coding is treated as 2,000,000 baud on the firmware side.
- C backend implementation notes include B115200 open flags in transport_framing.cpp.
- RPC limits: 1024-byte max payload, 64-byte raw frame ceiling, 58-byte v1 data chunks.
MCU Endpoint Mapping
Linux device paths mapped to board roles and fixed C-backend queue IDs (qid 0-5).
| Device path | Board | Firmware | qid |
|---|---|---|---|
| /dev/hello-motor-omni-0 | Omni wheel board 0 | Stepper | 0 |
| /dev/hello-motor-omni-1 | Omni wheel board 1 | Stepper | 1 |
| /dev/hello-motor-omni-2 | Omni wheel board 2 | Stepper | 2 |
| /dev/hello-motor-arm | Arm board | Stepper | 3 |
| /dev/hello-motor-lift | Lift board | Stepper | 4 |
| /dev/hello-power-periph | Power + IMU board | PowerPeriph | 5 |
ZMQ Client-Server Architecture
Three strict REQ/REP channels in Stretch Body: admin (5556), command (5557), and status (5558).
| Channel | Port | Server socket | Client socket | Request payload | Reply payload |
|---|---|---|---|---|---|
| admin | 5556 | REP bind tcp://*:5556 | REQ connect tcp://<host>:5556 | Raw bytes (ping/pause/unpause/kill) | Echoed admin response bytes |
| command | 5557 | REP bind tcp://*:5557 | REQ connect tcp://<host>:5557 | Python object list of command tuples | List of dispatched cmd_id values |
| status | 5558 | REP bind tcp://*:5558 | REQ connect tcp://<host>:5558 | Sentinel value 'STA' | Latest full robot status dictionary |
Full Command and Reply Chain
End-to-end flow from client command dispatch through transport framing and MCU reply decode.
| Step | From | To | Protocol | Description |
|---|---|---|---|---|
| 1 | StretchBodyClient | ZMQ Command Channel | REQ/REP tcp://<host>:5557 | Client sends batched commands as [subsystem, method, cmd_id, args, kwargs]. |
| 2 | StretchBodyServer | RobotServer._cb_command_dispatch | In-process dispatch | Server receives command list and calls target subsystem methods via getattr dispatch. |
| 3 | Arm/Lift/OmniBase/PowerPeriph API | Stepper / PowerPeriph firmware wrappers | Python method calls | Methods queue or emit array('B') payloads where payload[0] is the RPC ID. |
| 4 | Device class | Transport.do_rpc | Body transport API | Device-level wrapper selects push/pull and blocking/nonblocking behavior. |
| 5 | Transport | TransportPySerial or TransportCSerial | Python backend switch | Python backend uses AioSerial handlers; C backend uses ctypes -> libtransport.so. |
| 6 | Transaction handler | Framing layer | Hello Serial Transport v0/v1 | Payload chunks are framed and ACKed (v1 uses 58-byte data chunks). |
| 7 | Framing layer | USB CDC byte stream | COBS + CRC-16 Modbus + 0x00 delimiter | Frames append Modbus CRC, COBS-encode data, and terminate packets with 0x00. |
| 8 | Host USB device | MCU endpoints | USB CDC serial | Bytes travel through /dev/hello-motor-* and /dev/hello-power-periph device paths. |
| 9 | Firmware MCU | Host transport callback | ACK / RPC reply | MCU returns framed ACK or reply payload (reply IDs are +1 from command IDs). |
| 10 | RPC callback | Device status/config structs | Python unpack | Callbacks decode payload bytes into board status, telemetry, and configuration data. |
| 11 | StretchBodyClient | ZMQ Status Channel | REQ/REP tcp://<host>:5558 | Client sends status sentinel ('STA') to request latest aggregated robot status dict. |
| 12 | StretchBodyClient | ZMQ Admin Channel | REQ/REP tcp://<host>:5556 | Admin commands (ping/pause/unpause/kill) are exchanged as raw byte strings. |