# Variable Waypoint using both Tool Position and Joint Position

**URL:** <https://forum.universal-robots.com/t/variable-waypoint-using-both-tool-position-and-joint-position/21395>\
**Category:** Technical Questions\
**Created:** [May 18, 2022, 6:45am UTC](https://forum.universal-robots.com/t/variable-waypoint-using-both-tool-position-and-joint-position/21395 "2022-05-18T06:45:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![francis](https://avatars.discourse-cdn.com/v4/letter/f/ac8455/32.png) [@francis](https://forum.universal-robots.com/u/francis)\
**Post date:** [May 18, 2022, 6:45am UTC](https://forum.universal-robots.com/t/variable-waypoint-using-both-tool-position-and-joint-position/21395/1 "2022-05-18T06:45:32Z")

</div>

Is there a way in Java to create a variable waypoint, with that waypoint using both Tool Position and Joint Position?

I am currently able to create a variable waypoint with Tool Position using the code

> ExpressionBuilder eb = programAPI.getValueFactoryProvider().createExpressionBuilder();  
> var = vf.createGlobalVariable(getInstallationNode().getWaypointNameFromModel(selectedWaypoint), eb.append( **posToVar**.toString()).build()); `⇐This is my Position Details getting added to the global variable`  
> approachConfig = waypointNode.getConfigFactory().createVariablePositionConfig(var, approachWaypointDefaultBlends, approachMotionParams);  
> waypointNode.setConfig(approachConfig);

Is there a way to include the Joint Position details into the same variable?  
My expected outcome is that, after successfully adding the Joint Position details, when I use that waypoint in a program and start it, it will generate both GlobalVariable\_p for Tool Position details and GlobalVariable\_q for Joint Position details.

If anyone has any idea or could steer me in the right direction, your help will be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![aswathamang](https://avatars.discourse-cdn.com/v4/letter/a/b5a626/32.png) [@aswathamang](https://forum.universal-robots.com/u/aswathamang)\
**Post date:** [May 18, 2022, 11:58am UTC](https://forum.universal-robots.com/t/variable-waypoint-using-both-tool-position-and-joint-position/21395/2 "2022-05-18T11:58:48Z")

</div>

Hai @francis ,Sorry to say that I only understood your question partially, I assume that you are using the URCaps SDK for developing the program. So can actually make that is what I think. To put it as a rough sketch you can actually create two variables GlobalVariable\_p, GlobalVariable\_q with dummy values and assign the proper values once you wish to assign it using a getter , setter function calls.

To get the joint position you can verify this [JointPositions (api 1.3.0 API)](https://plus.universal-robots.com/apidoc/40237/com/ur/urcap/api/domain/value/jointposition/jointpositions.html),

To move the robot by actually generating and executing a urscript using the SDK as shown shown here:- [com.ur.urcap.api.domain.script (api 1.3.0 API)](https://plus.universal-robots.com/apidoc/40237/com/ur/urcap/api/domain/script/package-summary.html)

---

<div class="post-metadata">

**Author:** ![francis](https://avatars.discourse-cdn.com/v4/letter/f/ac8455/32.png) [@francis](https://forum.universal-robots.com/u/francis)\
**Post date:** [May 19, 2022, 1:18am UTC](https://forum.universal-robots.com/t/variable-waypoint-using-both-tool-position-and-joint-position/21395/3 "2022-05-19T01:18:31Z")

</div>

@aswathamang Thank you for your response.  
Yes, I am developing using URCaps SDK.  
I have a JointPosition object but I can’t find a way to integrate it into the waypoint variable.  
Waypoint0 is a waypoint variable I have added programmatically using tcp position and angles.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/2X/4/40aac3d8b6887c9a5ccaefed966e2c52e709fb26.png)

Below is the variables registered once I run my program.  
It only uses the tcp position and angles.  
If I was able to also add the joints position, I expect that a Waypoint0\_p for tcp position and angles, and a Waypoint0\_q for joints position will be generated.

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

If I understand correctly, what you’re suggesting is that use ScriptWriter to set the tcp position, angles and joints position, and movej to that waypoint.  
If so, instead of the MoveJ and Waypoint0 nodes, I would create a script node?

Sorry if it’s hard to understand. I’m fairly new to URCaps programming myself.
