1. Home
    1. Dashboard
    2. Search
  2. Forum
    1. Unresolved Threads
    2. Members
      1. Recent Activities
      2. Users Online
      3. Team Members
      4. Search Members
      5. Trophys
  3. Articles
  4. Blog
  5. Videos
  6. Jobs
  7. Shop
    1. Orders
  • Login or register
  • Search
This Thread
  • Everywhere
  • This Thread
  • This Forum
  • Articles
  • Pages
  • Forum
  • Blog Articles
  • Products
  • More Options
  1. Robotforum - Support and discussion community for industrial robots and cobots
  2. Forum
  3. General Category - Robot Forum
  4. Robot Geometry, Linear Algebra, Forward and Inverse Kinematics
Your browser does not support videos RoboDK Software for simulation and programming
Visit our Mainsponsor
IRBCAM
Robotics Channel
Robotics Training
Advertise in robotics
Sponsored Ads

Calculating Forward kinematics connection between theory and practice on example of KUKA robot

  • Askic
  • February 7, 2023 at 1:32 PM
  • Thread is Unresolved
  • Askic
    Reactions Received
    2
    Trophies
    1
    Posts
    25
    • February 7, 2023 at 1:32 PM
    • #1

    Hello guys,

    I have already read a couple of threads on this forum regarding the calculation of forward (direct) kinematics using DH parameters on real examples of KUKA robots.

    Most theory books use DH parameters extensively for calculating forward kinematics. I have found an example of DH parameters for KUKA KR500 robot. The datasheet is given here

    The table with DH parameters together with joint coordinate frames is given in the attachment.

    The direct kinematics is calculated as matrices multiplications (one for each joint) and the result matrix 4x4 matrix, let say denoted M. The last column of this transformation matrix is always in form: X,Y,Z,1. This means that element m41 is the X coordinate of the last coordinate frame in reference to the base coordinate frame, m42 is Y coordinate etc.

    Submatrix 3x3 with elements m11, m12, m13, m21,m22,m23,m31,m32,m33) is a rotation part of the transformation matrix M.

    So my question is the following:

    How to make a connection from the result of direct kinematics and actual position and orientation in KUKA robot language, which is given by X,Y,Z, A,B,C?

    It should be: m41 = X, m42 = Y, m43 = Z, and I wonder how to correlate A, B, C with 9 elements of a 3x3 rotation submatrix of matrix M?

    I hope you understand my question.

    Thank you very much!

    Images

    • KR500-DH paramters.png
      • 191.31 kB
      • 772 × 918
      • 60
  • panic mode
    Reactions Received
    1,262
    Trophies
    11
    Posts
    13,026
    • February 7, 2023 at 2:50 PM
    • #2

    is this homework?

    it is a six axis robot so each individual transform T1..T6 will have own set of XYZABC values that come from the DH table. that is six values but DH table only shows 4 two translations and two rotations. the "theta offset" is just fixed part of theta, not another degree of freedom

    d1 is displacement in the Z direction

    a1 is displacement in the X direction

    and can you guess what is the displacement value in the Y direction?

    Kuka uses order of rotations Rz(A)Ry(B)Rz(C) so the first rotation is about Z and by value A (theta), second rotations is about Y by value B (zero) and third is about X by value C (alpha).

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

  • Askic
    Reactions Received
    2
    Trophies
    1
    Posts
    25
    • February 7, 2023 at 4:04 PM
    • #3

    No it is not a homework. It is more like professional curiosity. I have used original (standard) DH notation according to this resource here: https://en.wikipedia.org/wiki/Denavit%E…berg_parameters

    I know for revolute joints, angle theta is a variable and for prismatic joints displacement d is variable. parameters a and alpha are constants and they depend on geometry of the robot.

    I also know that KUKA uses consecutive rotations A is rotation about Z, B is rotation about new Y, C is rotation about new X. So total rotation should be: Rz(A)*R_new_y(B)*R_new_x(C)

    DH convention uses rotations about z and x (previous and new) and translation in the z and x directions. Y axes are only chosen to complete right hand coordinate systems, so there are no displacements in the y directions.

    So If I understood correctly, I will be able to obtain 3x3 submatrix by multiplying (to the right) rotation matrices that are created by series of consecutive rotations of coordinate frames starting from the base until it matches last coordinate frame placed on the flange.

    I'll try to make a little example and compare results obtained by DH parameters and the result that should be obtained by simply rotation and translation of coordinate frames starting from the base to the last 6th coordinate frame associated to the last joint.

  • MOM
    Reactions Received
    175
    Trophies
    7
    Posts
    1,414
    • February 7, 2023 at 4:20 PM
    • #4

    This is the symbolic rotation matrix of Rz(A)*R_new_y(B)*R_new_x(C)

    (A = 1; B=2;C=3)

    In KUE_WEG.SRC you will find the function MAT_TO_RPY

    This should answer your questrion

  • MOM
    Reactions Received
    175
    Trophies
    7
    Posts
    1,414
    • February 7, 2023 at 4:46 PM
    • #5

    Your coordinate system {K0} is not correct: Z-Axis is pointing up

  • Online
    SkyeFire
    Reactions Received
    1,038
    Trophies
    12
    Posts
    9,369
    • February 7, 2023 at 8:03 PM
    • #6

    http://scilab.ninja/rtsx/online-help/

    I found this to be of assistance the last time I had to dig into this question, but I ended up not digging very far, as that part of the project was handed off to someone who already knew DH backwards and forwards.

    Still, since SciLab and the RTSX package are all open-source, there should be a lot there you can use.

  • MOM
    Reactions Received
    175
    Trophies
    7
    Posts
    1,414
    • February 7, 2023 at 11:07 PM
    • #7

    When you do a forward transformation there are a few rules:

    Rule 1:

    Two coordinate systems are given and must not be changed!

    RCS: Robot Coordinate System

    FCS: Flange Coordinate System

  • MOM
    Reactions Received
    175
    Trophies
    7
    Posts
    1,414
    • February 7, 2023 at 11:30 PM
    • #8

    Notice:

    Denavit Hartenberg is NOT Denavit Hartenberg

    You Have Denavit Hartenberg introduced by Denavit Hartenberg:

    T = rot.z(theta) * trans.z(d) * rot.x(alpha) * trans.x(a)

    (position of trans may vary)

    You have Denavit Hartenberg introduced by Craig:

    T = rot.x(alpha) * trans.x(a) * rot.z(theta) * trans.z(d)

    (position of trans may vary)

    Thus:

    you will get two sets of DH parameters! and have to choose

  • MOM
    Reactions Received
    175
    Trophies
    7
    Posts
    1,414
    • February 8, 2023 at 12:05 AM
    • #9

    Notice:

    You should draw the kinematic model of your robot all axes in zero position (makes live easier)

    Rule 2:

    The direction of Z-Axis should show the mathematical positive direction of the rotation.

    A1, A4 and A6 are inverted

    Example A1:

    Here you have two options:

    1) ignore it and use $AXIS_DIR[1] as given in $machine.dat (left sketch)

    2) use right sketch

    S0 = K0

    S1 = Kiro (internal robot Coordinate System)

    S2 = K1

  • MOM
    Reactions Received
    175
    Trophies
    7
    Posts
    1,414
    • February 8, 2023 at 1:21 AM
    • #10

    A little exercise:

    If we compare the two matrices we will find out

    cos(theta1) = 1 => theta1 = 0°

    sin(alpha1) = -1 => alpha1 = -90°

    a1 = a1*cos(theta1) = 350mm

    d1 = 675mm

    DH(DH) parameters:

    theta1 = 0°; d1 = 675mm; alpha1 = -90°; a = 350mm

    Ergo:

    Having the DH-Transformation and the corresponing transformation matrix we are able to extract the DH Parameters!

    In this case it worked - let us check other possibilities

  • Askic
    Reactions Received
    2
    Trophies
    1
    Posts
    25
    • February 8, 2023 at 9:20 AM
    • #11

    Thank you all for the replies, especially MOM.

    Regarding your observation about K{0}, normally I would also expect to choose Z0 axis to points upwards, but in general this coordinate frame can be fixed as initial condition. That is why first translation along the z axis is (d1) is negative.

    But in order to follow your example and notation I will use Z0 to point upwards. But can you please tell me from where you have a1 = 350 mm and d1 = 675 mm.

    But if we assume that first coordinate frame is already given like shown in the picture, then we have for the first transformation: translation along -z0 by 1045 mm, rotation around z0 by angle theta1, then translation along x1 by 500 mm, and then rotation around x1 by 90 deg. This way K{0} will match K{1}, so DH parameters are: a1 = 500 mm, alpha1 = pi/2, d1 = -1045mm, th1 = joint_angle (A1).

    Now the problem I see here is matching K{1} with K{2}. The normal between z1 and z2 axis has a distance 1300 mm along x2, so the a2 = 1300mm. Now in order to match K{1} with K{2}, it is needed th1 - rotation around z1 by pi/2, so the DH parameters in the second row should be:

    a2 = 1300, alpha2 = 0, d2 = 0; th2 = joing_angle(A2) - pi/2.

    Now, to match {K2} with {K3}, first there should be rotation about z2 for 180° (pi) plus additional joint_angle(A3) translatin along x3 by 55 mm and then rotation around x3 for -pi/2, so DH for the third row would be:

    a3 = 55, alpha3 = -pi/2, d3 = 0, th3 = joint_angle(A3) + pi.

    As you can see here there is a deviation in this logic to the complete DH table presented in the picture, but I have double checked everything and the DH table and final T06 transformation matrix is given in the attachment

    All this time I'm refereeing to the coordinate frames shown in the attached picture in the first post.

    So for the angles [0,30,-45,35,25,10] , the result transformation matrix is:

    Code
    [-0.23857,  0.10868,  0.96503,  2434.2]
    [ 0.65418, -0.71644,   0.2424,  70.297]
    [ 0.71773,  0.68913, 0.099823, -2354.0]
    [       0,        0,        0,     1.0]

    So my originally intended question was how to make correlation with the move instruction in KUKA robot programming language.

    Here I have 4x4 transformation matrix. X,Y and Z coordinates of the flange (in comparison to the fixed reference coordinate system K{0}) are: 2434.2, 70.3 and -2354.0 mm. So, how I can now connect A,B and C angles for rotation to the 3x3 submatrix inside this T06 matrix?

    I hope you understand what is my question here.

    I need to add more to this.

    If all angles are zeros, (as MOM said, to make my life easier) then T06 is

    Code
    [6.1232e-17, -6.1232e-17,         1.0,     1815.0]
    [6.1232e-17,        -1.0, -6.1232e-17, 4.2863e-15]
    [       1.0,  6.1232e-17, -6.1232e-17,    -2290.0]
    [         0,           0,           0,        1.0]

    In that case, If I look at the initial picture with K{0} and K{6}, then it looks to me that I can match {0} and {6} in the following way:

    1. Translate along z by (1045+1300-55) mm, then translate along x by (500+1025+290) mm

    2. Rotate about z axis for 180° (A = 180°), then rotate around new y for -90° (B = -90)

    If I do this in Matlab:

    Code
    v = [0 0 -(1045+1300-55)];
    T1 = trvec2tform(v);
    v = [500+1025+290 0 0];
    T2 = trvec2tform(v);
    T3r = rotz(180);
    T3 = rotm2tform(T3r);
    T4r = roty(-90);
    T4 = rotm2tform(T4r);
    
    Tres = T1*T2*T3*T4

    The result is:

    Code
    Tres =
    
               0           0           1        1815
               0          -1           0           0
               1           0           0       -2290
               0           0           0           1

    So in this case, there is a match in calculation.

    rotz(A=180)*roty(B=-90) would produce 3x3 submatrix.

    Images

    • DH parameters.png
      • 25.22 kB
      • 728 × 475
      • 35

    Edited 2 times, last by Askic (February 8, 2023 at 11:10 AM).

  • MOM
    Reactions Received
    175
    Trophies
    7
    Posts
    1,414
    • February 9, 2023 at 11:05 AM
    • #12

    th = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]:

    th = [ 0.0, -90.0, 90.0, 0.0, 0.0, 0.0]:

    Then my robot looks like this:

  • Askic
    Reactions Received
    2
    Trophies
    1
    Posts
    25
    • February 9, 2023 at 12:55 PM
    • #13

    Hello Mom,

    I assumed that all angles are zero when robot is in configuration like shown in the attached picture (this is how it is shown in the datasheet as well).

    Can you please, in your software set {0} in such way that z points downward and then recalculate. I'm pretty sure my result is correct and the main difference is the inital (or maybe home) configuration of the robot. I just assumed and calculated everything as if the robot is in the shown position when all angles are zero. Because base z axis points downward, that is why I had for Z coordinate: -2290.0.

    Images

    • MOM_differences.png
      • 161.77 kB
      • 845 × 920
      • 30
  • MOM
    Reactions Received
    175
    Trophies
    7
    Posts
    1,414
    • February 9, 2023 at 1:12 PM
    • #14

    Still asking why is your z-axis of the robot coordinate system looking downwards?

    the initial coordinate system is the world coodinate system z-axis pointing up (like in my drawing)

    the robot coordinate system is shifted and rotated using the frame $ROBROOT relative to the world coordinate system

    for floor mounted robots $ROBROOT = {X 0, Y 0, Z 0, A 0, B 0, C 0}

    For ceiling mounted robots $ROBROOT = {X 0, Y 0, Z 0, A 0, B 0, C 180}

    I also do not understand how you get your -2290!

    (was my fault: used 55mm instead of -55mm)

    Following my picture from post #12

    we have 1045 - 55 + 1300 = 2290

  • MOM
    Reactions Received
    175
    Trophies
    7
    Posts
    1,414
    • February 9, 2023 at 1:43 PM
    • #15

    If you use the data sheet then you should get

    How does you DH-calc looks like?

  • MOM
    Reactions Received
    175
    Trophies
    7
    Posts
    1,414
    • February 9, 2023 at 2:17 PM
    • #16

    OK,

    you were actually using $BASE = {X 0, Y 0, Z 0, A 0, B 0 ,C 180}

    Normally the Forward transformation should be done with $BASE and $TOOL with $NULLFRAME

  • Askic
    Reactions Received
    2
    Trophies
    1
    Posts
    25
    • February 10, 2023 at 7:42 AM
    • #17

    Okay, if I choose to have the base coordinate frame K{0} with the z axis points up, then the D_H parameters are:

    Code
    % D_H parameters:
    a1 = 500;   alpha1 = -pi/2;   d1 = 1045; th1 = 0;
    a2 = 1300;  alpha2 = 0;       d2 = 0;     th2 = deg2rad(0.0)-pi/2;
    a3 = 55;    alpha3 = -pi/2;   d3 = 0;     th3 = deg2rad(0.0)+pi;
    a4 = 0;     alpha4 = pi/2;    d4 = -1025; th4 = deg2rad(0.0);
    a5 = 0;     alpha5 = -pi/2;   d5 = 0;     th5 = deg2rad(0.0);
    a6 = 0;     alpha6 = pi;      d6 = -290;  th6 = deg2rad(0.0);

    This would produce the following homogeneous transformation matrices:

    Code
    T01 = 
    [ 6.12e-17,       1.0,        0,     500.0]
    [-6.12e-17,  3.75e-33,      1.0, -7.96e-14]
    [      1.0, -6.12e-17, 6.12e-17,    2340.0]
    [        0,         0,        0,       1.0]
    T02 =
    [ 6.1232e-17,         1.0,          0,       500.0]
    [-6.1232e-17,  3.7494e-33,        1.0, -7.9602e-14]
    [        1.0, -6.1232e-17, 6.1232e-17,      2345.0]
    [          0,           0,          0,         1.0]
    T03 =
    [6.1232e-17, -6.1232e-17,        -1.0,       500.0]
    [6.1232e-17,        -1.0,  6.1232e-17, -7.6234e-14]
    [      -1.0, -6.1232e-17, -6.1232e-17,      2290.0]
    [         0,           0,           0,         1.0]
    T04 =
    [6.1232e-17,        -1.0,          0,    1525.0]
    [6.1232e-17,  3.7494e-33,        1.0, -1.39e-13]
    [      -1.0, -6.1232e-17, 6.1232e-17,    2290.0]
    [         0,           0,          0,       1.0]
    T05 = 
    [6.1232e-17, -6.1232e-17,        -1.0,    1525.0]
    [6.1232e-17,        -1.0,  6.1232e-17, -1.39e-13]
    [      -1.0, -6.1232e-17, -6.1232e-17,    2290.0]
    [         0,           0,           0,       1.0]
    T06 =
    [6.1232e-17, -6.1232e-17,        1.0,      1815.0]
    [6.1232e-17,         1.0, 6.1232e-17, -1.5675e-13]
    [      -1.0,  6.1232e-17, 6.1232e-17,      2290.0]
    [         0,           0,          0,         1.0]
    Display More

    As you can see the final result is the same. There are differences in the intermediate results, but they are there because of the way I defined intermediate coordinate frames. You can see this as well as DH parameters table in the attachment.

    Which software do you use for making this plots and calculating matrices. Is it RTSX Ninja for SCILAB?

    Since we have the same T06 matrix, which is 4x4, now for joint angles: th = [ 0.0, -60.0, 90.0, 0.0, 0.0, 0.0], the result would be:

    Code
    ans =
     
    [       -0.5, -5.30288e-17,    0.866025,       485.49]
    [5.30288e-17,          1.0, 9.18485e-17, -7.71447e-14]
    [  -0.866025,  9.18485e-17,        -0.5,      989.869]
    [          0,            0,           0,          1.0]

    How this could be converted to the command in KUKA with A,B and C?

    Code
    DECL E6POS K0P1={X 485.0,Y 0.0,Z  989.9,A ??,B ??,C ??,S 18,T 34,E1 0.0,E2 0.0,E3 0.0,E4 0.0,E5 0.0,E6 0.0}

    Images

    • DH_param_MOM.jpg
      • 252.6 kB
      • 1,481 × 1,050
      • 30

    Edited once, last by Askic (February 10, 2023 at 1:19 PM).

  • MOM
    Reactions Received
    175
    Trophies
    7
    Posts
    1,414
    • February 10, 2023 at 1:03 PM
    • #18

    I am using Anaconda (Python and mathplotlib) and doing all the calculation myself

    My result look different:

    and the corresponding transformation matrices:

    RoboDK gives the same values

    You actually can download a testversion of RoboDK

    The robot would be a KR500 3

  • Askic
    Reactions Received
    2
    Trophies
    1
    Posts
    25
    • February 10, 2023 at 1:27 PM
    • #19

    OK,

    I have made a mistake in calculation for th = [0 -pi/3 pi/2 0 0 0]; and I corrected that, but the results are indeed different.

    Here is my Matlab code, it should be very easy to translate to Python:

    Code
    th = [0 -pi/3 pi/2 0 0 0];
    a1 = 500;   alpha1 = -pi/2;   d1 = 1045;  th1 = th(1);
    a2 = 1300;  alpha2 = 0;       d2 = 0;     th2 = th(2)-pi/2;
    a3 = 55;    alpha3 = -pi/2;   d3 = 0;     th3 = th(3)+pi;
    a4 = 0;     alpha4 = pi/2;    d4 = -1025; th4 = th(4);
    a5 = 0;     alpha5 = -pi/2;   d5 = 0;     th5 = th(5);
    a6 = 0;     alpha6 = pi;      d6 = -290;  th6 = th(6);
    
    T1 = DH_calc(a1,alpha1,d1,th1);
    T2 = DH_calc(a2,alpha2,d2,th2);
    T3 = DH_calc(a3,alpha3,d3,th3);
    T4 = DH_calc(a4,alpha4,d4,th4);
    T5 = DH_calc(a5,alpha5,d5,th5);
    T6 = DH_calc(a6,alpha6,d6,th6);
    
    T06_dh = T1*T2*T3*T4*T5*T6;
    
    function  T = DH_calc(a, alpha, d, th)
        T = [cos(th), -sin(th)*cos(alpha), sin(th)*sin(alpha), a*cos(th);
             sin(th), cos(th)*cos(alpha), -cos(th)*sin(alpha), a*sin(th);
             0,       sin(alpha),          cos(alpha),          d;
             0,         0,                  0,                  1];
    end
    Display More

    And this is my result for T06:

    Code
    [       -0.5, -5.30288e-17,    0.866025,       485.49]
    [5.30288e-17,          1.0, 9.18485e-17, -7.71447e-14]
    [  -0.866025,  9.18485e-17,        -0.5,      989.869]
    [          0,            0,           0,          1.0]

    But why there is a difference in X,Y and Z coordinates.

    I know exactly why there is a difference.

    First of all, in my case for all zero angles, the result is:

    Code
    [       -0.5, -5.30288e-17,    0.866025,       485.49]
    [5.30288e-17,          1.0, 9.18485e-17, -7.71447e-14]
    [  -0.866025,  9.18485e-17,        -0.5,      989.869]
    [          0,            0,           0,          1.0]

    which is the same result as in your case for A2 = -90° and A3 = 90°.

    So, there is an offset in my case, so If I want to move robot in the same position like in your case, then I need to calculate FW kinematics for the following input: th = [0 pi/6 0 0 0 0];

    In that case, the Matlab code I used above will give the same result as in your case for th= [0 -60 90 0 0 0].

    It is because of the definition of zero. In my case for all zero angles robot looked exactly like your position for [0 -90 90 0 0 0]

    P.S. Can you please share your Python matlplotlib code, I'd like to learn how this is plotted in Python.

    Edited 2 times, last by Askic (February 10, 2023 at 2:02 PM).

  • MOM
    Reactions Received
    175
    Trophies
    7
    Posts
    1,414
    • February 10, 2023 at 4:02 PM
    • #20

    You are using the DH transformation introduced by Denavit-Hartenberg

    So some of your parameters are wrong (a3 for instance is -55)

Advertising from our partners

IRBCAM
Robotics Channel
Robotics Training
Advertise in robotics
Advertise in Robotics
Advertise in Robotics

Job Postings

  • Anyware Robotics is hiring!

    yzhou377 February 23, 2025 at 4:54 AM
  • How to see your Job Posting (search or recruit) here in Robot-Forum.com

    Werner Hampel November 18, 2021 at 3:44 PM
Your browser does not support videos RoboDK Software for simulation and programming

Tag Cloud

  • abb
  • Backup
  • calibration
  • Communication
  • CRX
  • DCS
  • dx100
  • dx200
  • error
  • Ethernet
  • Ethernet IP
  • external axis
  • Fanuc
  • help
  • hmi
  • I/O
  • irc5
  • IRVIsion
  • karel
  • kawasaki
  • KRC2
  • KRC4
  • KRC 4
  • KRL
  • KUKA
  • motoman
  • Offset
  • PLC
  • PROFINET
  • Program
  • Programming
  • RAPID
  • robodk
  • roboguide
  • robot
  • robotstudio
  • RSI
  • safety
  • Siemens
  • simulation
  • SPEED
  • staubli
  • tcp
  • TCP/IP
  • teach pendant
  • vision
  • Welding
  • workvisual
  • yaskawa
  • YRC1000

Thread Tag Cloud

  • abb
  • Backup
  • calibration
  • Communication
  • CRX
  • DCS
  • dx100
  • dx200
  • error
  • Ethernet
  • Ethernet IP
  • external axis
  • Fanuc
  • help
  • hmi
  • I/O
  • irc5
  • IRVIsion
  • karel
  • kawasaki
  • KRC2
  • KRC4
  • KRC 4
  • KRL
  • KUKA
  • motoman
  • Offset
  • PLC
  • PROFINET
  • Program
  • Programming
  • RAPID
  • robodk
  • roboguide
  • robot
  • robotstudio
  • RSI
  • safety
  • Siemens
  • simulation
  • SPEED
  • staubli
  • tcp
  • TCP/IP
  • teach pendant
  • vision
  • Welding
  • workvisual
  • yaskawa
  • YRC1000
  1. Privacy Policy
  2. Legal Notice
Powered by WoltLab Suite™
As a registered Member:
* You will see no Google advertising
* You can translate posts into your local language
* You can ask questions or help the community with your knowledge
* You can thank the authors for their help
* You can receive notifications of replies or new topics on request
* We do not sell your data - we promise

JOIN OUR GREAT ROBOTICS COMMUNITY.
Don’t have an account yet? Register yourself now and be a part of our community!
Register Yourself Lost Password
Robotforum - Support and discussion community for industrial robots and cobots in the WSC-Connect App on Google Play
Robotforum - Support and discussion community for industrial robots and cobots in the WSC-Connect App on the App Store
Download