Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Inverse kinematics - robot

4 REPLIES 4
Reply
Message 1 of 5
sh3H24D
7118 Views, 4 Replies

Inverse kinematics - robot

Hi, is it possible to script and test some inverse kinematics on joints I added to a robot in my fusion 360 project?

4 REPLIES 4
Message 2 of 5
ekinsb
in reply to: sh3H24D

I'm not sure what kind of tests you want to do but true inverse kinematics are not currently supported through the API.  When you move an occurrence using the API you do that by setting the tranformation matrix associated with the occurrence using the transform property of the Occurrence object.  When you do this all joints are ignored.  You can move the occurence anywhere without any regard to joints.  Just as soon anything happens within the assembly to cause the assembly to recompute that part will snap back into the position defined by the joints.

 

You can perform forward kinematics through the API by doing the equivalent of the "Drive Joints" command but I suspect that's not what you're looking for.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 3 of 5
sh3H24D
in reply to: ekinsb

Oh, but drive joints maybe will work. An idea would be to make scripts that when I give them a parameter (maybe from command line?) like x1 y0 z0. My script then translates this to how the joints should move and move them. Would that be possible?
Message 4 of 5
ekinsb
in reply to: sh3H24D

In case drive joint will do what you need, here's some example code that demonstrates driving a joint.  I'm driving the joints through a series of changes to create an animation.  I wanted to attach the assembly I used but unfortunately, I built in the upcoming release so the f3d can't be used in the current release.  It's simple though.  I have an assembly that contains two instances of the same component (which is a subassembly made up of several parts).  That component is named "PistonAssembly".  Inside that component I have several joints that control the behavior of the parts within it.  One of those joints is a revolution joint named "Motor".  This program will find the two instances of the joint and drive them indepenedently of each other.

 

def driveJoint():
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface

        des = adsk.fusion.Design.cast(app.activeProduct)
        root = des.rootComponent
        
        # Get the two occurrences in the root.  These are two
        # instances of the same component.
        piston1 = root.occurrences.itemByName('PistonAssembly:1')
        piston2 = root.occurrences.itemByName('PistonAssembly:2')
        
        # Get the component referenced by the occurrences.
        pistonComp = piston1.component
        
        # Get the joint in the piston component.  It will be in 
        # the context of the piston component.
        motorJoint = pistonComp.joints.itemByName('Motor')
        
        # Create proxies of the joint for each occurrence.
        motor1 = motorJoint.createForAssemblyContext(piston1)
        motor2 = motorJoint.createForAssemblyContext(piston2)
        
        # Get the RevoluteJointMotion object from each joint.
        revJointMotion1 = motor1.jointMotion
        revJointMotion2 = motor2.jointMotion
        
        # Drive the joints.
        for i in range(0, 720, 3):        
            revJointMotion1.rotationValue = i * (math.pi/180.0)
            revJointMotion2.rotationValue = (i+180) * (math.pi/180.0)
            
            adsk.doEvents()
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc())) 

 

Here's a picture of the assembly and you can see the structure in the browser.

PistonAssembly.png


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 5 of 5
jrohit1110
in reply to: ekinsb

Hello Sir!

Can we have a way to somehow calculate angles and positions in Fusion 360 for static analysis on inverse kinematics problem? WhatI mean by this is, can we read angles(revolute joints), lengths(prismatic joints) in real time like how BricsCAD does. 

Video Link: https://www.youtube.com/watch?v=zWj3mZ3bkvI

If it isn't already there, it would be very much appreciated if included in the next update of Fusion 360.

Regards 

Rohit Kumar


Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report