# martin-axt/lerobot_cpp architecture

> Architecture diagram of the GitHub repository martin-axt/lerobot_cpp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/martin-axt/lerobot_cpp
- Repository: https://github.com/martin-axt/lerobot_cpp

## Overview

lerobot_cpp is a Linux C++ SDK for controlling SO-100/101 robots and Feetech STS3215 servos. The principal workflow is to command the SO101 in physical units; it clamps and converts joint values, then uses the servo application layer to issue motor operations through the Feetech protocol and Linux serial transport. The README also documents home, wave, and recording examples. Unsampled implementation details are represented only where documented; optional or otherwise unverified wiring is omitted.

Main entry points: [`src/robots/SO101.cpp`](https://github.com/martin-axt/lerobot_cpp/blob/main/src/robots/SO101.cpp) (SO101 controller), [`src/STS3215.cpp`](https://github.com/martin-axt/lerobot_cpp/blob/main/src/STS3215.cpp) (STS3215 control), [`src/SCS.cpp`](https://github.com/martin-axt/lerobot_cpp/blob/main/src/SCS.cpp) (SCS protocol), [`src/SCSerial.cpp`](https://github.com/martin-axt/lerobot_cpp/blob/main/src/SCSerial.cpp) (Linux serial I/O)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_robot["Robot control"]
  node_so101["SO101 controller<br/>[SO101.cpp]"]
  node_robotutils["Unit conversion<br/>[RobotUtils.cpp]"]
end

subgraph group_servo["Servo application"]
  node_sts["STS3215 control<br/>[STS3215.cpp]"]
  node_syncbuffer["Sync write buffer<br/>[SyncWriteBuffer.h]"]
  node_servoerrors["Servo errors<br/>[ServoErrors.h]"]
end

subgraph group_protocol["Communication"]
  node_scs["SCS protocol<br/>[SCS.cpp]"]
  node_serial["Linux serial I/O<br/>[SCSerial.cpp]"]
end

subgraph group_examples["Robot examples"]
  node_homeexample["SO101 home<br/>[SO101_Home.cpp]"]
  node_waveexample["SO101 wave<br/>[SO101_Wave.cpp]"]
  node_recordexample["SO101 record<br/>[SO101_Record.cpp]"]
end

node_user(("Robot operator"))
node_servohardware(("STS3215 servos"))

node_user -->|"commands joints"| node_so101
node_so101 -->|"converts units"| node_robotutils
node_so101 -->|"issues servo commands"| node_sts
node_sts -->|"builds sync writes"| node_syncbuffer
node_sts -.->|"uses protocol"| node_scs
node_scs -->|"dispatches I/O"| node_serial
node_serial -->|"transfers serial data"| node_servohardware
node_user -->|"runs example"| node_homeexample
node_user -->|"runs example"| node_waveexample
node_user -->|"runs example"| node_recordexample

click node_so101 "https://github.com/martin-axt/lerobot_cpp/blob/main/src/robots/SO101.cpp"
click node_robotutils "https://github.com/martin-axt/lerobot_cpp/blob/main/src/robots/RobotUtils.cpp"
click node_sts "https://github.com/martin-axt/lerobot_cpp/blob/main/src/STS3215.cpp"
click node_syncbuffer "https://github.com/martin-axt/lerobot_cpp/blob/main/include/lerobot_cpp/SyncWriteBuffer.h"
click node_servoerrors "https://github.com/martin-axt/lerobot_cpp/blob/main/include/lerobot_cpp/ServoErrors.h"
click node_scs "https://github.com/martin-axt/lerobot_cpp/blob/main/src/SCS.cpp"
click node_serial "https://github.com/martin-axt/lerobot_cpp/blob/main/src/SCSerial.cpp"
click node_homeexample "https://github.com/martin-axt/lerobot_cpp/blob/main/examples/robots/SO101_Home.cpp"
click node_waveexample "https://github.com/martin-axt/lerobot_cpp/blob/main/examples/robots/SO101_Wave.cpp"
click node_recordexample "https://github.com/martin-axt/lerobot_cpp/blob/main/examples/robots/SO101_Record.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_so101,node_robotutils toneBlue
class node_sts,node_syncbuffer,node_servoerrors toneAmber
class node_scs,node_serial toneMint
class node_homeexample,node_waveexample,node_recordexample toneRose
class node_user,node_servohardware toneIndigo
```

## Components

### Robot control

- [SO101 controller](https://github.com/martin-axt/lerobot_cpp/blob/main/src/robots/SO101.cpp): `src/robots/SO101.cpp`
- [Unit conversion](https://github.com/martin-axt/lerobot_cpp/blob/main/src/robots/RobotUtils.cpp): `src/robots/RobotUtils.cpp`

### Servo application

- [STS3215 control](https://github.com/martin-axt/lerobot_cpp/blob/main/src/STS3215.cpp): `src/STS3215.cpp`
- [Sync write buffer](https://github.com/martin-axt/lerobot_cpp/blob/main/include/lerobot_cpp/SyncWriteBuffer.h): `include/lerobot_cpp/SyncWriteBuffer.h`
- [Servo errors](https://github.com/martin-axt/lerobot_cpp/blob/main/include/lerobot_cpp/ServoErrors.h): `include/lerobot_cpp/ServoErrors.h`

### Communication

- [SCS protocol](https://github.com/martin-axt/lerobot_cpp/blob/main/src/SCS.cpp): `src/SCS.cpp`
- [Linux serial I/O](https://github.com/martin-axt/lerobot_cpp/blob/main/src/SCSerial.cpp): `src/SCSerial.cpp`

### Robot examples

- [SO101 home](https://github.com/martin-axt/lerobot_cpp/blob/main/examples/robots/SO101_Home.cpp): `examples/robots/SO101_Home.cpp`
- [SO101 wave](https://github.com/martin-axt/lerobot_cpp/blob/main/examples/robots/SO101_Wave.cpp): `examples/robots/SO101_Wave.cpp`
- [SO101 record](https://github.com/martin-axt/lerobot_cpp/blob/main/examples/robots/SO101_Record.cpp): `examples/robots/SO101_Record.cpp`

### Other components

- **Robot operator**
- **STS3215 servos**

## Connections

- Robot operator → SO101 controller: commands joints (evidence: `README.md`)
- SO101 controller → Unit conversion: converts units (evidence: `src/robots/SO101.cpp`)
- SO101 controller → STS3215 control: issues servo commands (evidence: `src/robots/SO101.cpp`)
- STS3215 control → Sync write buffer: builds sync writes (evidence: `src/STS3215.cpp`)
- STS3215 control → SCS protocol: uses protocol
- SCS protocol → Linux serial I/O: dispatches I/O (evidence: `src/SCSerial.cpp`)
- Linux serial I/O → STS3215 servos: transfers serial data (evidence: `src/SCSerial.cpp`)
- Robot operator → SO101 home: runs example (evidence: `README.md`)
- Robot operator → SO101 wave: runs example (evidence: `README.md`)
- Robot operator → SO101 record: runs example (evidence: `README.md`)
