Remote Procedure Call (RPC)

Remote Procedure Calls (RPC) are similar to normal function calls, except that the function is defined and executed remotely. On the remote system, the RPC function being called must exist with the same number of parameters and corresponding types (together, the function’s signature). If the function is not defined remotely, it stops program execution. The controller uses the XMLRPC standard to send the parameters to the remote site and retrieve the result(s). During an RPC call,  the controller waits for the remote function to complete.  The XMLRPC standard is, among others, supported by C++ (xmlrpc-c library), Python, and Java.

Creating a URScript program to initialize a camera, take a snapshot and retrieve a new target pose:

camera = rpc_factory("xmlrpc", "http://127.0.0.1/RPC2")
if (! camera.initialize("RGB")):
   popup("Camera was not initialized")
camera.takeSnapshot()
target = camera.getTarget()
camera.closeXMLRPCClientConnection()
...

First the rpc_factory (see Interfaces section) creates an XMLRPC connection to the specified remote server. The camera variable is the handle for the remote function calls. You must initialize the camera and therefore call camera.initialize("RGB").

The function returns a boolean value to indicate if the request was successful. To find a target position, the camera first takes a picture, hence the camera.takeSnapshot() call. Once the snapshot is taken, image analysis on the remote system calculates the location of the target. The program then requests the exact target location with the function call target = camera.getTarget().  On return, the target variable is assigned the result. The camera.initialize("RGB"), takeSnapshot(), and getTarget() functions are the responsibility of the RPC server.

The closeXMLRPCClientConnection function closes the XMLRPC connection created by the rpc_factory. It is recommended to close the connection periodically, or when it is not used for a longer time. Some server implementations have a default limit on RPC requests or inactivity watchdog timers.

The RPC handle does not automatically close the connection.

The technical support website: http://www.universal-robots.com/support contains more examples of XMLRPC servers.