How to calculate TCP given 4 Points

Hello All,

I am trying to mathematically calculate the TCP with 4 Points entered by the user, similar to what the TCP Wizard Button achieves. However, it is not obvious to me what URScript Calls are being used to calculate the TCP with the TCP Wizard Button. Any advice on how to calculate the TCP would be appreciated.

Example: 4 Points captured from the Base Frame with the TCP set to 0. TCP is then calculated with TCP Wizard Button.

( The X,Y,Z values are in mm and the RX, RY,RZ values are in degrees.)

  • Point 1: [65.7, -784.16, 291.58, 169.71, 12.32, 48.59]
  • Point 2: [378.39, -769.23, 313.14, 172.17, 4.70, -42.69]
  • Point 3: [341.84, -861.45, 349.34, 183.17, -42.86, -22.52]
  • Point 4: [208.6, -640.97, 253.82, 145.56, 19.65, -4.07]
  • TCP: [5.25, 95.13, 308.52]

If I understand correctly, we can visualize the TCP as a point existing on the surface of a sphere whose center is the flange center of the robot. Given that the X,Y,Z value of the flange center is 0,0,0, we can calculate the distance/radius from the TCP to the flange center. Radius = SQRT((XX)+(YY)+(Z*Z)).

  • Radius: 322.896.

Now, I want to achieve the same result mathematically. I started with the approach detailed in the answer in this stack overflow post. Calculate Sphere Center with 4 Points Basically, I am attempting to find the center of the sphere given 4 X,Y,Z Points. Implementing the answer and plugging in the above 4 points gives me the following center point and radius:

Center Point: [242.504, -870.923, 70.8936]
Radius: 295.787

Even if I translated the Center Point to the Origin and adjusted the Points, the Radius is still off by about 30 mm. So I’m starting to doubt my understanding of the TCP. Is there another approach that people are using to calculate the TCP mathematically or with URScript or C++. Feedback is greatly appreciated! I would love to better understand how these things work.

Joseph