# rhoban/onshape-to-robot architecture

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

- Interactive diagram: https://gitdiagram.com/rhoban/onshape-to-robot
- Repository: https://github.com/rhoban/onshape-to-robot

## Overview

Onshape to Robot retrieves a CAD assembly and converts it into a simulation-ready robot description. The main flow is configuration and user invocation, Onshape API retrieval, assembly interpretation, robot-model construction, optional model processors, then URDF, SDF, or MuJoCo export. The README names those three output formats. The graph also shows API caching and the documented simulation capability; unsampled modules are represented only where the tree or README supports the subsystem, so their internal wiring is not asserted.

Main entry points: [`onshape_to_robot/export.py`](https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/export.py) (Export command), [`onshape_to_robot/robot.py`](https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/robot.py) (Robot model), [`onshape_to_robot/exporter_urdf.py`](https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/exporter_urdf.py) (URDF exporter), [`onshape_to_robot/exporter_sdf.py`](https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/exporter_sdf.py) (SDF exporter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Inputs and entry"]
  node_config["Configuration<br/>[config.py]"]
  node_export_cmd["Export command<br/>[export.py]"]
end

subgraph group_cad["CAD retrieval"]
  node_api_client["Onshape client<br/>[client.py]"]
  node_onshape_api["Onshape API<br/>[onshape.py]"]
  node_cache[("Response cache<br/>[cache.py]")]
end

subgraph group_model["Robot modeling"]
  node_assembly["Assembly parser<br/>[assembly.py]"]
  node_builder["Robot builder<br/>[robot_builder.py]"]
  node_robot["Robot model<br/>[robot.py]"]
  node_geometry["Geometry model<br/>[geometry.py]"]
  node_expressions["Expression parser<br/>[expression.py]"]
end

subgraph group_processing["Model processing"]
  node_processor_base["Processor interface<br/>[processor.py]"]
  node_processors["Processor registry<br/>[processors.py]"]
  node_processor_modules["Robot processors"]
end

subgraph group_outputs["Exports and simulation"]
  node_exporter_base["Exporter base<br/>[exporter.py]"]
  node_urdf["URDF exporter<br/>[exporter_urdf.py]"]
  node_sdf["SDF exporter<br/>[exporter_sdf.py]"]
  node_mujoco_export["MuJoCo exporter<br/>[exporter_mujoco.py]"]
  node_simulation["Simulation<br/>[simulation.py]"]
end

node_user(("Robot author"))
node_simulator(("Physics simulator"))

node_user -->|"runs export"| node_export_cmd
node_export_cmd -->|"loads settings"| node_config
node_export_cmd -->|"builds model"| node_builder
node_export_cmd -->|"selects format"| node_urdf
node_export_cmd -->|"selects format"| node_sdf
node_export_cmd -->|"selects format"| node_mujoco_export
node_config -->|"loads registry"| node_processors
node_api_client -->|"sends requests"| node_onshape_api
node_api_client -->|"decorates reads"| node_cache
node_assembly -->|"requests CAD data"| node_api_client
node_assembly -->|"parses expressions"| node_expressions
node_builder -->|"constructs assembly"| node_assembly
node_builder -->|"builds model"| node_robot
node_robot -->|"holds geometry"| node_geometry
node_config -->|"configures processors"| node_processor_modules
node_processors -->|"registers modules"| node_processor_modules
node_processor_modules -->|"implements interface"| node_processor_base
node_export_cmd -->|"uses exporter"| node_exporter_base
node_urdf -->|"extends base"| node_exporter_base
node_sdf -->|"extends base"| node_exporter_base
node_mujoco_export -->|"extends base"| node_exporter_base
node_urdf -->|"serializes model"| node_robot
node_sdf -->|"serializes model"| node_robot
node_mujoco_export -->|"serializes model"| node_robot
node_urdf -->|"serializes geometry"| node_geometry
node_sdf -->|"serializes geometry"| node_geometry
node_mujoco_export -->|"serializes geometry"| node_geometry
node_user -.->|"runs simulation"| node_simulation
node_simulation -.->|"uses physics engine"| node_simulator

click node_config "https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/config.py"
click node_export_cmd "https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/export.py"
click node_api_client "https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/onshape_api/client.py"
click node_onshape_api "https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/onshape_api/onshape.py"
click node_cache "https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/onshape_api/cache.py"
click node_assembly "https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/assembly.py"
click node_builder "https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/robot_builder.py"
click node_robot "https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/robot.py"
click node_geometry "https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/geometry.py"
click node_expressions "https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/expression.py"
click node_processor_base "https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/processor.py"
click node_processors "https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/processors.py"
click node_processor_modules "https://github.com/rhoban/onshape-to-robot/tree/master/onshape_to_robot"
click node_exporter_base "https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/exporter.py"
click node_urdf "https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/exporter_urdf.py"
click node_sdf "https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/exporter_sdf.py"
click node_mujoco_export "https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/exporter_mujoco.py"
click node_simulation "https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/simulation.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_config,node_export_cmd toneBlue
class node_api_client,node_onshape_api,node_cache toneAmber
class node_assembly,node_builder,node_robot,node_geometry,node_expressions toneMint
class node_processor_base,node_processors,node_processor_modules toneRose
class node_exporter_base,node_urdf,node_sdf,node_mujoco_export,node_simulation,node_user,node_simulator toneIndigo
```

## Components

### Inputs and entry

- [Configuration](https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/config.py): `onshape_to_robot/config.py`
- [Export command](https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/export.py): `onshape_to_robot/export.py`

### CAD retrieval

- [Onshape client](https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/onshape_api/client.py): `onshape_to_robot/onshape_api/client.py`
- [Onshape API](https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/onshape_api/onshape.py): `onshape_to_robot/onshape_api/onshape.py`
- [Response cache](https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/onshape_api/cache.py): `onshape_to_robot/onshape_api/cache.py`

### Robot modeling

- [Assembly parser](https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/assembly.py): `onshape_to_robot/assembly.py`
- [Robot builder](https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/robot_builder.py): `onshape_to_robot/robot_builder.py`
- [Robot model](https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/robot.py): `onshape_to_robot/robot.py`
- [Geometry model](https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/geometry.py): `onshape_to_robot/geometry.py`
- [Expression parser](https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/expression.py): `onshape_to_robot/expression.py`

### Model processing

- [Processor interface](https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/processor.py): `onshape_to_robot/processor.py`
- [Processor registry](https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/processors.py): `onshape_to_robot/processors.py`
- [Robot processors](https://github.com/rhoban/onshape-to-robot/tree/master/onshape_to_robot): `onshape_to_robot`

### Exports and simulation

- [Exporter base](https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/exporter.py): `onshape_to_robot/exporter.py`
- [URDF exporter](https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/exporter_urdf.py): `onshape_to_robot/exporter_urdf.py`
- [SDF exporter](https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/exporter_sdf.py): `onshape_to_robot/exporter_sdf.py`
- [MuJoCo exporter](https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/exporter_mujoco.py): `onshape_to_robot/exporter_mujoco.py`
- [Simulation](https://github.com/rhoban/onshape-to-robot/blob/master/onshape_to_robot/simulation.py): `onshape_to_robot/simulation.py`

### Other components

- **Robot author**
- **Physics simulator**

## Connections

- Robot author → Export command: runs export (evidence: `README.md`)
- Export command → Configuration: loads settings (evidence: `onshape_to_robot/export.py`)
- Export command → Robot builder: builds model (evidence: `onshape_to_robot/export.py`)
- Export command → URDF exporter: selects format (evidence: `onshape_to_robot/export.py`)
- Export command → SDF exporter: selects format (evidence: `onshape_to_robot/export.py`)
- Export command → MuJoCo exporter: selects format (evidence: `onshape_to_robot/export.py`)
- Configuration → Processor registry: loads registry (evidence: `onshape_to_robot/config.py`)
- Onshape client → Onshape API: sends requests (evidence: `onshape_to_robot/onshape_api/client.py`)
- Onshape client → Response cache: decorates reads (evidence: `onshape_to_robot/onshape_api/client.py`)
- Assembly parser → Onshape client: requests CAD data (evidence: `onshape_to_robot/assembly.py`)
- Assembly parser → Expression parser: parses expressions (evidence: `onshape_to_robot/assembly.py`)
- Robot builder → Assembly parser: constructs assembly (evidence: `onshape_to_robot/robot_builder.py`)
- Robot builder → Robot model: builds model (evidence: `onshape_to_robot/robot_builder.py`)
- Robot model → Geometry model: holds geometry (evidence: `onshape_to_robot/robot.py`)
- Configuration → Robot processors: configures processors (evidence: `onshape_to_robot/config.py`)
- Processor registry → Robot processors: registers modules (evidence: `onshape_to_robot/processors.py`)
- Robot processors → Processor interface: implements interface (evidence: `onshape_to_robot/processor_merge_parts.py`)
- Export command → Exporter base: uses exporter (evidence: `onshape_to_robot/export.py`)
- URDF exporter → Exporter base: extends base (evidence: `onshape_to_robot/exporter_urdf.py`)
- SDF exporter → Exporter base: extends base (evidence: `onshape_to_robot/exporter_sdf.py`)
- MuJoCo exporter → Exporter base: extends base (evidence: `onshape_to_robot/exporter_mujoco.py`)
- URDF exporter → Robot model: serializes model (evidence: `onshape_to_robot/exporter_urdf.py`)
- SDF exporter → Robot model: serializes model (evidence: `onshape_to_robot/exporter_sdf.py`)
- MuJoCo exporter → Robot model: serializes model (evidence: `onshape_to_robot/exporter_mujoco.py`)
- URDF exporter → Geometry model: serializes geometry (evidence: `onshape_to_robot/exporter_urdf.py`)
- SDF exporter → Geometry model: serializes geometry (evidence: `onshape_to_robot/exporter_sdf.py`)
- MuJoCo exporter → Geometry model: serializes geometry (evidence: `onshape_to_robot/exporter_mujoco.py`)
- Robot author → Simulation: runs simulation (evidence: `README.md`)
- Simulation → Physics simulator: uses physics engine
