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.

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.

Re: Kinematic simulator in python?

Originally Posted by jwatte

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...

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/

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 :/

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...

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...

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 ^^