URCap - UR Software Architecture
This article is aimed at URCap Developers.
/Overview of UR software architecture
The UR Controller has two main software processes, that are important to the operation of a URCap.
Understanding their interaction may ease the development of a URCap.
/PolyScope
PolyScope is the graphical programming interface of Universal Robots.
It is the graphical interface, that the user interacts with to build and operate the robot program.
URCaps are plugins, which live inside PolyScope as OSGi-bundles.
/URControl
URControl is the real-time controller, that controls robot motion and executes robot programs.
Essentially, URControl receives the desired program from PolyScope, and converts this into commands that the individual joints follow.
When the user is developing their program in PolyScope, there are two main programming domains to consider. URCaps can contribute to either section. That is respectively program nodes, and installation nodes.
/Program node
Program nodes are ordered in a program tree, and make out the sequence that the robot executed, when running a program.
In respect to built-in nodes, this includes the Waypoint command, that makes up a position the robot moves to, when reaching this place in the program. The Set and Wait nodes are used to respectively set an output to a state, or wait for an input to reach a certain state, when reached in the program. Program nodes for branching such as If-Else and Switch-Case can be used to control the program flow. In essence, program nodes should be used for commands that should happen at a particular time in an application.
For a URCap this could typically include opening or closing a gripper, performing a picking sequence for a vision system or sending a message to a logging system.
Program nodes are generally designed to happen in every sequence of a program - i.e. calibration of a camera does not belong here.
When program nodes are placed in a program sequence, they are stored in a UR Program file (.urp).
/Installation node
Installation nodes contain setup and environment settings. They are not ordered, and contains configuration options for the area.
For build-in nodes this includes Tool Center Point configuration, payload of the empty end-effector, safety system configuration, environment coordinate systems, fieldbus setup etc.
An Installation (the collective of all Installation nodes) typically corresponds to a physical location the robot is located - i.e. the robots environment. Multiple Installations can be used, which will typically happen when a robot is physically moved within a production. In that sense each installation node can reflect its settings when the robot is located at that particular location.
For a URCap the Installation node should typically be used for basic configuration (IP address, and connection to an external device. Configuration of mounted hardware or connections, such as the mounting of an end-effector, or which terminals are used for electrical signals. Calibration/alignment of vision systems, and teaching of workpieces/parts to locate also belong in the installation domain.
Installation nodes have an option, to commit program code to the very beginning of a program, hence they are also good for initialization of hardware or initialization of variables used by the program nodes.
Installation nodes are saved in the Installation file (.installation), by default, that file is called "default.installation" unless unnamed by the user.
/Flow of control
When the user is building the program, using program nodes and installation nodes, each node contain their information in a DataModel object. The DataModel reflect the particular nodes configuration, as configured by the user. When the user eventually desires to execute the program by pressing the Play button, every node present in the program and installation are queried to contribute their URScript code. URScript code is the run-time code, that is being executed in a program.
Therefore the main objective of a node, is to be able to generate such URScript based on the users configuration.
Installation nodes contribute script to the pre-amble, and program nodes contribute script at their respective location in the program.
In the above example, the Installation nodes TCP and Mounting respectively contribute the URScript for configuring the robots Tool Center Point and payload, configured in the node, and defining the direction of gravity based on the robots mounting selection.
Following that, each program node contribute one or multiple lines of URScript, at their respective locations in the program. Nodes that are parent nodes (such as the Robot Program or If-statement) can both add URScript before and after their children. E.g. for the If-statement, that adds the if-statement code, then allows its children to add their code, in this case a Waypoint adding a move-command, and finally adds the "end"-statement to close off the if-statement.
A leaf node, such as the Waypoint or Set command can only add code at their own location, and are hence adding respectively a move-command and a script command to toggle a digital output.
The Move-node itself is not adding any script to the program, however the Move-node contains general parameters for any Waypoint-child-node, in this case defining the motion parameters to 1,2 m/s2 in acceleration, and a velocity of 0,5 m/s.
After all Installation Nodes and Program Nodes have built their own URScript, PolyScope will combine the complete script into a program definition. Putting the installation nodes URScript in a pre-amble (for purposes of initialization), and then building the program consisting of program nodes.
This complete URScript is sent to URControl. that takes care of actually executing this code, eventually making the robot move, and perform the other tasks included in the program.
URControl and PolyScope communicate using the Primary Client Interface (port 30001).
PolyScope by sending script-programs to URControl, and URControl constantly transmit information about the robot back to PolyScope, to be portrayed in the user interface.
As the user press Play, and PolyScope have collected the URScript code of every node, the complete script will be sent as a program to URControl using the Primary Client Interface.
When URControl have received the URScript code, URControl will start executing the script code line-by-line.
Typically, the program node part of the program will loop forever, making URControl repeat that particular sequence once and again, until the user decides to terminate the program.
When the program is playing, there is no interaction with the URCap nodes, hence all actions that should happen at run-time, should be executed in URScript.
Note:
If it is required, to execute customary code at runtime, it is possible for a URCap to add a daemon service, that can run in parallel to PolyScope and URControl. In this recpect, URScript can call into this daemon using interfaces such as XML-RPC or TCP sockets.