Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
98 changes: 98 additions & 0 deletions opcua_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"register_node_list_from_csv_path": {
"path": "simple_opcua_nodes.csv"
},
"create_flow": [
{
"name": "温度控制流程",
"action": [
{
"name": "温度控制动作",
"node_function_to_create": [
{
"func_name": "read_temperature",
"node_name": "Temperature",
"mode": "read"
},
{
"func_name": "read_heating_status",
"node_name": "HeatingStatus",
"mode": "read"
},
{
"func_name": "set_heating",
"node_name": "HeatingEnabled",
"mode": "write",
"value": true
}
],
"create_init_function": {
"func_name": "init_setpoint",
"node_name": "Setpoint",
"mode": "write",
"value": 25.0
},
"create_start_function": {
"func_name": "start_heating_control",
"node_name": "HeatingEnabled",
"mode": "write",
"write_functions": [
"set_heating"
],
"condition_functions": [
"read_temperature",
"read_heating_status"
],
"stop_condition_expression": "read_temperature >= 25.0 and read_heating_status"
},
"create_stop_function": {
"func_name": "stop_heating",
"node_name": "HeatingEnabled",
"mode": "write",
"value": false
},
"create_cleanup_function": null
}
]
},
{
"name": "报警重置流程",
"action": [
{
"name": "报警重置动作",
"node_function_to_create": [
{
"func_name": "reset_alarm",
"node_name": "ResetAlarm",
"mode": "call",
"value": []
}
],
"create_init_function": null,
"create_start_function": {
"func_name": "start_reset_alarm",
"node_name": "ResetAlarm",
"mode": "call",
"write_functions": [],
"condition_functions": [
"reset_alarm"
],
"stop_condition_expression": "True"
},
"create_stop_function": null,
"create_cleanup_function": null
}
]
},
{
"name": "完整控制流程",
"action": [
"温度控制流程",
"报警重置流程"
]
}
],
"execute_flow": [
"完整控制流程"
]
}
Empty file added python
Empty file.
41 changes: 41 additions & 0 deletions recipes/ros-humble-unilabos-msgs/bld_ament_cmake.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
:: Generated by vinca http://github.com/RoboStack/vinca.
:: DO NOT EDIT!
setlocal EnableDelayedExpansion

set "PYTHONPATH=%LIBRARY_PREFIX%\lib\site-packages;%SP_DIR%"

:: MSVC is preferred.
set CC=cl.exe
set CXX=cl.exe

rd /s /q build
mkdir build
pushd build

:: set "CMAKE_GENERATOR=Ninja"

:: try to fix long paths issues by using default generator
set "CMAKE_GENERATOR=Visual Studio %VS_MAJOR% %VS_YEAR%"
set "SP_DIR_FORWARDSLASHES=%SP_DIR:\=/%"

set PYTHON="%PREFIX%\python.exe"

cmake ^
-G "%CMAKE_GENERATOR%" ^
-DCMAKE_INSTALL_PREFIX=%LIBRARY_PREFIX% ^
-DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=True ^
-DPYTHON_EXECUTABLE=%PYTHON% ^
-DPython_EXECUTABLE=%PYTHON% ^
-DPython3_EXECUTABLE=%PYTHON% ^
-DSETUPTOOLS_DEB_LAYOUT=OFF ^
-DBUILD_SHARED_LIBS=ON ^
-DBUILD_TESTING=OFF ^
-DCMAKE_OBJECT_PATH_MAX=255 ^
-DPYTHON_INSTALL_DIR=%SP_DIR_FORWARDSLASHES% ^
--compile-no-warning-as-error ^
%SRC_DIR%\%PKG_NAME%\src\work
if errorlevel 1 exit 1

cmake --build . --config Release --target install
if errorlevel 1 exit 1
71 changes: 71 additions & 0 deletions recipes/ros-humble-unilabos-msgs/build_ament_cmake.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Generated by vinca http://github.com/RoboStack/vinca.
# DO NOT EDIT!

rm -rf build
mkdir build
cd build

# necessary for correctly linking SIP files (from python_qt_bindings)
export LINK=$CXX

if [[ "$CONDA_BUILD_CROSS_COMPILATION" != "1" ]]; then
PYTHON_EXECUTABLE=$PREFIX/bin/python
PKG_CONFIG_EXECUTABLE=$PREFIX/bin/pkg-config
OSX_DEPLOYMENT_TARGET="10.15"
else
PYTHON_EXECUTABLE=$BUILD_PREFIX/bin/python
PKG_CONFIG_EXECUTABLE=$BUILD_PREFIX/bin/pkg-config
OSX_DEPLOYMENT_TARGET="11.0"
fi

echo "USING PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}"
echo "USING PKG_CONFIG_EXECUTABLE=${PKG_CONFIG_EXECUTABLE}"

export ROS_PYTHON_VERSION=`$PYTHON_EXECUTABLE -c "import sys; print('%i.%i' % (sys.version_info[0:2]))"`
echo "Using Python ${ROS_PYTHON_VERSION}"
# Fix up SP_DIR which for some reason might contain a path to a wrong Python version
FIXED_SP_DIR=$(echo $SP_DIR | sed -E "s/python[0-9]+\.[0-9]+/python$ROS_PYTHON_VERSION/")
echo "Using site-package dir ${FIXED_SP_DIR}"

# see https://github.com/conda-forge/cross-python-feedstock/issues/24
if [[ "$CONDA_BUILD_CROSS_COMPILATION" == "1" ]]; then
find $PREFIX/lib/cmake -type f -exec sed -i "s~\${_IMPORT_PREFIX}/lib/python${ROS_PYTHON_VERSION}/site-packages~${BUILD_PREFIX}/lib/python${ROS_PYTHON_VERSION}/site-packages~g" {} + || true
find $PREFIX/share/rosidl* -type f -exec sed -i "s~$PREFIX/lib/python${ROS_PYTHON_VERSION}/site-packages~${BUILD_PREFIX}/lib/python${ROS_PYTHON_VERSION}/site-packages~g" {} + || true
find $PREFIX/share/rosidl* -type f -exec sed -i "s~\${_IMPORT_PREFIX}/lib/python${ROS_PYTHON_VERSION}/site-packages~${BUILD_PREFIX}/lib/python${ROS_PYTHON_VERSION}/site-packages~g" {} + || true
find $PREFIX/lib/cmake -type f -exec sed -i "s~message(FATAL_ERROR \"The imported target~message(WARNING \"The imported target~g" {} + || true
fi

if [[ $target_platform =~ linux.* ]]; then
export CFLAGS="${CFLAGS} -D__STDC_FORMAT_MACROS=1"
export CXXFLAGS="${CXXFLAGS} -D__STDC_FORMAT_MACROS=1"
fi;

# Needed for qt-gui-cpp ..
if [[ $target_platform =~ linux.* ]]; then
ln -s $GCC ${BUILD_PREFIX}/bin/gcc
ln -s $GXX ${BUILD_PREFIX}/bin/g++
fi;

cmake \
-G "Ninja" \
-DCMAKE_INSTALL_PREFIX=$PREFIX \
-DCMAKE_PREFIX_PATH=$PREFIX \
-DAMENT_PREFIX_PATH=$PREFIX \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_BUILD_TYPE=Release \
-DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE \
-DPython_EXECUTABLE=$PYTHON_EXECUTABLE \
-DPython3_EXECUTABLE=$PYTHON_EXECUTABLE \
-DPython3_FIND_STRATEGY=LOCATION \
-DPKG_CONFIG_EXECUTABLE=$PKG_CONFIG_EXECUTABLE \
-DPYTHON_INSTALL_DIR=$FIXED_SP_DIR \
-DSETUPTOOLS_DEB_LAYOUT=OFF \
-DCATKIN_SKIP_TESTING=$SKIP_TESTING \
-DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=True \
-DBUILD_SHARED_LIBS=ON \
-DBUILD_TESTING=OFF \
-DCMAKE_OSX_DEPLOYMENT_TARGET=$OSX_DEPLOYMENT_TARGET \
--compile-no-warning-as-error \
$SRC_DIR/$PKG_NAME/src/work

cmake --build . --config Release --target install
61 changes: 61 additions & 0 deletions recipes/ros-humble-unilabos-msgs/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package:
name: ros-humble-unilabos-msgs
version: 0.9.7
source:
path: ../../unilabos_msgs
folder: ros-humble-unilabos-msgs/src/work

build:
script:
sel(win): bld_ament_cmake.bat
sel(unix): build_ament_cmake.sh
number: 5
about:
home: https://www.ros.org/
license: BSD-3-Clause
summary: |
Robot Operating System

extra:
recipe-maintainers:
- ros-forge

requirements:
build:
- "{{ compiler('cxx') }}"
- "{{ compiler('c') }}"
- sel(linux64): sysroot_linux-64 2.17
- ninja
- setuptools
- sel(unix): make
- sel(unix): coreutils
- sel(osx): tapi
- sel(build_platform != target_platform): pkg-config
- cmake
- cython
- sel(win): vs2022_win-64
- sel(build_platform != target_platform): python
- sel(build_platform != target_platform): cross-python_{{ target_platform }}
- sel(build_platform != target_platform): numpy
host:
- numpy
- pip
- sel(build_platform == target_platform): pkg-config
- robostack-staging::ros-humble-action-msgs
- robostack-staging::ros-humble-ament-cmake
- robostack-staging::ros-humble-ament-lint-auto
- robostack-staging::ros-humble-ament-lint-common
- robostack-staging::ros-humble-ros-environment
- robostack-staging::ros-humble-ros-workspace
- robostack-staging::ros-humble-rosidl-default-generators
- robostack-staging::ros-humble-std-msgs
- robostack-staging::ros-humble-geometry-msgs
- robostack-staging::ros2-distro-mutex=0.5.*
run:
- robostack-staging::ros-humble-action-msgs
- robostack-staging::ros-humble-ros-workspace
- robostack-staging::ros-humble-rosidl-default-runtime
- robostack-staging::ros-humble-std-msgs
- robostack-staging::ros-humble-geometry-msgs
# - robostack-staging::ros2-distro-mutex=0.6.*
- sel(osx and x86_64): __osx >={{ MACOSX_DEPLOYMENT_TARGET|default('10.14') }}
19 changes: 19 additions & 0 deletions test/experiments/opcua_example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"nodes": [
{
"id": "id",
"name": "name",
"children": [
],
"parent": null,
"type": "device",
"class": "opcua_example",
"config": {
"url": "url",
"config_path": "unilabos/device_comms/opcua_client/opcua_workflow_example.json"
},
"data": {
}
}
]
}
19 changes: 19 additions & 0 deletions unilabos/device_comms/opcua_client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# OPC UA 通用客户端

本模块提供了一个通用的 OPC UA 客户端实现,可以通过外部配置(CSV文件)来定义节点,并通过JSON配置来执行工作流。

## 特点

- 支持通过 CSV 文件配置 OPC UA 节点(只需提供名称、类型和数据类型,支持节点为中文名,需指定NodeLanguage)
- 自动查找服务器中的节点,无需知道确切的节点ID
- 提供工作流机制
- 支持通过 JSON 配置创建工作流

## 使用方法

step1: 准备opcua_nodes.csv文件
step2: 编写opcua_workflow_example.json,以定义工作流。指定opcua_nodes.csv
step3: 编写工作流对应action
step4: 编写opcua_example.yaml注册表
step5: 编写opcua_example.json组态图。指定opcua_workflow_example.json定义工作流文件

12 changes: 12 additions & 0 deletions unilabos/device_comms/opcua_client/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from unilabos.device_comms.opcua_client.client_o import OpcUaClient, BaseClient
from unilabos.device_comms.opcua_client.node.uniopcua import Variable, Method, Object, NodeType, DataType

__all__ = [
'OpcUaClient',
'BaseClient',
'Variable',
'Method',
'Object',
'NodeType',
'DataType',
]
Loading