This document explains how to convert CAD models from Onshape to URDF for use in simulation environments like PyBullet. It specifically focuses on converting single components and creating dummy elements to track in PyBullet.
![]() |
![]() |
- My Environment Setup
- Setting Up Onshape API Keys
- Preparing Your Onshape CAD Model
- Creating Dummy Elements
- Configuring Conversion Parameters
- Running the Conversion
- Loading the Model in PyBullet
- Common Issues and Solutions
- Python 3.9.17
- PyBullet 3.2.6
- onshape-to-robot 0.3.26
- Log in to the Onshape Developer Portal
- Click on "API Keys" and create a new API key
- Note down your Access Key and Secret Key
When designing your robot model in Onshape, follow these guidelines:
-
Naming Convention:
- Ensure all parts have unique names
- Use meaningful names without special characters
- Suggested naming format:
part_name_joint_type(e.g.,arm_revolute)
-
Part Relationships:
- Define part relationships using Onshape assembly constraints
- Supported constraint types: revolute, prismatic, fixed, etc.
-
Material Properties:
- Set material properties (density, color, etc.) for each part
- Use "Physical Properties" in Onshape to set mass, inertia, etc.
- Create a part studio to build a small component such as a cube (this will serve as your dummy element)
- Create an assembly and use a fastened mate to combine your CAD model with the dummy element
- In the Mate Features panel, rename the mate to follow the naming pattern:
frame_XXX
To export your robot, first create a directory:
mkdir my-robotCreate a my-robot/config.json file with the following parameters:
{
"onshape_api": "https://cad.onshape.com",
"onshape_access_key": "YOUR_ACCESS_KEY",
"onshape_secret_key": "YOUR_SECRET_KEY",
"documentId": "YOUR_DOCUMENT_ID",
"outputFormat": "urdf",
"assemblyName": "YOUR_ASSEMBLY_NAME",
"robotName": "your_robot_name"
}Parameter descriptions:
onshape_api: Onshape API URL, typicallyhttps://cad.onshape.comonshape_access_keyandonshape_secret_key: API keys from the developer portaldocumentId: Onshape document ID (obtained from the document URL)outputFormat: Output format, typicallyurdfassemblyName: Name of the assembly in OnshaperobotName: Name for the generated robot (used in URDF files)
Execute the following command in the directory containing your config.json:
onshape-to-robot my-robotAfter conversion, you'll find the generated URDF file and associated resources in the current directory.
Use the built-in PyBullet viewer from onshape-to-robot:
onshape-to-robot-bullet my-robotObserve the information displayed in the terminal. It shows the center position of the component, as well as the positions and rotations of the dummy elements.
# Example output for the board model
Center of mass:
[0.09052898 0.038593 0.01066 ]
upperleft_frame
- x=0.028440 y=0.057826 z=0.003990
- r=0.000000 p=-0.000002 y=0.094388
lowerleft_frame
- x=0.033152 y=0.008049 z=0.003990
- r=0.000000 p=-0.000002 y=0.094388
upperright_frame
- x=0.147906 y=0.069136 z=0.003990
- r=0.000000 p=-0.000002 y=0.094388
lowerright_frame
- x=0.152618 y=0.019359 z=0.003990
- r=0.000000 p=-0.000002 y=0.094388Error message:
Warning: Link name is not unique, link names in the same model have to be unique
Solution:
- Ensure all parts in Onshape have unique names
For more information, visit the Onshape to Robot Documentation.

