Advantech Robotic Suite/OPCUAClient Node
= 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.
OPCUA Node is a ROS node for user to subscribe sensor form OPCUA server, user can use OPCUA data in the user's subscriber program and do the post procedure, for example parse/store/analysis etc.
Contents
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/ROS2_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
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 foxy environmant variables:$ source /opt/ros/foxy/setup.bashStep2. Setup Advantech ROS Message:
$ source /usr/local/Advantech/ros/foxy/include/edge-converter-ros2/adv_msgs/install/local_setup.bashStep3. Go to node.js OPCUA sample path:
$ cd /usr/local/Advantech/ros/foxy/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:<br/> node name: rclnodejs_OPCUAClient_subscriber<br/> message topic: /adv/opcuaclient<br/> ----------------------------------------------<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.98247999955607<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.396799999928998<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.98223999955607<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.372799999928997<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.98199999955607<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.348799999928996<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.981759999556076<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.324799999928995<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.98151999955608<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.300799999928994<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.98127999955608<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.276799999928993<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.98103999955608<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.252799999928992<br/>
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 foxy environmant variables:$ source /opt/ros/foxy/setup.bashStep2. Setup Advantech ROS Message:
$ source /usr/local/Advantech/ros/foxy/include/edge-converter-ros2/adv_msgs/install/local_setup.bashStep3. Go to node.js OPCUA sample path:
$ cd /usr/local/Advantech/ros/foxy/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" 26Step5. Received data:
[INFO] [1671432195.232498528] [adv.rclnodejs_OPCUAClient_setter]: Waiting for action server...<br/> [INFO] [1671432195.890056725] [adv.rclnodejs_OPCUAClient_setter]: Sending goal request...<br/> [INFO] [1671432196.076197797] [adv.rclnodejs_OPCUAClient_setter]: Goal accepted<br/> [INFO] [1671432196.310811395] [adv.rclnodejs_OPCUAClient_setter]: Received feedback: status = {"status":200,"sensor":"OPCUAClient/OPCUA-01/Node/Temperature-SetPoint","info":"Success","ts":1671432196198}<br/> [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 foxy environmant variables:$ source /opt/ros/foxy/setup.bashStep2. Setup Advantech ROS Message:
$ source /usr/local/Advantech/ros/foxy/include/edge-converter-ros2/adv_msgs/install/local_setup.bashStep3. Setup OPCUA sample variables:
$ source /usr/local/Advantech/ros/foxy/sample_code/edge-data-client/install/local_setup.bashStep4. Run Python OPCUA sample:
$ ros2 run rclpy_edge_data_client listener "rclpy_OPCUAClient_subscriber" "/adv/opcuaclient"Step5. Verify received data:
You have entered arguments:<br/> node name: rclpy_OPCUAClient_subscriber<br/> message topic: /adv/opcuaclient<br/> ----------------------------------------------<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.98247999955607<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.396799999928998<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.98223999955607<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.372799999928997<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.98199999955607<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.348799999928996<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.981759999556076<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.324799999928995<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.98151999955608<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.300799999928994<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.98127999955608<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.276799999928993<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.98103999955608<br/> 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 foxy environmant variables:$ source /opt/ros/foxy/setup.bashStep2. Setup Advantech ROS Message:
$ source /usr/local/Advantech/ros/foxy/include/edge-converter-ros2/adv_msgs/install/local_setup.bashStep3. Setup OPCUA node variables:
$ source /usr/local/Advantech/ros/foxy/sample_code/edge-data-client/install/local_setup.bashStep4. 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:<br/> node name: rclcpp_OPCUAClient_subscriber<br/> message topic: /adv/opcuaclient<br/> ----------------------------------------------<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.98247999955607<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.396799999928998<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.98223999955607<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.372799999928997<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.98199999955607<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.348799999928996<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.981759999556076<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.324799999928995<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.98151999955608<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.300799999928994<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.98127999955608<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.276799999928993<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Humidity, v = 59.98103999955608<br/> Data: sensor = OPCUAClient/OPCUA-01/Node/Temperature, v = 28.252799999928992