# Changing TCP Position programmatically

**URL:** <https://forum.universal-robots.com/t/changing-tcp-position-programmatically/2021>\
**Category:** URScript\
**Created:** [May 24, 2018, 11:59am UTC](https://forum.universal-robots.com/t/changing-tcp-position-programmatically/2021 "2018-05-24T11:59:05Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon86511138](https://avatars.discourse-cdn.com/v4/letter/a/c68b51/32.png) [@anon86511138](https://forum.universal-robots.com/u/anon86511138)\
**Post date:** [May 24, 2018, 11:59am UTC](https://forum.universal-robots.com/t/changing-tcp-position-programmatically/2021/1 "2018-05-24T11:59:06Z")

</div>

hey,  
I’m trying to make the Robot do a circular path relative to a point (a gripped Object) which is different from the TCP of the robot. I was wondering if it is somehow possible to change the Robots Tcp online so that the MoveP command would move the way i want or if i have to handle the transformation on my side.  
thanks

---

<div class="post-metadata">

**Author:** ![anon42905246](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@anon42905246](https://forum.universal-robots.com/u/anon42905246)\
**Post date:** [May 24, 2018, 12:13pm UTC](https://forum.universal-robots.com/t/changing-tcp-position-programmatically/2021/2 "2018-05-24T12:13:22Z")

</div>

You can use set\_tcp() function. Just give your new TCP data as parameter. You can look it up in script manual.

---

<div class="post-metadata">

**Author:** ![anon86511138](https://avatars.discourse-cdn.com/v4/letter/a/c68b51/32.png) [@anon86511138](https://forum.universal-robots.com/u/anon86511138)\
**Post date:** [May 25, 2018, 9:50am UTC](https://forum.universal-robots.com/t/changing-tcp-position-programmatically/2021/3 "2018-05-25T09:50:22Z")

</div>

would this have an impact on the performance of the robot since the new tcp is only a virtual one and won’t be in the centre of mass of the actual tool?

---

<div class="post-metadata">

**Author:** ![anon42905246](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@anon42905246](https://forum.universal-robots.com/u/anon42905246)\
**Post date:** [May 25, 2018, 10:14am UTC](https://forum.universal-robots.com/t/changing-tcp-position-programmatically/2021/4 "2018-05-25T10:14:09Z")

</div>

Depends if you use this function:

> **set\_payload** (m, CoG)
> 
> Set payload mass and center of gravity  
> Alternatively one could use `set_payload_mass` and  
> `set_payload_cog`.
> 
> Sets the mass and center of gravity (abbr. CoG) of the payload.  
> This function must be called, when the payload weight or weight  
> distribution changes - i.e when the robot picks up or puts down a  
> heavy workpiece.
> 
> The CoG argument is optional - if not provided, the Tool Center Point  
> (TCP) will be used as the Center of Gravity (CoG). If the CoG argument  
> is omitted, later calls to set\_tcp(pose) will change CoG to the new TCP.  
> The CoG is specified as a vector, [CoGx, CoGy, CoGz], displacement,  
> from the toolmount.
> 
> Parameters  
> _m_: mass in kilograms  
> _CoG_: Center of Gravity: [CoGx, CoGy, CoGz] in meters.  
> Optional.  
> Example command: set\_payload(3., [0,0,.3])  
> • Example Parameters:  
> – _m_ = 3 → mass is set to 3 kg payload  
> – _CoG_ = [0,0,.3] → Center of Gravity is set to x=0 mm, y=0 mm,  
> _z_=300mm from the center of the tool mount in tool  
> coordinates

To be honest it is a bit complicated, so best if you search the forum and script manual yourself to understand how it works. I wouldn’t want to mix it up.

---

<div class="post-metadata">

**Author:** ![ajp](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/ajp/32/471_2.png) [@ajp](https://forum.universal-robots.com/u/ajp)\
**Post date:** [May 29, 2018, 2:19am UTC](https://forum.universal-robots.com/t/changing-tcp-position-programmatically/2021/5 "2018-05-29T02:19:48Z")

</div>

The TCP is set independently of the CoG and payload, so you shouldn’t have any issues changing the tcp with set\_tcp().

---

<div class="post-metadata">

**Author:** ![anon42905246](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@anon42905246](https://forum.universal-robots.com/u/anon42905246)\
**Post date:** [May 29, 2018, 4:27am UTC](https://forum.universal-robots.com/t/changing-tcp-position-programmatically/2021/6 "2018-05-29T04:27:15Z")

</div>

If I understand it correctly, if you call `set_payload` at least once it changes the way `set_tcp` behaves. Is that right?  
If I call `set_payload(4)`, then `set_tcp(0,0,0.050)` will put CoG at new TCP.

---

<div class="post-metadata">

**Author:** ![ajp](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/ajp/32/471_2.png) [@ajp](https://forum.universal-robots.com/u/ajp)\
**Post date:** [May 29, 2018, 5:03am UTC](https://forum.universal-robots.com/t/changing-tcp-position-programmatically/2021/7 "2018-05-29T05:03:08Z")

</div>

Yes that appears to be what the manual says but I haven’t tested this behavior. I’d recommend always calling set\_payload() with a CoG argument to avoid this.

---

<div class="post-metadata">

**Author:** ![jbm](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/jbm/32/614_2.png) [@jbm](https://forum.universal-robots.com/u/jbm)\
**Post date:** [May 31, 2018, 7:59am UTC](https://forum.universal-robots.com/t/changing-tcp-position-programmatically/2021/8 "2018-05-31T07:59:14Z")

</div>

Also note, that there are two new sub-functions to `set_payload(m, CoG)` which respectively are `set_payload_mass(m)` and `set_payload_cog(cog)` that you could use, to avoid the confusion.

---

<div class="post-metadata">

**Author:** ![anon19565564](https://avatars.discourse-cdn.com/v4/letter/a/848f3c/32.png) [@anon19565564](https://forum.universal-robots.com/u/anon19565564)\
**Post date:** [December 1, 2020, 1:39am UTC](https://forum.universal-robots.com/t/changing-tcp-position-programmatically/2021/9 "2020-12-01T01:39:41Z")

</div>

> [@anon42905246](#):
>
> **set\_payload** (m, CoG)

So, If i set the Mass and CoG int the Script (by set\_payload(m, CoG)), and just  
use Join Angle Poses (like "movej([0,-0.98,-2.6,-2.1,-1.6,1.5],3,3,0,0) " …  
Do I have to set the TCP?

---

<div class="post-metadata">

**Author:** ![ajp](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/ajp/32/471_2.png) [@ajp](https://forum.universal-robots.com/u/ajp)\
**Post date:** [December 1, 2020, 3:08am UTC](https://forum.universal-robots.com/t/changing-tcp-position-programmatically/2021/10 "2020-12-01T03:08:13Z")

</div>

You can run the robot without setting TCP, however the safety system uses TCP position in calculating force and position limits, so it’s recommended to do so.

---

<div class="post-metadata">

**Author:** ![anon19565564](https://avatars.discourse-cdn.com/v4/letter/a/848f3c/32.png) [@anon19565564](https://forum.universal-robots.com/u/anon19565564)\
**Post date:** [December 1, 2020, 10:41am UTC](https://forum.universal-robots.com/t/changing-tcp-position-programmatically/2021/11 "2020-12-01T10:41:45Z")

</div>

Do you have any example of program that changes the TCP for each point of a path?  
Like glue dispensing aplication. I want to know how to do that in the corect way.

---

<div class="post-metadata">

**Author:** ![ajp](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/ajp/32/471_2.png) [@ajp](https://forum.universal-robots.com/u/ajp)\
**Post date:** [December 2, 2020, 4:18am UTC](https://forum.universal-robots.com/t/changing-tcp-position-programmatically/2021/12 "2020-12-02T04:18:52Z")

</div>

Can you explain the use case in a bit more detail? Not sure I understand why you’d need to change the TCP like this?

---

<div class="post-metadata">

**Author:** ![anon19565564](https://avatars.discourse-cdn.com/v4/letter/a/848f3c/32.png) [@anon19565564](https://forum.universal-robots.com/u/anon19565564)\
**Post date:** [December 2, 2020, 12:40pm UTC](https://forum.universal-robots.com/t/changing-tcp-position-programmatically/2021/13 "2020-12-02T12:40:46Z")

</div>

[Dass-PUR.script](https://forum.universal-robots.com/uploads/short-url/9J4JVL4eDJb07eeUq3WFlP3bW5J.script) (9.2 KB)

Have a look in this program. Do you think is ok work like this?  
I does a glue dispensing path over a outsole shoes

---

<div class="post-metadata">

**Author:** ![ajp](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/ajp/32/471_2.png) [@ajp](https://forum.universal-robots.com/u/ajp)\
**Post date:** [December 3, 2020, 3:24am UTC](https://forum.universal-robots.com/t/changing-tcp-position-programmatically/2021/14 "2020-12-03T03:24:09Z")

</div>

I don’t see anything obviously wrong with the program. Is the robot holding the dispenser or the shoe? If it’s the shoe and the dispenser is static you should look into remote TCP functionality to ensure that you maintain a constant speed relative to the dispensing head.

---

<div class="post-metadata">

**Author:** ![anon19565564](https://avatars.discourse-cdn.com/v4/letter/a/848f3c/32.png) [@anon19565564](https://forum.universal-robots.com/u/anon19565564)\
**Post date:** [December 3, 2020, 10:36am UTC](https://forum.universal-robots.com/t/changing-tcp-position-programmatically/2021/15 "2020-12-03T10:36:28Z")

</div>

It holds the shoes and the dispenser is static.  
I´m trying to make this program better, becouse I had some complaim about the way that I made it.  
I made this program at 2017, and that time we just have the CB series (RTPC for now is not available to CB series).

Now we are changing the production to E-Series, and i will change the programs to remote TCP. As I Know, remote tcp was just releases about 6 month ago. So just now I started to change to It. Corona broke my legs here ☹

---

<div class="post-metadata">

**Author:** ![ajp](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/ajp/32/471_2.png) [@ajp](https://forum.universal-robots.com/u/ajp)\
**Post date:** [December 4, 2020, 7:03am UTC](https://forum.universal-robots.com/t/changing-tcp-position-programmatically/2021/16 "2020-12-04T07:03:29Z")

</div>

What were the complaints? My first question would be why it was written in script and not in polyscope? That makes it much harder to adjust any of the waypoints in the program.

---

<div class="post-metadata">

**Author:** ![anon19565564](https://avatars.discourse-cdn.com/v4/letter/a/848f3c/32.png) [@anon19565564](https://forum.universal-robots.com/u/anon19565564)\
**Post date:** [December 4, 2020, 4:11pm UTC](https://forum.universal-robots.com/t/changing-tcp-position-programmatically/2021/17 "2020-12-04T16:11:02Z")

</div>

Actualy I just made it in script to be easy to change it!  
I draw the glue spray in Rhino3D (the shoes all came in Rhino3D files), and take the geometry and convert the coordinates.  
Then i made a Java Desktop program that convert it to Script (doing almost the same way that the new “toolpath” function in e-series). In This program I can changes the angle, height, size, etc of the glue dispensing. And as shoes I have a lot of diferent sizes and models ( each model have more then 10 sizes, and left/right, and we work with about 3 models…so around 70/80 programs!). So I have and qrcode reader that read the programs and send it to the UR3 via script.

---

<div class="post-metadata">

**Author:** ![ajp](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/ajp/32/471_2.png) [@ajp](https://forum.universal-robots.com/u/ajp)\
**Post date:** [December 7, 2020, 3:28am UTC](https://forum.universal-robots.com/t/changing-tcp-position-programmatically/2021/18 "2020-12-07T03:28:27Z")

</div>

Seems like a good approach. Would potentially be convenient for the path to be relative to a feature (user coordinate frame) so that operators can make small adjustments in case something moves in the production environment.

---

<div class="post-metadata">

**Author:** ![anon19565564](https://avatars.discourse-cdn.com/v4/letter/a/848f3c/32.png) [@anon19565564](https://forum.universal-robots.com/u/anon19565564)\
**Post date:** [December 11, 2020, 10:01am UTC](https://forum.universal-robots.com/t/changing-tcp-position-programmatically/2021/19 "2020-12-11T10:01:03Z")

</div>

Actually I have a reference point that we can change It.

Today the robot that run this program shows the C264A0 error… any ideais that what can cause it?

---

<div class="post-metadata">

**Author:** ![ajp](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/ajp/32/471_2.png) [@ajp](https://forum.universal-robots.com/u/ajp)\
**Post date:** [December 15, 2020, 2:40am UTC](https://forum.universal-robots.com/t/changing-tcp-position-programmatically/2021/20 "2020-12-15T02:40:04Z")

</div>

Hi @anon19565564, for help in dealing with error codes, please contact your distributor, we have a separate system for handling post sales service issues.
