# haozhang04/leggedskilldeploy architecture

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

- Interactive diagram: https://gitdiagram.com/haozhang04/leggedskilldeploy
- Repository: https://github.com/haozhang04/leggedskilldeploy

## Overview

LeggedSkillDeploy is a state-machine-based Python framework for deploying multiple learned robot policies in simulation or on a Go1 Pro. The principal workflow starts in a simulator or real-robot runner, accepts operator commands, evaluates policies through the deployment and policy layers, then sends robot commands through a simulation or hardware interface. The README documents MuJoCo, GLFW, Gazebo, and real Go1 operation, plus policies for several robot types and keyboard, Xbox, and phone controls. Some subsystems are represented from README or index evidence; their internal wiring is not inferred.

Main entry points: [`src/scripts/rl_sdk.py`](https://github.com/haozhang04/leggedskilldeploy/blob/main/src/scripts/rl_sdk.py) (Policy runtime), [`src/rl_gazebo.py`](https://github.com/haozhang04/leggedskilldeploy/blob/main/src/rl_gazebo.py) (Gazebo runner), [`src/scripts/rl_deploy.py`](https://github.com/haozhang04/leggedskilldeploy/blob/main/src/scripts/rl_deploy.py) (Policy deployment), [`src/input_dev/keyboard_control.py`](https://github.com/haozhang04/leggedskilldeploy/blob/main/src/input_dev/keyboard_control.py) (Keyboard controls)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime entrypoints"]
  node_mujoco["MuJoCo runner<br/>[rl_mujoco.py]"]
  node_glfw["GLFW runner<br/>[rl_mujoco_glfw.py]"]
  node_gazebo["Gazebo runner<br/>[rl_gazebo.py]"]
  node_realrunner["Real robot runner<br/>[rl_real_go1.py]"]
  node_descriptions["Robot descriptions"]
end

subgraph group_control["Operator control"]
  node_keyboard["Keyboard controls"]
  node_phone["Phone web controls"]
  node_xbox["Xbox controls<br/>[xbox_control.py]"]
  node_xboxpygame["Xbox controls"]
end

subgraph group_policy["Policy execution"]
  node_deploy["Policy deployment<br/>[rl_deploy.py]"]
  node_sdk["Policy runtime<br/>[rl_sdk.py]"]
  node_data["Robot and control data<br/>[rl_data.py]"]
  node_motion["Motion loader<br/>[motion_loader.py]"]
  node_observations["Observation buffer"]
  node_math["Quaternion utilities<br/>[math.py]"]
end

subgraph group_io["Robot interfaces"]
  node_mujocoio["MuJoCo I/O<br/>[IOMuJoCo.py]"]
  node_gazeboio["Gazebo I/O<br/>[IOGazebo.py]"]
  node_realio["Go1 hardware I/O<br/>[IOReal_go1.py]"]
end

subgraph group_hardware["Go1 protocol"]
  node_connection["Unitree connection"]
  node_lowcmd["Low-level commands<br/>[lowCmd.py]"]
  node_lowstate["Low-level state<br/>[lowState.py]"]
  node_complex["Protocol data types<br/>[complex.py]"]
  node_common["Protocol encoding<br/>[common.py]"]
  node_enums["Protocol enums<br/>[enums.py]"]
end

node_operator(("Operator"))

node_operator -->|"provides keys"| node_keyboard
node_operator -->|"provides input"| node_xbox
node_operator -->|"provides input"| node_phone
node_mujoco -->|"creates deployment"| node_deploy
node_glfw -->|"creates deployment"| node_deploy
node_gazebo -->|"creates deployment"| node_deploy
node_realrunner -->|"creates deployment"| node_deploy
node_mujoco -->|"creates interface"| node_mujocoio
node_glfw -->|"creates interface"| node_mujocoio
node_gazebo -->|"creates interface"| node_gazeboio
node_realrunner -->|"creates interface"| node_realio
node_mujoco -->|"starts controls"| node_keyboard
node_mujoco -->|"starts controls"| node_phone
node_mujoco -->|"selects controls"| node_xbox
node_glfw -->|"starts controls"| node_keyboard
node_glfw -->|"starts controls"| node_phone
node_glfw -->|"selects controls"| node_xboxpygame
node_gazebo -->|"starts controls"| node_keyboard
node_gazebo -->|"starts controls"| node_phone
node_gazebo -->|"starts controls"| node_xbox
node_realrunner -->|"starts controls"| node_keyboard
node_realrunner -->|"starts controls"| node_phone
node_realrunner -->|"starts controls"| node_xbox
node_keyboard -->|"updates control"| node_sdk
node_phone -->|"uses control data"| node_data
node_xbox -->|"updates control"| node_sdk
node_xboxpygame -->|"updates control"| node_sdk
node_deploy -->|"uses policy runtime"| node_sdk
node_deploy -->|"uses control data"| node_data
node_sdk -->|"uses data types"| node_data
node_sdk -->|"loads motion"| node_motion
node_sdk -->|"uses buffer"| node_observations
node_sdk -->|"uses quaternion math"| node_math
node_realio -->|"builds commands"| node_lowcmd
node_realio -->|"reads state"| node_lowstate
node_realio -->|"uses data types"| node_complex
node_realio -->|"sends over connection"| node_connection
node_lowcmd -->|"uses data types"| node_complex
node_lowcmd -->|"uses encoding"| node_common
node_lowcmd -->|"uses modes"| node_enums
node_lowstate -->|"uses data types"| node_complex
node_lowstate -->|"uses decoding"| node_common
node_lowstate -->|"uses enums"| node_enums
node_complex -->|"uses conversions"| node_common
node_complex -->|"uses modes"| node_enums
node_connection -->|"uses protocol helpers"| node_common
node_connection -->|"handles state"| node_lowstate
node_descriptions -.->|"supports simulation"| node_gazebo

click node_mujoco "https://github.com/haozhang04/leggedskilldeploy/blob/main/src/rl_mujoco.py"
click node_glfw "https://github.com/haozhang04/leggedskilldeploy/blob/main/src/rl_mujoco_glfw.py"
click node_gazebo "https://github.com/haozhang04/leggedskilldeploy/blob/main/src/rl_gazebo.py"
click node_realrunner "https://github.com/haozhang04/leggedskilldeploy/blob/main/src/rl_real_go1.py"
click node_keyboard "https://github.com/haozhang04/leggedskilldeploy/blob/main/src/input_dev/keyboard_control.py"
click node_phone "https://github.com/haozhang04/leggedskilldeploy/blob/main/src/input_dev/phone_web_control.py"
click node_xbox "https://github.com/haozhang04/leggedskilldeploy/blob/main/src/input_dev/xbox_control.py"
click node_xboxpygame "https://github.com/haozhang04/leggedskilldeploy/blob/main/src/input_dev/xbox_control_pygame.py"
click node_deploy "https://github.com/haozhang04/leggedskilldeploy/blob/main/src/scripts/rl_deploy.py"
click node_sdk "https://github.com/haozhang04/leggedskilldeploy/blob/main/src/scripts/rl_sdk.py"
click node_data "https://github.com/haozhang04/leggedskilldeploy/blob/main/src/scripts/rl_data.py"
click node_motion "https://github.com/haozhang04/leggedskilldeploy/blob/main/src/scripts/motion_loader.py"
click node_observations "https://github.com/haozhang04/leggedskilldeploy/blob/main/src/scripts/observation_buffer.py"
click node_math "https://github.com/haozhang04/leggedskilldeploy/blob/main/src/utils/math.py"
click node_mujocoio "https://github.com/haozhang04/leggedskilldeploy/blob/main/src/interface/IOMuJoCo.py"
click node_gazeboio "https://github.com/haozhang04/leggedskilldeploy/blob/main/src/interface/IOGazebo.py"
click node_realio "https://github.com/haozhang04/leggedskilldeploy/blob/main/src/interface/IOReal_go1.py"
click node_connection "https://github.com/haozhang04/leggedskilldeploy/blob/main/motor_sdk/go1_pro_sdk/ucl/unitreeConnection.py"
click node_lowcmd "https://github.com/haozhang04/leggedskilldeploy/blob/main/motor_sdk/go1_pro_sdk/ucl/lowCmd.py"
click node_lowstate "https://github.com/haozhang04/leggedskilldeploy/blob/main/motor_sdk/go1_pro_sdk/ucl/lowState.py"
click node_complex "https://github.com/haozhang04/leggedskilldeploy/blob/main/motor_sdk/go1_pro_sdk/ucl/complex.py"
click node_common "https://github.com/haozhang04/leggedskilldeploy/blob/main/motor_sdk/go1_pro_sdk/ucl/common.py"
click node_enums "https://github.com/haozhang04/leggedskilldeploy/blob/main/motor_sdk/go1_pro_sdk/ucl/enums.py"
click node_descriptions "https://github.com/haozhang04/leggedskilldeploy/tree/main/robot_description/urdf/src"

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_mujoco,node_glfw,node_gazebo,node_realrunner,node_descriptions toneBlue
class node_keyboard,node_phone,node_xbox,node_xboxpygame toneAmber
class node_deploy,node_sdk,node_data,node_motion,node_observations,node_math toneMint
class node_mujocoio,node_gazeboio,node_realio toneRose
class node_connection,node_lowcmd,node_lowstate,node_complex,node_common,node_enums,node_operator toneIndigo
```

## Components

### Runtime entrypoints

- [MuJoCo runner](https://github.com/haozhang04/leggedskilldeploy/blob/main/src/rl_mujoco.py): `src/rl_mujoco.py`
- [GLFW runner](https://github.com/haozhang04/leggedskilldeploy/blob/main/src/rl_mujoco_glfw.py): `src/rl_mujoco_glfw.py`
- [Gazebo runner](https://github.com/haozhang04/leggedskilldeploy/blob/main/src/rl_gazebo.py): `src/rl_gazebo.py`
- [Real robot runner](https://github.com/haozhang04/leggedskilldeploy/blob/main/src/rl_real_go1.py): `src/rl_real_go1.py`
- [Robot descriptions](https://github.com/haozhang04/leggedskilldeploy/tree/main/robot_description/urdf/src): `robot_description/urdf/src`

### Operator control

- [Keyboard controls](https://github.com/haozhang04/leggedskilldeploy/blob/main/src/input_dev/keyboard_control.py): `src/input_dev/keyboard_control.py`
- [Phone web controls](https://github.com/haozhang04/leggedskilldeploy/blob/main/src/input_dev/phone_web_control.py): `src/input_dev/phone_web_control.py`
- [Xbox controls](https://github.com/haozhang04/leggedskilldeploy/blob/main/src/input_dev/xbox_control.py): `src/input_dev/xbox_control.py`
- [Xbox controls](https://github.com/haozhang04/leggedskilldeploy/blob/main/src/input_dev/xbox_control_pygame.py): `src/input_dev/xbox_control_pygame.py`

### Policy execution

- [Policy deployment](https://github.com/haozhang04/leggedskilldeploy/blob/main/src/scripts/rl_deploy.py): `src/scripts/rl_deploy.py`
- [Policy runtime](https://github.com/haozhang04/leggedskilldeploy/blob/main/src/scripts/rl_sdk.py): `src/scripts/rl_sdk.py`
- [Robot and control data](https://github.com/haozhang04/leggedskilldeploy/blob/main/src/scripts/rl_data.py): `src/scripts/rl_data.py`
- [Motion loader](https://github.com/haozhang04/leggedskilldeploy/blob/main/src/scripts/motion_loader.py): `src/scripts/motion_loader.py`
- [Observation buffer](https://github.com/haozhang04/leggedskilldeploy/blob/main/src/scripts/observation_buffer.py): `src/scripts/observation_buffer.py`
- [Quaternion utilities](https://github.com/haozhang04/leggedskilldeploy/blob/main/src/utils/math.py): `src/utils/math.py`

### Robot interfaces

- [MuJoCo I/O](https://github.com/haozhang04/leggedskilldeploy/blob/main/src/interface/IOMuJoCo.py): `src/interface/IOMuJoCo.py`
- [Gazebo I/O](https://github.com/haozhang04/leggedskilldeploy/blob/main/src/interface/IOGazebo.py): `src/interface/IOGazebo.py`
- [Go1 hardware I/O](https://github.com/haozhang04/leggedskilldeploy/blob/main/src/interface/IOReal_go1.py): `src/interface/IOReal_go1.py`

### Go1 protocol

- [Unitree connection](https://github.com/haozhang04/leggedskilldeploy/blob/main/motor_sdk/go1_pro_sdk/ucl/unitreeConnection.py): `motor_sdk/go1_pro_sdk/ucl/unitreeConnection.py`
- [Low-level commands](https://github.com/haozhang04/leggedskilldeploy/blob/main/motor_sdk/go1_pro_sdk/ucl/lowCmd.py): `motor_sdk/go1_pro_sdk/ucl/lowCmd.py`
- [Low-level state](https://github.com/haozhang04/leggedskilldeploy/blob/main/motor_sdk/go1_pro_sdk/ucl/lowState.py): `motor_sdk/go1_pro_sdk/ucl/lowState.py`
- [Protocol data types](https://github.com/haozhang04/leggedskilldeploy/blob/main/motor_sdk/go1_pro_sdk/ucl/complex.py): `motor_sdk/go1_pro_sdk/ucl/complex.py`
- [Protocol encoding](https://github.com/haozhang04/leggedskilldeploy/blob/main/motor_sdk/go1_pro_sdk/ucl/common.py): `motor_sdk/go1_pro_sdk/ucl/common.py`
- [Protocol enums](https://github.com/haozhang04/leggedskilldeploy/blob/main/motor_sdk/go1_pro_sdk/ucl/enums.py): `motor_sdk/go1_pro_sdk/ucl/enums.py`

### Other components

- **Operator**

## Connections

- Operator → Keyboard controls: provides keys (evidence: `README.md`)
- Operator → Xbox controls: provides input (evidence: `README.md`)
- Operator → Phone web controls: provides input (evidence: `README.md`)
- MuJoCo runner → Policy deployment: creates deployment (evidence: `src/rl_mujoco.py`)
- GLFW runner → Policy deployment: creates deployment (evidence: `src/rl_mujoco_glfw.py`)
- Gazebo runner → Policy deployment: creates deployment (evidence: `src/rl_gazebo.py`)
- Real robot runner → Policy deployment: creates deployment (evidence: `src/rl_real_go1.py`)
- MuJoCo runner → MuJoCo I/O: creates interface (evidence: `src/rl_mujoco.py`)
- GLFW runner → MuJoCo I/O: creates interface (evidence: `src/rl_mujoco_glfw.py`)
- Gazebo runner → Gazebo I/O: creates interface (evidence: `src/rl_gazebo.py`)
- Real robot runner → Go1 hardware I/O: creates interface (evidence: `src/rl_real_go1.py`)
- MuJoCo runner → Keyboard controls: starts controls (evidence: `src/rl_mujoco.py`)
- MuJoCo runner → Phone web controls: starts controls (evidence: `src/rl_mujoco.py`)
- MuJoCo runner → Xbox controls: selects controls (evidence: `src/rl_mujoco.py`)
- GLFW runner → Keyboard controls: starts controls (evidence: `src/rl_mujoco_glfw.py`)
- GLFW runner → Phone web controls: starts controls (evidence: `src/rl_mujoco_glfw.py`)
- GLFW runner → Xbox controls: selects controls (evidence: `src/rl_mujoco_glfw.py`)
- Gazebo runner → Keyboard controls: starts controls (evidence: `src/rl_gazebo.py`)
- Gazebo runner → Phone web controls: starts controls (evidence: `src/rl_gazebo.py`)
- Gazebo runner → Xbox controls: starts controls (evidence: `src/rl_gazebo.py`)
- Real robot runner → Keyboard controls: starts controls (evidence: `src/rl_real_go1.py`)
- Real robot runner → Phone web controls: starts controls (evidence: `src/rl_real_go1.py`)
- Real robot runner → Xbox controls: starts controls (evidence: `src/rl_real_go1.py`)
- Keyboard controls → Policy runtime: updates control (evidence: `src/input_dev/keyboard_control.py`)
- Phone web controls → Robot and control data: uses control data (evidence: `src/input_dev/phone_web_control.py`)
- Xbox controls → Policy runtime: updates control (evidence: `src/input_dev/xbox_control.py`)
- Xbox controls → Policy runtime: updates control (evidence: `src/input_dev/xbox_control_pygame.py`)
- Policy deployment → Policy runtime: uses policy runtime (evidence: `src/scripts/rl_deploy.py`)
- Policy deployment → Robot and control data: uses control data (evidence: `src/scripts/rl_deploy.py`)
- Policy runtime → Robot and control data: uses data types (evidence: `src/scripts/rl_sdk.py`)
- Policy runtime → Motion loader: loads motion (evidence: `src/scripts/rl_sdk.py`)
- Policy runtime → Observation buffer: uses buffer (evidence: `src/scripts/rl_sdk.py`)
- Policy runtime → Quaternion utilities: uses quaternion math (evidence: `src/scripts/rl_sdk.py`)
- Go1 hardware I/O → Low-level commands: builds commands (evidence: `src/interface/IOReal_go1.py`)
- Go1 hardware I/O → Low-level state: reads state (evidence: `src/interface/IOReal_go1.py`)
- Go1 hardware I/O → Protocol data types: uses data types (evidence: `src/interface/IOReal_go1.py`)
- Go1 hardware I/O → Unitree connection: sends over connection (evidence: `src/interface/IOReal_go1.py`)
- Low-level commands → Protocol data types: uses data types (evidence: `motor_sdk/go1_pro_sdk/ucl/lowCmd.py`)
- Low-level commands → Protocol encoding: uses encoding (evidence: `motor_sdk/go1_pro_sdk/ucl/lowCmd.py`)
- Low-level commands → Protocol enums: uses modes (evidence: `motor_sdk/go1_pro_sdk/ucl/lowCmd.py`)
- Low-level state → Protocol data types: uses data types (evidence: `motor_sdk/go1_pro_sdk/ucl/lowState.py`)
- Low-level state → Protocol encoding: uses decoding (evidence: `motor_sdk/go1_pro_sdk/ucl/lowState.py`)
- Low-level state → Protocol enums: uses enums (evidence: `motor_sdk/go1_pro_sdk/ucl/lowState.py`)
- Protocol data types → Protocol encoding: uses conversions (evidence: `motor_sdk/go1_pro_sdk/ucl/complex.py`)
- Protocol data types → Protocol enums: uses modes (evidence: `motor_sdk/go1_pro_sdk/ucl/complex.py`)
- Unitree connection → Protocol encoding: uses protocol helpers (evidence: `motor_sdk/go1_pro_sdk/ucl/unitreeConnection.py`)
- Unitree connection → Low-level state: handles state (evidence: `motor_sdk/go1_pro_sdk/ucl/unitreeConnection.py`)
- Robot descriptions → Gazebo runner: supports simulation (evidence: `README.md`)
