OPC UA Client Example

This example will show you how you can add OPC-UA Client connectivity to RoboDK. RoboDK includes an OPC-UA add-in that allows you to add OPC UA compatibility to your RoboDK projects.

In this example you’ll learn how to get the data from the RoboDK Station via OPC UA Client.

OPC UA - Image 63

Station parameters screen is displayed and press “Clear All” to delete all Station parameters.

OPC UA - Image 64

Implementation with Interface

We can create one more RoboDK project with the OPC UA server is configurated and started.

OPC UA - Image 65

Add Client

This section shows how to add an OPC UA client.

Enter the Endpoint URL, for example: opc.tcp://127.0.0.1:48441.

You need to match the IP address and port configuration to your Target OPC UA server.

OPC UA - Image 66

Press “Connect” to establish the connection.

if there is a message with” Server variables retrieved. Right Click the station item and select ‘Station parameters’ to see the variables.”, the connection is established.

OPC UA - Image 67

Right Click your Station and select “Station parameters”.

OPC UA - Image 68

Nodes

You can check the details of each Node from the nodes section.

OPC UA - Image 69

Implementation with the RoboDK API

After you get the Nodes data from OPC UA Server via OPC UA client in RoboDK, you can also get these data by using RoboDK-Python-API.

Installation

You can reference this link to install the RoboDK Python-API.

https://robodk.com/doc/en/PythonAPI/intro.html#how-to-install

Or install the robodk package for Python manually:

pip install robodk

Script

This example script shows how to get the station parameters via the Python API of RoboDK.

from robodk import robolink    # RoboDK API

 

RDK = robolink.Robolink()

 

from robodk import *      # RoboDK API

from robolink import *    # Robot toolbox

itemlist = RDK.ItemList()

if itemlist:

# Get all Station Parameters

print('Vaild Paramaters are configurated in your Station..')

StationParameters=RDK.getParams()

for StationParameter in StationParameters:

    print("Station Parameters %s : %s"%(StationParameter[0],str((StationParameter[1]))))

else:

print('No Parameter list..')

Here is the result of the Example Script:

Vaild Paramaters are configurated in your Station..

Station Parameters RoboDK : RoboDK 64 bit v5.5.3.23031

Station Parameters time : 02/14/2023 03:58:29.191.000.000

Station Parameters SimulationSpeed : 13.8551

Station Parameters Station : MyTestStation