# Using set\_tcp() before using userInteraction.getUserDefinedRobotPosition fail

**URL:** <https://forum.universal-robots.com/t/using-set-tcp-before-using-userinteraction-getuserdefinedrobotposition-fail/18863>\
**Category:** Java\
**Created:** [January 24, 2022, 4:03pm UTC](https://forum.universal-robots.com/t/using-set-tcp-before-using-userinteraction-getuserdefinedrobotposition-fail/18863 "2022-01-24T16:03:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![j-p.royer](https://avatars.discourse-cdn.com/v4/letter/j/9de0a6/32.png) [@j-p.royer](https://forum.universal-robots.com/u/j-p.royer)\
**Post date:** [January 24, 2022, 4:03pm UTC](https://forum.universal-robots.com/t/using-set-tcp-before-using-userinteraction-getuserdefinedrobotposition-fail/18863/1 "2022-01-24T16:03:09Z")

</div>

Hi @jbm ,

I first add TCPs (let say “Bob” and “Paul”) of my own through the JAVA API. Then I am trying to override the TCP before using the “UserDefinedRobotPosition” to define a waypoint in this TCP. Once the waypoint is accepted, I store the value in the contribution DataModel and reset the TCP to the one the customer set as Active (let say TCP\_1).

To do so, I override the tcp using “set\_tcp(Bob\_values\_as\_pose)” function in urscript via the secondary client socket port 30002. Once that is done, I call the UserDefinedRobotPosition to set the waypoint.

Here is my problem, sometimes Polyscope shows the interface with the right TCP (“Bob”) and sometimes not (TCP\_1).  
Adding textmsg() to my script to get\_tcp\_offset() validate that my set\_tcp() command as work properly.

It does the samething with the “robotMovement.requestUserToMoveRobot()”

Why is that not consistent? Am I doing something wrong or not?

Thank you!

---

<div class="post-metadata">

**Author:** ![Ebbe](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/ebbe/32/1413_2.png) [@Ebbe](https://forum.universal-robots.com/u/Ebbe)\
**Post date:** [January 25, 2022, 9:13am UTC](https://forum.universal-robots.com/t/using-set-tcp-before-using-userinteraction-getuserdefinedrobotposition-fail/18863/2 "2022-01-25T09:13:58Z")

</div>

Hi @j-p.royer,

It should be consistent. But please keep in mind that other process can set the active TCP as well. Each time a program is started Polyscope will set it to default.  
Are sending the secondary program just before the other method? If that is the case you might also be struggling with some timing challenges.

Best regards  
Ebbe

---

<div class="post-metadata">

**Author:** ![j-p.royer](https://avatars.discourse-cdn.com/v4/letter/j/9de0a6/32.png) [@j-p.royer](https://forum.universal-robots.com/u/j-p.royer)\
**Post date:** [January 25, 2022, 1:45pm UTC](https://forum.universal-robots.com/t/using-set-tcp-before-using-userinteraction-getuserdefinedrobotposition-fail/18863/3 "2022-01-25T13:45:02Z")

</div>

Hi @Ebbe thank you for your fast response ,

I confirm that the script method has been sent and execute before using the Java API.  
Which process can set the tcp back to default if timing is ok?

By “Each time a program is started Polyscope will set it to default.”, you mean that the one that I set become the default one?

I sent it as a primary program through the secondary client. Is that ok?

Thank you!

---

<div class="post-metadata">

**Author:** ![Ebbe](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.universal-robots.com/ebbe/32/1413_2.png) [@Ebbe](https://forum.universal-robots.com/u/Ebbe)\
**Post date:** [January 28, 2022, 7:21am UTC](https://forum.universal-robots.com/t/using-set-tcp-before-using-userinteraction-getuserdefinedrobotposition-fail/18863/4 "2022-01-28T07:21:50Z")

</div>

Hi @j-p.royer,

My concern is not that it is change in the short time from you sent the “set\_tcp()” script. But with the call you have changed it in URControl, but Polyscope might not have read it back from URControl yet. The primary interface is running 10Hz, so if your script is changing the active TCP it might take Polyscope up to 100ms to be updated.

Ebbe
