UtilitiesOnshape to URDF

Onshape to URDF Converter

pip install kscale-onshape-library

This library is what we use at K-Scale for interacting with OnShape. It is a wrapper around the OnShape API that allows us to easily import parts from OnShape into our projects.

Here is an example of a robot converted using the kol CLI, with the input OnShape model on the right and the output URDF on the left.

Onshape to URDF

To reproduce the above example, you can run the following command:

kol run https://cad.onshape.com/documents/3037473d78845106e95befb1/w/e3a76b21fff5430d0e9ecfb5/e/1d74e2fed25abed64482828a robot

Installation

pip install kscale-onshape-library
pip install 'kscale-onshape-library @ git+https://github.com/kscalelabs/onshape.git@master'  # Install from Github
pip install 'kscale-onshape-library[all]'  # Install all dependencies

In order to access the OnShape API, you need to define ONSHAPE_ACCESS_KEY and ONSHAPE_SECRET_KEY using a key generated here.

Usage

The KOL CLI provides several subcommands for different operations:

kol <subcommand> [options]

Available subcommands:

  • run: Download from Onshape and post-process
  • download: Only download from Onshape
  • postprocess: Post-process an existing URDF
  • pybullet: Run PyBullet simulation

Download and Post-process

To download a model from Onshape and apply post-processing:

kol run <onshape-document-url> <output-directory>

To see additional configuration options, consult the config file here.

Download Only

To only download a model from Onshape without post-processing:

kol download <document-url> <output-directory>

Options are similar to the run subcommand.

Post-process Existing URDF

To apply post-processing to an existing URDF file:

kol postprocess <urdf-path>

PyBullet Simulation

To run a PyBullet simulation with the processed URDF:

kol pybullet <urdf-path> [options]

Simulation

The output of the onshape library is simply a robot floating in space. Luckily, most simulators which support URDFs are able to define an environment within code. More changes are needed to make MJCF files simulation ready. The pipeline also generates an MJCF file by default.

Support for other file formats like USD files for IsaacLab will be helpful as well.