forward kinematics transformation matrix is different when I use fkine command and when I computed mathematically

156 views
Skip to first unread message

Priyadarshini Ravichandran

unread,
Apr 28, 2017, 5:32:11 PM4/28/17
to Robotics & Machine Vision Toolboxes
Dear all,

I am getting different transformation matrix for forward kinematics 

when I use fkine method:

close all; clear;

 

%leftarm

L(1) = Link([0,0,0.935852,3.1415926536,0]);

L(2) = Link([0,0.660,0,0,1]);

L(3) = Link([0,0.400,0.025,-1.5707963268,0]);

L(4) = Link([0,0.455,0,0,0]);

L(5) = Link([0,0,0,-1.5707963268,0]);

L(6) = Link([0,0.420,0,1.5707963268,0]);

L(7) = Link([0,0,0,-1.5707963268,0]);

L(8) = Link([0,0.080,0,0,0]);

 

L(1).qlim = [0 pi];

L(2).qlim = [0 2];

L(3).qlim = [-2.96706 2.96706];

L(4).qlim = [-3.31613 0.785398];

L(5).qlim = [-2.094395 2.722714];

L(6).qlim = [-3.22886 3.22886];

L(7).qlim = [-2.094395 2.094395];

L(8).qlim = [-6.108652 6.108652];

 

 

Tbasel = transl([0 0 2])

Ttooll=[1 0 0 0;0 -1 0 0;0 0 -1 0.5;0 0 0 1];  %works fine

 

 

roboL1 = SerialLink(L,'name', 'Left','base',Tbasel,'tool',Ttooll)

 q0l=[pi;0.660;pi/4;pi/4;pi/4;pi/4;0;pi/4];

T0l=roboL1.fkine(q0l);



solution using fkine command

 T0l =

 

   -0.7071   -0.0000   -0.7071    0.0753

   -0.7071    0.0000    0.7071   -0.3677

    0.0000    1.0000   -0.0000    0.9400

         0         0         0    1.0000



when I compute directly using DH matrix

syms theta1 theta2 theta3 theta4 theta5 theta6 theta7 theta8 a1 a3 d2 d3 d4 d6 d8

 

%Define transformations:

D1_0 = [cos(theta1), sin(theta1), 0, a1*cos(theta1);

sin(theta1), -cos(theta1), 0, a1*sin(theta1);

0, 0, -1, 0;

0, 0, 0, 1];

 

D2_1  = [cos(theta2), -sin(theta2), 0, 0;

sin(theta2), cos(theta2), 0, 0;

0, 0, 1, d2;

0, 0, 0, 1];

 

D3_2 = [cos(theta3), 0, -sin(theta3), a3*cos(theta3);

sin(theta3), 0, cos(theta3), a3*sin(theta3);

0, -1, 0, d3;

0, 0, 0, 1];

 

D4_3 = [cos(theta4), -sin(theta4), 0, 0;

sin(theta4), cos(theta4), 0, 0;

0, 0, 1, d4;

0, 0, 0, 1];

 

D5_4 = [cos(theta5), 0, -sin(theta5), 0;

sin(theta5), 0, cos(theta5), 0;

0, -1, 0, 0;

0, 0, 0, 1];

 

D6_5 = [cos(theta6), 0, sin(theta6), 0;

sin(theta6), 0, -cos(theta6), 0;

0, 1, 0, d6;

0, 0, 0, 1];

 

D7_6 = [cos(theta7), 0, -sin(theta7), 0;

sin(theta7), 0, cos(theta7), 0;

0, -1, 0, 0;

0, 0, 0, 1];

 

D8_7 = [cos(theta8), -sin(theta8), 0, 0;

sin(theta8), cos(theta8), 0, 0;

0, 0, 1, d8;

0, 0, 0, 1];

 

%Determine transformation

 

D1_0 = simplify(D1_0);

 

D2_0 = D1_0 * D2_1;

D2_0 = simplify(D2_0)

 

D3_0 = D2_0*D3_2;

D3_0 = simplify(D3_0)

 

D4_0 = D3_0*D4_3;

D4_0 = simplify(D4_0)

 

D5_0 = D4_0*D5_4;

D5_0 = simplify(D5_0)

 

D6_0 = D5_0*D6_5;

D6_0 = simplify(D6_0)

 

D7_0 = D6_0*D7_6;

D7_0 = simplify(D7_0)

 

D8_0 = D7_0*D8_7;

D8_0 = simplify(D8_0)

 

a1=0.935852; d2=0.660;  d3=0.400; a3=0.025; d4=0.455; d6=0.420; d8=0.080; 

theta1=pi;    theta2=0.660;    theta3=pi/4; theta4=pi/4;  theta5=pi/4;  theta6=pi/4;    theta7=0;   theta8=pi/4;

subs(D8_0)



solution using the above is 


 -0.9921         0    0.1251   -0.4250

   -0.1251         0   -0.9921   -0.4144

         0   -1.0000         0   -1.0600

         0         0         0    1.0000


why I am getting different transforamtion matrix for forward analysis, please explain...

Peter Corke

unread,
Apr 29, 2017, 8:32:23 PM4/29/17
to Robotics & Machine Vision Toolboxes
In the first example joint 2 is prismatic, is that intended?  You have specified a non-zero rotation angle as well?  

Priyadarshini Ravichandran

unread,
Apr 30, 2017, 5:49:04 AM4/30/17
to Robotics & Machine Vision Toolboxes
yes sir, it is prismatic for joint 2 both in the first and second example. I want the prismatic joint limits to be in [0 2] meters so I mentioned using qlim command.

and I would like to know whether the transformation matrix is different for revolute and prismatic joints?.

My problem is I am not getting the same solution for both the examples with the same parameters. the first example is using fkine command and second example is using DH transformation matrix with the same parameters. please let me know where I am doing mistakes, sir. looking forward to hear from you

Peter Corke

unread,
Apr 30, 2017, 8:06:30 PM4/30/17
to Robotics & Machine Vision Toolboxes
In your code you specify that joint 2 has a rotation and a translation, both of 0.66.  Is this intended?  For the RTB example you have specified a rotation of zero and a translation of 0.66.  Different parameters, therefore different answers.

Priyadarshini Ravichandran

unread,
May 1, 2017, 5:03:59 AM5/1/17
to Robotics & Machine Vision Toolboxes
I rectified my mistake and got the solution, thank u so much.

Erik van Oene

unread,
May 26, 2017, 1:16:20 PM5/26/17
to Robotics & Machine Vision Toolboxes
I guess due to your Base and tool transforms

Erik

Shivaji Islavath

unread,
Jul 23, 2017, 12:13:31 AM7/23/17
to Robotics & Machine Vision Toolboxes
my forward kinematics from the transformation matrix is different from fkine command, all robot joints are revolute.....(any suggestion please)

Erik van Oene

unread,
Jul 23, 2017, 6:51:22 AM7/23/17
to Robotics & Machine Vision Toolboxes
Try plotting both and see which one is correct and why.

Erik

Erik van Oene

unread,
Jul 23, 2017, 1:21:48 PM7/23/17
to Robotics & Machine Vision Toolboxes
Hi,

I had the ability to check your code using Matlab.

As I thought a few posts ago, indeed you base and tool transform are the reason for the difference in results. When I put both the base and tool transform to eye(4), the results are the same.

So either, remove the base and tool transforms or include them in you hand made transformation matrix.

Erik 

Op zondag 23 juli 2017 12:51:22 UTC+2 schreef Erik van Oene:

shiva...@gmail.com

unread,
Jul 26, 2017, 1:01:28 PM7/26/17
to Robotics & Machine Vision Toolboxes
Sir,

Both, fkine and transformation matrices giving same results only for zero joint angles.

for other than zero angles its giving different results..can you please explain....

Regards,

Shivaji

Erik van Oene

unread,
Jul 26, 2017, 5:24:17 PM7/26/17
to Robotics & Machine Vision Toolboxes, shiva...@gmail.com
Although I didn't check it, I think I found a mistake in D2_1.
There you specify a rotation part using theta2 and a translation using d2. In the serialLink I only see a translational part. 
Later you substitute theta2 = 0.666 which is actually the same as d2.

I didn't check the code itself... but there may be some other mistakes... If so, I guess plotting them step by step would help... Try to do it DOF by DOF. without the symbolics.
So start from a 2DOF robot.. and check it for some random q.
Go to a 3DOF robot and check again...

Please be careful with copying variables to other variable names... like q0l and theta1 till theta 8 and d2 etc... 
And use the variables instead of typing the numbers hard coded every time. This makes it prone to mistakes / errors!

Hope this helps

Op woensdag 26 juli 2017 19:01:28 UTC+2 schreef shivaji.564ATgmail.com:
Reply all
Reply to author
Forward
0 new messages