Giter Site home page Giter Site logo

fusion2pybullet's Introduction

Fusion2Pybullet

Archive Note: I will no longer sutdy and work in Robitics. Please fork and develop on your needs.

简体中文 | English

Developed from @syuntoku14/fusion2urdf.

What is this script?

A Fusion 360 script to export urdf files. This is a PyBullet adpative version.

Note: Only support "Revolute", "Rigid" and "Slider" joint currently. Also I don't have plans to work on rigid group and other types of joints.

This exports:

  • .urdf files of the model
  • .stl files of your model
  • A example hello.py to load your model into PyBullet.

03/03/2021: Pull the fix for xyz calculation from 01/09/2021 commit d2e754086f092ac81c481a0c3862e3cecb1f4dfe in syuntoku14/fusion2urdf

  • If you see that your components move arround the map center in rviz try this update
  • More Infos see this link

03/27/2020 update2: Add a supplementary script Joint2Graphviz to check assembled structures.

03/27/2020 update: Add "Do not Capture Design History" to fix InternalValidationError. See Developer Notes

03/25/2020: Supporting exportation of nested components.

Fusion Add-in

Add this script into Fusion 360 via Tools -> Add-Ins

Before using this script

  1. Some other notes for getting avoid of warnings:
    1. Change language preference to English
    2. Rename any full-width symbol to half-width symbol (like and ())
  2. Set up base_link
  3. Suggestion: Use Joint2Graphviz to check your assembled structure!
  4. Check if your default unit is mm or not. If you set it to some other unit, you need to manually adjust the scale when exporting the stl fils. See FAQ

Using script inside Fusion 360: Example

  1. Set up the components properly
  • Unit should be mm (See FAQ if it's not)

  • A base_link

  • Your file should not conatin extra file link. If any, right click on the component, do 'Break Link'

    • File links will be generated when you do something like 'Insert into current design'
    • So please make sure you did had a backup when you do the 'Break link' operations.
  • Check component and joint names (Set English as the language if necessary)

  • IMPORTANT! Set up joints properly

    • Supplementary script: Joint2Graphviz will generate a txt file capable for Graphviz. Copy the content to WebGraphviz to check the graph. Usually a correct model should be a DAG with 'base_link' as the only root.

    • In fusion, when you hit 'J' to assemble joints, note that the exporter consider component 1 as 'child' and component 2 as 'parent'. For example, when you want to assemble a 4-wheel car with middle cuboid as base_link, you should assemble the vehicle with wheel as component 1 and 'base_link' as component 2.

    • For example, you should be assemble your model to make result of check_urdf simple_car.urdf like the following. i.e. BL, BR, FL, FR as component 1 and base_link as component 2 when you assemble these 4 joints.

     robot name is: simple_car
       ---------- Successfully Parsed XML ---------------
       root Link: base_link has 4 child(ren)
           child(1):  BL_1
           child(2):  BR_1
           child(3):  FL_1
           child(4):  FR_1
    
  1. Run the script and select storing location

    • Note: Don't save your file after running the scripts! DesignType will be set to "Direct Mode" and some temporary components will be created. That's not the changes you want!
  2. Enjoy from python hello_bullet.py !

FAQ

What to do when error pops out

  • Bugs are usually caused by wrongly set up joints relationships
  • Nest-component support might also lead to undocumented bugs. So remove the nesting structure helps a lot.

Since the script still cannot showing warnings and errors elegantly, if you cannot figure out what went wrong with the model while bugs are usually caused by wrongly set up joints relationships, you can do the following things:

  1. Make sure every joints are set up correct (parent and child relationship). If failed --->
  2. Re-tidy your design to make it not include any nest-components. Use this script. If failed --->
  3. Try the stable version Branch: stable.
  4. Run with debug mode and check what happens

How to check if I assembled my links and joints correctly

A supporting script here: Joint2Graphviz for details

What if my unit is not mm

You have to modify Bullet_URDF_Exporter/core/Link.py. Search scale

(Please ping me if you find any other place that should also be modified)

        # visual
        visual = SubElement(link, 'visual')
        origin_v = SubElement(visual, 'origin')
        origin_v.attrib = {'xyz':' '.join([str(_) for _ in self.xyz]), 'rpy':'0 0 0'}
        geometry_v = SubElement(visual, 'geometry')
        mesh_v = SubElement(geometry_v, 'mesh')
        mesh_v.attrib = {'filename': self.repo + self.name + '.stl','scale':'0.001 0.001 0.001'} ## scale = 0.001 means mm to m. Modify it according if using another unit
        material = SubElement(visual, 'material')
        material.attrib = {'name':'silver'}
        
        # collision
        collision = SubElement(link, 'collision')
        origin_c = SubElement(collision, 'origin')
        origin_c.attrib = {'xyz':' '.join([str(_) for _ in self.xyz]), 'rpy':'0 0 0'}
        geometry_c = SubElement(collision, 'geometry')
        mesh_c = SubElement(geometry_c, 'mesh')
        mesh_c.attrib = {'filename': self.repo + self.name + '.stl','scale':'0.001 0.001 0.001'} ## scale = 0.001 means mm to m. Modify it according if using another unit
        material = SubElement(visual, 'material')

fusion2pybullet's People

Contributors

yanshil 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

Watchers

 avatar  avatar  avatar  avatar  avatar

fusion2pybullet's Issues

Joint creation example for documentation

The project looks really great and useful, but it's a bit hard to understand how to setup the joints in fusion to make it work. As someone that does use fusion regularly, it is still unclear to me how to name or set up joints. Is a walkthrough available somewhere, or could something be worked on?

URDF exporter not running

Hi,

This looks like a great tool. One issue I have is that it will not run. No error message or anything. I have tried both this version also the stable version. And i have tried it on a simple 4DOF legged robot and also a simple box. The graphwiz does work the the tree structure looks good as far as I can tell.

This is the text output:

digraph G { "base_link" -> "leg_v21leg1" [ label = "Rev1" ]
"base_link" -> "leg_v22leg1" [ label = "Rev2" ]
"base_link" -> "leg_v23leg1" [ label = "Rev3" ]
"base_link" -> "leg_v24leg1" [ label = "Rev4" ]
}

I ensured I have no nested components and that my base_link is called base_link.

Do you have any suggestions on how I might get it to work?

Thanks,
Stephen

Material Problem

I set material in fusion360, but in urdf I just see one material 'silver', and the physical property is different from property in fuison360, for example mass, moment of inertial.
I will appreciate if someone can answer my question.

error with the connections between old_component1 and servo_v11

I am trying to export my biped robot from fusion but I get the following error:

Joint Rigid5: There seems to be an error with the connection between
old_component1
and
servo_v11

Check whether the connections
parent=component2=old_component1
child=cpmponent1=servo_v11
are correct or if you need to swap component1<=>component2

I can't seem to find any error between the connections in the model. Also, I checked the design with Joint2Graphviz, and evrrything looks fine.

Joint axes are incorrect.

Hi! Thank you for this Addin!
It saves a lot of time, as before we had to export each mesh file in a separate format(via fusion2urdf) in-order for Pybullet to accept the mesh file format. This takes care of it instantaneously.

Although I ran into a joint axes mismatch (below). I think that you can use the mesh exporter that you have here, and fusion2urdf's original code for joint axes and urdf creation and it would be perfect

I have also provided the video of how it should actually look like (which was made with fusion2urdf)

Output: (Please excuse the music. This is my first time using screenrecord application )

Fusion to Pybullet Video:

simplescreenrecorder-2021-02-13_00.25.49.mp4

Fusion to URDF Video:

simplescreenrecorder-2021-02-13_00.45.38.mp4

My modified hello_bullet.py code, video output:

#!/usr/bin/env python3
import pybullet as p
import time
import pybullet_data
physicsClient = p.connect(p.GUI)#or p.DIRECT for non-graphical version
p.setAdditionalSearchPath(pybullet_data.getDataPath()) #optionally
p.setGravity(0,0,0)
# planeId = p.loadURDF("plane.urdf")
cubeStartPos = [0,0,0]
cubeStartOrientation = p.getQuaternionFromEuler([0,0,0])
robotId = p.loadURDF("V14_URDF.urdf",cubeStartPos, cubeStartOrientation, 
                   # useMaximalCoordinates=1, ## New feature in Pybullet
                   useFixedBase=True,
                   flags=p.URDF_USE_INERTIA_FROM_FILE)
val = 0 

for i in range (10000):
    p.stepSimulation()
    time.sleep(1./240.)
    # for j in range(p.getNumJoints(robotId)):
    	# p.setJointMotorControl2(robotId,j,controlMode=p.POSITION_CONTROL,targetPosition=val)
    	# val = val +0.001
    p.setJointMotorControl2(robotId,2,controlMode=p.POSITION_CONTROL,targetPosition=val)
    val = val +0.001
    p.setJointMotorControl2(robotId,3,controlMode=p.POSITION_CONTROL,targetPosition=val)
    val = val +0.001

cubePos, cubeOrn = p.getBasePositionAndOrientation(robotId)
print(cubePos,cubeOrn)
p.disconnect()

Warm Regards,
Rohit Kumar J

Enhancement: Add preset fields to the exporter inorder to include addditional preset conditions

Hi! We could add a few preset joint criteria as shown here. Of course, it will need manual tuning to get it even close to being realistic (eg. joint-limits, calibration, damping, effort, etc), But I think this could be a good enhancement. I will try to create a pull request.
Example:
image
We could just input these values directly and the users can modify them at will. We will need to provide a disclaimer in the Readme file tho.

Warm Regards,
Rohit

Joint location issue

Hi there,

I am having what seems to be the same joint location calculation issue that was previously fixed. I am using the latest code and the latest fusion. I can successfully create a URDF file, but when placed in a viewer / pybullet the rotation of the joints is incorrect. I have attatched the URDF file that I have generated, and can also provide the fusion file if neccessary.

Thanks
Assembly_urdf_modded.zip

Units does not scale

That's a really nice tool you made, I am sad I just discovered it!

However, I found a small issue or maybe I've missed something :

In Fusion 360 if the document settings are in anything other than mm , the URDF model will not scale.
For example if I use cm as default units in Fusion then the URDF model will be 1/10 the size of the original.
Not a huge deal just good to know.

Thanks again for your work!

Joints being rotated 90degrees

Hi i have used your plugin in the past with great success but now (supposetly after latest F360 update) joints are rotated by 90 degrees in the same direction. Please refer to the images below. I deduct the issue is somehow related on fusion2urdf plugin that your plugin is based on since i've got similar results while using the other one.
pre
post

[EDIT] I will just add that i've also tried without adding assemblies, just every single part imported to the design and joined to the base link. I'am almost sure my joints are set correctly (as i said, I've used the plugin in the past) and i've also doublechecked them with Joint2Grphviz.

Issues with Joint.make_joints_dict

Hello, I am having the following problem:

Before Running:
image


After Running:
image

On the side, you can see the joints go yellow when I run the script. Could this be a reason? Some of the joints were created with the "As-built joint" which results in a rigid joint.

I tried debugging it myself:

str(root.joints):
image

str(root.joints[0])
image

But I can't print with ui.messageBox inside the Joint.py file, even if I pass in ui

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.