Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
0d13f36
Removed before script and updated travis config
destogl May 26, 2017
af0679b
hallo
Oct 13, 2017
364f6a1
Added finished ROS message generation
May 2, 2018
e5dddee
ignored .idea folder
May 8, 2018
de961b2
removed .idea folder in git repository
May 8, 2018
872a866
synchronize changes
May 9, 2018
e74a088
changed export function
yangpeiren May 11, 2018
e3f3f58
delete cached pyc files
yangpeiren May 11, 2018
ee3ff21
update ros_message
May 11, 2018
d48e376
updated ros_topics
yangpeiren May 15, 2018
f8d51e5
add comments to ros_message while reviewing
May 16, 2018
86df732
sync modifications
yangpeiren May 17, 2018
b6dc4bf
update ros_actions
May 17, 2018
971941c
add comments to some file
yangpeiren May 20, 2018
87129e4
Add potential change positions and problems in the code
yangpeiren May 30, 2018
2ffc859
add todos to ros_server and ros_messages
yangpeiren Jun 3, 2018
6e2ad9f
change to use the original recursion of opcua
yangpeiren Jun 5, 2018
3df82ec
update submodule python-opcua
yangpeiren Jun 6, 2018
ac13607
version with functional service call
yangpeiren Jun 6, 2018
4509a6c
changed ros message
yangpeiren Jun 9, 2018
682c6a0
created new ua methods for ROS, rewote message module
yangpeiren Jun 11, 2018
40973c1
updated issue description
yangpeiren Jun 13, 2018
cd6cf7a
add check function in handling message
Jun 13, 2018
47bdf9e
one unstable version
yangpeiren Jun 14, 2018
5f4d88c
a stable version with message
yangpeiren Jun 14, 2018
ee8453c
added data type dictionary
yangpeiren Jun 18, 2018
fec8bcf
with working extesion objects
yangpeiren Jun 20, 2018
4fc0b9e
extension object works in UAExpert
yangpeiren Jun 20, 2018
0be0622
a packed working version with extension objects
yangpeiren Jun 21, 2018
9f1956b
working service call based on extension object
yangpeiren Jun 21, 2018
eda6f32
automatic generate services according to ros node info
yangpeiren Jun 22, 2018
fb89f7f
fixed running bug on lab computer
yangpeiren Jun 27, 2018
27620f9
with working topic publication function
yangpeiren Aug 9, 2018
9678ea5
merge the operation of the two data type creation class into one
yangpeiren Aug 11, 2018
fcc2425
first working version 2.0
yangpeiren Aug 14, 2018
f68df9f
with time comparison function
yangpeiren Aug 14, 2018
ebc1c12
updated export class
yangpeiren Aug 14, 2018
de16ac5
changed file structure, added rosparam
yangpeiren Aug 15, 2018
a44ca3f
support recursion copy and array copy between ros and ua classes
yangpeiren Aug 16, 2018
c6740a4
bug fixing in modelling ROS actions
yangpeiren Aug 18, 2018
f25147a
change back submodule
yangpeiren Aug 18, 2018
78b76e4
updated extension for python-opcua
yangpeiren Aug 20, 2018
d8b72d8
adapt to new extension object structure
yangpeiren Aug 20, 2018
af8193a
updated opcua extension module
yangpeiren Aug 21, 2018
d6e1a29
adapt to new changes of opcua extension
yangpeiren Aug 21, 2018
a7a9538
changed signature sequence of some methods
yangpeiren Aug 21, 2018
96ab105
refactored unhealty dependency
yangpeiren Aug 21, 2018
0a3ef33
a stable discriminant method for ros action
yangpeiren Aug 23, 2018
5ac776f
remove message.xml
yangpeiren Aug 23, 2018
e3aa175
removed message.xml
yangpeiren Aug 23, 2018
7bd949b
reorganized ros modelling, added rosparam
yangpeiren Aug 24, 2018
87ba765
refactored ros_server
yangpeiren Aug 24, 2018
7a5bd0c
refactored ros_info_manage
yangpeiren Aug 24, 2018
6ea1ae5
added client
yangpeiren Aug 24, 2018
bed2ece
with fully functional client
yangpeiren Aug 27, 2018
e5833bf
add launch for client
yangpeiren Aug 27, 2018
bddee99
Update known_issues.md
yangpeiren Aug 27, 2018
11ac4fb
fixed recursively traverse params
yangpeiren Aug 28, 2018
433b4f7
study on import bugs
yangpeiren Aug 28, 2018
1bf91f5
fixed bugs in client
yangpeiren Aug 28, 2018
f0fadc6
fixed small bugs in client
yangpeiren Aug 28, 2018
acfcfc1
added function: writable rosparam
yangpeiren Aug 30, 2018
b2cc196
with working client
yangpeiren Sep 1, 2018
5845d22
add support of using ros_opcua_viewer
yangpeiren Sep 6, 2018
f2a8025
elaborated examples
yangpeiren Sep 6, 2018
a518b12
copyed readme from kinetic-devel branch
yangpeiren Sep 7, 2018
6cf7691
elaborated readme
yangpeiren Sep 7, 2018
35c9b0d
updated issue, updated submodule
yangpeiren Sep 14, 2018
7d63108
add presentation
yangpeiren Sep 14, 2018
8c4cb1f
Update README.md
yangpeiren Sep 14, 2018
4236715
Added server uri as param.
destogl Jan 29, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*~
*.pyc
.idea
venv
ros_opcua_impl_python_opcua/scripts/*.xml
ros_opcua_impl_python_opcua/export/*.xml
4 changes: 0 additions & 4 deletions .travis.before.bash

This file was deleted.

1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ env:
- export PYTHONPATH=$PWD/ros_opcua_impl_python_opcua/python-opcua:$PYTHONPATH
matrix:
- ROS_DISTRO="indigo" ROS_REPOSITORY_PATH=http://packages.ros.org/ros/ubuntu
# - ROS_DISTRO="kinetic" ROS_REPOSITORY_PATH=http://packages.ros.org/ros/ubuntu
install:
- git clone https://github.com/ros-industrial/industrial_ci.git .ci_config
script:
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,20 @@ Clone the repository with:
git clone --recursive https://github.com/iirob/ros_opcua_communication.git
```


## Getting started

Please check readme files of the packages:

* [ros_opcua_impl_freeopcua](ros_opcua_impl_freeopcua/README.md)
* [ros_opcua_impl_python_opcua](ros_opcua_impl_python_opcua/README.md)


## ROS Distro Support

| | Indigo | Kinetic |
|:-------:|:------:|:-------:|
| Branch | [`indigo-devel`](https://github.com/iirob/ros_opcua_communication/tree/indigo-devel) | [`kinetic_devel`](https://github.com/iirob/ros_opcua_communication/tree/kinetic-devel) |
| Status | [![Build Status](https://travis-ci.org/iirob/ros_opcua_communication.svg?branch=indigo-devel)](https://travis-ci.org/iirob/ros_opcua_communication) | [![Build Status](https://travis-ci.org/iirob/ros_opcua_communication.svg?branch=kinetic-devel)](https://travis-ci.org/iirob/ros_opcua_communication) |
| Version | [version](http://repositories.ros.org/status_page/ros_indigo_default.html?q=ros_opcua_communication) | [version](http://repositories.ros.org/status_page/ros_kinetic_default.html?q=ros_opcua_communication) |

111 changes: 111 additions & 0 deletions ros_opcua_impl_python_opcua/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# ros_opcua_impl_python_opcua

This package provides a python implementation of OPC UA server, which models ROS in OPC UA protocol. The server provides access to all ROS topics, services, actions, parameters and nodes, besides an OPC UA client is provided to explore the contents of the server.

## Getting started with ros_opcua_impl_python_opcua package

### Start up

1. After cloning the package locally, an initial build is needed. As a standard ROS package, of course `catkin_make` is the ideal tool to do this, if you are new to ROS, please check [here](http://wiki.ros.org/ROS/Tutorials/BuildingPackages) to figure out how to build the package. After building, please do not forget to **source the package**.

2. Start the server (the starting will take some time, wait until you see the output `server started`) using:

```
roslaunch ros_opcua_impl_python_opcua rosopcua.launch
```

Then a ROS node named `rosopcua` could be seen in ROS, this node takes related ROS contents and models them in OPC UA protocol.

3. Run some ROS Nodes to test, they should afterward visible in the server. For example one can start `turtlesim_node`:

```
rosrun turtlesim turtlesim_node
```

4. Start the UaExpert as OPC UA client and connect to the server, if you have not installed it locally, please check [here](https://www.unified-automation.com/products/development-tools/uaexpert.html) to download it. The initial address you should type in UaExpert is `opc.tcp://0.0.0.0:21554/ROSServer`, afterward if you want to test with server and client located in different computers, this address can be found in `ros_opcua_impl_python_opcua/basic_server_client.py` under the variant `server_end_point`.

After a successful connection, all ROS topics, services, actions, parameters and nodes mapped to the OPC UA can be seen.

### Basic operations

1. Call a service. To move the turtle from example, choose `Objects->Services->turtle1/teleport_relative`, right click and choose call. Enter the new position (for instance 1, 1) of the turtle and then the turtle should move.

2. Interact with topics. In `Objects->Topics->turtle1/pose` one can follow the position of the turtle in real time. To check the full effect of this try to move turtle using [Robot Steering](https://wiki.ros.org/rqt_robot_steering) rqt-Plugin, or run:

```
rosrun turtlesim turtle_teleop_key
```

and move the turtle there. To publish messages under a ROS topic, you may choose `Objects->Topics->Topic publish->/turtle1/color_sensor`, call the method and the background color should be changed.

3. ROS msgs and srvs. They are modeled internally and linked under `Types->DataTypes->ROSDataType`.

## Rough project structure

Below is an overview of the folders and files in this project:

+ config, include the configuration file, will be loaded while launching the server node, a more specific explanation can be found in chapter "Configurations".
+ export, OPC UA nodes could be exported there, not interested for using
+ launch, includes 3 launch files
+ python-opcua, the foundation framework of this project
+ scripts, the main code folder of this project
+ known_issues.md, records the solved and unsolved problems of this project

...

## Interacting with the OPC UA server without `UaExpert`

`scripts/ros_opc_ua_client.py` is a ROS implementation of OPC UA client, which allows to connect with any OPC UA server, to start it, run:

```
roslaunch ros_opcua_impl_python_opcua opcuaclient.launch
```

After this 8 different services available under the ROS node `opcuaclient` can be seen, they can be called with `rosservice` (please **first call connect** service before calling other services) or more leisurely, with python scripts, there are two examples in file `scripts/opcua_client_application_example.py` and `scripts/opcua_client_application_example_ros.py` respectively.

## Configurations

Some parameters are designed in the file `config/params.yaml`, which supports advanced functions, below is a list of them:

| Parameter name | Default value| Comment|
| :---: | :---: |:----------------|
|namespace|'/'|filters of the ros topics, services, actions, parameters and nodes, default '/' means no filter|
|automatic_refresh|true|True will start automatic refresh of ros nodes, otherwise the user should call refresh manually|
|refresh_cycle_time|0.5|The cycle time of the automatic refresh, the time unit is second|
|show_nodes|true|Switch for masking the display of ROS nodes|
|show_topics|true|Switch for masking the display of ROS topics|
|show_services|true|Switch for masking the display of ROS services|
|show_params|true|Switch for masking the display of ROS parameters|
|import_xml_msgs|false|Controls if data types will be imported from an xml file or generate on-the-fly, its address is written in `/scripts/ros_opc_ua_comm.py` under the variable `message_export_path`, the nodes to be imported should be generated with the script `scripts/ros_server_export_message.py`, do not set it to true until the bug mentioned there is fixed|
|parameter_writable|true|Controls if the variables in parameters are writable|

## For developers

### Project hierarchy

The project is organized in a 5 layer hierarchy:

| Layer | Correspondent files | Comment|
| :---: | :---: |:----------------|
|Application|`scripts/opcua_client_application_example.py`, `scripts/opcua_client_application_example_ros.py`|possible application examples|
|Top|`scripts/ros_server.py`, `scripts/ros_server_export_message.py`, `scripts/ros_opc_ua_client.py`|built OPC UA server, manage ROS information with different information managers|
|High|`scripts/ros_info_manage.py`|created ROS information managers to manage the ROS services set, topic set, and ROS node set|
|Middle|`scripts/ros_opc_ua_comm.py` other classes|build the communication proxy of ROS topics, services based on the UA objects|
|Low|`scripts/ros_opc_ua_comm.py` class `OpcUaROSMessage`|created correspondent OPC UA extension object of rosmsg, rossrv|
|Bottom|`python-opcua/opcua/common/type_dictionary_buider.py`| extension object support in python-opcua|

### Msgs and Srvs used in `scripts/ros_opc_ua_client.py`

They can be found under the root folder under `ros_opcua_communication/ros_opcua_msgs` and `ros_opcua_communication/ros_opcua_srvs`.

The msg `TypeValue.msg` is designed for transferring arbitrary data structure between ROS and OPC UA in ROS world, to transfer an ROS object as data, the name of the object should be written in `type` string, the complete object should be serialized and written in the string field `string_d`. Please check `scripts/opcua_client_application_example_ros.py` to figure out detailed usage.

### Tricks that may help

Inheriting the two classes in `scripts/basic_server_client.py` can save time for further developing.

To implement filters in static modeling, it would be better to modify the low layer; in dynamic modeling, it would be better to modify the class `ROSInfoAgent` in the high layer, so that the server does not "see" a specific node, topic, service or parameter.

### Under the hood

Please check [this file](https://github.com/iirob/ros_opcua_communication/blob/interactive_ros/ros_opcua_impl_python_opcua/ROS-OPC%20UA%20Connector%203.0.pdf) for detailed information.
Binary file not shown.
22 changes: 22 additions & 0 deletions ros_opcua_impl_python_opcua/config/params.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,23 @@
# endpoint of the server
end_point: 'opc.tcp://141.3.80.78:18801/ROSServer'
# range of the ros topics, services and actions, default '/' means no filter
namespace: '/'
# True will start automatic refresh of ros nodes
automatic_refresh: true
# The automatic refresh time, if automatic_refresh is false this will not be considered
# The unit is second
refresh_cycle_time: 0.5
# Switches for specific ros information
show_nodes: true
show_topics: true
show_services: true
show_params: true
# True means data types will be imported from an xml file, its address is written in
# ./scripts/ros_opc_ua_comm under the variable message_export_path.
# False means the data types will be generated on the fly.
# FIXME: Please notice, do not set it to true before the bug in ./scripts/ros_server fixed.
import_xml_msgs: false
# Control if the variables in parameters are writable
parameter_writable: true
# TODO: filters for specific topics, services
#topics: [/turle1/cmd_vel, /turtle1/color_sensor]
36 changes: 13 additions & 23 deletions ros_opcua_impl_python_opcua/known_issues.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,22 @@
# Known Issues or problems

## Actions
* Wrong Argument Parsing, as Int32 type arguments are wrongly parsed to Int16 ua.Arguments()
(See BlinkyAction, PoliceAction on SR2 Robot in Lab for example)
## ROS Topic deleting problem

* Move_Base_Simple action has special case as to fix Errors that were thrown, possibly it is a malformed Action Definition
```python
if 'move_base_simple' in self.name:
self.goal_instance = self.goal_class()
else:
self.goal_instance = self.goal_class().goal
```
- [ ] Error message: `[WARN] [1535063519.464253]: Inbound TCP/IP connection failed: connection from sender terminated before handshake header received. 0 bytes were received. Please check sender for additional details.`

* Actions are seen as Actions when */goal*, */feedback*, */result* or */status* is in the topic name, better heuristic possibly needed
Problem lies on ROS side, please check [here](https://github.com/Microsoft/WSL/issues/1391#issuecomment-300076193).

* We ignore "header" in the goal call message instance to create our Arguments (and back the other way). Possible mistake See:
```python
while cur_slot == 'header':
rospy.logdebug("ignoring header")
object_counter += 1
if object_counter < len(sample.__slots__):
cur_slot = sample.__slots__[object_counter]
```
The [pull request](https://github.com/ros/ros_comm/pull/1050/files) to repair it in ros-lunar.

## Topics:
This problem happens sometimes, not always.

* Better Idea for publishing OPC UA Data ?
## Import xml instead of directly generate messages

## Services
* Methods return value Strings are not correctly transfered to OPC UA somehow (maybe an UAExpert issue, as they can be printed in the call method onto the console correctly)
- [ ] The created extension objects can not be displayed correctly in UAExpert by importing xml, the import function seem to have mixed OPC UA dictionary and data type nodes, the created data became one specific node.

Besides, for a test case with 395 ros messages:

direct generation takes about 1.6s
xml import takes about 2.4s but works incorrectly

A ros parameter `import_xml_msgs` is imported to support both xml import and create on-the-fly.
3 changes: 3 additions & 0 deletions ros_opcua_impl_python_opcua/launch/opcuaclient.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<launch>
<node name="opcuaclient" pkg="ros_opcua_impl_python_opcua" type="ros_opc_ua_client.py" output="screen" />
</launch>
1 change: 0 additions & 1 deletion ros_opcua_impl_python_opcua/launch/rosopcua.launch
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
<node name="rosopcua" pkg="ros_opcua_impl_python_opcua" type="ros_server.py" output="screen">
<rosparam command="load" file="$(find ros_opcua_impl_python_opcua)/config/params.yaml"/>
</node>

</launch>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<launch>
<node name="rosopcua" pkg="ros_opcua_impl_python_opcua" type="ros_server_export_message.py" output="screen">
<rosparam command="load" file="$(find ros_opcua_impl_python_opcua)/config/params.yaml"/>
</node>
</launch>
1 change: 1 addition & 0 deletions ros_opcua_impl_python_opcua/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

<author email="denis.stogl@kit.edu">Denis Štogl</author>
<author email="ukdrq@student.kit.edu">Daniel Draper</author>
<author email="peiren.yang@student.kit.edu">Peiren Yang</author>

<buildtool_depend>catkin</buildtool_depend>

Expand Down
2 changes: 1 addition & 1 deletion ros_opcua_impl_python_opcua/python-opcua
Submodule python-opcua updated 119 files
Loading