Difference between revisions of "Advantech Robotic Suite/OPCUAClient Node"

From ESS-WIKI
Jump to: navigation, search
(Created page with " <br/> = Brief = The OPC Unified Architecture (UA), released in 2008, is a platform independent service-oriented architecture that integrates all the functionality of the ind...")
 
 
(16 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
+
= Brief =
<br/> = 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.
 
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.
+
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.
  
<br/> &nbsp;
+
<br/><br/>
  
 
= Topic definition =
 
= Topic definition =
  
The topic of OPCUA node data are defined as below:<br/> <pre>/adv/opcuaclient</pre>
+
The topic of OPCUA node data are defined as below:
 +
<pre>/adv/opcuaclient</pre>
  
&nbsp;
+
<br/>
  
 
= Message definition =
 
= Message definition =
Line 18: Line 18:
 
The messages definition of SUSI node is defined in below link:
 
The messages definition of SUSI node is defined in below link:
  
[http://ess-wiki.advantech.com.tw/view/ROS2_Suite_Advantech_ROS2_Data_Format http://ess-wiki.advantech.com.tw/view/ROS2_Suite_Advantech_ROS2_Data_Format]
+
http://ess-wiki.advantech.com.tw/view/Advantech_Robotic_Suite/Advantech_ROS2_Data_Format
  
&nbsp;
+
<br/>
  
 
= Configuration =
 
= Configuration =
  
To config OPCUA node settings, please refer the guide: [http://ess-wiki.advantech.com.tw/view/OPC-UA_Client http://ess-wiki.advantech.com.tw/view/OPC-UA_Client]
+
To config OPCUA node settings, please refer the guide: http://ess-wiki.advantech.com.tw/view/OPC-UA_Client
 +
 
 +
<br/>
 +
 
 +
= 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:
 +
<pre>$ source /opt/ros/${ROS_DISTRO}/setup.bash</pre>
 +
 
 +
Step2. Setup OPCUAClient Node message:
 +
<pre>$ source /usr/local/Advantech/ros/${ROS_DISTRO}/include/edge-converter-ros2/adv_msgs/install/local_setup.bash</pre>
 +
 
 +
Step3. List all topics:
 +
<pre>$ ros2 topic list</pre>
 +
 
 +
output:
 +
<pre>
 +
/adv/parameter_events
 +
/adv/opcuaclient
 +
/parameter_events
 +
/rosout
 +
</pre>
  
 
&nbsp;
 
&nbsp;
 +
 +
Step4. Subscribe node data
 +
 +
<pre>$ ros2 topic echo /adv/opcuaclient</pre>
 +
 +
output:
 +
<pre>
 +
---
 +
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
 +
---
 +
</pre>
 +
 +
<br/>
  
 
= Sample Client =
 
= Sample Client =
  
 
This session describe how to subscribe OPCUA node data by node's topic.
 
This session describe how to subscribe OPCUA node data by node's topic.
 +
<br/>
  
 
== Node.js ==
 
== Node.js ==
Line 36: Line 87:
 
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.
 
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.
  
&nbsp;
+
<br/>
  
 
'''Steps - Subscribe Sensor'''
 
'''Steps - Subscribe Sensor'''
  
Step1. Setup ROS2 foxy environmant variables:<br/> <pre>$ source /opt/ros/foxy/setup.bash</pre>
+
Step1. Setup ROS2 environmant variables, replace ${ROS_DISTRO} with your ROS2 distribution (foxy, humble) to run this command:
 +
<pre>$ source /opt/ros/${ROS_DISTRO}/setup.bash</pre>
  
Step2. Setup Advantech ROS Message:<br/> <pre>$ source /usr/local/Advantech/ros/foxy/include/edge-converter-ros2/adv_msgs/install/local_setup.bash</pre>
+
Step2. Setup OPCUAClient NodeS message:
 +
<pre>$ source /usr/local/Advantech/ros/${ROS_DISTRO}/include/edge-converter-ros2/adv_msgs/install/local_setup.bash</pre>
  
Step3. Go to node.js OPCUA sample path:<br/> <pre>$ cd /usr/local/Advantech/ros/foxy/sample_code/edge-data-client/rclnodejs_edge_data_client/</pre>
+
Step3. Go to node.js OPCUA sample path:
 +
<pre>$ cd /usr/local/Advantech/ros/${ROS_DISTRO}/sample_code/edge-data-client/rclnodejs_edge_data_client/</pre>
  
Step4. Run node.js OPCUA sample:<br/> <pre>$ &nbsp;node example_SubscribeSensor.js "rclnodejs_OPCUAClient_subscriber" "/adv/opcuaclient"</pre>
+
Step4. Run node.js OPCUA sample:
 +
<pre>$ node example_SubscribeSensor.js "rclnodejs_OPCUAClient_subscriber" "/adv/opcuaclient"</pre>
  
Step5. Verify received data:<br/> <pre>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/> </pre>
+
Step5. Verify received data:
  
<br/> &nbsp;
+
<pre>
 +
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
 +
</pre>
  
'''Steps - Set sensor'''
+
<br/><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.
 
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:<br/> <pre>$ source /opt/ros/foxy/setup.bash</pre>
+
Step1. Setup ROS2 environmant variables, replace ${ROS_DISTRO} with your ROS2 distribution (foxy, humble) to run this command:
 +
<pre>$ source /opt/ros/${ROS_DISTRO}/setup.bash</pre>
  
Step2. Setup Advantech ROS Message:<br/> <pre>$ source /usr/local/Advantech/ros/foxy/include/edge-converter-ros2/adv_msgs/install/local_setup.bash</pre>
+
Step2. Setup OPCUAClient NodeOS Message:
 +
<pre>$ source /usr/local/Advantech/ros/${ROS_DISTRO}/include/edge-converter-ros2/adv_msgs/install/local_setup.bash</pre>
  
Step3. Go to node.js OPCUA sample path:<br/> <pre>$ cd /usr/local/Advantech/ros/foxy/sample_code/edge-data-client/rclnodejs_edge_data_client/</pre>
+
Step3. Go to node.js OPCUA sample path:
 +
<pre>$ cd /usr/local/Advantech/ros/${ROS_DISTRO}/sample_code/edge-data-client/rclnodejs_edge_data_client/</pre>
  
 
Step4. Run OPCUA node set sensor sample:
 
Step4. Run OPCUA node set sensor sample:
  
Command:<br/> <pre>node example_SetSensor.js [node name] [action] [sensor] [type] [value]</pre>
+
Command:
 +
<pre>node example_SetSensor.js [node name] [action] [sensor] [type] [value]</pre>
  
Example:<br/> <pre>$ node example_SetSensor.js "rclnodejs_OPCUAClient_setter" "adv_opcuaclient_set" "OPCUAClient/OPCUA-01/Node/Temperature-SetPoint" "v" 26</pre>
+
Example:
 +
<pre>$ node example_SetSensor.js "rclnodejs_OPCUAClient_setter" "adv_opcuaclient_set" "OPCUAClient/OPCUA-01/Node/Temperature-SetPoint" "v" 26</pre>
  
Step5. Received data:<br/> <pre>[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
+
Step5. Received data:
 +
<pre>
 +
[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
  
 
</pre>
 
</pre>
  
<br/> &nbsp;
+
<br/><br/>
  
 
== Python ==
 
== Python ==
Line 80: Line 167:
 
'''Steps - Subscribe Sensor'''
 
'''Steps - Subscribe Sensor'''
  
Step1. Setup ROS2 foxy environmant variables:<br/> <pre>$ source /opt/ros/foxy/setup.bash</pre>
+
Step1. Setup ROS2 environmant variables, replace ${ROS_DISTRO} with your ROS2 distribution (foxy, humble) to run this command:
 +
<pre>$ source /opt/ros/${ROS_DISTRO}/setup.bash</pre>
  
Step2. Setup Advantech ROS Message:<br/> <pre>$ source /usr/local/Advantech/ros/foxy/include/edge-converter-ros2/adv_msgs/install/local_setup.bash</pre>
+
Step2. Setup OPCUAClient Node message:
 +
<pre>$ source /usr/local/Advantech/ros/${ROS_DISTRO}/include/edge-converter-ros2/adv_msgs/install/local_setup.bash</pre>
  
Step3. Setup OPCUA sample variables:<br/> <pre>$ source /usr/local/Advantech/ros/foxy/sample_code/edge-data-client/install/local_setup.bash</pre>
+
Step3. Setup OPCUA sample variables:
 +
<pre>$ source /usr/local/Advantech/ros/${ROS_DISTRO}/sample_code/edge-data-client/install/local_setup.bash</pre>
  
Step4. Run Python OPCUA sample:<br/> <pre>$ ros2 run rclpy_edge_data_client listener "rclpy_OPCUAClient_subscriber" "/adv/opcuaclient"</pre>
+
Step4. Run Python OPCUA sample:
 +
<pre>$ ros2 run rclpy_edge_data_client listener "rclpy_OPCUAClient_subscriber" "/adv/opcuaclient"</pre>
  
Step5. Verify received data:<br/> <pre>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
+
Step5. Verify received data:
 +
<pre>
 +
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
  
 
</pre>
 
</pre>
  
<br/> &nbsp;
+
<br/><br/>
  
 
== C++ ==
 
== C++ ==
Line 100: Line 210:
 
'''Steps - Subscribe Sensor'''
 
'''Steps - Subscribe Sensor'''
  
Step1. Setup ROS2 foxy environmant variables:<br/> <pre>$ source /opt/ros/foxy/setup.bash</pre>
+
Step1. Setup ROS2 environmant variables, replace ${ROS_DISTRO} with your ROS2 distribution (foxy, humble) to run this command:
 +
<pre>$ source /opt/ros/${ROS_DISTRO}/setup.bash</pre>
  
Step2. Setup Advantech ROS Message:<br/> <pre>$ source /usr/local/Advantech/ros/foxy/include/edge-converter-ros2/adv_msgs/install/local_setup.bash</pre>
+
Step2. Setup OPCUAClient Node message:
 +
<pre>$ source /usr/local/Advantech/ros/${ROS_DISTRO}/include/edge-converter-ros2/adv_msgs/install/local_setup.bash</pre>
  
Step3. Setup OPCUA node variables:<br/> <pre>$ source /usr/local/Advantech/ros/foxy/sample_code/edge-data-client/install/local_setup.bash</pre>
+
Step3. Setup OPCUA node variables:
 +
<pre>$ source /usr/local/Advantech/ros/${ROS_DISTRO}/sample_code/edge-data-client/install/local_setup.bash</pre>
  
Step4. Run Python OPCUA sample client:<br/> <pre>$ ros2 run rclcpp_edge_data_client listener "rclcpp_OPCUAClient_subscriber" "/adv/opucaclient"</pre>
+
Step4. Run Python OPCUA sample client:
 +
<pre>$ ros2 run rclcpp_edge_data_client listener "rclcpp_OPCUAClient_subscriber" "/adv/opcuaclient"</pre>
  
Step5. Verify received data:<br/> <pre>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
+
Step5. Verify received data:
 +
<pre>
 +
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
  
 
</pre>
 
</pre>
 
[[Category:Editor]]<br/> &nbsp;
 

Latest revision as of 08:37, 6 November 2024

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/opcuaclient"

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