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. General Discussion of Industrial Robots Only
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

Robot Math

  • foffulaRob
  • April 26, 2021 at 4:05 PM
  • Thread is Resolved
  • foffulaRob
    Reactions Received
    3
    Trophies
    3
    Posts
    46
    • April 26, 2021 at 4:05 PM
    • #1

    Goodmorning,

    i have a problem with a kuka robot. i will not specify the robot because i think it's common for everyone. When i do a calculation with the robot and then with a calculator the results are different.

    i make an example:

    On robot : 1402.64*1402.64*199.69= 392869920

    On calculator: 1402.64*1402.64*199.69= 392869900,239424

    For the robot i'm using a REAL variable. This is just a little calculation, part of a bigger one. I have already a problem if it is so different.

    I don't get it, why the results are so different? Why doest it happens?

  • panic mode
    Reactions Received
    1,294
    Trophies
    11
    Posts
    13,126
    • April 26, 2021 at 5:26 PM
    • #2

    that is because you do not understand data types and REAL variable limitations.

    REAL is a 32-bit variable but only 23 bits are used for mantissa or significand.

    that is because REAL data type is encoded, 1 bit is used for sign and 8 more bits are used for exponent so from original 32bits used for REAL, only 23 bits remain for significand... (or 24 because there is a trick in binary format representation that recycles MSB of the significand)

    so using only 23 bits one can represented maximum 8388608 states

    but your significand value is 392869900239424

    (when looking at significand, decimal point or decimal comma is just cosmetic...)

    to represent such value you would need more bits (more states).

    unlike REAL, integers are not encoded so all bits could be part of significand.

    but even so, with 32 bits you only get up 4294967296 states.

    so 32-bit data types simply cannot store your value with accuracy that you expect.

    and KRL does not implement 64-bit FLOAT or CURRENCY. if you want to retain as many digits as possible you have few options but each requires intimate knowledge of computing systems.

    then you could get something like 392869900.24 instead of 392869920

    for more info read https://en.wikipedia.org/wiki/IEEE_754

    using 64-bit FLOAT one gets 53 (54) bits for significand.

    Currency is another format that uses 80-bits in total.

    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

  • panic mode
    Reactions Received
    1,294
    Trophies
    11
    Posts
    13,126
    • April 26, 2021 at 5:31 PM
    • #3

    we all know that 1/3.0 is 0.33333333333333333333333

    but when constrained to 32-bit REAL you get rounded result as seen here. note that 23bit significand means that in base 10, only maybe 7 or so figures are correct but you are expecting 15 or more.

    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

  • SkyeFire
    Reactions Received
    1,060
    Trophies
    12
    Posts
    9,456
    • April 26, 2021 at 6:27 PM
    • #4

    Yeah. For 99.9% of applications, it never matters, b/c for robots, you usually only do math like this to compute motion offsets. And when we're talking about mm, anything past 0.01, maybe 0.001, is simply noise -- the robot cannot move accurately enough for the difference to matter.

    For example, a typical industrial robot rated for a 200kg payload might have a rated repeatability of 0.1mm, and an accuracy of 1.0mm. So anything more than 1 decimal place serves little purpose, aside from reducing rounding error when projecting coordinates throughout the robot's reach envelope. So most robots' math capabilities are built to be "good enough," and not waste resources on trying to go further.

    (from personal experience, this can trip you when you're trying to program the robot in a vehicle coordinate system where the the origin is 100m away from the robot's base. But in a case like that, you need to convert your coordinate system at the CAD/Simulation level, not try to do mathematical projection in the robot)

    For the very rare 0.1% of applications where higher precision is required, it's usually achieved by the use of special tuning, anti-backlash techniques, or external high-accuracy measuring devices feeding corrections to the robot (often a combination of 2 or more).

  • panic mode
    Reactions Received
    1,294
    Trophies
    11
    Posts
    13,126
    • April 26, 2021 at 6:55 PM
    • #5

    yes, doing math externally using 64-bit or higher is a one way to go. the other thing is to rethink what the numbers actually represent. if the value is a distance in mm, then 392869900.24mm is nearly 393km or 244miles.

    so using 32-bit REAL one gets some 20mm approximation error on a length of 392.9km which is not that bad. if this robot was on a 40m long rail, this rounding error would be 10000x smaller too - on the order of a micrometer. so to really see if this is even a problem, one would need to know what the numbers represent.

    here is an example of direct assignment (error is 12.24 or 0.000003%)

    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

  • foffulaRob
    Reactions Received
    3
    Trophies
    3
    Posts
    46
    • April 27, 2021 at 10:59 AM
    • #6

    Goodmorning. Thanks for the replies. my problem was that I needed to calculate the radius of an arc passing through 3 points. To do that I used a system with 3 variables with very high X, Y terms due to the high distance of the points taken from the origin of the base. Approximating how the robot does made the error in the end turned out to be too large (The radious in the end it should have been 25 but it was 21 for the robot calculation). I was able to realize that it was a problem related to the max value of a REAL, but since I cannot rely on a PC to do the calculations I was "forced", as a solution, to consider the first point of the arc as the point of origin (so that the terms of my system were smaller). After that I still couldn't understand the problem about REAL but you solved a huge dilemma for me. Thanks so much guys.

    Quote
  • panic mode
    Reactions Received
    1,294
    Trophies
    11
    Posts
    13,126
    • April 27, 2021 at 2:24 PM
    • #7

    maybe post your code or method to compute the result. that will offer chance to comment on it and offer tips to resolve it.

    not sure what do you mean by radius 25 or 21. is that millimeters?

    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

  • foffulaRob
    Reactions Received
    3
    Trophies
    3
    Posts
    46
    • April 27, 2021 at 3:19 PM
    • #8

    Ye, i was talking about the radius of the arc ( in millimeters).

    Anyway this is the code i wrote to calculate the radius of my arc.

    The first part is just the resolution of the system to find out a,b,c. after that i calculate the arc.

    i tryed with the traslation of the origin to the first point of the arc to "fix" the approssimation of the robot and now it is working good.

    Code
    GLOBAL DEFFCT REAL RArc(X1:IN,Y1:IN,X2:IN,Y2:IN,X3:IN,Y3:IN)
    ;Questa funzione serve a trovare il raggio di una circonferenza passante per 3 punti.
    ;EQUAZIONE CIRCONFERENZA PASSANTE PER 3 PUNTI FORMA ESPLICITA
    ;X^2+Y^2+ax+by+c=0
    ;--
    ;EQUAZIONE CIRCONFERENZA PASSANTE PER 3 PUNTI FORMA IMPLICITA
    ;(X-Xo)^2+(Y-Yo)^2=r^2 
    ;--
    ;RELAZIONE MATEMATICA TRA FORMA IMPLICITA ED ESPLICITA
    ;X^2+Y^2-2*Xo*X-2*Yo*Y+Xo^2+Y0^2-r
    ;-2Xo=a
    ;-2Yo=b
    ;X^2+Y^2-r^2=c
    ;--
    ;FORMULA ANGOLO CONOSCENDO CATETO ADIACENTE E IPOTENUSA
    ;ACOS(CATETO/IPOTENUSA)
    DECL REAL X1,Y1,X2,Y2,X3,Y3
    DECL REAL X1_EL2,Y1_EL2,X2_EL2,Y2_EL2,X3_EL2,Y3_EL2,Xo_EL2,Yo_EL2
    DECL REAL a,b,c,r
    DECL REAL Xo,Yo
    ;--
    ;FORMULA DELL'EQUAZIONE DI UNA CIRCONFERENZA
    ;{X1^2+Y1^2+aX1+Y1+c=0
    ;--
    ;METTO I TERMINI NEL SISTEMA
    ;{X1^2+Y1^2+aX1+bY1+c=0
    ;{X2^2+Y2^2+aX2+bY2+c=0
    ;{X3^2+Y3^2+aX3+bY3+c=0
    ;--
    ;TRASLO LO ZERO DELLA BASE AL PRIMO PUNTO DEL ARCO ED ESTRAPOLO LE COORDINATE DEGLI ALTRI DUE PUNTI
    X2=X2-X1
    Y2=Y2-Y1
    X3=X3-X1
    Y3=Y3-Y1
    X1=0
    Y1=0
    ;ELEVO I TERMINI DA INSERIRE NEL SISTEMA ( POW_NUM() --> FUNZIONE PER ELEVARE A POTENZA)
    X1_EL2=POW_NUM(X1,2)
    Y1_EL2=POW_NUM(Y1,2) 
    X2_EL2=POW_NUM(X2,2)
    Y2_EL2=POW_NUM(Y2,2) 
    X3_EL2=POW_NUM(X3,2) 
    Y3_EL2=POW_NUM(Y3,2) 
    ;--
    ;ISOLO LE INCOGNITE (ULTIMO PASSAGGIO DEL SISTEMA)
    ;c=-X1^2-Y1^2-X1*a-Y1*b
    ;b=(-X2^2-Y2^2-X2a+X1^2+Y1^2+X1a))/(Y2-Y1)
    ;a=(X2^2*Y3+Y2^2*Y3-X1^2*Y3-Y1^2*Y3+X1^2*Y2-X1^2*Y1+Y1^2*Y2-X2^2*Y1-Y2^2*Y1+X1^2*Y1-X3^2*Y2+X3^2*Y1-Y3^2*Y2+Y3^2*Y1)/(X3*Y2-X3*Y1-X2*Y3+X1*Y3-X1*Y2+X2*Y1)
    ;--
    ;CALCOLO a,b,c partendo da "a" con i calcoli (avendo già b e c isolate),poi sostituisco in "b" e successivamente in "c" per trovare tutte le incognite.
    ;Scrivo direttamente la parte risolutiva del sistema
    a=(X2_EL2*Y3+Y2_EL2*Y3-X1_EL2*Y3-Y1_EL2*Y3+X1_EL2*Y2-X1_EL2*Y1+Y1_EL2*Y2-X2_EL2*Y1-Y2_EL2*Y1+X1_EL2*Y1-X3_EL2*Y2+X3_EL2*Y1-Y3_EL2*Y2+Y3_EL2*Y1)/(X3*Y2-X3*Y1-X2*Y3+X1*Y3-X1*Y2+X2*Y1)
    b=(-X2_EL2-Y2_EL2-a*X2+X1_EL2+Y1_EL2+a*X1)/(Y2-Y1)
    c=-X1_EL2-Y1_EL2-a*X1-b*Y1
    ;CALCOLO X E Y D'ORIGINE
    Xo=-a/2
    Yo=-b/2
    ;ELEVO A POTENZA Xo,Yo
    Xo_EL2=POW_NUM(Xo,2)
    Yo_EL2=POW_NUM(Yo,2)
    ;CALCOLO IL RAGGIO
    r=SQRT(Xo_EL2+Yo_EL2-c)   
    RETURN r
    ENDFCT
    Display More
  • panic mode
    Reactions Received
    1,294
    Trophies
    11
    Posts
    13,126
    • April 27, 2021 at 3:43 PM
    • #9

    so what kind of input data you are feeding into your function?

    i just tried some large input values for three points that form 25.000mm radius and got good result..

    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

  • foffulaRob
    Reactions Received
    3
    Trophies
    3
    Posts
    46
    • April 27, 2021 at 4:22 PM
    • #10

    Now it works with big numbers because i modified it.

    in the lines:

    ---------

    ;TRASLO LO ZERO DELLA BASE AL PRIMO PUNTO DEL ARCO E ESTRAPOLO LE COORDINATE DEGLI ALTRI DUE PUNTI

    X2=X2-X1

    Y2=Y2-Y1

    X3=X3-X1

    Y3=Y3-Y1

    X1=0

    Y1=0

    ---------

    I set the input values of first point as zero (origin). Then i calculate the delta between zero and the other 2 points.

    It's like i am drawing my arc not where his really position is but near the zero of the base. In this way the x,y values of my 3 points are low. In the end i just need to find a radius of an arc. If it's a kilometer far from my origin or just at 2 millimiters it doesn't change the radius value. But for me is better use the little values instead of big ones.

    I'm not sure if i explained it well.

  • panic mode
    Reactions Received
    1,294
    Trophies
    11
    Posts
    13,126
    • April 27, 2021 at 4:27 PM
    • #11

    very good workaround.

    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

  • foffulaRob
    Reactions Received
    3
    Trophies
    3
    Posts
    46
    • April 27, 2021 at 4:37 PM
    • #12

    Thank you again for the help. Have a good day.

  • MOM
    Reactions Received
    176
    Trophies
    7
    Posts
    1,424
    • April 28, 2021 at 11:31 PM
    • #13

    foffulaRob

    I just wondering what kind of robot you are using.

    panic mode made a test with a 25m radius and it worked well.

    Normally for distance you have to expect 1/10th of millimeter and for degree 1/1000th of degree.

    In your first post you mentioned the number 392869920 (for kuka, these are mm) and this means, that you are actually talking about 392.7 km. What kind of robot is that?

    I did not know that kuka is selling a robot this size


  • hermann
    Reactions Received
    411
    Trophies
    9
    Posts
    2,621
    • April 29, 2021 at 10:11 AM
    • #14
    Quote from MOM

    In your first post you mentioned the number 392869920 (for kuka, these are mm) and this means, that you are actually talking about 392.7 km. What kind of robot is that?

    This value was an intermediate result in the calculation. The initial value was 1402 mm, that's a normal robot.

  • admirk
    Reactions Received
    2
    Trophies
    3
    Posts
    13
    • April 29, 2021 at 4:12 PM
    • #15

    post #9 actually states that issue is resolved. i missed that too when i skimmed over the topic...

    hello

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

Similar Threads

  • Position Converter - Convert from XYZWPR Rep to Joint Rep and Back

    • Nation
    • November 27, 2018 at 12:18 AM
    • Manuals, Software and Tools for Fanuc Robots (you should look here first before posting)
  • Math behind the 3-point method for TCP

    • machinekoder
    • March 9, 2021 at 3:41 PM
    • KUKA Robot Forum
  • NX100 robot at standstill feedback

    • Robottech
    • January 21, 2021 at 11:59 PM
    • Yaskawa Motoman Robot Forum
  • Introducing Myself and Asking Question about Torque Calculation

    • ferik
    • September 21, 2020 at 1:47 PM
    • General Discussion of Industrial Robots Only
  • geometricModel.math.Point and geometricModel.math.Vector

    • aswin
    • November 25, 2019 at 7:20 PM
    • KUKA LBR IIWA
  • Vehicle Zero Coordinate - Robot Base Reference Set Up

    • darek8711
    • September 29, 2019 at 7:49 PM
    • General Discussion of Industrial Robots Only
  • execute another .java application by code

    • evo85210
    • April 17, 2019 at 7:29 AM
    • KUKA LBR IIWA
  • Cannot find trigonometric functions

    • ashwinmudigonda
    • February 19, 2018 at 11:12 PM
    • Fanuc Robot Forum
  • LBR iiwa - detect a force coming from the left/right

    • robotneuling
    • May 7, 2017 at 1:40 PM
    • KUKA Robot Forum

Tags

  • KUKA
  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