|
1 |
| -# Sequence Diagram |
| 1 | +# Developer Documentation |
2 | 2 |
|
3 |
| -<body> |
4 |
| - <pre class="mermaid"> |
5 |
| - sequenceDiagram |
6 |
| - participant User as User |
7 |
| - participant Client as onshape-robotics-toolkit.client |
8 |
| - participant Onshape as Onshape Server |
9 |
| - participant Robot as onshape-robotics-toolkit.robot |
| 3 | +This document provides an overview of how the onshape-robotics-toolkit library works internally and how different components interact with each other. |
10 | 4 |
|
11 |
| - User->>Client: Initialize Client with API Keys |
12 |
| - Client->>Onshape: Authenticate with Access Key & Secret Key |
13 |
| - Onshape-->>Client: Return Authentication Token |
| 5 | +## Architecture Overview |
14 | 6 |
|
15 |
| - User->>Client: Request Document Information (e.g., document URL) |
16 |
| - Client->>Onshape: Send GET request for Document Details |
17 |
| - Onshape-->>Client: Return Document Metadata (JSON) |
18 |
| - Client-->>User: Deliver Document Metadata |
| 7 | +The library is organized into several key components: |
| 8 | +- **Client**: Handles all communication with the Onshape API |
| 9 | +- **Robot**: Manages the robot model creation and URDF export |
| 10 | +- **Assembly**: Represents the CAD assembly structure |
| 11 | +- **Utilities**: Helper functions for various operations |
19 | 12 |
|
20 |
| - User->>Client: Request CAD Assembly |
21 |
| - Client->>Onshape: Send GET request for Assembly Details |
22 |
| - Onshape-->>Client: Return Assembly Data (JSON) |
23 |
| - Client-->>User: Deliver Assembly Data |
| 13 | +## Workflow Overview |
24 | 14 |
|
25 |
| - User->>Robot: Initiate URDF Export Workflow |
26 |
| - Robot-->>Onshape: Parse Assembly Data for URDF |
27 |
| - Robot-->>User: Deliver Robot model (URDF) |
| 15 | +### 1. Authentication and Connection |
| 16 | +The library first establishes a secure connection with Onshape: |
| 17 | +- Users provide API credentials (access key and secret key) |
| 18 | +- The Client component handles authentication and maintains the session |
| 19 | +- All subsequent API requests use this authenticated session |
28 | 20 |
|
29 |
| - User->>User: Use URDF for Simulation or Control |
| 21 | +### 2. Document Access |
| 22 | +Once authenticated: |
| 23 | +- The library can access Onshape documents using either URLs or direct document IDs |
| 24 | +- Document metadata is retrieved to verify access and get necessary identifiers |
| 25 | +- Assembly information is cached to minimize API calls |
30 | 26 |
|
31 |
| -</body> |
| 27 | +### 3. Assembly Processing |
| 28 | +The assembly processing workflow: |
| 29 | +1. Retrieves the full assembly structure from Onshape |
| 30 | +2. Parses the hierarchical relationship between components |
| 31 | +3. Identifies joints, mate connectors, and other relevant features |
| 32 | +4. Creates an internal representation of the robot structure |
| 33 | + |
| 34 | +### 4. URDF Generation |
| 35 | +The URDF export process: |
| 36 | +1. Analyzes the assembly structure |
| 37 | +2. Maps Onshape constraints to URDF joints |
| 38 | +3. Exports geometry in specified formats |
| 39 | +4. Generates a complete URDF file with proper kinematics |
| 40 | + |
| 41 | +## Sequence Diagram |
| 42 | + |
| 43 | +The following sequence diagram illustrates the main interactions between components: |
| 44 | + |
| 45 | +<pre class="mermaid"> |
| 46 | +sequenceDiagram |
| 47 | + participant User as User |
| 48 | + participant Client as onshape-robotics-toolkit.client |
| 49 | + participant Onshape as Onshape Server |
| 50 | + participant Robot as onshape-robotics-toolkit.robot |
| 51 | + |
| 52 | + User->>Client: Initialize Client with API Keys |
| 53 | + Client->>Onshape: Authenticate with Access Key & Secret Key |
| 54 | + Onshape-->>Client: Return Authentication Token |
| 55 | + |
| 56 | + User->>Client: Request Document Information (e.g., document URL) |
| 57 | + Client->>Onshape: Send GET request for Document Details |
| 58 | + Onshape-->>Client: Return Document Metadata (JSON) |
| 59 | + Client-->>User: Deliver Document Metadata |
| 60 | + |
| 61 | + User->>Client: Request CAD Assembly |
| 62 | + Client->>Onshape: Send GET request for Assembly Details |
| 63 | + Onshape-->>Client: Return Assembly Data (JSON) |
| 64 | + Client-->>User: Deliver Assembly Data |
| 65 | + |
| 66 | + User->>Robot: Initiate URDF Export Workflow |
| 67 | + Robot-->>Onshape: Parse Assembly Data for URDF |
| 68 | + Robot-->>User: Deliver Robot model (URDF) |
| 69 | + |
| 70 | + User->>User: Use URDF for Simulation or Control |
| 71 | +</pre> |
| 72 | + |
| 73 | +## Key Classes and Their Roles |
| 74 | + |
| 75 | +### Client Class |
| 76 | +- Manages API authentication |
| 77 | +- Handles all HTTP requests to Onshape |
| 78 | +- Implements rate limiting and error handling |
| 79 | +- Caches responses when appropriate |
| 80 | + |
| 81 | +### Robot Class |
| 82 | +- Represents the complete robot model |
| 83 | +- Manages the conversion from CAD assembly to URDF |
| 84 | +- Handles coordinate transformations |
| 85 | +- Provides visualization utilities |
| 86 | + |
| 87 | +### Assembly Class |
| 88 | +- Represents the CAD assembly structure |
| 89 | +- Maintains parent-child relationships |
| 90 | +- Tracks mate connections and constraints |
| 91 | +- Manages geometric transformations |
0 commit comments