# Calculate Offset between TCPs?

**URL:** <https://forum.universal-robots.com/t/calculate-offset-between-tcps/32892>\
**Category:** URScript\
**Created:** [February 21, 2024, 10:38pm UTC](https://forum.universal-robots.com/t/calculate-offset-between-tcps/32892 "2024-02-21T22:38:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jpomo](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@jpomo](https://forum.universal-robots.com/u/jpomo)\
**Post date:** [February 21, 2024, 10:38pm UTC](https://forum.universal-robots.com/t/calculate-offset-between-tcps/32892/1 "2024-02-21T22:38:17Z")

</div>

I’m having trouble calculating an offset between TCPs.

I have two probes on the end-effector, mounted 20mm apart in X and 0mm apart in Y.

My block of code looks like this:

```auto
set -->TCP to Probe1
Assignment: var1 = get_actual_tcp_pose()
set--> TCP to Probe2
Assignment: var2 = get_actual_tcp_pose()

offset = p[var1[0]-var2[0], var1[1]-var2[1], etc.]
 

```

However, the offset for X is larger than expected (~50mm rather than the expected 20mm).

Is this an incorrect way to calculate an offset between TCPs?

Thanks!

---

<div class="post-metadata">

**Author:** ![Robpod](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/robpod/32/5837_2.png) [@Robpod](https://forum.universal-robots.com/u/Robpod)\
**Post date:** [February 22, 2024, 6:42am UTC](https://forum.universal-robots.com/t/calculate-offset-between-tcps/32892/2 "2024-02-22T06:42:35Z")

</div>

Hi @jpomo,  
you can take into account all coordinates of TCP in this way:

```auto
tcp1 = get_actual_tcp_pose()
tcp2 = get_actual_tcp_pose()
offset = pose_trans(pose_inv(tcp1), tcp2)

```

 ![immagine](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/2X/f/f9b983d0cd22273d649fcdca72c04e84e552abbb.png)

---

<div class="post-metadata">

**Author:** ![jpomo](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@jpomo](https://forum.universal-robots.com/u/jpomo)\
**Post date:** [February 22, 2024, 10:51pm UTC](https://forum.universal-robots.com/t/calculate-offset-between-tcps/32892/3 "2024-02-22T22:51:32Z")

</div>

Got it! Thank you for the reply!
