# Accessing Waypoints/Poses in UR Script

**URL:** <https://forum.universal-robots.com/t/accessing-waypoints-poses-in-ur-script/2056>\
**Category:** URScript\
**Created:** [June 1, 2018, 9:45am UTC](https://forum.universal-robots.com/t/accessing-waypoints-poses-in-ur-script/2056 "2018-06-01T09:45:25Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon75015020](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@anon75015020](https://forum.universal-robots.com/u/anon75015020)\
**Post date:** [June 1, 2018, 9:45am UTC](https://forum.universal-robots.com/t/accessing-waypoints-poses-in-ur-script/2056/1 "2018-06-01T09:45:25Z")

</div>

Hello,

UR differtinates between variables (e.g p = p[0,0,0,0,0,0]) and poses (e.g fixed Waypoint\_1 in a movel-command).  
Im working on a script that needs to access poses. Currently I get a syntax error that says Waypoint\_1 is not defined. The Pose is declared and used in a Move-Command. The Call of the Script is also after the call of the Move-Command.

I think the workaround to save the Pose to a variable would work, but is there any reason why poses can´t be directly accessed via script code ?

The Problem might be more related to the Move-command and the handling of the Waypoint instead of the general datatype pose.

For now i will save the pose to a variable, but Im thankful for every advice.

Thank you  
Best Regards,  
Alexander Apostolidis

---

<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:** [June 2, 2018, 4:24am UTC](https://forum.universal-robots.com/t/accessing-waypoints-poses-in-ur-script/2056/2 "2018-06-02T04:24:59Z")

</div>

The Waypoint names only exist within the Polyscope program structure, they are not exported to script. If you look at the script generated from the URP you’ll see that the waypoint names only appear in the label messages, the move commands just contain the pose values. They also don’t appear in the variables tab. So your current method is correct, if you want to access them in script you must first assign them to a variable.

---

<div class="post-metadata">

**Author:** ![anon75015020](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@anon75015020](https://forum.universal-robots.com/u/anon75015020)\
**Post date:** [June 4, 2018, 7:23am UTC](https://forum.universal-robots.com/t/accessing-waypoints-poses-in-ur-script/2056/3 "2018-06-04T07:23:48Z")

</div>

Thanks for your reply !

---

<div class="post-metadata">

**Author:** ![anon4270358](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@anon4270358](https://forum.universal-robots.com/u/anon4270358)\
**Post date:** [April 3, 2020, 9:21am UTC](https://forum.universal-robots.com/t/accessing-waypoints-poses-in-ur-script/2056/4 "2020-04-03T09:21:16Z")

</div>

Hello ajp

i am having similar troubles with scripts and poses. I have analized and conclude the same as you, as i see that you are well informed about this topic i would like to ask if you know a way to modify a pose value in a script, i have tried different ways, but i have not foud the correct method, i would really appreciate if you can help.

Best Regards

Miguel

---

<div class="post-metadata">

**Author:** ![anon6218630](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@anon6218630](https://forum.universal-robots.com/u/anon6218630)\
**Post date:** [April 6, 2020, 6:39pm UTC](https://forum.universal-robots.com/t/accessing-waypoints-poses-in-ur-script/2056/5 "2020-04-06T18:39:32Z")

</div>

I’m not sure if you are able to edit waypoint values through a script. You are however able to use the waypoint values by taking the name of your waypoint and appending it with an \_p for a pose or an \_q for the joint values.

For example, if I have a waypoint defined in polyscope called `wpStart`…  
To use `wpStart` in my custom script function, I can call `wpStart_p` for the pose and `wpStart_q` for the joint values. To edit these values, you would most-likely assign a new variable (pose) with the value `wpStart_p` and make any modifications to that variable.

E.g. `pMid = pose_trans(wpStart_p,p[0,0,0.05,0,0,0])`

I hope this helps!

---

<div class="post-metadata">

**Author:** ![anon4270358](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@anon4270358](https://forum.universal-robots.com/u/anon4270358)\
**Post date:** [April 7, 2020, 12:37pm UTC](https://forum.universal-robots.com/t/accessing-waypoints-poses-in-ur-script/2056/6 "2020-04-07T12:37:23Z")

</div>

Hello navk

Thanks for your reply, i just tested what you have recommend but unfortunately, it is not working for me, i am using version 3.11, do you have any further tips?

Regards Miguel

---

<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:** [April 8, 2020, 4:39am UTC](https://forum.universal-robots.com/t/accessing-waypoints-poses-in-ur-script/2056/7 "2020-04-08T04:39:07Z")

</div>

Hi @miguel

These \_p and \_q values are only available in e-Series 5.x software, not CB3 3.x.

What are you trying to do exactly? You can modify individual elements in a pose the same way as your can in a list - eg:

```
a = Waypoint_1
a[0] = 0.2
```

---

<div class="post-metadata">

**Author:** ![anon4270358](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@anon4270358](https://forum.universal-robots.com/u/anon4270358)\
**Post date:** [April 8, 2020, 6:26am UTC](https://forum.universal-robots.com/t/accessing-waypoints-poses-in-ur-script/2056/8 "2020-04-08T06:26:16Z")

</div>

HI @ajp

i have a program where i have teached a lot of positions, there is a lot of programing logic and also scripting, now we have to deliver the machine and our end customer has requested a suitable teach mode for our robot, my client has someone on site that can teach positions but as the code is a little complex, my customer does not want to look for every positions in the code.

I try to program a teach mode in a separete urp, the first part is done i have the same waypoints and i save the data in installation variables.

Unfortuantely i have not achieved the second part, the second part consists in reading this installation variables and assigning it to the real waypoints avoiding the complexity to look for these positions in the software.

i am glad to hear suggestions

Best Regads

Miguel

---

<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:** [April 8, 2020, 10:59am UTC](https://forum.universal-robots.com/t/accessing-waypoints-poses-in-ur-script/2056/9 "2020-04-08T10:59:17Z")

</div>

I’m not sure I fully understand your scenario… How many waypoints do you have that need to be modified? Are they defined in Script or Polyscope Waypoints?

If they are Polyscope Waypoints could you put copies of the key waypoints (linked to the waypoints down further in the program) in a folder at the start of the program that is not executed? If they have clear well defined names, these could be adjusted, and then the linked waypoint further down the program would also change.

Example below. Move command inside If False node would not execute.

 ![2020-04-08_18-55-47](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/2X/a/aa221441a522022cf7aefd3ef127d814c22a41fd.png)

---

<div class="post-metadata">

**Author:** ![je1](https://avatars.discourse-cdn.com/v4/letter/j/8dc957/32.png) [@je1](https://forum.universal-robots.com/u/je1)\
**Post date:** [July 10, 2020, 10:39am UTC](https://forum.universal-robots.com/t/accessing-waypoints-poses-in-ur-script/2056/10 "2020-07-10T10:39:40Z")

</div>

Hi @ajp, can you provide a code sample for what you did 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:** [July 13, 2020, 1:41am UTC](https://forum.universal-robots.com/t/accessing-waypoints-poses-in-ur-script/2056/11 "2020-07-13T01:41:02Z")

</div>

Hi @je1,

This was all just laid out in Polyscope using the link waypoints function for the sake of the screenshot, no code behind it really. What are you looking for in a sample?

---

<div class="post-metadata">

**Author:** ![je1](https://avatars.discourse-cdn.com/v4/letter/j/8dc957/32.png) [@je1](https://forum.universal-robots.com/u/je1)\
**Post date:** [July 13, 2020, 3:11pm UTC](https://forum.universal-robots.com/t/accessing-waypoints-poses-in-ur-script/2056/12 "2020-07-13T15:11:36Z")

</div>

Hi,  
thank you for the reply. I am not sure how to Add the “BeforeStart” Folder outside of the RobotProgram, while coding. I attach a screenshot of the function I have. I want it to be created before the RobotProgram tree, like on your screenshot.

 ![create_subtree](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/2X/2/27dcce7feca1c7f1be60c3acffc8e185cb3ee025.png)

---

<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:** [July 14, 2020, 1:58am UTC](https://forum.universal-robots.com/t/accessing-waypoints-poses-in-ur-script/2056/13 "2020-07-14T01:58:53Z")

</div>

Hi @je1,

I’m afraid I’m not equipped to provide much support on the Java SDK so one of the other guys can hopefully answer that question.

One alternative approach that I could recommend from a Polyscope perspective would be to add a folder below the Robot Program that doesn’t get executed, but again can’t tell you exactly how to do that in Java.
