K-Scale's library for programmatically interacting with OnShape
Project description
K-Scale 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.
Getting Started
Install the library using pip:
pip install kscale-onshape-library
Or, if you want to install directly from Github:
pip install 'kscale-onshape-library @ git+https://github.com/kscalelabs/onshape.git@master'
Or, if you're developing the library, do:
git clone git@github.com:kscalelabs/onshape.git && cd onshape
conda create -y -n kol python=3.11 && conda activate kol
pip install -e '.[dev]'
In order to access the OnShape API, you need to define ONSHAPE_ACCESS_KEY
and ONSHAPE_SECRET_KEY
using a key generated here.
Usage
To convert an assembly to a URDF, use the following command:
kol urdf https://cad.onshape.com/documents/DDDDDDDD/w/WWWWWWWW/e/EEEEEEEE
You can visualize the resulting URDF using PyBullet:
pip install pybullet
kol pybullet robot/<urdf-name>.urdf
To convert an assembly to a MJCF, use the following command:
kol mjcf https://cad.onshape.com/documents/DDDDDDDD/w/WWWWWWWW/e/EEEEEEEE
You can visualize the resulting MJCF using MuJoCO:
mjpython -m kol.scripts.cli mujoco robot/<mjcf-name>.xml
Advanced Tools
For improving simulation speed and reducing internal collisions, you can choose to merge a URDF at each of its fixed joints.
kol merge-fixed-joints robot/URDF.urdf
To simplify each of the meshes in a URDF using vertex clustering:
kol simplify-all robot/URDF.urdf
To cleanup the meshes directory by removing all meshes not referenced in a urdf:
kol cleanup-mesh-dir robot/URDF.urdf
For example, if you wanted to download the 5-DOF stompy arm, merge and simplify, then clean the directory.
kol urdf https://cad.onshape.com/documents/afaee604f6ca311526a6aec8/w/29af84cb974c2d825b71de39/e/4fef6bce7179a665e62b03ba
&& kol merge-fixed-joints robot/assembly_1.urdf
&& kol simplify-all robot/assembly_1_merged.urdf
&& kol cleanup-mesh-dir robot/assembly_1_merged_simplified.urdf
Notes
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for kscale_onshape_library-0.0.15.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6632a1d3626fc359634ad92a46fc63c1f234a43a54a832bcc289dc3e905dd0a7 |
|
MD5 | 0ae888d7cac45b47f244d8cab3e008c4 |
|
BLAKE2b-256 | 506847b2b5137dfbe3c8ebc49f3d0dd2efb9fc8fa9ece86f1ec3491748c73036 |
Hashes for kscale_onshape_library-0.0.15-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35174f7c507d3b63a16952bdfc02a0a0e31dc8a83630b755ad268e25678c1bed |
|
MD5 | 401b2b5eeb0e592047b9801ba239fbe3 |
|
BLAKE2b-256 | 22cdb5a17d62ee3dc33ee5a20ada623ece80bbf8e1503e458cec9bf2b18e15ea |