Using the OPC UA Service
************************

Enabling the OPC UA Service
===========================

The OPC UA service is by default enabled on Franka robot FP3/FR3. To check if the feature
is enabled on your robot go to *Settings* -> *System* -> *Installed Features*. If the list contains
*OPC UA* the service is enabled and ready to be used.

.. note::

   A manually disabled feature can be re-enabled in the Franka World. More information of how to install
   a feature can be found in the `Franka World Manual <https://download.franka.de/franka-world-manual/>`_.


Connect to and browse the OPC UA Server
=======================================

This documentation explains how to connect to the robot's OPC UA server and access its functionality via the software `uaExpert <https://www.unified-automation.com/products/development-tools/uaexpert.html>`_.

Starting uaExpert
-----------------

.. figure:: img/uaExpert_startup.png
    :width: 100%
    :align: center
    :alt: alternate text
    :figclass: align-center

    Main screen of uaExpert after startup

The general user interface of uaExpert consists of several areas. The most important areas for browsing the OPC UA server of Franka robots, are the following:

+---------------+----------+---------------------------------------------------------------------------+
| Area Name     | Description                                                                          |
+===============+==========+===========================================================================+
| Project       | Shows all OPC UA servers that have been configured                                   |
+---------------+----------+---------------------------------------------------------------------------+
| Address Space | Shows the hierarchy tree with all items, that the OPC UA server provides             |
+---------------+----------+---------------------------------------------------------------------------+
| Attributes    | Shows the detailed settings of the currently selected item in the address space area |
+---------------+----------+---------------------------------------------------------------------------+
| Log           | Shows log messages                                                                   |
+---------------+--------------------------------------------------------------------------------------+

Creating a new Server and Connecting to it
------------------------------------------

First, you need to add the OPC UA server of the robot. In order to do that, select *Server* / *Add* from the menu bar.

.. figure:: img/uaExpert_addServer.png
    :width: 250pt
    :align: center
    :alt: alternate text
    :figclass: align-center

    Adding a new server

You need to fill out the input fields, as in the example image above. If you are running the OPC UA service as a feature of the robot, the *Endpoint URL* will be the IP address of the robot. If you are running the OPC UA service externally, use the IP adress of the device which is running the service. The default OPC UA port is 4840. UAExpert should use this port by default if you do not specify any particular port.

As username and password, you have to use the username and password which you use when logging in to the robot with your webbrowser via ``robot.franka.de``.

**Please be aware, that currently the password is not encrypted and will be transmitted in plain text.**

.. _ua-expert-browse:

Browsing the OPC UA server
--------------------------

After successful connection, all items of the OPC UA server are hierarchically displayed in the *Address Space* area. You can click on items to expand and inspect them.

.. figure:: img/uaExpert_browse.png
    :width: 100%
    :align: center
    :alt: alternate text
    :figclass: align-center

    Browsing the OPC UA Server

Right click on method items and select *Call* from the context menu to call them. Doing so will display a new window, in which you can configure the input arguments to the method call. After clicking the *Call* button, the output results will be shown in the same window.

.. figure:: img/uaExpert_callMethod.png
    :width: 250pt
    :align: center
    :alt: alternate text
    :figclass: align-center

    Calling a method with uaExpert and inspecting the return value
