I'm learning about robotics and comparing two ways to calculate homogeneous transformation matrix. I'm comparing PoE (product of exponentials) and Denavit-Hartenberg parameters. For the same base frame and same position and orientation of the final (end effector frame) these two ways should produce the same result (i.e. coordinate transformation between base - fixed frame and tool's frame). However, I'm not getting the same result and this is because I don't use D-H parameters correctly. I'm pretty sure the error is the third row of D-H table. Mutual positions of the joints is in such way, I cannot determine the axis correctly.
Here is what I did so far. Any help or advice is greatly appreciated.
However, if I do step by step calculation in Matlab, I got correct result
The code is:
L1 = 0.4; L2 = 0.3; th1 = pi/4; th2 = pi/3; th3 = pi/6;
%step by step Tms
% rotate around z by th1
T1m = rotm2tform(rotz(th1*180/pi));
%translate on x axis by L1
T21m = [1 0 0 L1;0 1 0 0;0 0 1 0; 0 0 0 1];
T22m = rotm2tform(rotx(90)) * rotm2tform(rotz(th2*180/pi));
% rotate around x by -90°
T31m= rotm2tform(rotz(-90))
% translate on x axis by L2
T32m = [1 0 0 L2;0 1 0 0;0 0 1 0; 0 0 0 1];
%rotate around x by -90°then rotate around z by th3
T33m = rotm2tform(rotx(-90)) * rotm2tform(rotz(th3*180/pi));
%calculate final transf matrix
Tms = T1m*T21m*T22m*T31m*T32m*T33m
The correct result should be:
0.1768 -0.9186 0.3536 0.4666
0.8839 0.3062 0.3536 0.4666
-0.4330 0.2500 0.8660 -0.1500
0 0 0 1.0000