# tool-as-interface/tool_as_interface architecture

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

- Interactive diagram: https://gitdiagram.com/tool-as-interface/tool_as_interface
- Repository: https://github.com/tool-as-interface/tool_as_interface

## Overview

Tool-as-Interface collects human-play video or teleoperated robot demonstrations, preprocesses data, trains a diffusion policy, and evaluates it on a real robot. Its runtime combines real-robot control and camera/observation processing with dataset, policy, and model layers. README documents the main user workflow; source-index references support several internal dependencies. Some script-to-runtime links and unsampled subsystem details remain unverified, so those relationships are omitted or dashed.

Main entry points: [`ti/policy/diffusion_unet_hybrid_image_policy.py`](https://github.com/tool-as-interface/tool_as_interface/blob/main/ti/policy/diffusion_unet_hybrid_image_policy.py) (Image Diffusion Policy), [`ti/real_world/real_ur5e_env.py`](https://github.com/tool-as-interface/tool_as_interface/blob/main/ti/real_world/real_ur5e_env.py) (UR5e Environment), [`scripts/demo_real_ur5e.py`](https://github.com/tool-as-interface/tool_as_interface/blob/main/scripts/demo_real_ur5e.py) (Robot Demo), [`scripts/eval_real_ur5e.py`](https://github.com/tool-as-interface/tool_as_interface/blob/main/scripts/eval_real_ur5e.py) (Robot Evaluation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_collection["Demonstration Collection"]
  node_human_capture["Human Capture"]
  node_human_prep["Human Preprocessing"]
  node_robot_demo["Robot Demo<br/>[demo_real_ur5e.py]"]
end

subgraph group_robot["Robot Runtime"]
  node_teleop["Teleoperation Devices<br/>[spacemouse.py]"]
  node_ur5e_env["UR5e Environment<br/>[real_ur5e_env.py]"]
  node_rtde["RTDE Controller"]
  node_kinova["Kinova Controller"]
  node_cameras["Camera Capture<br/>[multi_realsense.py]"]
  node_inference["Observation Processing"]
  node_segmentation["Object Segmentation<br/>[segmentation.py]"]
  node_evaluation["Robot Evaluation<br/>[eval_real_ur5e.py]"]
  node_human_evaluation["Human-Play Evaluation"]
end

subgraph group_learning["Data and Learning"]
  node_training["Policy Training"]
  node_dataset[("Real Dataset<br/>[real_dataset.py]")]
  node_replay[("Replay Buffer<br/>[replay_buffer.py]")]
  node_policy["Image Diffusion Policy"]
  node_normalizer["Tensor Normalization<br/>[normalizer.py]"]
  node_unet["Conditional UNet"]
end

subgraph group_support["Shared Runtime"]
  node_shared_memory[("Shared Memory")]
  node_gello_bridge["GELLO Bridge"]
end

node_operator(("Operator"))
node_human(("Human Demonstrator"))
node_robot(("Robot"))
node_wandb(("Weights &amp; Biases"))

node_human -->|"records play"| node_human_capture
node_human_capture -->|"preprocesses video"| node_human_prep
node_operator -->|"starts demo"| node_robot_demo
node_robot_demo -.->|"selects interface"| node_teleop
node_operator -->|"launches training"| node_training
node_training -->|"logs training"| node_wandb
node_dataset -->|"reads episodes"| node_replay
node_dataset -->|"uses normalization"| node_normalizer
node_policy -->|"normalizes inputs"| node_normalizer
node_policy -->|"uses denoiser"| node_unet
node_operator -->|"starts evaluation"| node_evaluation
node_operator -->|"starts evaluation"| node_human_evaluation
node_evaluation -.->|"runs on robot"| node_ur5e_env
node_human_evaluation -.->|"runs on robot"| node_ur5e_env
node_ur5e_env -.->|"controls robot"| node_rtde
node_kinova -->|"uses ring buffer"| node_shared_memory
node_rtde -->|"uses ring buffer"| node_shared_memory
node_gello_bridge -->|"uses ring buffer"| node_shared_memory
node_inference -->|"requests masks"| node_segmentation
node_cameras -.->|"provides observations"| node_inference
node_evaluation -.->|"queries policy"| node_policy
node_human_evaluation -.->|"queries policy"| node_policy
node_robot_demo -.->|"collects demonstrations"| node_ur5e_env

click node_human_capture "https://github.com/tool-as-interface/tool_as_interface/blob/main/scripts/collect_human_video.py"
click node_human_prep "https://github.com/tool-as-interface/tool_as_interface/blob/main/scripts/preprocess_human_play.py"
click node_robot_demo "https://github.com/tool-as-interface/tool_as_interface/blob/main/scripts/demo_real_ur5e.py"
click node_teleop "https://github.com/tool-as-interface/tool_as_interface/blob/main/ti/devices/spacemouse.py"
click node_ur5e_env "https://github.com/tool-as-interface/tool_as_interface/blob/main/ti/real_world/real_ur5e_env.py"
click node_rtde "https://github.com/tool-as-interface/tool_as_interface/blob/main/ti/real_world/rtde_interpolation_controller.py"
click node_kinova "https://github.com/tool-as-interface/tool_as_interface/blob/main/ti/real_world/kinova_interpolation_controller.py"
click node_cameras "https://github.com/tool-as-interface/tool_as_interface/blob/main/ti/real_world/multi_realsense.py"
click node_inference "https://github.com/tool-as-interface/tool_as_interface/blob/main/ti/real_world/real_inference_util.py"
click node_segmentation "https://github.com/tool-as-interface/tool_as_interface/blob/main/ti/utils/segmentation.py"
click node_evaluation "https://github.com/tool-as-interface/tool_as_interface/blob/main/scripts/eval_real_ur5e.py"
click node_human_evaluation "https://github.com/tool-as-interface/tool_as_interface/blob/main/scripts/eval_real_ur5e_human.py"
click node_training "https://github.com/tool-as-interface/tool_as_interface/blob/main/scripts/train_diffusion_policy.py"
click node_dataset "https://github.com/tool-as-interface/tool_as_interface/blob/main/ti/diffusion_dataset/real_dataset.py"
click node_replay "https://github.com/tool-as-interface/tool_as_interface/blob/main/ti/common/replay_buffer.py"
click node_policy "https://github.com/tool-as-interface/tool_as_interface/blob/main/ti/policy/diffusion_unet_hybrid_image_policy.py"
click node_normalizer "https://github.com/tool-as-interface/tool_as_interface/blob/main/ti/model/common/normalizer.py"
click node_unet "https://github.com/tool-as-interface/tool_as_interface/blob/main/ti/model/diffusion/conditional_unet1d.py"
click node_shared_memory "https://github.com/tool-as-interface/tool_as_interface/blob/main/ti/shared_memory/shared_memory_ring_buffer.py"
click node_gello_bridge "https://github.com/tool-as-interface/tool_as_interface/blob/main/ti/devices/gello_shared_memory.py"

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_human_capture,node_human_prep,node_robot_demo toneBlue
class node_teleop,node_ur5e_env,node_rtde,node_kinova,node_cameras,node_inference,node_segmentation,node_evaluation,node_human_evaluation toneAmber
class node_training,node_dataset,node_replay,node_policy,node_normalizer,node_unet toneMint
class node_shared_memory,node_gello_bridge toneRose
class node_operator,node_human,node_robot,node_wandb toneIndigo
```

## Components

### Demonstration Collection

- [Human Capture](https://github.com/tool-as-interface/tool_as_interface/blob/main/scripts/collect_human_video.py): `scripts/collect_human_video.py`
- [Human Preprocessing](https://github.com/tool-as-interface/tool_as_interface/blob/main/scripts/preprocess_human_play.py): `scripts/preprocess_human_play.py`
- [Robot Demo](https://github.com/tool-as-interface/tool_as_interface/blob/main/scripts/demo_real_ur5e.py): `scripts/demo_real_ur5e.py`

### Robot Runtime

- [Teleoperation Devices](https://github.com/tool-as-interface/tool_as_interface/blob/main/ti/devices/spacemouse.py): `ti/devices/spacemouse.py`
- [UR5e Environment](https://github.com/tool-as-interface/tool_as_interface/blob/main/ti/real_world/real_ur5e_env.py): `ti/real_world/real_ur5e_env.py`
- [RTDE Controller](https://github.com/tool-as-interface/tool_as_interface/blob/main/ti/real_world/rtde_interpolation_controller.py): `ti/real_world/rtde_interpolation_controller.py`
- [Kinova Controller](https://github.com/tool-as-interface/tool_as_interface/blob/main/ti/real_world/kinova_interpolation_controller.py): `ti/real_world/kinova_interpolation_controller.py`
- [Camera Capture](https://github.com/tool-as-interface/tool_as_interface/blob/main/ti/real_world/multi_realsense.py): `ti/real_world/multi_realsense.py`
- [Observation Processing](https://github.com/tool-as-interface/tool_as_interface/blob/main/ti/real_world/real_inference_util.py): `ti/real_world/real_inference_util.py`
- [Object Segmentation](https://github.com/tool-as-interface/tool_as_interface/blob/main/ti/utils/segmentation.py): `ti/utils/segmentation.py`
- [Robot Evaluation](https://github.com/tool-as-interface/tool_as_interface/blob/main/scripts/eval_real_ur5e.py): `scripts/eval_real_ur5e.py`
- [Human-Play Evaluation](https://github.com/tool-as-interface/tool_as_interface/blob/main/scripts/eval_real_ur5e_human.py): `scripts/eval_real_ur5e_human.py`

### Data and Learning

- [Policy Training](https://github.com/tool-as-interface/tool_as_interface/blob/main/scripts/train_diffusion_policy.py): `scripts/train_diffusion_policy.py`
- [Real Dataset](https://github.com/tool-as-interface/tool_as_interface/blob/main/ti/diffusion_dataset/real_dataset.py): `ti/diffusion_dataset/real_dataset.py`
- [Replay Buffer](https://github.com/tool-as-interface/tool_as_interface/blob/main/ti/common/replay_buffer.py): `ti/common/replay_buffer.py`
- [Image Diffusion Policy](https://github.com/tool-as-interface/tool_as_interface/blob/main/ti/policy/diffusion_unet_hybrid_image_policy.py): `ti/policy/diffusion_unet_hybrid_image_policy.py`
- [Tensor Normalization](https://github.com/tool-as-interface/tool_as_interface/blob/main/ti/model/common/normalizer.py): `ti/model/common/normalizer.py`
- [Conditional UNet](https://github.com/tool-as-interface/tool_as_interface/blob/main/ti/model/diffusion/conditional_unet1d.py): `ti/model/diffusion/conditional_unet1d.py`

### Shared Runtime

- [Shared Memory](https://github.com/tool-as-interface/tool_as_interface/blob/main/ti/shared_memory/shared_memory_ring_buffer.py): `ti/shared_memory/shared_memory_ring_buffer.py`
- [GELLO Bridge](https://github.com/tool-as-interface/tool_as_interface/blob/main/ti/devices/gello_shared_memory.py): `ti/devices/gello_shared_memory.py`

### Other components

- **Operator**
- **Human Demonstrator**
- **Robot**
- **Weights & Biases**

## Connections

- Human Demonstrator → Human Capture: records play (evidence: `README.md`)
- Human Capture → Human Preprocessing: preprocesses video (evidence: `README.md`)
- Operator → Robot Demo: starts demo (evidence: `README.md`)
- Robot Demo → Teleoperation Devices: selects interface
- Operator → Policy Training: launches training (evidence: `README.md`)
- Policy Training → Weights & Biases: logs training (evidence: `README.md`)
- Real Dataset → Replay Buffer: reads episodes (evidence: `ti/diffusion_dataset/real_dataset.py`)
- Real Dataset → Tensor Normalization: uses normalization (evidence: `ti/diffusion_dataset/real_dataset.py`)
- Image Diffusion Policy → Tensor Normalization: normalizes inputs (evidence: `ti/policy/diffusion_unet_hybrid_image_policy.py`)
- Image Diffusion Policy → Conditional UNet: uses denoiser (evidence: `ti/policy/diffusion_unet_hybrid_image_policy.py`)
- Operator → Robot Evaluation: starts evaluation (evidence: `README.md`)
- Operator → Human-Play Evaluation: starts evaluation (evidence: `README.md`)
- Robot Evaluation → UR5e Environment: runs on robot
- Human-Play Evaluation → UR5e Environment: runs on robot
- UR5e Environment → RTDE Controller: controls robot
- Kinova Controller → Shared Memory: uses ring buffer (evidence: `ti/real_world/kinova_interpolation_controller.py`)
- RTDE Controller → Shared Memory: uses ring buffer (evidence: `ti/real_world/rtde_interpolation_controller.py`)
- GELLO Bridge → Shared Memory: uses ring buffer (evidence: `ti/devices/gello_shared_memory.py`)
- Observation Processing → Object Segmentation: requests masks (evidence: `ti/real_world/real_inference_util.py`)
- Camera Capture → Observation Processing: provides observations
- Robot Evaluation → Image Diffusion Policy: queries policy
- Human-Play Evaluation → Image Diffusion Policy: queries policy
- Robot Demo → UR5e Environment: collects demonstrations
