Skip to content

Commit 9855d98

Browse files
committed
2026-teamH-wiki-entry CAD to URDF
1 parent 8df0f6a commit 9855d98

8 files changed

Lines changed: 363 additions & 47 deletions

File tree

23.1 KB
Loading
25.3 KB
Loading
83 KB
Loading
269 KB
Loading
9.04 KB
Loading
190 KB
Loading

wiki/simulation/cad-to-urdf.md

Lines changed: 313 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,313 @@
1+
---
2+
date: 2026-04-23
3+
title: Creating a URDF from a CAD Model using OnShape
4+
published: true
5+
---
6+
This tutorial covers the process of taking a robot CAD model and exporting it
7+
as a URDF (Unified Robot Description Format) file. You will learn what a URDF
8+
is, how to bring a SolidWorks assembly into OnShape, how to set up joints and
9+
links correctly, and how to export the final URDF. The steps use SolidWorks
10+
as the starting CAD tool and OnShape for the export pipeline, but the
11+
concepts apply to other CAD tools as well. By the end, you will have a URDF
12+
file ready to load into a simulator like Isaac Sim or Gazebo, or into a ROS 2
13+
pipeline for real robot control.
14+
15+
## What is a URDF?
16+
17+
A URDF is an XML file that describes a robot's physical structure. Simulators
18+
and robot software like ROS use it to understand how a robot is built, what
19+
parts it has, how they connect, and how they move relative to each other.
20+
21+
A URDF describes the robot as a tree of links and joints:
22+
23+
- **Link**: a rigid body such as a base plate, arm segment, or gripper finger.
24+
Each link has geometry (the mesh shape), mass, and inertia properties.
25+
- **Joint**: the connection between two links. It defines how one link moves
26+
relative to another. Common types are:
27+
- `fixed` — no motion, the two links are rigidly attached
28+
- `revolute` — rotation about a single axis (e.g., a hinge or motor)
29+
- `prismatic` — sliding along a single axis (e.g., a linear actuator)
30+
- **Parent/Child**: joints connect a parent link to a child link. The whole
31+
robot forms a tree starting from a single root, usually called `base_link`.
32+
33+
A simple two-link arm would look like this in structure:
34+
35+
```
36+
base_link
37+
└── shoulder_joint (revolute)
38+
└── upper_arm_link
39+
└── elbow_joint (revolute)
40+
└── forearm_link
41+
```
42+
43+
Inside the URDF file, a single joint looks like this:
44+
45+
```
46+
<joint name="shoulder_joint" type="revolute">
47+
<parent link="base_link"/>
48+
<child link="upper_arm_link"/>
49+
<axis xyz="0 0 1"/>
50+
<limit lower="-1.57" upper="1.57" effort="10" velocity="1.0"/>
51+
</joint>
52+
```
53+
54+
The `axis` field defines which direction the joint rotates around. The `limit`
55+
field sets the minimum and maximum angle in radians, along with effort and
56+
velocity limits. Getting these values right is important for simulation — a
57+
joint with wrong limits will either not move or move past its physical range.
58+
59+
## Step 1: Prepare Your CAD Assembly
60+
61+
Before importing into OnShape, make sure your CAD assembly is clean
62+
and well-organized. This will save significant time during the joint
63+
assignment step. A messy assembly with undefined mates or floating parts will
64+
cause problems after import.
65+
66+
- Each moving part should be a separate component in the assembly
67+
- Parts that move together as one rigid body should be grouped or mated as
68+
fixed in the CAD
69+
- Suppress any cosmetic or non-structural parts such as bolts, labels, and
70+
fasteners that you do not need in simulation. These add unnecessary
71+
complexity to the URDF and slow down the simulator.
72+
73+
It is also worth sketching out your intended link tree on paper before
74+
starting. Knowing which parts form each link, and which joints connect them,
75+
makes the OnShape setup much faster.
76+
77+
## Step 2: Import Your CAD File into OnShape
78+
79+
(Note that this is commmon to all CAD softwares. Solidworks is just chosen as an example)
80+
81+
OnShape supports two main import approaches for SolidWorks assemblies.
82+
83+
### Option A: Import SolidWorks Files Directly
84+
85+
OnShape can import SolidWorks native files (`.sldprt` and `.sldasm`).
86+
87+
1. Go to <https://cad.onshape.com> and log in
88+
2. Click **Create** in the top left corner
89+
3. Select **Import**
90+
4. Upload your `.sldasm` file along with all referenced `.sldprt` part files
91+
5. OnShape will convert the assembly and open it as a new document
92+
93+
> Import all part files together with the assembly file in one upload.
94+
> OnShape needs all referenced parts to reconstruct the assembly correctly.
95+
> If you upload only the `.sldasm` without the part files, parts will appear
96+
> missing or as empty shells.
97+
98+
This approach preserves your existing SolidWorks mate structure, which saves
99+
time in the joint assignment step. However, it can sometimes produce broken
100+
references or missing geometry if the SolidWorks file uses external references
101+
or complex configurations.
102+
103+
### Option B: Export as STEP and Import (Recommended)
104+
105+
A more reliable approach is to export your SolidWorks assembly as a STEP file
106+
(`.step` or `.stp`) and import that into OnShape instead. STEP is a universal
107+
CAD exchange format that OnShape handles cleanly without broken references.
108+
109+
To export from SolidWorks:
110+
1. Go to **File** > **Save As**
111+
2. Set the file type to **STEP AP214** or **STEP AP203**
112+
3. Save the file
113+
114+
Then import into OnShape the same way — **Create** > **Import** > select the
115+
`.step` file.
116+
117+
The tradeoff is that STEP files do not preserve mate or assembly structure.
118+
All parts will appear as independent bodies in OnShape, and you will need to
119+
manually group parts that belong to the same rigid link before assigning mates.
120+
For most robot assemblies this is straightforward since the grouping follows
121+
the physical structure of the robot.
122+
123+
Once imported, check that all parts appear correctly. Cosmetic issues like
124+
color or appearance can be ignored, but make sure no parts are missing.
125+
Rotate the model and inspect it from multiple angles.
126+
127+
OnShape may change the appearance of some parts during conversion. This does
128+
not affect the URDF export — only geometry and mate structure matter.
129+
130+
## Step 3: Name Your Parts
131+
132+
The OnShape URDF exporter reads part names to build the link names in the
133+
URDF. If your parts are named `Part1`, `Part2`, and so on, your URDF will be
134+
very hard to read and debug.
135+
136+
In the parts list on the left panel:
137+
- Rename each part to match the link name you want in the URDF
138+
- Use underscores and no spaces (e.g., `base_link`, `upper_arm`, `wrist_link`)
139+
- Keep names short and descriptive
140+
- Parts that will be combined into one rigid link can share a name or be
141+
merged before export
142+
143+
![Image of the links on onshape, labeled clearly](/assets/images/simulation/onshape_link_names.png)
144+
## Step 4: Assign Joints Using Mates
145+
146+
In OnShape, joints in the URDF come from mates between parts. You need to
147+
define a mate for each joint in your robot.
148+
149+
### Mate Connectors
150+
151+
Before creating mates, you should define **Mate Connectors** on each part.
152+
A mate connector is a coordinate frame you place on a part to define exactly
153+
where and in what orientation a mate will be created. Think of it as marking
154+
the precise joint location on the geometry.
155+
156+
To add a mate connector:
157+
1. Right click on a part in the assembly
158+
2. Select **Add mate connector** (or just click on the mate connector button near the "Insert" button on the toolbar at the top)
159+
3. Place it at the center of the joint — for example, at the center of a
160+
rotating shaft or hinge pin
161+
4. Orient the Z axis of the connector to match the intended axis of rotation
162+
or translation. The Z axis of the mate connector becomes the joint axis
163+
in the URDF.
164+
165+
> Taking time to place mate connectors accurately is worth it. A poorly
166+
> placed connector will result in the wrong joint origin in the URDF, which
167+
> causes the robot geometry to appear offset or rotated incorrectly in
168+
> simulation.
169+
170+
The image below shows a mate connector in the figure as well as the menu on the left (highlighted)
171+
![Mate connector](/assets/images/simulation/onshape_mate_connector.png)
172+
173+
### Creating Mates
174+
175+
Once mate connectors are placed, create mates between them:
176+
![alt text](/assets/images/simulation/onshape_revolute_mate_menu.png)
177+
1. For each joint, choose the correct mate type (look at the image above to see the place where the mates will be):
178+
- **Fastened mate** becomes a `fixed` joint in the URDF
179+
- **Revolute mate** becomes a `revolute` joint
180+
- **Slider mate** becomes a `prismatic` joint
181+
2. Select the mate connector on the parent part and the mate connector on
182+
the child part
183+
3. Name each mate clearly (e.g., `shoulder_revolute`, `elbow_revolute`)
184+
185+
> Every joint must connect exactly one parent part to one child part.
186+
> The assembly must form a tree with no loops. If part A connects to part B
187+
> and part B connects back to part A through a different mate, the URDF will
188+
> be invalid.
189+
190+
The axis direction of the mate connector is particularly important. In the
191+
URDF, the joint axis is defined by the Z axis of the mate connector on the
192+
child part. If you orient the connector wrong in OnShape, the joint will
193+
rotate around the wrong direction in simulation. After creating each mate,
194+
animate it in OnShape to confirm the motion direction matches what you expect
195+
before moving on.
196+
197+
The image below shows OnShape mate dialog showing a revolute mate being defined between two mate connectors
198+
![Revolute joint](/assets/images/simulation/onshape_revolute_joint.png)
199+
200+
### Setting Joint Limits
201+
202+
To set joint limits, click on the mate in the feature tree, open its
203+
properties, and enter the minimum and maximum angle or distance. The
204+
OnShape URDF exporter reads these directly and writes them into the URDF
205+
limit tag.
206+
207+
If you skip this step, the exported URDF will have no limits on those joints.
208+
In simulation this means the joint can rotate freely to any angle, which
209+
usually causes the robot to collapse or behave unrealistically.
210+
211+
212+
## Step 5: Export the URDF
213+
214+
Once your parts are named and all mates are defined, you can export the URDF
215+
directly from OnShape.
216+
217+
Right click on the file name in the tab bar at the bottom of the screen.
218+
Click **Export**. In the export dialog, select **URDF** as the target file
219+
format and then click **Export**. It will take a few minutes for the export
220+
to process and download depending on the complexity of your assembly.
221+
222+
![Export](/assets/images/simulation/export.png)
223+
224+
This will generate a zip file containing:
225+
- `robot.urdf` — the URDF file describing your robot's structure
226+
- A folder of mesh files (`.stl` or `.obj`) for each link's geometry
227+
228+
Extract the zip file and keep the mesh folder in the same directory as the
229+
URDF file. The URDF references the meshes using relative paths, so moving
230+
them apart will cause the robot geometry to not load.
231+
232+
## Step 6: Validate the URDF
233+
234+
You can use online URDF viewers such as
235+
<https://viewer.robotsfan.com/> to visually inspect the robot
236+
without needing a full simulator installed. Load the entire folder generated by the onshape (urdf and the meshes) and check that all links appear in the right positions and
237+
orientations.
238+
239+
In the image below, you can see the entire folder (urdf + meshes loaded), which then generates the robot structure, the joint-link tree, etc. The viewer displays four key panels:
240+
241+
Files panel (left) — shows the loaded package with the meshes/ folder and urdf/autolab.urdf file, confirming the relative path structure is intact and the viewer resolved all references correctly.
242+
3D Viewport (center) — renders the full robot geometry using the loaded meshes, allowing you to visually confirm that all links appear in the correct positions and orientations.
243+
Joints panel (center) — lists every joint (arm_1_0 through arm_6_0) with interactive sliders so you can manually drive each joint and verify that motion direction and limits match your expectations.
244+
Structure panel (right) — displays the full parent-child link tree, from arm_shoulder_4 at the base up through wrist_2_p4 at the tip, confirming the tree has no loops and the hierarchy exported correctly.
245+
![URDF Validation](/assets/images/simulation/urdf_validation.png)
246+
247+
## Common Issues and Fixes
248+
249+
**Parts are missing after import into OnShape**
250+
Make sure you uploaded all `.sldprt` files together with the `.sldasm` file
251+
in one import batch. OnShape cannot resolve external references if the part
252+
files are missing.
253+
254+
**Joints move in the wrong direction**
255+
Flip the axis in the OnShape mate properties, re-export, and re-validate.
256+
You can also edit the axis line directly in the URDF file as a quicker fix.
257+
258+
**Joint limits are wrong or missing**
259+
Set limits in the mate properties in OnShape before exporting. The exporter
260+
reads them directly from the mate. If limits are missing the joint will be
261+
unconstrained in simulation.
262+
263+
**Part masses are zero**
264+
Assign a material to each part in OnShape so the exporter can compute mass
265+
from density. Alternatively, edit the inertial blocks in the URDF file
266+
manually after export.
267+
268+
**check_urdf reports a loop**
269+
Your assembly has a part connected to more than one parent. Find and remove
270+
the extra mate causing the loop.
271+
272+
**Meshes do not appear in the simulator**
273+
Check that the mesh folder is in the same directory as the URDF. The URDF
274+
uses relative paths like `meshes/base_link.stl` — if the mesh folder is
275+
moved or renamed the simulator cannot find the geometry.
276+
277+
## Opening Your URDF in Isaac Sim
278+
279+
1. Enable the `isaacsim.asset.importer.urdf` extension if not already active:
280+
**Window** > **Extensions** > search for `isaacsim.asset.importer.urdf` and enable it
281+
2. Go to **File** > **Import** and select your `robot.urdf` file
282+
3. In the import settings:
283+
- Set **USD Output** to your desired output location
284+
- Check **Static Base** if your robot has a fixed base (e.g. a mounted arm)
285+
- Enable **Allow Self-Collision** under the Colliders section
286+
4. Click **Import** — the robot will appear in the stage
287+
288+
> Keep the `meshes/` folder in the same directory as the `.urdf` file before
289+
> importing, or Isaac Sim will not resolve the geometry paths correctly.
290+
291+
292+
## Summary
293+
294+
To generate a URDF from a SolidWorks CAD model: clean up your assembly,
295+
import it into OnShape, rename parts to match your intended link names, assign
296+
mates for each joint with correct axis directions and limits, then export as
297+
URDF. Validate the output with check_urdf or an online viewer before using
298+
it in a simulator or ROS package. Getting the assembly structure and mate
299+
setup right before export avoids most common errors downstream.
300+
301+
## See Also
302+
- [ROS URDF Documentation](http://wiki.ros.org/urdf)
303+
304+
## Further Reading
305+
- URDF XML specification: <http://wiki.ros.org/urdf/XML>
306+
- OnShape Learning Center: <https://learn.onshape.com>
307+
- Online URDF Viewer: <https://myrobotics.eu/urdftools/viewer/>
308+
309+
## References
310+
- Open Robotics, "URDF XML Specification," ROS Wiki, 2021. [Online].
311+
Available: <http://wiki.ros.org/urdf/XML>
312+
- OnShape, "Importing and Exporting Files," OnShape Help, 2024. [Online].
313+
Available: <https://cad.onshape.com/help>

0 commit comments

Comments
 (0)