Trossen Accelerometer Gyro Top Banner
Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Kinematic simulator in python?

  1. #1
    Join Date
    Apr 2013
    Location
    San Francisco, CA
    Posts
    14
    Images
    3
    Rep Power
    6

    Kinematic simulator in python?

    Hi folks! Does anyone know of a kinematics simulator package, preferably written in python? I have a new hexapod robot Grinder ( http://forums.trossenrobotics.com/ro...=49#ad-image-0 ) that I am writing IK software for. I have the IK equations ready to go, but it would be so much faster and simpler to create a simulator for the robot in software so that I can write and test the IK framework without needing the actual robot...

    I am currently using the lib_robotis.py libraries from hizook, but I am in the process of rolling the code into ROS. Servos are dynamixels, but I am hoping to write a completely standalone simulator.

    Any ideas?

    cheers,

    nick.

  2. #2
    Join Date
    Apr 2012
    Posts
    1,860
    Images
    25
    Rep Power
    64

    Re: Kinematic simulator in python?

    A (long) while back, I used SWIG to generate bindings for the ODE physics simulation package.
    The Python sites list a library called PyODE which I believe might still be maintained as a ready-made option.
    Another high quality physics simulation library is Bullet; there seems to exist a pybullet open source library but it doesn't seem well maintained.

  3. #3
    Join Date
    Apr 2013
    Location
    San Francisco, CA
    Posts
    14
    Images
    3
    Rep Power
    6

    Re: Kinematic simulator in python?

    Quote Originally Posted by jwatte View Post
    A (long) while back, I used SWIG to generate bindings for the ODE physics simulation package.
    The Python sites list a library called PyODE which I believe might still be maintained as a ready-made option.
    Another high quality physics simulation library is Bullet; there seems to exist a pybullet open source library but it doesn't seem well maintained.
    Thanks for the tip, looks like I can do some interesting things with pyODE and visualPython. I had been looking at omd but it doesn't seem to have much support and the original site is gone... I'll install pyODE and visualPython and post my results...

    cheers,

    n.

  4. Trossen Desktop RoboTurret Thread Banner
  5. #4
    Join Date
    Apr 2013
    Location
    San Francisco, CA
    Posts
    14
    Images
    3
    Rep Power
    6

    Re: Kinematic simulator in python?

    I have had some success with the vpython approach. So far I have a basic linkage system built up, integrated with my IK code for generating the neccesary coordinates. I have to create a new frame for each linkage, then in each step move it to its new position and set the axis to its new orientation. Not pretty (codewise) but it works. I have attached two files if you want to try it. You can get vpython at http://www.vpython.org/

    grinder_simulator_01.py - Z/Y linkage mechanism
    grinder_simulator_02.py - X/Z/Y mechanism with Z/Y mechanism rotating around X axis. Tricky... still working on it.
    grinder_simulator_python.zip

  6. Re: Kinematic simulator in python?

    I have written a simulator for Xachi a while back, from scratch, using VPython for the visualization.
    You might be able to either reuse some parts of it, or maybe just get some ideas, since it's not made to be generic/reusable... I wrote it quite quickly and it developed organically :/

    http://xevel.fr/other/Xachikoma_20130422.zip

    There are 3 folders:
    * Simu: contains all the simulator-related files. Most of them are not
    The simulator itself is ran with Simu/xachikoma_simu.py.
    Open it in VIDLE then run it with F5. There might be some folders to add to the python path if the xachi package is not found.
    A lot of stuff in this folder are stand alone little experiments, or visualization of what the robot sees (like the LDS, the CMUcam...) and is turned off by default.
    ik_visu.py are the visualization classes, manipulator.py has some useful little things.

    * xachi: contains all the code running in the robot. The IK code is in xachi/control/ik_nodes.py, with some more stuff in ik_helpers.py.

    * xachiRemote: a C# app to remote control Xachi, based on ZMQ for communication, with ways to create various combination of keys and different modes of control - that's what makes xachi move smoothly right now But that's not the topic.

    The idea is that I have a tree of IK nodes, each one knows how to solve its own IK, body being the root and each limb being one of its children. Solving the IK problem stores the mathematical state (angles in radians) in the IK node itself.
    These values are either used to transform that into commands for the servo (on the robot) or for the visualization (simu).
    I haven't written rotation manipulators but I could if needed.




    Since then, I have just started (in the plane back from San Francisco actually!) new simu, just to have a look at some leg configurations and the associated control software for my next beast (for Mech Warfare!):
    http://xevel.fr/other/new_quad.py
    Download it and put it in the Simu folder of the previous archive, it uses some helper stuff that lies around - I think.

    There is very little to it right now, but it might give you some ideas about how to make some simple stuff.
    Currently, it only has a class that represents a servo and the kinematics link from it to the next actuator.

    I'm sure there is a lot of obscure stuff around, feel free to ask, I might even be able to make a stripped down "educatioal" version (=easier for people to understand how it works so that they can benefit from reading the source code or even reuse parts of it) if there is some interest...



    ---
    XD Team - http://xevel.org (now in English!)

  7. #6
    Join Date
    Apr 2013
    Location
    San Francisco, CA
    Posts
    14
    Images
    3
    Rep Power
    6

    Re: Kinematic simulator in python?

    What version of vpython were you using? I am getting a variety of errors... likely because it's based on an old version.

  8. Re: Kinematic simulator in python?

    I'm using Python 2.7 and the latest associated VPython version, 6.05. Are you using Python 3.x?
    What errors do you get ?
    Last edited by Xevel; 05-02-2013 at 11:43 PM.
    ---
    XD Team - http://xevel.org (now in English!)

  9. #8
    Join Date
    Apr 2013
    Location
    San Francisco, CA
    Posts
    14
    Images
    3
    Rep Power
    6

    Re: Kinematic simulator in python?

    OK I figured it out, made a couple of small changes to ik_visu.py and got it working. Nice simulator! I'm definitely stealing your control panel...


    def __init__(self, body, frame_in):

    self.body = body

    self.body_frame = frame(frame = frame_in, pos = body.pos)

    self.ring = ring(frame=self.body_frame, pos=(0,0,58.5), axis=(0,0,1), radius = 100, thickness=2, color = color.blue)

    self.pyramid = pyramid(frame=self.body_frame, pos=(100,0,58.5), size=(10,17,5), color=color.red )
    Last edited by psyclops; 05-03-2013 at 10:42 PM.

  10. #9
    Join Date
    Apr 2013
    Location
    San Francisco, CA
    Posts
    14
    Images
    3
    Rep Power
    6

    Re: Kinematic simulator in python?

    Success! I realized I could massively simplify the simulator by a) reducing all linkages to cylinders and b) only using frames for each leg, and c) simply moving the cylinder linkage ends to the x,y coords generated by my IK equations. I rewrote the code in about an hour and now have a full robot simulator that I can throw foot x,y,z coords at and it will show me visually what the robot is doing. Awesome.

    See python code at url below. I have a simple demo going with all six legs swinging back and forth and up and down. Now I need to integrate it into my robot code...

    http://www.gotrobots.com/grinder/simulator/grinder_simulator.py


  11. Re: Kinematic simulator in python?

    Looks very cool
    The equations are, like you showed me, much faster when developed and written with only trigonometry instead or vectors/matrices, but I still find them a little harder to read
    I might take that into account for my next project where performance will be an important factor ^^

    Can't wait to see what gait you will make with that tool !
    ---
    XD Team - http://xevel.org (now in English!)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Bioloid Simulator
    By MattD in forum Software and Programming
    Replies: 2
    Last Post: 09-02-2014, 11:00 AM
  2. simulator robot
    By light86 in forum Software and Programming
    Replies: 4
    Last Post: 06-06-2013, 05:25 PM
  3. Question(s) choosing platform for project (biped, torque control servo, advanced kinematic)
    By sergeyko in forum Robotics General Discussion
    Replies: 7
    Last Post: 05-16-2011, 02:02 AM
  4. Project My Inverse kinematic software for controlling robot arms.
    By Pinter75 in forum Project Showcase
    Replies: 1
    Last Post: 09-10-2010, 11:01 PM
  5. Contest Entry My flight simulator
    By gokhotit in forum Project Showcase
    Replies: 1
    Last Post: 08-22-2007, 11:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •