[Robotics] Computing IK Joint Angles Pt. [SOLVED]

Benoit Bolsee benoit.bolsee at online.be
Wed Jul 22 11:56:52 CEST 2009


Very nice!
 
About the Matrix API mult problem, I got confirmation that this problem
exists and the normal way to work around that is to use something like:
 
BA =
bones['shoulder'].matrix['ARMATURESPACE'].rotationPart().transposed()
 
which allows to use standard multiplication function. Note that in that
case, the function to extract the angle must be changed as the matrix
becomes row major.
 
You may be interested to know that I'm working on a project with the KUL
to implement a new IK algorithm and support external IK target in the
Game Engine. The new IK algorithm is stateful, which means that the
joint angles are available directly in the IK state variables (there is
no Python API yet to get them).  Being able to track external targets in
the GameEngine is an important step for the robotic applications, it
opens the door for simulation and real time control of robot. More
information here:
http://wiki.blender.org/index.php/Dev:Source/GameEngine/RobotIKSolver
 
/Benoit

-----Original Message-----
From: robotics-bounces at blender.org [mailto:robotics-bounces at blender.org]
On Behalf Of Florian Lier
Sent: mercredi 22 juillet 2009 10:35
To: Blender and Robotics
Subject: Re: [Robotics] Computing IK Joint Angles Pt. [SOLVED]


Hey all - especially Benoit,

wow, I would never have aspersed the python API to mess up the matrix
mult. ...

I really appreciate your help, without your engagement I would have
calculated matrices for the next few weeks.
I needed to alter the code somewhat, because the DoF are little
different from my "sample amature" so I added 
an additional axis to the "def EulerAngleFromMatrix(R, axis)" function.

Everything seems to be fine so far, so I created a video which shows how
Blender can controll a real Robot (Software).
THANKS again - big time!

Here's the video: http://www.vimeo.com/5699910

Cheers, Florian



Benoit Bolsee wrote: 

Hi Florian,
 
I had a look on your file and modified it to get it working. While doing
that, I noticed several important points:
- better use dictionary access by bone name instead of index number, it
is more portable
- you cannot avoid using the bone rest pose because Blender introduces
180 roll all the time, which ruins the angle calculation based only on
the pose matrix
- I discovered a major flaw in the MathUtil library: it treats the
matrix as row major for matrix operations like multiplication but
Blender returns column major matrices. I wonder how nobody noticed that.
I had implement my own matrix multiplication function to work around
that. Maybe it is my ignorance of the Blender Python API.
 
Attached you will find the script that gives exact joint angles. The
logic is quite simple and systematic: the joint angle is computed from
the difference between 1) the pose of a bone when combining the pose of
its parent and its own rest pose 2) its actual pose. The difference is
only due to the angle and as you only use 1DoF joints, it is quite
simple to extract the angle.
 
Regards,
Benoit
 

-----Original Message-----
From: robotics-bounces at blender.org [mailto:robotics-bounces at blender.org]
On Behalf Of Florian Lier
Sent: jeudi 16 juillet 2009 20:51
To: Blender and Robotics; Blender Foundation Python list
Subject: [Robotics] Computing IK Joint Angles Pt.3


Hey all and especially Benoit,

i've implemented Benoits approach for computing joint angles (in
degrees)

To recapitulate the problem:

I've modelled a robot arm with 5 joints (all joints are revolute
joints). The arm is
driven by an "empty" target to an IK solver on top of the bone chain. I
need to
get the joint angles in degrees or rad. Those joint angles are in range
of the X,Y,Z
limits of the bones which form the chain.

The approach: 

relativePose[n] = inverse(poseMatrixTail[n-1])*poseMatrix[n]



"where n is the bone for which you compute the joint values and

poseMatrixTail is simply poseMatrix where the 4th column is replaced by

tail. For the root bone, poseMatrixTail is the identity matrix."



As far as I've tested the setup all angles are computed correctly. The
only problem is, that

I need to convert the angles from poseMatrix -> toEuler(). That's the
last pitfall. Euler angles

are a bit tricky because the represent [yaw, pitch, bank]. By rotating
some (or one) of the

parent bone/s the YAW, PITCH, BANK locally changes for the "target bone"
[n] (for which I want to

compute the joint angle) so the resulting angle is either positive or
negative - what's not THAT bad. 

The biggest problem is - an euler angle is represented like [x (yaw),z
(pitch),y (bank)]. 

Let's assume a bone rotates about the x axis (its' DoF). If all bones
are in rest position the output when 

rotation the bone is like: [100, x, x] after rotation one of it's
parents the result is maybe: [x,x,100]. 

To me there's so predictable coherence whether the result can be found
in x y or z.



How can someone solve this problem?



I've digged deep in the blender source code especially in armature.c and
the IK_Solver sources.

The angle I need is represented as a float value in there :/.  



[blender source from svn]



blender/intern/iksolver/intern/IK_QSegment.cpp [line 602]



BUT wrapping this code to Python, making the code invokable and finally
extending the Python API 

seems a little to exaggerated to me ... 



So having the feature to extract several angles from an IK chain would
be great in case of using blender

for robotics.



It would be great if someone can help me out - or if we can solve this
problem in a more general manner

like really extending the python API ? I'll attach the appropriate blend
file so everybody can play around

or visualize the problem. Most of the code is documented.



You can find the blend file here:
http://www.icram.de/BpyJointAngles.blend



Cheers, Florian





P.S. Sorry for crossposting this, but this is / maybe / not only a
robotics issue...










  _____  


_______________________________________________

Robotics mailing list

Robotics at blender.org

http://lists.blender.org/mailman/listinfo/robotics


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.blender.org/pipermail/robotics/attachments/20090722/e4abb04a/attachment-0001.htm 


More information about the Robotics mailing list