Advantech Robotic Suite/OPCUAClient Node
Contents
Brief
The OPC Unified Architecture (UA), released in 2008, is a platform independent service-oriented architecture that integrates all the functionality of the individual OPC Classic specifications into one extensible framework.
OPCUAClient Node is a ROS2 node, it can be set to subscribe data form OPCUA server and provide ROS2 DDS topic for user to subscribe, user can quickly receive OPCUA data and do the post data process, for example data parse/store/analysis etc. Below chapter will introduce you about how to use OPCUAClient Node.
Topic definition
The topic of OPCUA node data are defined as below:
/adv/opcuaclient
Message definition
The messages definition of SUSI node is defined in below link:
http://ess-wiki.advantech.com.tw/view/Advantech_Robotic_Suite/Advantech_ROS2_Data_Format
Configuration
To config OPCUA node settings, please refer the guide: http://ess-wiki.advantech.com.tw/view/OPC-UA_Client
Message update
The message is updated periodically, you can use ROS2 utility to verify the data update:
Subscribe Sensor using ROS2 utility
Step1. Setup ROS2 environmant variables:
$ source /opt/ros/${ROS_DISTRO}/setup.bash
Step2. Setup OPCUAClient Node message:
$ source /usr/local/Advantech/ros/${ROS_DISTRO}/include/edge-converter-ros2/adv_msgs/install/local_setup.bash
Step3. List all topics:
$ ros2 topic list
output:
/adv/parameter_events /adv/opcuaclient /parameter_events /rosout
Step4. Subscribe node data
$ ros2 topic echo /adv/opcuaclient
output:
--- sensor: OPCUAClient/OPCUA-01/Node/Temperature type: v bv: false v: 25.713000000426085 sv: '' ts: 1677661555546 --- sensor: OPCUAClient/OPCUA-01/Node/Humidity type: v bv: false v: 59.999999999653745 sv: '' ts: 1677661556561 ---
Sample Client
This session describe how to subscribe OPCUA node data by node's topic.
Node.js
The program rclnodejs_edge_data_client is a node.js example for user to learning how to use rclnodejs client to subscribe OPCUA node's data. Please follow below steps to run the program, when the program launched, it will subscribe OPCUA node's sensor data and print the data in the console screen.
Steps - Subscribe Sensor
Step1. Setup ROS2 environmant variables, replace ${ROS_DISTRO} with your ROS2 distribution (foxy, humble) to run this command:
$ source /opt/ros/${ROS_DISTRO}/setup.bash
Step2. Setup OPCUAClient NodeS message:
$ source /usr/local/Advantech/ros/${ROS_DISTRO}/include/edge-converter-ros2/adv_msgs/install/local_setup.bash
Step3. Go to node.js OPCUA sample path:
$ cd /usr/local/Advantech/ros/${ROS_DISTRO}/sample_code/edge-data-client/rclnodejs_edge_data_client/
Step4. Run node.js OPCUA sample:
$ node example_SubscribeSensor.js "rclnodejs_OPCUAClient_subscriber" "/adv/opcuaclient"
Step5. Verify received data:
You have entered arguments: node name: rclnodejs_OPCUAClient_subscriber message topic: /adv/opcuaclient ---------------------------------------------- Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.98247999955607 Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.396799999928998 Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.98223999955607 Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.372799999928997 Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.98199999955607 Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.348799999928996 Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.981759999556076 Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.324799999928995 Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.98151999955608 Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.300799999928994 Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.98127999955608 Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.276799999928993 Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.98103999955608 Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.252799999928992
Steps - Set sensor
This session describe how to set OPCUA data by set action. To run the set sensor sample, your device need have writable sensor supported for OPCUA driver.
Step1. Setup ROS2 environmant variables, replace ${ROS_DISTRO} with your ROS2 distribution (foxy, humble) to run this command:
$ source /opt/ros/${ROS_DISTRO}/setup.bash
Step2. Setup OPCUAClient NodeOS Message:
$ source /usr/local/Advantech/ros/${ROS_DISTRO}/include/edge-converter-ros2/adv_msgs/install/local_setup.bash
Step3. Go to node.js OPCUA sample path:
$ cd /usr/local/Advantech/ros/${ROS_DISTRO}/sample_code/edge-data-client/rclnodejs_edge_data_client/
Step4. Run OPCUA node set sensor sample:
Command:
node example_SetSensor.js [node name] [action] [sensor] [type] [value]
Example:
$ node example_SetSensor.js "rclnodejs_OPCUAClient_setter" "adv_opcuaclient_set" "OPCUAClient/OPCUA-01/Node/Temperature-SetPoint" "v" 26
Step5. Received data:
[INFO] [1671432195.232498528] [adv.rclnodejs_OPCUAClient_setter]: Waiting for action server... [INFO] [1671432195.890056725] [adv.rclnodejs_OPCUAClient_setter]: Sending goal request... [INFO] [1671432196.076197797] [adv.rclnodejs_OPCUAClient_setter]: Goal accepted [INFO] [1671432196.310811395] [adv.rclnodejs_OPCUAClient_setter]: Received feedback: status = {"status":200,"sensor":"OPCUAClient/OPCUA-01/Node/Temperature-SetPoint","info":"Success","ts":1671432196198} [INFO] [1671432196.331143326] [adv.rclnodejs_OPCUAClient_setter]: Goal suceeded with result: 202
Python
The program rclpy_edge_data_client is a Python client example for user to understand how to use rclpy to subscribe OPCUA node's data. Please follow below steps to run the program, when the program launched, it will subscribe OPCUA node's sensor and print the data in the console screen.
Steps - Subscribe Sensor
Step1. Setup ROS2 environmant variables, replace ${ROS_DISTRO} with your ROS2 distribution (foxy, humble) to run this command:
$ source /opt/ros/${ROS_DISTRO}/setup.bash
Step2. Setup OPCUAClient Node message:
$ source /usr/local/Advantech/ros/${ROS_DISTRO}/include/edge-converter-ros2/adv_msgs/install/local_setup.bash
Step3. Setup OPCUA sample variables:
$ source /usr/local/Advantech/ros/${ROS_DISTRO}/sample_code/edge-data-client/install/local_setup.bash
Step4. Run Python OPCUA sample:
$ ros2 run rclpy_edge_data_client listener "rclpy_OPCUAClient_subscriber" "/adv/opcuaclient"
Step5. Verify received data:
You have entered arguments: node name: rclpy_OPCUAClient_subscriber message topic: /adv/opcuaclient ---------------------------------------------- Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.98247999955607 Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.396799999928998 Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.98223999955607 Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.372799999928997 Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.98199999955607 Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.348799999928996 Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.981759999556076 Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.324799999928995 Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.98151999955608 Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.300799999928994 Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.98127999955608 Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.276799999928993 Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.98103999955608 Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.252799999928992
C++
The program rclcpp_edge_data_client is a C++ example for user to understand how to use rclcpp to subscribe OPCUA node's data. Please follow below steps to run the program, when the program launched, it will subscribe OPCUA node's sensor and print the data in the console screen.
Steps - Subscribe Sensor
Step1. Setup ROS2 environmant variables, replace ${ROS_DISTRO} with your ROS2 distribution (foxy, humble) to run this command:
$ source /opt/ros/${ROS_DISTRO}/setup.bash
Step2. Setup OPCUAClient Node message:
$ source /usr/local/Advantech/ros/${ROS_DISTRO}/include/edge-converter-ros2/adv_msgs/install/local_setup.bash
Step3. Setup OPCUA node variables:
$ source /usr/local/Advantech/ros/${ROS_DISTRO}/sample_code/edge-data-client/install/local_setup.bash
Step4. Run Python OPCUA sample client:
$ ros2 run rclcpp_edge_data_client listener "rclcpp_OPCUAClient_subscriber" "/adv/opucaclient"
Step5. Verify received data:
You have entered arguments: node name: rclcpp_OPCUAClient_subscriber message topic: /adv/opcuaclient ---------------------------------------------- Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.98247999955607 Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.396799999928998 Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.98223999955607 Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.372799999928997 Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.98199999955607 Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.348799999928996 Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.981759999556076 Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.324799999928995 Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.98151999955608 Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.300799999928994 Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.98127999955608 Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.276799999928993 Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.98103999955608 Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.252799999928992