GithubHelp home page GithubHelp logo

rhoban / onshape-to-robot Goto Github PK

View Code? Open in Web Editor NEW
213.0 22.0 45.0 4.2 MB

Converting OnShape assembly to robot definition (SDF or URDF) through OnShape API

License: MIT License

Python 99.79% Makefile 0.21%
robotics onshape cad urdf sdf

onshape-to-robot's Introduction

OnShape to Robot (SDF/URDF)

This tool is based on the OnShape API to retrieve informations from an assembly and build an SDF or URDF model suitable for physics simulation.

onshape-to-robot's People

Contributors

atticusrussell avatar csamid avatar gregwar avatar renaudponcelet avatar velovix avatar xavcrn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

onshape-to-robot's Issues

Document simulation.py

Explain what it is possible to do with simulation.py, that is basically a wrapper around pyBullet

Unable to find assembly in this document

I'm getting this error:

Unable to find assembly in this document

I think it's getting to the page but for some reason, it's not finding the assembly.
Does anyone have any suggestions that might give e a workaround of this? Thanks!

Any way to use without Onshape?

Since onShape is a very expensive and paid tool not most of us have access to it. Can this extension to be generalised for CAD files without OnShape

Maybe something like Solidworks? I know there is an extension there to export for UDSF but that is not even similiar to what this repo does. ( Automatically finding tree structure etc)

Add output file name in config

Instead of using "robot" as a mandatory file name for the generated .urdf or .sdf file, the name could be set in the config, and keep "robot" as a default value.

colab

hey i have tried it with google colab but its show something like this

  • Checking OpenSCAD presence...
    Can't run openscad -v, disabling OpenSCAD support
    TIP: consider installing openscad:
    sudo add-apt-repository ppa:openscad/releases
    sudo apt-get update
    sudo apt-get install openscad

  • Checking MeshLab presence...

  • Retrieving workspace ID ...

  • Using workspace id: 98cee18311a3b8d7c10abc42
  • Retrieving elements in the document, searching for the assembly...
  • Found assembly, id: 9332fc5299824befd8ebf702, name: "Robot"

onshape-to-robot is not able write all the parts of robot in urdf

Actually, I'm working on robotic arm, in which i have created all the joints and links but when i try to convert it in urdf, it is just converting some the parts of the robot.

Link of the document.

below image shows my document in onshape. All the fastened and revolute are working fine, and i am also able to move my arm in assembly.


robot_photo


And this the photo of converting process. It has detected all the dofs but not writing them in urdf.

teminal_photo

Though some of part of robot are not imported successfully, and is shows error like this "Contains faulty topology", which you can see in below image.

error_photo_1

But this error containing part are being imported in porject folder and in urdf file as well. And also i am able to run this part in bullet, shown below.

bullet_photo

That's why i am not able to get, where am i making mistake? So it would be really great if anybody can help me in this problem.

Thank You..

PackageName in collisions STL?

Ping @SammyRamone , I don't know the exact purpose of packageName (i expect it is about defining the path of your STLs?), but isn't it a bug that it is not also appended in the STLs files that are uses for collisions (assuming you don't use pure shapes) ?

Setting joint properties

We could allow user to set joints properties on config.json

However, we should handle the fact that multiple types of joints can be used, with different properties (maybe another issue)

Handle joint "sign"

The signs of the motors should be manageable somehow, maybe at least providing a way for the user to invert joint axis orientations in URDF

Merging collision shapes

Currently using the "mergeSTLs" option will only merge the visual stls in an URDF. The collision will still consist out of multiple stl files.
Is this intended behaviour?
If yes please document it better in the documentation by stating that only visual stls are merged.
Otherwise, I did a small hack to make it work (which should not be merged upstream due to bad code quality): bit-bots@390ea00
It works but for my model I had to deactivate collision with parents (using the URDF_USE_SELF_COLLISION_EXCLUDE_ALL_PARENTS flag) since it would lead to some self collisions otherwise.

Only part of dof is displayed in pybullet simulator issue

Hello, thank you for making good tool.

I almost completed applying your program to the my own robot.
Onshape_1

test

However, the problem that only two of the four wheels are displayed continued. Thus, I need some help for solving that problem.

4

Curiously, I confirmed that the first two of the revolulate mate, named dof_wheel, is displayed correctly. This is confirmed by a phenomenon that occurred in the same manner even when the order is changed.

Maybe I'd be grateful if you give me some advice for this phenomenon.

P.S.
Here is my Onshape robot model link : https://cad.onshape.com/documents/242e5d0f2f1cbff393c8e507/w/d559dc996c8b8bc22d12a621/e/61eb8c1b97972fad8186460d

Thank you,
From Dohyeong Kim

Merge STLs?

Instead of adding all STLs one by one in the <visual> section, maybe they could be merged

This only affects visual

How could we keep the color then?
Using obj?
Simplifications?

WARNING: part X has no dynamics (maybe it is a surface)

Hello,
Last year in December I generated correctly the urdf from my onshape model which contained faulty topology (although it looks good visually). The newest version of onshape-to-robot that I tried a few days ago shows a problem: WARNING: part X has no dynamics (maybe it is a surface). It creates the urdf file but without linking to an stl model. I generated again a correct urdf with v.0.3.4 so definitely something changed between the newest and that version. I am not sure if this behaviour was desired but at least it prevents me from using the newest version because I cannot change the imported model in onshape and I cannot find what causes the faulty topology.

Support for MuJoCo (MJCF)

Good point: MuJoCo seems to outperform other physics engine
Bad point: license is paid, so less reproductibility

But supporting MJCF (MuJoCo XML description format) would be feasible

@SammyRamone : do you use MuJoCo?

Origin changes on Assembly copy

Dear Onshape-Team,

I had a problem with your product.

In our project, we want to build a constrained model for machine learning.
To solve this, I copied the main assembly and adjusted the joint limits.

When exporting the assembly with onshape-to-robot, we experienced changes in the origins of the joint tag.
This lead to an erroneous behaviour in our simulation.

Specifically the <origin> tag within the <joint> tag changes.

Is this intended?
If yes, how can I avoid this behaviour?
If no, will you resolve this or is there a known work around?

Kind regards,
Thomas

Problems with gear relation

Seems like the "load_robot.py" has a problem with gear ratio (throws error in line 140). Seems like an easy fix to add a suppression, but i am not really confident with the code. Maybe it is possible to fix

Allow links to contain "composite parts"

Composite Parts are a relatively new addition to OnShape and are super useful to import standard parts in your robot. They can be assigned a material and a mass (for "closed composite") or behave as assemblies (therefore weighting as the sum of the components (for "open composite").

To allow composite parts to behave as "normal parts" just a single line needs changing:

return self._api.request('get', '/api/assemblies/d/'+did+'/'+type+'/'+wid+'/e/'+eid, query={'includeMateFeatures': 'true', 'includeMateConnectors': 'true'}).json()

add 'includeNonSolids' to the list of the queries

return self._api.request('get', '/api/assemblies/d/'+did+'/'+type+'/'+wid+'/e/'+eid, query={'includeMateFeatures': 'true', 'includeNonSolids': 'true'}).json()

python modules missed?

$ ./onshape-to-robot.py robots/myrobot
Traceback (most recent call last):
  File "./onshape-to-robot.py", line 4, in <module>
    from robot_description import RobotURDF, RobotSDF
  File "/home/nvidia/onshape-to-robot/robot_description.py", line 5, in <module>
    import stl_combine
  File "/home/nvidia/onshape-to-robot/stl_combine.py", line 5, in <module>
    import stl
  File "/home/nvidia/.local/lib/python2.7/site-packages/stl/__init__.py", line 2, in <module>
    import stl.ascii

ImportError: No module named ascii
$ python3 -m onshape-to-robot.py robots/myrobot

Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/usr/lib/python3.6/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/home/nvidia/onshape-to-robot/onshape-to-robot.py", line 4, in <module>
    from robot_description import RobotURDF, RobotSDF
  File "/home/nvidia/onshape-to-robot/robot_description.py", line 5, in <module>
    import stl_combine
  File "/home/nvidia/onshape-to-robot/stl_combine.py", line 7, in <module>
    from stl import mesh
  File "/home/nvidia/.local/lib/python3.6/site-packages/stl/mesh.py", line 4, in <module>
    class Mesh(stl.BaseStl):
AttributeError: module 'stl' has no attribute 'BaseStl'
``

Pulling from Branches

Hello,
i can not find a possibility to onshape-to-robot on a specified branch. The script seems to just take the last one active.
Can you add the Workspace Id in the Config.json to solve this ?

joint damping and friction

I implemented additional config values to specify joint damping and friction for URDFs on my fork (see bit-bots@ef9db6e). The implementation is basically the same as for the joint velocity and torque.
Are you interested in having this upstream? If yes, I can do a PR or you can just copy the few lines of code.

API for conversion to sdf files supported by the IGNITION GAZEBO

Hi there,

Currently, the API supports conversion from the native format to the SDF file (supported by Gazebo classic). I am looking for an API that would change this to the SDF files supported by the ignition gazebo. Any idea on how to do that?

Note: The SDF files supported by the Gazebo(classic) and Gazebo ignition have a significant difference. Please refer this.

Thanks

Using URDF Inertia in Simulation

Just a small thing. When loading the URDF into bullet it does not use the provided Inertias but recomputes them:

by default, Bullet recomputed the inertia tensor based on mass and volume of the collision shape. If you can provide more accurate inertia tensor, use this flag.

You need to set the URDF_USE_INERTIA_FROM_FILE flag to prevent this here

self.robot = p.loadURDF(robotPath,
startPos, startOrientation,
flags=p.URDF_USE_SELF_COLLISION, useFixedBase=fixed)

I think it would be good to change this in the simulation, as people may get confused why the model is behaving incorrectly after adding good inertia values in the config using the "dynamics" parameter.

Root [occurrences]; KeyError

I'm trying to download the cad into urdf. It seems like there is no occurrences from onshape.

  • Retrieving assembly "Assembly 10" with id d5ee290fc2a98e8ecce43ea0
    Traceback (most recent call last):
    File "/home/xxxxxxx/.local/bin/onshape-to-robot", line 3, in
    from onshape_to_robot import onshape_to_robot
    File "/home/xxxxxxx/.local/lib/python3.8/site-packages/onshape_to_robot/onshape_to_robot.py", line 14, in
    from .load_robot import
    File "/home/xxxxxxx/.local/lib/python3.8/site-packages/onshape_to_robot/load_robot.py", line 94, in
    for occurrence in root['occurrences']:
    KeyError: 'occurrences'

Can it be a problem with the CAD?

Thanks

Collisions issue with sdf, not urdf

Hello, I am trying to use an onshape model with ROS. I was able to follow the directions and make an urdf for the robot but now I am trying to get an sdf, but I get the following error:

image

Ignoring configuration option in config.json

When I use the export tool, it seems to ignore the configuration specification in the config.json file:

Eg:

"documentId": "abcdefghi123456789", "outputFormat": "urdf", "assemblyName": "myrobot", "versionId": "abcdefghi123456789", "configuration: "extra long legs",

no matter what I put, the default configuration is always exported. Is there something I am missing?

Additionally - some of my links in the top level assembly are sub-assemblies. Is there any way to specify configurations for these sub-assemblies?

Issue reading limits

Got this error while reading Limits for revolute joint

Traceback (most recent call last):
File "/home/onshape-to-robot/onshape-to-robot", line 3, in
from onshape_to_robot import onshape_to_robot
File "/home/onshape-to-robot/onshape_to_robot/onshape_to_robot.py", line 15, in
from .load_robot import
File "/home/onshape-to-robot/onshape_to_robot/load_robot.py", line 166, in
limits = getLimits(jointType, data['name'])
File "/home/onshape-to-robot/onshape_to_robot/features.py", line 84, in getLimits
minimum = readParameterValue(parameter)
File "/home/onshape-to-robot/onshape_to_robot/features.py", line 61, in readParameterValue
if value['message']['booleanValue'] == parameterValue:
KeyError: 'booleanValue'

Do you guys know any workaround?

onshape-to-robot inports old state of a document

Hi!

I'm trying to use onshape-to-robot now and facing the following issue:

  1. First import went just fine.
  2. All the next imports do not represent the actual state of a document

I've tried to clear cache, delete all files, update timestamp for the config json - nothing helps.

Here is the current state of my assembly:
image
And here is what I find in stl file:
image

Can it be a glitch of the onshape's API?

PS: It looks like onshape's configuration variables are not evaluated properly.

Br, Alex

Error 404 while using OnShape API

Hello

I am trying to create a urdf file from an onshape model of a robot manipulator arm, and I am getting the following error:

  • Checking OpenSCAD presence...

  • Checking MeshLab presence...

  • Retrieving workspace ID ...

  • Using workspace id: dfe513c099f86b8f8b4b33c1
  • Retrieving elements in the document, searching for the assembly...
  • Found assembly, id: e7806a8b6e8ca46848b0ad73, name: "Bravo_7"
  • Retrieving assembly "Bravo_7" with id e7806a8b6e8ca46848b0ad73

  • Getting assembly features, scanning for DOFs...

  • Found DOF: j7 (revolute)[0.087: 6.196]
  • Found DOF: j6 (revolute)[0.0: 3.142]
  • Found DOF: j5 (revolute)[0.0: 3.142]
  • Found DOF: j4 (revolute)[0.087: 6.196]
  • Found DOF: j3 (revolute)[0.0: 3.142]
    WARNING: joint dof_j2 of type revolute has no limits
  • Found DOF: j2 (revolute)
  • Found total 6 DOFs

  • Building robot tree

  • Trunk is Base <1>

  • Adding top-level instance [Base <1>]

  • Adding part RS2-276-def <1>
  • Adding part RS2-266-def <1>
  • Adding top-level instance [Link1 <1>]
  • Adding part RS2-249-def <1>
  • Adding part RS2-217-def <1>
  • Adding top-level instance [Link2 <1>]
  • Adding part RS2-236-def <1>
  • Adding part RS2-214-def <1>
  • Adding part RS2-212-def <1>
  • Adding part RS2-250-def <1>
    ! ERROR (404) while using OnShape API
    ! <!doctype html>
<title ng-bind="$root.title">Onshape</title>
<link rel="stylesheet" type="text/css" href="/css/jquery-ui/jquery-ui-1.10.4.custom.css" />
<link rel="stylesheet" type="text/css" href="/css/jquery.contextMenu.css" />
<link rel="stylesheet" type="text/css" href="/css/glyphicons.css" />
<link rel="stylesheet" type="text/css" href="/css/demoserver-bootstrap.css" />
<link rel="stylesheet" type="text/css" href="/css/jquery.nouislider.css" />
<link rel="stylesheet" type="text/css" href="/css/colorpicker-themes.css" />

<link rel="stylesheet" href="/css/bootstrap/bootstrap.css"/>
<link rel='stylesheet' type='text/css' href='/css/fonts.css' />

  <link href="/css/newton.css" rel="stylesheet">

  <script src="/js/runtime.31d2b0b55f004549b961.js"></script>
  <script src="/js/vendor-bundle.31d2b0b55f004549b961.js"></script>
  <script src="/js/webpack-vendor.31d2b0b55f004549b961.js"></script>
  <script src="/js/woolsthorpe.31d2b0b55f004549b961.js"></script>
  <script src="/css/newton.31d2b0b55f004549b961.js"></script>

<script type="text/javascript" src="https://js.stripe.com/v2/" async></script>
<script type="text/javascript" src="https://www.zuora.com/apps/Hosted/lite2/js/HPM2Security.js" async></script>

I tried to isolate the error and I believe it has something to do with Link2 of my model, but I am not sure what can the error with this part of the robot be. Can somebody explain me what does the html part of the error means? because a lot of the text does not make any sense.

Here is the link to my onshape document:

https://cad.onshape.com/documents/6fdce4c712a1f625a0e4df69/w/dfe513c099f86b8f8b4b33c1/e/5bd485de8a70d7474f8490c3

This is the isolated link of the arm that I believe is causing the problem:

https://cad.onshape.com/documents/c7f4343ab134d605156724b1/w/35a6d286ff1923733e540600/e/17437e1268bcb23d70d88912

Thank you in advance

Troubleshooting trunkOccurrence issue

This is the error we received when running the code. Trying to figure out what we need to troubleshoot to resolve this. Any help provided is appreciated. Thanks!

(env) ubuntu@ubuntu:~/onshape-to-robot$ ./onshape-to-robot.py robots/swervedrive

  • Retrieving workspace ID ...
  • Workspace id: 8d370ad12960758f3af7ebdf
  • Retrieving elements in the document, searching for the assembly...
  • Found assembly, id: f36c9e0cbc8985502f31fac7, name: "Swerve Chassis"
  • Retrieving assembly
  • Getting assembly features, scanning for DOFs...
    Found dof: bl_angle
    Found dof: bl_speed
    Found dof: br_angle
    Found dof: br_angle
    Found dof: fr_angle
    Found dof: fr_speed
    Found dof: fl_angle
    Found dof: fl_speed
  • Found 4 DOFs
  • Building robot tree
    Traceback (most recent call last):
    File "./onshape-to-robot.py", line 214, in
    trunkOccurrence = getOccurrence([trunk])
    File "./onshape-to-robot.py", line 97, in getOccurrence
    return occurrences[tuple(path)]
    KeyError: (None,)

Cannot Retrieve Workspace ID

Hello! I've been trying to use this useful program but I seem to be having trouble actually retrieving my OnShape Workspace. I have followed the documentation and created a new API key on OnShape of which I've put into my ~/.bashrc and sourced. I have deleted and created multiple keys but I always end up with the same result:

$ onshape-to-robot onshape-to-robot-examples/2wheels/

* Checking OpenSCAD presence...
* Checking MeshLab presence...

* Retrieving workspace ID ...
https://cad.onshape.com/api/documents/862948a6ea6d38343e1d3272?
! ERROR (403) while using OnShape API

Small documentation error

In the example config.json, "mergeSTLs" and "simplifySTLs" are set to "false" whereas they can be only “no”, “visual”, “collision” or “all”.

Combining STLs also for collision

It is possible to combine and simplify STLs, mainly to lighten the output robot description, but also as workaround for #16

However, this should be possible to also use those light STL files for collisions tags

Parallel robots?

From design point of view, that would imply changing the way the robot parts are imported in the current script
Is it possible in URDF/SDF?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.