python-opcua is an open source pure python library for OPC UA communication. It implements client/server communication method of OPC UA standard and include many features of the standards(security, address space, information model, DA, HA, A&E, invoking method, etc.). Its official webpage url is https://github.com/FreeOpcUa/python-opcua. As of this writing this library is deprecated.
In this article we will illustrate how to read/write data and invoke method from Elite CS series robot through OPC UA communication by using the client library.
Connect PC to robot controller at port 'FB1'.
1. Make sure system version is 2.30 or above.
1. Make sure openssl library version is 1.1.1g or above
2. Install python-opcua library. Please refer to its webpage for installation steps.https://github.com/FreeOpcUa/python-opcua#installation
1. Download the attached python client program. 📎client-minimal.py
2. Open a terminal and issue the following commands to generate X509 certificate and private key
elite@ubuntu:~$ openssl req -x509 -newkey rsa:2048 -keyout my_private_key.pem -out my_cert.pem -days 355 -nodes -addext "subjectAltName = URI:urn:open62541.server.application"
elite@ubuntu:~$ openssl x509 -outform der -in my_cert.pem -out my_cert.der
3. Open the program file and modify variable settings to match the real configuration.
ip = "192.168.1.10" # ip address of robot controller FB1 port
port = "4840" # port for OPC UA service. No need to change
app_uri = "urn:open62541.server.application" # application uri for OPC UA server. No need to change
security_policy = "Basic256Sha256" # security policy. No need to change
security_mode = "SignAndEncrypt" # security mode. No need to change
cert = "my_cert.pem" # change it to the certificate generated in previous step
p_key = "my_private_key.pem" # change it to the private key generated in previous step
user = "elite" # user name for authentication. No need to change
password = "elibot" # password for authentication. No need to change
4. Save program and execute it in terminal.
elite@ubuntu:~$ python3 client-minimal.py
Program runs and prints the result.
· To retrieve node by id, node's id can be found in the [Attributes] panel of 'UA Expert'.
is_power_on = client.get_node("ns=1;i=54319")
· To trace node in the address space tree, provide the path from root node all the way to leaf node.
myvar = root.get_child(["0:Objects", "1:EliteROBOTS","6:Controller","6:ControllerOperatingInfo","6:Status","6:RobotMode"])
Each node's name can be referenced in the [Attributes] panel in 'UA Expert'.
· The complete library API can be referenced here:https://python-opcua.readthedocs.io/en/latest/#
The Python client program may not be able to connect to Elite robot successfully.
If this problem occurs to you, please download the modified program file 📎client.pyand overwrite the one in your own python opc-ua library(better backup the old program first). In case of python bundled pip, it should be in the location: ~/.local/lib/python3.x/site-packages/opcua/client