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. Industrial Robot Support and Discussion Center
  4. KUKA Robot Forum
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

How to calcul 3D point in a coordinate system to another one?

  • shkyo30
  • June 20, 2016 at 11:32 AM
  • Thread is Resolved
  • shkyo30
    Trophies
    3
    Posts
    12
    • June 20, 2016 at 11:32 AM
    • #1

    Hello everybody, I'm a newbie here...

    I've a problem about coordinate system in Kuka KRC1. I need to code a little program in C# (because there are hundred of trajectories) to transform all the 3D coordinate (x,y,z,a,b,c) in the Base n°1 to the Base n°2, and the Tool never change.

    How can I do that?... ??? Maybe have you the transformation matrix (4x4) of Kuka system?

    Many thanks in advance for your help!

  • Online
    SkyeFire
    Reactions Received
    1,038
    Trophies
    12
    Posts
    9,371
    • June 20, 2016 at 2:01 PM
    • #2

    INV_POS() is a system function in KRL that performs a matrix inversion of a FRAME, POS, or E6POS type variable.

    The Geometric Operator (a ':' character) performs a matrix cross-product on any two FRAME or POS-type variables.

    Between them, these two will do everything you need. They're both discussed at length in the forum archives. The G.O. is documented in the KRL manuals, although for some reason INV_POS isn't.

  • Fubini
    Reactions Received
    270
    Trophies
    9
    Posts
    1,866
    • June 20, 2016 at 2:14 PM
    • #3

    Or look at <C:\KRC\UTIL\CHG_POS> on you KRC Installation or <Internat\Krcsetup\Krc\Util\Chg_pos> on your KRC Setup CD/Disk. The tool Chg_pos.exe is for base (and tool) changes.

    For the underlying math you can look at e.g.:
    https://www.robot-forum.com/robotforum/kuk…76527/#msg76527

    or

    https://www.robot-forum.com/robotforum/kuk…82246/#msg82246

    Fubini

    Edited once, last by Fubini (June 20, 2016 at 2:18 PM).

  • shkyo30
    Trophies
    3
    Posts
    12
    • June 20, 2016 at 3:58 PM
    • #4
    Quote from SkyeFire


    INV_POS() is a system function in KRL that performs a matrix inversion of a FRAME, POS, or E6POS type variable.

    The Geometric Operator (a ':' character) performs a matrix cross-product on any two FRAME or POS-type variables.

    Between them, these two will do everything you need. They're both discussed at length in the forum archives. The G.O. is documented in the KRL manuals, although for some reason INV_POS isn't.

    Thanks, but I don't use KRL, my conversion program will be in (Microsoft) C# to directly manipulate .dat and .src files extracted from Kuka robot backups... That's the reason I search the transformation matrix! :icon_wink:

    I'll see your links Fubini, thanks

  • Spl
    Reactions Received
    5
    Trophies
    3
    Posts
    178
    • June 20, 2016 at 4:56 PM
    • #5

    Have you tried OrangeEdit?

    http://www.orangeapps.de/?lng=en&page=apps/orangeedit

  • shkyo30
    Trophies
    3
    Posts
    12
    • June 20, 2016 at 5:08 PM
    • #6
    Quote from Spl


    Have you tried OrangeEdit?

    http://www.orangeapps.de/?lng=en&page=apps/orangeedit

    No, I don't know this soft, is it especially for Kuka robot? Can I have the transformation matrix with it?

    I work directly in C# with Visual Studio 2015 to manipulate (and modify) robot trajectories, not only for Kuka, sometimes Fanuc too.

  • shkyo30
    Trophies
    3
    Posts
    12
    • June 21, 2016 at 10:33 AM
    • #7

    I'm back with problems... :icon_wink:

    Firstable, some precisions:
    I have the original base (x 0.0,y 1126.5, z 805.0, a 0.0, b 0.0, c 0.0) with one point (x 1490.458,y -1126.5, z 1459.4, a 180.0, b 81.6634, c 180.0)

    and the new one (x -49.907, y 1060.275, z 791.113, a 3.2965, b 1.9967, c 0.115) with the same point but now with (x 1424.618,y -1144.036, z 1526.147, a 176.7055, b 83.6634, c 180)

    I know that, because I've two test trajectories, the first one with the original base and five points in that base. And the second traj with the new base and the same five points but in the new coordinate system.

    My translation vector is (-49.907,-66.225,-13.887)

    Firstable I used a translation matrix:
    1 0 0 0
    0 1 0 0
    0 0 1 0
    -49.907 -66.225 -13.887 1

    and after I tried to use that (from Fubini) to calculate the 3 rotations in the same time:

    Code
    public static double[][] matrix(double aDeg, double bDeg, double cDeg) {
          //ABC: Euler angles, A: round z-axis     B: round y-axis        C: round y-axis
          double a = -aDeg * PI / 180;
          double b = -bDeg * PI / 180;
          double c = -cDeg * PI / 180;
          double ca = Math.cos(a);
          double sa = Math.sin(a);
          double cb = Math.cos(b);
          double sb = Math.sin(b);
          double cc = Math.cos(c);
          double sc = Math.sin(c);
          double[][] tt = new double[4][];
          tt[0] = new double[] { ca * cb, sa * cc + ca * sb * sc, sa * sc - ca * sb * cc, 0 };
          tt[1] = new double[] { -sa * cb, ca * cc - sa * sb * sc, ca * sc + sa * sb * cc, 0};
          tt[2] = new double[] { sb, -cb * sc, cb * cc, 0 };
          tt[3] = new double[] { 0, 0, 0, 1 };
    
    
          return tt;
       }
    Display More

    But when I use the new base coordinate to calculate the new 3D position of the point, it's totally false!! ??? :hmmm:

    I'm not very efficient ( :icon_confused: ) in maths, and I don't understand where is my mistake... Please can you help me?

  • Fubini
    Reactions Received
    270
    Trophies
    9
    Posts
    1,866
    • June 21, 2016 at 11:55 AM
    • #8

    Hi,

    did you use the transponed Matrix compared to

    1 0 0 0
    0 1 0 0
    0 0 1 0
    -49.907 -66.225 -13.887 1

    I know many Microsoft Tools always use transponed matrices (I do not know why), but our algorithms are for non transponed matrices like

    1 0 0 -49.907
    0 1 0 -66.225
    0 0 1 -13.887
    0 0 0 1

    Fubini

  • Spl
    Reactions Received
    5
    Trophies
    3
    Posts
    178
    • June 21, 2016 at 12:40 PM
    • #9

    To solve a pose in base 2, you have to solve the equation wHb1*b1Hp = wHb2*b2Hp, from which you get b2Hp = inverse(wHb2)*wHb1*b1Hp.

    wHb1 = 4-by-4 matrix of your base 1 in world
    wHb2 = 4-by-4 matrix of your base 2 in world
    b1Hp = 4-by-4 matrix of your pose in base 1
    b2Hp = 4-by-4 matrix of your pose in base 2

  • shkyo30
    Trophies
    3
    Posts
    12
    • June 21, 2016 at 1:38 PM
    • #10
    Quote from Fubini


    Hi,

    did you use the transponed Matrix compared to

    1 0 0 0
    0 1 0 0
    0 0 1 0
    -49.907 -66.225 -13.887 1

    I know many Microsoft Tools always use transponed matrices (I do not know why), but our algorithms are for non transponed matrices like

    1 0 0 -49.907
    0 1 0 -66.225
    0 0 1 -13.887
    0 0 0 1

    Fubini

    Display More

    I use the first one and not the transponed matrix, because when I try my own matrix:
    1 0 0 0
    0 1 0 0
    0 0 1 0
    -49.907 -66.225 -13.887 1

    I got the same results than when I use the TranslateTransform3D function (in Media3D library in C#)

    example just to illustrate:

    Code
    TranslateTransform3D matTransl = new TranslateTransform3D(-49.907, -66.225, -13.887);
    pointRep2 = matTransl.Transform(pointRep1);

    and

    Code
    Matrix3D matriceTranslate = new Matrix3D(1, 0, 0, 0,
                                            0, 1, 0, 0,
                                            0, 0, 1, 0,
                                            -49.907, -66.225, -13.887, 1);
    pointRep2 = pointRep1 * MatriceTranslate;

    got exactly the same results for pointRep2...

    And now, for the rotations I tried with the transponed of your matrix (I hope)
    ((ca * cb), (-sa * cb), sb, 0,
    (sa * cc + ca * sb * sc), (ca * cc - sa * sb * sc), (-cb * sc), 0,
    (sa * sc - ca * sb * cc), (ca * sc + sa * sb * cc), (cb * cc), 0,
    0, 0, 0, 1)

    Results failed... :sadsmiley:

  • shkyo30
    Trophies
    3
    Posts
    12
    • June 21, 2016 at 3:10 PM
    • #11
    Quote from Spl


    To solve a pose in base 2, you have to solve the equation wHb1*b1Hp = wHb2*b2Hp, from which you get b2Hp = inverse(wHb2)*wHb1*b1Hp.

    wHb1 = 4-by-4 matrix of your base 1 in world
    wHb2 = 4-by-4 matrix of your base 2 in world
    b1Hp = 4-by-4 matrix of your pose in base 1
    b2Hp = 4-by-4 matrix of your pose in base 2

    I'm not very good in maths (long time ago for me...) :icon_frown:
    For the 4x4 matrix of the positions and the bases, how can I write them?? :hmmm: ???

    For a 3D point, I think it's (x, y, z, w) like (1490.458, -1126.5, 1459.4, 1) for my first point, but how can I include rx, ry and rz?
    And I don't know for the base...

    Edited once, last by shkyo30 (June 21, 2016 at 3:13 PM).

  • Spl
    Reactions Received
    5
    Trophies
    3
    Posts
    178
    • June 21, 2016 at 3:12 PM
    • #12

    0.997739 0.0574681 -0.0348419 16.4261
    -0.0574331 0.998348 0.00200591 -1062.98
    0.0348996 -2.92901e-07 0.999391 -788.889
    0 0 0 1

    *

    1 0 0 0
    0 1 0 1126.5
    0 0 1 805
    0 0 0 1

    *

    -0.144988 -9.2377e-10 0.989433 1490.46
    -1.26753e-08 1 -9.2377e-10 -1126.5
    -0.989433 -1.26753e-08 -0.144988 1459.4
    0 0 0 1

    =

    -0.110187 0.0574681 0.992248 1424.62
    0.0063424 0.998348 -0.0571171 -1144.04
    -0.993891 -3.05601e-07 -0.110369 1526.15
    0 0 0 1

    =

    1424.62 -1144.04 1526.15 176.706 83.6635 -180

    1st matrix is the inverse of the new base
    2nd matrix is the old base
    3rd matrix is the pose in old base
    4th matrix is the pose in the new base

  • Metalikooky
    Reactions Received
    2
    Trophies
    3
    Posts
    78
    • June 21, 2016 at 7:26 PM
    • #13
    Quote from SkyeFire


    INV_POS() is a system function in KRL that performs a matrix inversion of a FRAME, POS, or E6POS type variable.

    The Geometric Operator (a ':' character) performs a matrix cross-product on any two FRAME or POS-type variables.

    Between them, these two will do everything you need. They're both discussed at length in the forum archives. The G.O. is documented in the KRL manuals, although for some reason INV_POS isn't.

    Is this the same as the INVERSE() function?

  • Spl
    Reactions Received
    5
    Trophies
    3
    Posts
    178
    • June 21, 2016 at 7:30 PM
    • #14

    I have never used it, but I would guess so.

  • Online
    SkyeFire
    Reactions Received
    1,038
    Trophies
    12
    Posts
    9,371
    • June 21, 2016 at 9:48 PM
    • #15

    No, INVERSE() takes a Cartesian coordinate and converts it into an Axis variable.

  • Spl
    Reactions Received
    5
    Trophies
    3
    Posts
    178
    • June 22, 2016 at 6:06 AM
    • #16

    Ah, of course the KRL functions aren't the same, but I wasn't think of the KRL inverse function.

  • shkyo30
    Trophies
    3
    Posts
    12
    • June 22, 2016 at 11:06 AM
    • #17

    Spl I'm sorry but I don't understand how you make the 4x4 matrix for the first point...

    I think it's a translation in first like this:
    1 0 0 1490.458
    0 1 0 -1126.5
    0 0 1 1459.4
    0 0 0 1

    and just after it's a 3D rotation like this:
    cos(ry)*cos(rz) -cos(ry)*sin(rz) sin(ry) 0
    sin(rx)*sin(ry)*cos(rz)+cos(rx)*sin(rz) -sin(rx)*sin(ry)*sin(rz)+cos(rx)*cos(rz) -sin(rx)*cos(ry) 0
    -cos(rx)*sin(ry)*cos(rz)+sin(rx)*sin(rz) cos(rx)*sin(ry)*sin(rz)+sin(rx)*cos(rz) cos(rx)*cos(ry) 0
    0 0 0 1

    with Kuka A=RZ, B=RY, C=RX, and of course I transform degre in radian with (rx*PI)/180 before calculation

    But with this method, I never find your values... :hmmm: ??? :bawling:

    Please can you help me? (Once again...)

  • Spl
    Reactions Received
    5
    Trophies
    3
    Posts
    178
    • June 22, 2016 at 11:35 AM
    • #18

    I'm using the following C++ code with the Eigen libraries http://eigen.tuxfamily.org/index.php?title=Main_Page

    Vector3f e;
    e << 180.0, 81.6634, 180.0;
    e *= M_PI / 180.0;

    float sx, sy, sz;
    float cx, cy, cz;

    sx = sin(e(2)), sy = sin(e(1)), sz = sin(e(0));
    cx = cos(e(2)), cy = cos(e(1)), cz = cos(e(0));

    Matrix3f ret;
    ret << cy*cz, cz*sx*sy - cx*sz, cx*cz*sy + sx*sz,
    cy*sz, cx*cz + sx*sy*sz, -cz*sx + cx*sy*sz,
    -sy, cy*sx, cx*cy;

    Hope this helps you.

  • shkyo30
    Trophies
    3
    Posts
    12
    • June 22, 2016 at 11:44 AM
    • #19

    OK thanks, I'll try to find the same function in the Media3D library (or maybe Direct3D) for Microsoft C# because I don't code in C++ :icon_wink:

  • shkyo30
    Trophies
    3
    Posts
    12
    • June 22, 2016 at 5:39 PM
    • #20

    I (finally) found a solution, but it's a little strange because I've a little gap on my x,y,z ... :hmmm:

    To calculate point and bases, I use this 4x4 matrix:
    cos(ry)*cos(rz) -cos(ry)*sin(rz) sin(ry) x
    sin(rx)*sin(ry)*cos(rz)+cos(rx)*sin(rz) -sin(rx)*sin(ry)*sin(rz)+cos(rx)*cos(rz) -sin(rx)*cos(ry) y
    -cos(rx)*sin(ry)*cos(rz)+sin(rx)*sin(rz) cos(rx)*sin(ry)*sin(rz)+sin(rx)*cos(rz) cos(rx)*cos(ry) z
    0 0 0 1

    and, at the end of your equation, I found x=1424.763 y=-1141.131 z=1528.186 ...

    with your method, you find exactly the good values (1424.618,-1144.036,1526.147)!!!

    It's strange because I use double type all time, it's 64bits precision in C#, have you any idea to explain this gap??

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