Universal Robots+

Adding ready .urp subprogram by clicking the button


I have a ready working URScript with some subprograms. I want to use the URCap, so that the user can specify what setup he has and when he’s done, he would click a button such as in the PickorPlace example to create a tree. Based on user’s answers in the UI part, different subprograms would show up in the tree. I have the subprograms ready in .urp. Next step is that, the user should teach the waypoints in the subprograms (these are essentially subprograms for specific movements, like BIN_2_HOME). When ready the program could be run or saved for future use.

I saw some threads where GenerateScript method and appendRaw were used, but from what I understand it is only executed when the program is run. I need to create the tree beforehand and have some parts in yellow, so that the program can’t be run, before waypoints are taught.

What should be my approach?


i don’t know if i got this right - i think what you mean is you want the program not to be defined until the waypoints of your user-selected program are set. Is that right?

In this case, you can use the isDefined() function of your child urcap nodes to check if they have children (e.g.waypoint nodes), if not, return false.

thanks for the reply. Yes, I want that and I am aware of that feature.

My questions are: is it possible to create a subprogram from a ready .urp file or script? Can this subprogram have undefined waypoints? Is it possible to add that subprogram to the Robot Program when a button is clicked?

When I transfer the main program into the URCap, how can I do it neatly? Do I have to rewrite it, can I pass the UR script when the button is clicked? My idea is to create the main structure using java commands and add the ready code in the needed places, but from what I understand the AppendLine/AppendRaw functions can be executed only, when the program is run. So I am not sure how to do it.


there is no possiblity to build nested urp files unless you implement an xml parser that can read the urp files and insert the necessary information in the other ur program.

What you can do tho is either implement a urcap that parses an existing URScript File from your URCap resources or even any Script File that is located on the robot.

What i did in this case was to save the information (e.g. waypoint data or movement configuration) in the datamodel of the parent urcap and insert the data into the scriptwriter for program execution

You can also add this without Waypoint information but this depends on your task (?) If you saved your waypoint information in another node you can call this data from a script variable name using the global scope.

Hi, thank you again for the reply.

I’ll parse an exisiting URScript File.

One last question:
Do you know what command to use to create a subprogram in the tree? A simple example in the photo. I did this in the Structure tab, but would like to put a command in a function in the ContributionNode.


you can’t insert a program node or folder on the top level robot program tree from a urcap. What you can do is implementing a urscript function in the installationnode of your urcap which is then inside the robot program preamble and can be called any time in your robot program

Ok, now I understand what I need to do. Thank you :slight_smile:

I’ll have URscript functions in the installation node and I will create some teachable key_waypoint variables, like in this post: Accessing Waypoints/Poses in UR Script, which I will pass into the script functions.

My last uncertainty is how should I call the urscript function IN ANY PLACE in the robot program? what syntax should it have? I know I can write write.append(“Program_Name(variables)”) in the Generate Script, but how to call it in any place I need?