# unitreerobotics/dfx_inspire_service architecture

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

- Interactive diagram: https://gitdiagram.com/unitreerobotics/dfx_inspire_service
- Repository: https://github.com/unitreerobotics/dfx_inspire_service

## Overview

DFX Inspire Hand service bridges Unitree DDS motor commands and state messages to the hand’s serial protocol. H1 and G1 launch paths configure different serial arrangements, then periodically apply 12 joint commands and read 12 joint states. The graph covers the sampled runtime and README-documented example capability; example internals were not sampled, so its link is documented rather than source-verified.

Main entry points: [`inspire_h1.cpp`](https://github.com/unitreerobotics/dfx_inspire_service/blob/master/inspire_h1.cpp) (Periodic hand runner), [`include/dds/Subscription.h`](https://github.com/unitreerobotics/dfx_inspire_service/blob/master/include/dds/Subscription.h) (Command subscription), [`inspire_g1.cpp`](https://github.com/unitreerobotics/dfx_inspire_service/blob/master/inspire_g1.cpp) (G1 service), [`include/dds/Publisher.h`](https://github.com/unitreerobotics/dfx_inspire_service/blob/master/include/dds/Publisher.h) (State publisher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Service entrypoints"]
  node_h1["H1 service<br/>[inspire_h1.cpp]"]
  node_g1["G1 service<br/>[inspire_g1.cpp]"]
  node_config["Runtime parameters<br/>[param.h]"]
  node_runner["Periodic hand runner<br/>[inspire_h1.cpp]"]
end

subgraph group_messaging["DDS messaging"]
  node_command_sub["Command subscription<br/>[Subscription.h]"]
  node_state_pub["State publisher<br/>[Publisher.h]"]
end

subgraph group_hardware["Hand hardware"]
  node_hand_protocol["Hand protocol control<br/>[inspire.h]"]
  node_serial["Serial transport<br/>[SerialPort.h]"]
  node_hand{{"Inspire hands"}}
end

node_user(("DDS client"))
node_example["Hand example client<br/>[hand_example.cpp]"]

node_user -->|"sends commands"| node_command_sub
node_command_sub -->|"provides commands"| node_runner
node_h1 -->|"reads options"| node_config
node_g1 -->|"reads options"| node_config
node_h1 -->|"starts"| node_runner
node_g1 -->|"starts"| node_runner
node_runner -->|"checks freshness"| node_command_sub
node_runner -->|"sets and reads"| node_hand_protocol
node_hand_protocol -->|"sends and receives"| node_serial
node_serial -->|"serial frames"| node_hand
node_runner -->|"publishes states"| node_state_pub
node_state_pub -->|"sends state topic"| node_user
node_example -.->|"DDS client example"| node_user

click node_h1 "https://github.com/unitreerobotics/dfx_inspire_service/blob/master/inspire_h1.cpp"
click node_g1 "https://github.com/unitreerobotics/dfx_inspire_service/blob/master/inspire_g1.cpp"
click node_config "https://github.com/unitreerobotics/dfx_inspire_service/blob/master/include/param.h"
click node_runner "https://github.com/unitreerobotics/dfx_inspire_service/blob/master/inspire_h1.cpp"
click node_command_sub "https://github.com/unitreerobotics/dfx_inspire_service/blob/master/include/dds/Subscription.h"
click node_state_pub "https://github.com/unitreerobotics/dfx_inspire_service/blob/master/include/dds/Publisher.h"
click node_hand_protocol "https://github.com/unitreerobotics/dfx_inspire_service/blob/master/include/inspire.h"
click node_serial "https://github.com/unitreerobotics/dfx_inspire_service/blob/master/include/SerialPort.h"
click node_example "https://github.com/unitreerobotics/dfx_inspire_service/blob/master/example/hand_example.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_h1,node_g1,node_config,node_runner,node_user,node_example toneBlue
class node_command_sub,node_state_pub toneAmber
class node_hand_protocol,node_serial,node_hand toneMint
```

## Components

### Service entrypoints

- [H1 service](https://github.com/unitreerobotics/dfx_inspire_service/blob/master/inspire_h1.cpp): `inspire_h1.cpp`
- [G1 service](https://github.com/unitreerobotics/dfx_inspire_service/blob/master/inspire_g1.cpp): `inspire_g1.cpp`
- [Runtime parameters](https://github.com/unitreerobotics/dfx_inspire_service/blob/master/include/param.h): `include/param.h`
- [Periodic hand runner](https://github.com/unitreerobotics/dfx_inspire_service/blob/master/inspire_h1.cpp): `inspire_h1.cpp`

### DDS messaging

- [Command subscription](https://github.com/unitreerobotics/dfx_inspire_service/blob/master/include/dds/Subscription.h): `include/dds/Subscription.h`
- [State publisher](https://github.com/unitreerobotics/dfx_inspire_service/blob/master/include/dds/Publisher.h): `include/dds/Publisher.h`

### Hand hardware

- [Hand protocol control](https://github.com/unitreerobotics/dfx_inspire_service/blob/master/include/inspire.h): `include/inspire.h`
- [Serial transport](https://github.com/unitreerobotics/dfx_inspire_service/blob/master/include/SerialPort.h): `include/SerialPort.h`
- **Inspire hands**

### Other components

- **DDS client**
- [Hand example client](https://github.com/unitreerobotics/dfx_inspire_service/blob/master/example/hand_example.cpp): `example/hand_example.cpp`

## Connections

- DDS client → Command subscription: sends commands (evidence: `README.md`)
- Command subscription → Periodic hand runner: provides commands (evidence: `inspire_h1.cpp`)
- H1 service → Runtime parameters: reads options (evidence: `inspire_h1.cpp`)
- G1 service → Runtime parameters: reads options (evidence: `inspire_g1.cpp`)
- H1 service → Periodic hand runner: starts (evidence: `inspire_h1.cpp`)
- G1 service → Periodic hand runner: starts (evidence: `inspire_g1.cpp`)
- Periodic hand runner → Command subscription: checks freshness (evidence: `inspire_h1.cpp`)
- Periodic hand runner → Hand protocol control: sets and reads (evidence: `inspire_h1.cpp`)
- Hand protocol control → Serial transport: sends and receives (evidence: `include/inspire.h`)
- Serial transport → Inspire hands: serial frames
- Periodic hand runner → State publisher: publishes states (evidence: `inspire_h1.cpp`)
- State publisher → DDS client: sends state topic (evidence: `README.md`)
- Hand example client → DDS client: DDS client example (evidence: `README.md`)
