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

Florian Lier blender at icram.de
Wed Jul 22 10:35:29 CEST 2009


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/59fe46f0/attachment.htm 


More information about the Robotics mailing list