urml-opcua-runtime 0.5.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- urml_opcua_runtime-0.5.2/.gitignore +117 -0
- urml_opcua_runtime-0.5.2/PKG-INFO +102 -0
- urml_opcua_runtime-0.5.2/README.md +70 -0
- urml_opcua_runtime-0.5.2/SPEC-GAPS.md +62 -0
- urml_opcua_runtime-0.5.2/pyproject.toml +80 -0
- urml_opcua_runtime-0.5.2/src/urml_opcua_runtime/__init__.py +23 -0
- urml_opcua_runtime-0.5.2/src/urml_opcua_runtime/_version.py +3 -0
- urml_opcua_runtime-0.5.2/src/urml_opcua_runtime/adapter.py +336 -0
- urml_opcua_runtime-0.5.2/src/urml_opcua_runtime/config.py +77 -0
- urml_opcua_runtime-0.5.2/src/urml_opcua_runtime/py.typed +0 -0
- urml_opcua_runtime-0.5.2/tests/__init__.py +0 -0
- urml_opcua_runtime-0.5.2/tests/integration/__init__.py +0 -0
- urml_opcua_runtime-0.5.2/tests/integration/test_opcua_adapter_live.py +60 -0
- urml_opcua_runtime-0.5.2/tests/test_opcua_adapter.py +137 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# --- Python ---
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
.Python
|
|
7
|
+
build/
|
|
8
|
+
dist/
|
|
9
|
+
develop-eggs/
|
|
10
|
+
downloads/
|
|
11
|
+
eggs/
|
|
12
|
+
.eggs/
|
|
13
|
+
lib/
|
|
14
|
+
lib64/
|
|
15
|
+
parts/
|
|
16
|
+
sdist/
|
|
17
|
+
var/
|
|
18
|
+
wheels/
|
|
19
|
+
*.egg-info/
|
|
20
|
+
.installed.cfg
|
|
21
|
+
*.egg
|
|
22
|
+
MANIFEST
|
|
23
|
+
|
|
24
|
+
# Virtual envs
|
|
25
|
+
.venv/
|
|
26
|
+
venv/
|
|
27
|
+
env/
|
|
28
|
+
ENV/
|
|
29
|
+
.python-version
|
|
30
|
+
|
|
31
|
+
# Test / coverage / mypy / pyright
|
|
32
|
+
.coverage
|
|
33
|
+
.coverage.*
|
|
34
|
+
.cache
|
|
35
|
+
.pytest_cache/
|
|
36
|
+
.mypy_cache/
|
|
37
|
+
.dmypy.json
|
|
38
|
+
.pyre/
|
|
39
|
+
.pyright/
|
|
40
|
+
htmlcov/
|
|
41
|
+
nosetests.xml
|
|
42
|
+
coverage.xml
|
|
43
|
+
*.cover
|
|
44
|
+
.hypothesis/
|
|
45
|
+
.tox/
|
|
46
|
+
|
|
47
|
+
# --- Node / web tooling (kept out of core repo; here for safety) ---
|
|
48
|
+
node_modules/
|
|
49
|
+
.pnp.*
|
|
50
|
+
.yarn/cache/
|
|
51
|
+
.yarn/unplugged/
|
|
52
|
+
.yarn/build-state.yml
|
|
53
|
+
.yarn/install-state.gz
|
|
54
|
+
npm-debug.log*
|
|
55
|
+
yarn-debug.log*
|
|
56
|
+
yarn-error.log*
|
|
57
|
+
|
|
58
|
+
# --- C++ / Rust build artifacts (in case reference runtimes land here in early Phase 1) ---
|
|
59
|
+
target/
|
|
60
|
+
*.o
|
|
61
|
+
*.obj
|
|
62
|
+
*.a
|
|
63
|
+
*.lib
|
|
64
|
+
*.dll
|
|
65
|
+
*.dylib
|
|
66
|
+
*.exe
|
|
67
|
+
*.pdb
|
|
68
|
+
cmake-build-*/
|
|
69
|
+
CMakeCache.txt
|
|
70
|
+
CMakeFiles/
|
|
71
|
+
CMakeScripts/
|
|
72
|
+
Testing/
|
|
73
|
+
cmake_install.cmake
|
|
74
|
+
install_manifest.txt
|
|
75
|
+
compile_commands.json
|
|
76
|
+
|
|
77
|
+
# --- ROS 2 build dirs ---
|
|
78
|
+
build/
|
|
79
|
+
install/
|
|
80
|
+
log/
|
|
81
|
+
|
|
82
|
+
# --- Editor and OS junk ---
|
|
83
|
+
.vscode/
|
|
84
|
+
.idea/
|
|
85
|
+
*.swp
|
|
86
|
+
*.swo
|
|
87
|
+
*~
|
|
88
|
+
.DS_Store
|
|
89
|
+
Thumbs.db
|
|
90
|
+
desktop.ini
|
|
91
|
+
|
|
92
|
+
# --- Local-only artifacts ---
|
|
93
|
+
.env
|
|
94
|
+
.env.*
|
|
95
|
+
*.log
|
|
96
|
+
*.tmp
|
|
97
|
+
.local/
|
|
98
|
+
.scratch/
|
|
99
|
+
|
|
100
|
+
# --- Outreach campaign artifacts (operational, not part of the open standard) ---
|
|
101
|
+
# Target lists, message drafts, tracking data, and the launch-approval record
|
|
102
|
+
# stay local. They are private to the maintainer; committing them would
|
|
103
|
+
# telegraph the campaign before launch and could embarrass listed projects.
|
|
104
|
+
outreach/
|
|
105
|
+
|
|
106
|
+
# Outreach dashboard SQLite mirror (RFC-0275). Derived from
|
|
107
|
+
# examples/lighthouses/outreach*.yaml via tools/scripts/refresh_outreach_db.py.
|
|
108
|
+
# Regenerated on demand by `make outreach-refresh`.
|
|
109
|
+
tools/outreach.db
|
|
110
|
+
tools/.outreach.db
|
|
111
|
+
|
|
112
|
+
# Local Claude Code settings (per-machine; permission rules, etc.). Not committed.
|
|
113
|
+
.claude/settings.json
|
|
114
|
+
.claude/settings.local.json
|
|
115
|
+
|
|
116
|
+
# Claude Code session worktrees (`claude -w <name>`); see AGENTS.md "Parallel sessions".
|
|
117
|
+
.claude/worktrees/
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: urml-opcua-runtime
|
|
3
|
+
Version: 0.5.2
|
|
4
|
+
Summary: Industrial-automation reference runtime for URML — OPC UA Robotics, zero ROS.
|
|
5
|
+
Project-URL: Homepage, https://github.com/urml-dev/URML
|
|
6
|
+
Project-URL: Repository, https://github.com/urml-dev/URML
|
|
7
|
+
Project-URL: Issues, https://github.com/urml-dev/URML/issues
|
|
8
|
+
Author: URML Maintainers
|
|
9
|
+
License: BUSL-1.1
|
|
10
|
+
Keywords: fieldbus,industrial,opc-ua,opcua,plc,robotics,runtime,urml
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: Other/Proprietary License
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering
|
|
19
|
+
Requires-Python: >=3.11
|
|
20
|
+
Requires-Dist: pydantic<3,>=2.6
|
|
21
|
+
Requires-Dist: pyyaml<7,>=6.0
|
|
22
|
+
Requires-Dist: urml-ros2-runtime>=0.5.2
|
|
23
|
+
Requires-Dist: urml-validator>=0.5.2
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: mypy>=1.10; extra == 'dev'
|
|
26
|
+
Requires-Dist: pytest-cov>=5; extra == 'dev'
|
|
27
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
28
|
+
Requires-Dist: ruff>=0.5; extra == 'dev'
|
|
29
|
+
Provides-Extra: opcua
|
|
30
|
+
Requires-Dist: asyncua<2,>=1.0; extra == 'opcua'
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
<p align="center">
|
|
34
|
+
<a href="https://urml.dev"><img src="https://urml.dev/favicon.svg" alt="URML" width="72" height="72"></a>
|
|
35
|
+
</p>
|
|
36
|
+
|
|
37
|
+
<p align="center">
|
|
38
|
+
A small, opinionated, human-readable language for describing robot intent.
|
|
39
|
+
</p>
|
|
40
|
+
|
|
41
|
+
<p align="center">
|
|
42
|
+
<a href="https://urml.dev"><b>urml.dev</b></a>
|
|
43
|
+
</p>
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
# urml-opcua-runtime
|
|
48
|
+
|
|
49
|
+
**Industrial-automation reference runtime for URML** — `OpcUaAdapter` for **OPC UA Robotics** cells, via `asyncua`.
|
|
50
|
+
|
|
51
|
+
OPC UA Robotics is the universal factory-floor / PLC companion spec. This adapter is the industrial-automation analog of the PX4/marine no-ROS proof and mirrors `BlueRovAdapter`: lazy `asyncua`, **no ROS 2 dependency**, a lazily-opened cached client, failures returned not raised. It hits the manufacturer / federal-procurement wedge ([RFC-0007](../../docs/rfcs/0007-manufacturer-go-to-market.md)) and complements the shipped industrial-arm family + [RFC-0013](../../docs/rfcs/0013-industrial-layer2-primitives.md) primitives. Built against the frozen substrate Protocol per [RFC-0014](../../docs/rfcs/0014-substrate-conformance.md).
|
|
52
|
+
|
|
53
|
+
## Method coverage
|
|
54
|
+
|
|
55
|
+
| URML primitive | v0.1 |
|
|
56
|
+
|---|---|
|
|
57
|
+
| `move_to` / `hover` | call the configured per-location OPC UA method node |
|
|
58
|
+
| `dock` | call the configured station-service method — **the path RFC-0013 `swap_tool` rides, preserved** |
|
|
59
|
+
| `grasp` / `release` | call the configured manipulation method |
|
|
60
|
+
| `wait` | hold (success) |
|
|
61
|
+
| `measure` / `wait_for` | read the configured variable node |
|
|
62
|
+
| `report` | structured record to a local sink (no cloud) |
|
|
63
|
+
| `scan` | documented not-supported result: no area-scan controller (a scan is waypoints plus a capture at each one) |
|
|
64
|
+
|
|
65
|
+
`detect`, `capture`, `speak`, `listen` return `not_supported_on_opcua_cell` (pair a vision/HMI companion). The drone trio returns `not_applicable_opcua`.
|
|
66
|
+
|
|
67
|
+
## Spec gaps (RFC-0014 protocol)
|
|
68
|
+
|
|
69
|
+
This runtime surfaced two genuinely inexpressible needs — filed as **RFC-0015** (ControlProgram/PLC-method invocation) and **RFC-0016** (real-time/cyclic manifest block), both `Draft`, maintainer-decided. They are **not** silently bolted on. See [`SPEC-GAPS.md`](SPEC-GAPS.md), which also flags the `asyncua` **LGPL-3.0** optional-dependency posture for maintainer ratification.
|
|
70
|
+
|
|
71
|
+
## Install / use
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
pip install -e reference/opcua-runtime[opcua] # installs asyncua
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
from urml_opcua_runtime import OpcUaAdapter, OpcUaConfig
|
|
79
|
+
from urml_opcua_runtime.adapter import MethodTarget
|
|
80
|
+
cfg = OpcUaConfig(location_to_method={"pick_bin": MethodTarget(method="ns=2;s=MoveTo", args=["pick_bin"])})
|
|
81
|
+
with OpcUaAdapter(cfg) as cell:
|
|
82
|
+
assert cell.send_navigation_goal(location="pick_bin").success
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Status
|
|
86
|
+
|
|
87
|
+
**v0.1 (this release):**
|
|
88
|
+
- `OpcUaAdapter` + `OpcUaConfig` (asyncua, no ROS). `opcua_cell` US-provenance manifest + `conformance/fixtures/industrial/07_opcua_cell_positive.yaml` (RFC-0013 `pick_from`/`place_at`) verified through the runner (hermetic against `MockROSAdapter`; adapter-agnostic against `OpcUaAdapter`).
|
|
89
|
+
- Hermetic unit tests: nav (configured + unmapped), dock/swap_tool, grasp, measure, scan (not supported), lifecycle, the unconfigured / not-supported / not-applicable sentinels, the missing-`[opcua]`-extra error, the conformance hook; no asyncua install required.
|
|
90
|
+
- Gated `.github/workflows/opcua-integration.yml`: `opcua-smoke` (real asyncua), `opcua-arm64-build` (the Jetson-class QEMU signal), `opcua-server-e2e` against a local asyncua server (first run is a calibration run by design — the established px4/ros2/marine convention).
|
|
91
|
+
|
|
92
|
+
**Follow-ups (not yet):** RFC-0015/0016 outcomes; a bundled asyncua demo server for the e2e.
|
|
93
|
+
|
|
94
|
+
## Core Commitment
|
|
95
|
+
|
|
96
|
+
Business Source License 1.1: free for non-production use, commercial license for production (see [`LICENSING.md`](../../LICENSING.md)). No vendor coupling, no cloud dependency. `asyncua` is an LGPL-3.0 *optional* dependency — see SPEC-GAPS.md.
|
|
97
|
+
|
|
98
|
+
## Related documents
|
|
99
|
+
|
|
100
|
+
- [`/reference/marine-runtime/`](../marine-runtime/) — the zero-ROS sibling whose structure this mirrors.
|
|
101
|
+
- [`/docs/rfcs/0014-substrate-conformance.md`](../../docs/rfcs/0014-substrate-conformance.md) — the conformance contract.
|
|
102
|
+
- [`/docs/rfcs/0015-control-program-invocation.md`](../../docs/rfcs/0015-control-program-invocation.md) · [`/docs/rfcs/0016-realtime-cyclic-manifest-block.md`](../../docs/rfcs/0016-realtime-cyclic-manifest-block.md) — the surfaced spec gaps.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://urml.dev"><img src="https://urml.dev/favicon.svg" alt="URML" width="72" height="72"></a>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
A small, opinionated, human-readable language for describing robot intent.
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="https://urml.dev"><b>urml.dev</b></a>
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# urml-opcua-runtime
|
|
16
|
+
|
|
17
|
+
**Industrial-automation reference runtime for URML** — `OpcUaAdapter` for **OPC UA Robotics** cells, via `asyncua`.
|
|
18
|
+
|
|
19
|
+
OPC UA Robotics is the universal factory-floor / PLC companion spec. This adapter is the industrial-automation analog of the PX4/marine no-ROS proof and mirrors `BlueRovAdapter`: lazy `asyncua`, **no ROS 2 dependency**, a lazily-opened cached client, failures returned not raised. It hits the manufacturer / federal-procurement wedge ([RFC-0007](../../docs/rfcs/0007-manufacturer-go-to-market.md)) and complements the shipped industrial-arm family + [RFC-0013](../../docs/rfcs/0013-industrial-layer2-primitives.md) primitives. Built against the frozen substrate Protocol per [RFC-0014](../../docs/rfcs/0014-substrate-conformance.md).
|
|
20
|
+
|
|
21
|
+
## Method coverage
|
|
22
|
+
|
|
23
|
+
| URML primitive | v0.1 |
|
|
24
|
+
|---|---|
|
|
25
|
+
| `move_to` / `hover` | call the configured per-location OPC UA method node |
|
|
26
|
+
| `dock` | call the configured station-service method — **the path RFC-0013 `swap_tool` rides, preserved** |
|
|
27
|
+
| `grasp` / `release` | call the configured manipulation method |
|
|
28
|
+
| `wait` | hold (success) |
|
|
29
|
+
| `measure` / `wait_for` | read the configured variable node |
|
|
30
|
+
| `report` | structured record to a local sink (no cloud) |
|
|
31
|
+
| `scan` | documented not-supported result: no area-scan controller (a scan is waypoints plus a capture at each one) |
|
|
32
|
+
|
|
33
|
+
`detect`, `capture`, `speak`, `listen` return `not_supported_on_opcua_cell` (pair a vision/HMI companion). The drone trio returns `not_applicable_opcua`.
|
|
34
|
+
|
|
35
|
+
## Spec gaps (RFC-0014 protocol)
|
|
36
|
+
|
|
37
|
+
This runtime surfaced two genuinely inexpressible needs — filed as **RFC-0015** (ControlProgram/PLC-method invocation) and **RFC-0016** (real-time/cyclic manifest block), both `Draft`, maintainer-decided. They are **not** silently bolted on. See [`SPEC-GAPS.md`](SPEC-GAPS.md), which also flags the `asyncua` **LGPL-3.0** optional-dependency posture for maintainer ratification.
|
|
38
|
+
|
|
39
|
+
## Install / use
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install -e reference/opcua-runtime[opcua] # installs asyncua
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
from urml_opcua_runtime import OpcUaAdapter, OpcUaConfig
|
|
47
|
+
from urml_opcua_runtime.adapter import MethodTarget
|
|
48
|
+
cfg = OpcUaConfig(location_to_method={"pick_bin": MethodTarget(method="ns=2;s=MoveTo", args=["pick_bin"])})
|
|
49
|
+
with OpcUaAdapter(cfg) as cell:
|
|
50
|
+
assert cell.send_navigation_goal(location="pick_bin").success
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Status
|
|
54
|
+
|
|
55
|
+
**v0.1 (this release):**
|
|
56
|
+
- `OpcUaAdapter` + `OpcUaConfig` (asyncua, no ROS). `opcua_cell` US-provenance manifest + `conformance/fixtures/industrial/07_opcua_cell_positive.yaml` (RFC-0013 `pick_from`/`place_at`) verified through the runner (hermetic against `MockROSAdapter`; adapter-agnostic against `OpcUaAdapter`).
|
|
57
|
+
- Hermetic unit tests: nav (configured + unmapped), dock/swap_tool, grasp, measure, scan (not supported), lifecycle, the unconfigured / not-supported / not-applicable sentinels, the missing-`[opcua]`-extra error, the conformance hook; no asyncua install required.
|
|
58
|
+
- Gated `.github/workflows/opcua-integration.yml`: `opcua-smoke` (real asyncua), `opcua-arm64-build` (the Jetson-class QEMU signal), `opcua-server-e2e` against a local asyncua server (first run is a calibration run by design — the established px4/ros2/marine convention).
|
|
59
|
+
|
|
60
|
+
**Follow-ups (not yet):** RFC-0015/0016 outcomes; a bundled asyncua demo server for the e2e.
|
|
61
|
+
|
|
62
|
+
## Core Commitment
|
|
63
|
+
|
|
64
|
+
Business Source License 1.1: free for non-production use, commercial license for production (see [`LICENSING.md`](../../LICENSING.md)). No vendor coupling, no cloud dependency. `asyncua` is an LGPL-3.0 *optional* dependency — see SPEC-GAPS.md.
|
|
65
|
+
|
|
66
|
+
## Related documents
|
|
67
|
+
|
|
68
|
+
- [`/reference/marine-runtime/`](../marine-runtime/) — the zero-ROS sibling whose structure this mirrors.
|
|
69
|
+
- [`/docs/rfcs/0014-substrate-conformance.md`](../../docs/rfcs/0014-substrate-conformance.md) — the conformance contract.
|
|
70
|
+
- [`/docs/rfcs/0015-control-program-invocation.md`](../../docs/rfcs/0015-control-program-invocation.md) · [`/docs/rfcs/0016-realtime-cyclic-manifest-block.md`](../../docs/rfcs/0016-realtime-cyclic-manifest-block.md) — the surfaced spec gaps.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://urml.dev"><img src="https://urml.dev/favicon.svg" alt="URML" width="72" height="72"></a>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
A small, opinionated, human-readable language for describing robot intent.
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="https://urml.dev"><b>urml.dev</b></a>
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# SPEC-GAPS — urml-opcua-runtime
|
|
16
|
+
|
|
17
|
+
Per the spec-gap protocol (RFC-0014): this runtime is built strictly
|
|
18
|
+
against the frozen substrate Protocol. Anything the OPC UA Robotics
|
|
19
|
+
substrate needs that URML cannot express is recorded here and, if
|
|
20
|
+
genuinely inexpressible, promoted to a numbered RFC Draft for
|
|
21
|
+
maintainer decision — never a silent primitive/schema change.
|
|
22
|
+
|
|
23
|
+
## Genuinely inexpressible → RFC Drafts filed
|
|
24
|
+
|
|
25
|
+
- **RFC-0015 — ControlProgram / PLC-method invocation.** OPC UA
|
|
26
|
+
Robotics cells routinely expose "run named ControlProgram P with
|
|
27
|
+
arguments" or "call vendor method M". This is *not* `move_to`,
|
|
28
|
+
`grasp`, or `report`, and — unlike RFC-0013's `swap_tool`, which
|
|
29
|
+
legitimately rides `send_docking_goal` because it *is* a station
|
|
30
|
+
service — a general program/method call is not a station service.
|
|
31
|
+
No existing primitive composes it. Filed as RFC-0015 (Draft); until
|
|
32
|
+
accepted, the adapter exposes only nav/dock/grasp/measure/report and
|
|
33
|
+
does not invent a primitive.
|
|
34
|
+
|
|
35
|
+
- **RFC-0016 — Real-time / cyclic manifest block.** A fieldbus/OPC UA
|
|
36
|
+
cell often has a cyclic update period, a watchdog, and a requested
|
|
37
|
+
packet interval (RPI). The Layer-1 manifest has no block to declare
|
|
38
|
+
these, so a runtime cannot state the timing contract it operates
|
|
39
|
+
under. This is a manifest-schema field, not a primitive. Filed as
|
|
40
|
+
RFC-0016 (Draft); v0.1 ships without it (timing is deployment config
|
|
41
|
+
in `opcua_adapter.yaml`, not URML-declared).
|
|
42
|
+
|
|
43
|
+
## Composable (no gap, documented)
|
|
44
|
+
|
|
45
|
+
- **Station services** (e.g. `swap_tool`, `park`) → `send_docking_goal`
|
|
46
|
+
with the service name, exactly the RFC-0013 path. Preserved
|
|
47
|
+
unchanged; `service_to_method` in `OpcUaConfig` maps it.
|
|
48
|
+
- **Per-location motion** → `send_navigation_goal(location=...)` →
|
|
49
|
+
configured method node. Named-pose only (the companion spec is
|
|
50
|
+
method/node oriented); raw pose goals return an honest unsuccessful
|
|
51
|
+
result, not a gap.
|
|
52
|
+
|
|
53
|
+
## Maintainer ratification flag (not a spec gap)
|
|
54
|
+
|
|
55
|
+
`asyncua` is **LGPL-3.0**. In-repo code is BSL 1.1 and depends on it
|
|
56
|
+
**only** via the optional `[opcua]` extra, never imported at module
|
|
57
|
+
load (the same posture as `rclpy` / `pymavlink`), so the Core
|
|
58
|
+
Commitment boundary is intact and this runtime is outside that
|
|
59
|
+
boundary regardless. Whether an LGPL optional dependency in a
|
|
60
|
+
reference runtime is acceptable is a licensing-posture call for the
|
|
61
|
+
maintainer to ratify on this PR. Fallback if rejected: gate the OPC UA
|
|
62
|
+
server-integration to CI only, or vendor a minimal pure-Apache client.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.27"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "urml-opcua-runtime"
|
|
7
|
+
version = "0.5.2"
|
|
8
|
+
description = "Industrial-automation reference runtime for URML — OPC UA Robotics, zero ROS."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "BUSL-1.1" }
|
|
11
|
+
requires-python = ">=3.11"
|
|
12
|
+
authors = [{ name = "URML Maintainers" }]
|
|
13
|
+
keywords = ["robotics", "industrial", "opc-ua", "opcua", "plc", "fieldbus", "urml", "runtime"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"License :: Other/Proprietary License",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
20
|
+
"Programming Language :: Python :: 3.11",
|
|
21
|
+
"Programming Language :: Python :: 3.12",
|
|
22
|
+
"Topic :: Scientific/Engineering",
|
|
23
|
+
]
|
|
24
|
+
dependencies = [
|
|
25
|
+
"pydantic>=2.6,<3",
|
|
26
|
+
"PyYAML>=6.0,<7",
|
|
27
|
+
"urml-validator>=0.5.2",
|
|
28
|
+
"urml-ros2-runtime>=0.5.2",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[project.optional-dependencies]
|
|
32
|
+
# OPC UA Robotics is the universal factory-floor companion spec; asyncua
|
|
33
|
+
# (opcua-asyncio) is the pure-Python client/server, ships an in-memory
|
|
34
|
+
# Server for hermetic tests, and is fully offline (no cloud). It is
|
|
35
|
+
# imported lazily (this extra), so urml_opcua_runtime imports on every
|
|
36
|
+
# host without it. NOTE: asyncua is LGPL-3.0. In-repo code is BSL 1.1
|
|
37
|
+
# and depends on it ONLY through this optional extra, never at module
|
|
38
|
+
# load (the same posture as rclpy / pymavlink). The LGPL-optional-dep
|
|
39
|
+
# posture is flagged for maintainer ratification — see SPEC-GAPS.md.
|
|
40
|
+
opcua = [
|
|
41
|
+
"asyncua>=1.0,<2",
|
|
42
|
+
]
|
|
43
|
+
dev = [
|
|
44
|
+
"pytest>=8",
|
|
45
|
+
"pytest-cov>=5",
|
|
46
|
+
"ruff>=0.5",
|
|
47
|
+
"mypy>=1.10",
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
[project.urls]
|
|
51
|
+
Homepage = "https://github.com/urml-dev/URML"
|
|
52
|
+
Repository = "https://github.com/urml-dev/URML"
|
|
53
|
+
Issues = "https://github.com/urml-dev/URML/issues"
|
|
54
|
+
|
|
55
|
+
[tool.hatch.build.targets.wheel]
|
|
56
|
+
packages = ["src/urml_opcua_runtime"]
|
|
57
|
+
|
|
58
|
+
[tool.ruff]
|
|
59
|
+
line-length = 120
|
|
60
|
+
target-version = "py311"
|
|
61
|
+
src = ["src", "tests"]
|
|
62
|
+
|
|
63
|
+
[tool.ruff.lint]
|
|
64
|
+
select = ["E", "F", "W", "I", "B", "UP", "N", "ANN", "RUF"]
|
|
65
|
+
ignore = ["ANN401"]
|
|
66
|
+
|
|
67
|
+
[tool.ruff.lint.per-file-ignores]
|
|
68
|
+
"tests/*" = ["ANN"]
|
|
69
|
+
|
|
70
|
+
[tool.mypy]
|
|
71
|
+
strict = true
|
|
72
|
+
python_version = "3.11"
|
|
73
|
+
plugins = ["pydantic.mypy"]
|
|
74
|
+
mypy_path = "src"
|
|
75
|
+
packages = ["urml_opcua_runtime"]
|
|
76
|
+
|
|
77
|
+
[tool.pytest.ini_options]
|
|
78
|
+
minversion = "8.0"
|
|
79
|
+
testpaths = ["tests"]
|
|
80
|
+
addopts = ["-q", "--strict-markers"]
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""urml_opcua_runtime — industrial-automation reference runtime for URML.
|
|
2
|
+
|
|
3
|
+
OpcUaAdapter (+ OpcUaConfig, load_opcua_config)
|
|
4
|
+
OPC UA Robotics companion-spec robot cells via asyncua. **No ROS 2
|
|
5
|
+
dependency** — the industrial-automation analog of the PX4/marine
|
|
6
|
+
no-ROS proof, hitting the factory-floor / federal-procurement wedge
|
|
7
|
+
(RFC-0007). asyncua is imported lazily (the [opcua] extra), so this
|
|
8
|
+
module loads on every host. Built against the frozen substrate
|
|
9
|
+
Protocol per RFC-0014; spec gaps are recorded in SPEC-GAPS.md, not
|
|
10
|
+
silently patched.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
from urml_opcua_runtime._version import __version__
|
|
16
|
+
from urml_opcua_runtime.adapter import OpcUaAdapter, OpcUaConfig, load_opcua_config
|
|
17
|
+
|
|
18
|
+
__all__ = [
|
|
19
|
+
"OpcUaAdapter",
|
|
20
|
+
"OpcUaConfig",
|
|
21
|
+
"__version__",
|
|
22
|
+
"load_opcua_config",
|
|
23
|
+
]
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
"""OpcUaAdapter — OPC UA Robotics cell, via asyncua.
|
|
2
|
+
|
|
3
|
+
OPC UA Robotics is the universal factory-floor companion spec; this is
|
|
4
|
+
the industrial-automation analog of the PX4/marine no-ROS proof and
|
|
5
|
+
mirrors :class:`BlueRovAdapter`: lazy ``asyncua``, **no ROS 2
|
|
6
|
+
dependency**, a lazily-opened cached client, failures returned not
|
|
7
|
+
raised. It hits the manufacturer / federal-procurement wedge
|
|
8
|
+
(RFC-0007) and complements the shipped industrial-arm family +
|
|
9
|
+
RFC-0013 primitives.
|
|
10
|
+
|
|
11
|
+
## v0.1 method coverage
|
|
12
|
+
|
|
13
|
+
Supported (mapped onto configured OPC UA method/variable nodes):
|
|
14
|
+
|
|
15
|
+
- ``move_to`` / ``hover`` → call the configured per-location method
|
|
16
|
+
node (location → method+args via :class:`OpcUaConfig`).
|
|
17
|
+
- ``dock`` → call the configured station-service method; this is the
|
|
18
|
+
path RFC-0013 ``swap_tool`` rides (service name keyed in config),
|
|
19
|
+
preserved unchanged.
|
|
20
|
+
- ``grasp`` / ``release`` → call the configured manipulation method.
|
|
21
|
+
- ``wait`` → no-op success (a cell holds position).
|
|
22
|
+
- ``measure`` / ``wait_for`` → read the configured variable node once.
|
|
23
|
+
- ``report`` → structured record to a local sink (no cloud — manifesto).
|
|
24
|
+
- ``scan`` → documented not-supported result: this adapter does not
|
|
25
|
+
expand an area into waypoints or capture along them.
|
|
26
|
+
|
|
27
|
+
Not supported by a bare cell (returned, not raised): ``detect``,
|
|
28
|
+
``capture``, ``speak``, ``listen`` — pair a vision/HMI companion. The
|
|
29
|
+
drone trio ``take_off`` / ``land`` / ``return_to_home`` are
|
|
30
|
+
``not_applicable_opcua``.
|
|
31
|
+
|
|
32
|
+
A general "invoke a named ControlProgram / PLC method with arguments"
|
|
33
|
+
is **not** expressible with the current primitives (it is not a
|
|
34
|
+
station service, unlike ``swap_tool``); that is a recorded spec gap
|
|
35
|
+
(see ``SPEC-GAPS.md`` → RFC-0015), not silently bolted on here.
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
from __future__ import annotations
|
|
39
|
+
|
|
40
|
+
from contextlib import suppress
|
|
41
|
+
from typing import Any, Literal
|
|
42
|
+
|
|
43
|
+
from urml_ros2_runtime.substrate.base import (
|
|
44
|
+
CaptureResult,
|
|
45
|
+
DetectionResult,
|
|
46
|
+
ListenResult,
|
|
47
|
+
ManipulationResult,
|
|
48
|
+
MeasurementResult,
|
|
49
|
+
NavigationResult,
|
|
50
|
+
ProgramCallResult,
|
|
51
|
+
ScanResult,
|
|
52
|
+
SubstrateResult,
|
|
53
|
+
WaitResult,
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
from urml_opcua_runtime._version import __version__
|
|
57
|
+
from urml_opcua_runtime.config import MethodTarget, OpcUaConfig, load_opcua_config
|
|
58
|
+
|
|
59
|
+
__all__ = [
|
|
60
|
+
"MethodTarget",
|
|
61
|
+
"OpcUaAdapter",
|
|
62
|
+
"OpcUaConfig",
|
|
63
|
+
"__version__",
|
|
64
|
+
"load_opcua_config",
|
|
65
|
+
]
|
|
66
|
+
|
|
67
|
+
_NOT_SUPPORTED = (
|
|
68
|
+
"not_supported_on_opcua_cell: a bare OPC UA Robotics cell has no {capability}. "
|
|
69
|
+
"Pair it with a vision/HMI companion adapter; the URML program, manifest, "
|
|
70
|
+
"and validator are unchanged."
|
|
71
|
+
)
|
|
72
|
+
_NOT_APPLICABLE = "not_applicable_opcua: {capability} has no meaning for a fixed industrial cell."
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def _require_asyncua() -> Any:
|
|
76
|
+
"""Lazy-import asyncua's sync client with a clear error when missing."""
|
|
77
|
+
try:
|
|
78
|
+
from asyncua.sync import Client # type: ignore[import-not-found,unused-ignore]
|
|
79
|
+
except ImportError as exc:
|
|
80
|
+
raise RuntimeError(
|
|
81
|
+
"asyncua is not installed. OpcUaAdapter requires the [opcua] extra.\n"
|
|
82
|
+
" Install with: pip install urml-opcua-runtime[opcua]"
|
|
83
|
+
) from exc
|
|
84
|
+
return Client
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class OpcUaAdapter:
|
|
88
|
+
"""OPC UA Robotics adapter implementing the URML ROSAdapter Protocol."""
|
|
89
|
+
|
|
90
|
+
BRAND = "opcua"
|
|
91
|
+
|
|
92
|
+
def __init__(self, config: OpcUaConfig | None = None) -> None:
|
|
93
|
+
self._client_cls = _require_asyncua()
|
|
94
|
+
self._config = config or OpcUaConfig()
|
|
95
|
+
self._client: Any = None
|
|
96
|
+
self._objects: Any = None
|
|
97
|
+
self._reports: list[dict[str, Any]] = []
|
|
98
|
+
self._closed = False
|
|
99
|
+
|
|
100
|
+
def _connect(self) -> Any:
|
|
101
|
+
if self._client is not None:
|
|
102
|
+
return self._client
|
|
103
|
+
client = self._client_cls(self._config.endpoint_url, timeout=self._config.connect_timeout_seconds)
|
|
104
|
+
client.connect()
|
|
105
|
+
self._client = client
|
|
106
|
+
self._objects = client.get_node(self._config.objects_node)
|
|
107
|
+
return client
|
|
108
|
+
|
|
109
|
+
def _call(self, mt: MethodTarget) -> Any:
|
|
110
|
+
self._connect()
|
|
111
|
+
return self._objects.call_method(mt.method, *mt.args)
|
|
112
|
+
|
|
113
|
+
def close(self) -> None:
|
|
114
|
+
if self._closed:
|
|
115
|
+
return
|
|
116
|
+
if self._client is not None:
|
|
117
|
+
with suppress(Exception):
|
|
118
|
+
self._client.disconnect()
|
|
119
|
+
self._closed = True
|
|
120
|
+
|
|
121
|
+
def __enter__(self) -> OpcUaAdapter:
|
|
122
|
+
return self
|
|
123
|
+
|
|
124
|
+
def __exit__(self, *_: object) -> None:
|
|
125
|
+
self.close()
|
|
126
|
+
|
|
127
|
+
# ------------------------------------------------------------------
|
|
128
|
+
# Supported
|
|
129
|
+
# ------------------------------------------------------------------
|
|
130
|
+
|
|
131
|
+
def send_navigation_goal(
|
|
132
|
+
self,
|
|
133
|
+
*,
|
|
134
|
+
location: str | None = None,
|
|
135
|
+
pose: dict[str, float] | None = None,
|
|
136
|
+
frame: str | None = None,
|
|
137
|
+
carrying: dict[str, Any] | None = None,
|
|
138
|
+
speed: float | None = None,
|
|
139
|
+
) -> NavigationResult:
|
|
140
|
+
if location is None:
|
|
141
|
+
return NavigationResult(
|
|
142
|
+
success=False,
|
|
143
|
+
reason="opcua_requires_named_location: an OPC UA cell drives to named "
|
|
144
|
+
"method-mapped poses; raw pose goals are not exposed by the companion spec.",
|
|
145
|
+
)
|
|
146
|
+
mt = self._config.resolve_location(location)
|
|
147
|
+
if mt is None:
|
|
148
|
+
return NavigationResult(
|
|
149
|
+
success=False,
|
|
150
|
+
reason=f"location_not_configured: {location!r} is declared in the "
|
|
151
|
+
"manifest but not mapped to a method in opcua_adapter.yaml.",
|
|
152
|
+
)
|
|
153
|
+
self._call(mt)
|
|
154
|
+
return NavigationResult(success=True, final_pose=None, frame=frame or "cell")
|
|
155
|
+
|
|
156
|
+
def send_docking_goal(self, *, station: str, service: str, until: str | None = None) -> NavigationResult:
|
|
157
|
+
mt = self._config.resolve_service(service)
|
|
158
|
+
if mt is None:
|
|
159
|
+
return NavigationResult(
|
|
160
|
+
success=False,
|
|
161
|
+
reason=f"service_not_configured: station service {service!r} (station "
|
|
162
|
+
f"{station!r}) is not mapped to a method in opcua_adapter.yaml.",
|
|
163
|
+
)
|
|
164
|
+
self._call(mt)
|
|
165
|
+
return NavigationResult(success=True, final_pose=None, frame="cell")
|
|
166
|
+
|
|
167
|
+
def send_manipulation_goal(
|
|
168
|
+
self,
|
|
169
|
+
*,
|
|
170
|
+
action: Literal["grasp", "release"],
|
|
171
|
+
target: dict[str, Any] | None = None,
|
|
172
|
+
force_n: float | None = None,
|
|
173
|
+
approach: Literal["top", "side", "front", "auto"] = "auto",
|
|
174
|
+
release_mode: Literal["drop", "place", "hand_to_user"] | None = None,
|
|
175
|
+
release_at: dict[str, Any] | str | None = None,
|
|
176
|
+
arm: str | None = None,
|
|
177
|
+
grasp_type: str | None = None,
|
|
178
|
+
target_motion: str | None = None,
|
|
179
|
+
) -> ManipulationResult:
|
|
180
|
+
mt = self._config.manipulation_methods.get(action)
|
|
181
|
+
if mt is None:
|
|
182
|
+
return ManipulationResult(
|
|
183
|
+
success=False,
|
|
184
|
+
reason=f"manipulation_method_not_configured: {action!r} is not mapped "
|
|
185
|
+
"to a method in opcua_adapter.yaml.",
|
|
186
|
+
)
|
|
187
|
+
self._call(mt)
|
|
188
|
+
return ManipulationResult(success=True)
|
|
189
|
+
|
|
190
|
+
def wait_passively(self, *, duration_seconds: float) -> SubstrateResult:
|
|
191
|
+
self._connect()
|
|
192
|
+
return SubstrateResult(success=True)
|
|
193
|
+
|
|
194
|
+
def take_measurement(self, *, what: str, target: str | None, sensor: str | None) -> MeasurementResult:
|
|
195
|
+
if self._config.measurement_node is None:
|
|
196
|
+
return MeasurementResult(success=True, payload={"value": None, "what": what})
|
|
197
|
+
self._connect()
|
|
198
|
+
node = self._client.get_node(self._config.measurement_node)
|
|
199
|
+
value = node.read_value()
|
|
200
|
+
return MeasurementResult(success=True, payload={"value": value, "what": what})
|
|
201
|
+
|
|
202
|
+
def wait_for_condition(
|
|
203
|
+
self,
|
|
204
|
+
*,
|
|
205
|
+
kind: Literal["event", "signal", "input", "sensor_threshold"],
|
|
206
|
+
name: str | None,
|
|
207
|
+
input_mode: str | None,
|
|
208
|
+
threshold: dict[str, Any] | None,
|
|
209
|
+
timeout_seconds: float | None,
|
|
210
|
+
) -> WaitResult:
|
|
211
|
+
if self._config.measurement_node is None:
|
|
212
|
+
self._connect()
|
|
213
|
+
return WaitResult(success=True, timed_out=False, payload=None)
|
|
214
|
+
node = self._client.get_node(self._config.measurement_node) if self._connect() else None
|
|
215
|
+
value = node.read_value() if node is not None else None
|
|
216
|
+
return WaitResult(success=True, timed_out=False, payload={"value": value})
|
|
217
|
+
|
|
218
|
+
def emit_report(
|
|
219
|
+
self,
|
|
220
|
+
*,
|
|
221
|
+
to: str,
|
|
222
|
+
facts: dict[str, Any],
|
|
223
|
+
attachments: list[str] | None,
|
|
224
|
+
status: Literal["success", "partial", "failure"],
|
|
225
|
+
severity: Literal["info", "notice", "warning", "error"],
|
|
226
|
+
) -> SubstrateResult:
|
|
227
|
+
self._reports.append({"to": to, "status": status, "severity": severity, "facts": facts})
|
|
228
|
+
return SubstrateResult(success=True)
|
|
229
|
+
|
|
230
|
+
def run_scan(
|
|
231
|
+
self,
|
|
232
|
+
*,
|
|
233
|
+
area: dict[str, Any],
|
|
234
|
+
pattern: Literal["serpentine", "spiral", "grid", "adaptive"],
|
|
235
|
+
overlap: float,
|
|
236
|
+
altitude: float | None,
|
|
237
|
+
media: Literal["photo", "video", "sensor_only"],
|
|
238
|
+
sensor: str | None,
|
|
239
|
+
) -> ScanResult:
|
|
240
|
+
# A scan is waypoints plus a capture at each one, and this adapter
|
|
241
|
+
# does neither. Reporting success would claim an area was covered
|
|
242
|
+
# when nothing moved.
|
|
243
|
+
return ScanResult(success=False, reason=_NOT_SUPPORTED.format(capability="area-scan controller"))
|
|
244
|
+
|
|
245
|
+
# ------------------------------------------------------------------
|
|
246
|
+
# Not supported by a bare cell
|
|
247
|
+
# ------------------------------------------------------------------
|
|
248
|
+
|
|
249
|
+
def query_detection(
|
|
250
|
+
self,
|
|
251
|
+
*,
|
|
252
|
+
object_class: str,
|
|
253
|
+
attributes: dict[str, Any] | None = None,
|
|
254
|
+
where_near: str | None = None,
|
|
255
|
+
where_within: float | None = None,
|
|
256
|
+
) -> DetectionResult:
|
|
257
|
+
return DetectionResult(success=False, reason=_NOT_SUPPORTED.format(capability="onboard detection"))
|
|
258
|
+
|
|
259
|
+
def capture_media(
|
|
260
|
+
self,
|
|
261
|
+
*,
|
|
262
|
+
media: Literal["photo", "video"],
|
|
263
|
+
target: str | None,
|
|
264
|
+
duration_seconds: float | None,
|
|
265
|
+
attributes: dict[str, Any] | None,
|
|
266
|
+
camera: str | None = None,
|
|
267
|
+
) -> CaptureResult:
|
|
268
|
+
return CaptureResult(success=False, reason=_NOT_SUPPORTED.format(capability="recordable camera"))
|
|
269
|
+
|
|
270
|
+
def emit_speech(
|
|
271
|
+
self,
|
|
272
|
+
*,
|
|
273
|
+
utterance: str,
|
|
274
|
+
locale: str | None,
|
|
275
|
+
style: Literal["notice", "warning", "conversational"],
|
|
276
|
+
interrupt: bool,
|
|
277
|
+
) -> SubstrateResult:
|
|
278
|
+
return SubstrateResult(success=False, reason=_NOT_SUPPORTED.format(capability="speaker"))
|
|
279
|
+
|
|
280
|
+
def acquire_speech(
|
|
281
|
+
self,
|
|
282
|
+
*,
|
|
283
|
+
prompt: str | None,
|
|
284
|
+
locale: str | None,
|
|
285
|
+
timeout_seconds: float | None,
|
|
286
|
+
expected: Literal["free_form", "confirmation", "choice"],
|
|
287
|
+
choices: list[str] | None,
|
|
288
|
+
) -> ListenResult:
|
|
289
|
+
return ListenResult(success=False, reason=_NOT_SUPPORTED.format(capability="microphone"))
|
|
290
|
+
|
|
291
|
+
def call_named_program(
|
|
292
|
+
self,
|
|
293
|
+
*,
|
|
294
|
+
name: str,
|
|
295
|
+
args: dict[str, Any] | None = None,
|
|
296
|
+
) -> ProgramCallResult:
|
|
297
|
+
"""``call_program``: invoke an OPC UA method node by name (RFC-0015).
|
|
298
|
+
|
|
299
|
+
This is the primitive's motivating case: an OPC UA Robotics cell
|
|
300
|
+
exposes its ControlProgram / commissioned routines as method nodes.
|
|
301
|
+
The manifest-declared program name resolves to a method NodeId in
|
|
302
|
+
``opcua_adapter.yaml``; the adapter calls it on the ObjectsNode with
|
|
303
|
+
the configured literal args followed by any ``call_program`` args, and
|
|
304
|
+
surfaces the method's return as an opaque payload.
|
|
305
|
+
"""
|
|
306
|
+
mt = self._config.resolve_program(name)
|
|
307
|
+
if mt is None:
|
|
308
|
+
return ProgramCallResult(
|
|
309
|
+
success=False,
|
|
310
|
+
reason=f"program_not_configured: program {name!r} is not mapped to a "
|
|
311
|
+
"method node in opcua_adapter.yaml (program_to_method).",
|
|
312
|
+
)
|
|
313
|
+
self._connect()
|
|
314
|
+
call_args = [*mt.args, *(args.values() if args else [])]
|
|
315
|
+
result = self._objects.call_method(mt.method, *call_args)
|
|
316
|
+
payload = None if result is None else {"value": result}
|
|
317
|
+
return ProgramCallResult(success=True, payload=payload)
|
|
318
|
+
|
|
319
|
+
def send_takeoff_goal(self, *, altitude: float, climb_rate: float | None = None) -> NavigationResult:
|
|
320
|
+
return NavigationResult(success=False, reason=_NOT_APPLICABLE.format(capability="take_off"))
|
|
321
|
+
|
|
322
|
+
def send_land_goal(
|
|
323
|
+
self,
|
|
324
|
+
*,
|
|
325
|
+
at: str | None = None,
|
|
326
|
+
precision: Literal["standard", "precise"] = "standard",
|
|
327
|
+
) -> NavigationResult:
|
|
328
|
+
return NavigationResult(success=False, reason=_NOT_APPLICABLE.format(capability="land"))
|
|
329
|
+
|
|
330
|
+
def send_return_to_home_goal(
|
|
331
|
+
self,
|
|
332
|
+
*,
|
|
333
|
+
speed: float | None = None,
|
|
334
|
+
altitude: float | None = None,
|
|
335
|
+
) -> NavigationResult:
|
|
336
|
+
return NavigationResult(success=False, reason=_NOT_APPLICABLE.format(capability="return_to_home"))
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"""Deployment-side configuration for ``OpcUaAdapter``.
|
|
2
|
+
|
|
3
|
+
An OPC UA Robotics cell exposes its capabilities as method and variable
|
|
4
|
+
*nodes* under a server endpoint. Which node ids carry "move to a named
|
|
5
|
+
location", "run a station service", "grip", "read a sensor" are
|
|
6
|
+
deployment- and vendor-specific, so they do NOT belong in the URML
|
|
7
|
+
program, manifest, or envelope — they live in an ``opcua_adapter.yaml``
|
|
8
|
+
alongside the URML artifacts (the same principle as the PX4 runtime's
|
|
9
|
+
``location_to_pose`` and the marine runtime's ``location_to_waypoint``).
|
|
10
|
+
|
|
11
|
+
The adapter calls methods on the server's ObjectsNode by node id; the
|
|
12
|
+
objects node id and per-capability method node ids are all config.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
from pathlib import Path
|
|
18
|
+
|
|
19
|
+
import yaml
|
|
20
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class MethodTarget(BaseModel):
|
|
24
|
+
"""A node-id of an OPC UA method plus the literal args to call it with."""
|
|
25
|
+
|
|
26
|
+
model_config = ConfigDict(extra="forbid")
|
|
27
|
+
|
|
28
|
+
method: str = Field(..., description="NodeId of the method to call, e.g. 'ns=2;s=MoveTo'.")
|
|
29
|
+
args: list[str] = Field(default_factory=list, description="Literal string args passed to the method.")
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class OpcUaConfig(BaseModel):
|
|
33
|
+
"""OPC UA Robotics connection + node-mapping config."""
|
|
34
|
+
|
|
35
|
+
model_config = ConfigDict(extra="forbid")
|
|
36
|
+
|
|
37
|
+
endpoint_url: str = Field(
|
|
38
|
+
default="opc.tcp://127.0.0.1:4840/urml/",
|
|
39
|
+
description="OPC UA server endpoint. A local asyncua demo server uses opc.tcp://127.0.0.1:4840/.",
|
|
40
|
+
)
|
|
41
|
+
objects_node: str = Field(
|
|
42
|
+
default="i=85",
|
|
43
|
+
description="NodeId of the parent object the capability methods hang off (default: Objects).",
|
|
44
|
+
)
|
|
45
|
+
connect_timeout_seconds: float = 5.0
|
|
46
|
+
|
|
47
|
+
#: location name -> the MoveTo-style method + args that drives there.
|
|
48
|
+
location_to_method: dict[str, MethodTarget] = Field(default_factory=dict)
|
|
49
|
+
#: station-service name (e.g. swap_tool, park) -> its method + args.
|
|
50
|
+
service_to_method: dict[str, MethodTarget] = Field(default_factory=dict)
|
|
51
|
+
#: 'grasp' / 'release' -> their method nodes.
|
|
52
|
+
manipulation_methods: dict[str, MethodTarget] = Field(default_factory=dict)
|
|
53
|
+
#: a variable NodeId read by `measure` / polled by `wait_for`.
|
|
54
|
+
measurement_node: str | None = None
|
|
55
|
+
#: manifest-declared program name -> its OPC UA method node (RFC-0015
|
|
56
|
+
#: call_program). This is the motivating case: an OPC UA Robotics
|
|
57
|
+
#: ControlProgram / method node invoked by name.
|
|
58
|
+
program_to_method: dict[str, MethodTarget] = Field(default_factory=dict)
|
|
59
|
+
|
|
60
|
+
def resolve_location(self, name: str) -> MethodTarget | None:
|
|
61
|
+
return self.location_to_method.get(name)
|
|
62
|
+
|
|
63
|
+
def resolve_service(self, name: str) -> MethodTarget | None:
|
|
64
|
+
return self.service_to_method.get(name)
|
|
65
|
+
|
|
66
|
+
def resolve_program(self, name: str) -> MethodTarget | None:
|
|
67
|
+
return self.program_to_method.get(name)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def load_opcua_config(path: str | Path) -> OpcUaConfig:
|
|
71
|
+
"""Parse an ``opcua_adapter.yaml`` file into an ``OpcUaConfig``."""
|
|
72
|
+
p = Path(path)
|
|
73
|
+
with p.open(encoding="utf-8") as fh:
|
|
74
|
+
data = yaml.safe_load(fh) or {}
|
|
75
|
+
if not isinstance(data, dict):
|
|
76
|
+
raise ValueError(f"opcua-config file {p} did not contain a YAML mapping at the top level.")
|
|
77
|
+
return OpcUaConfig.model_validate(data)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"""Live smoke for OpcUaAdapter under a real ``asyncua`` install.
|
|
2
|
+
|
|
3
|
+
The OPC UA analog of the PX4 runtime's
|
|
4
|
+
``tests/integration/test_px4_adapter_live.py``. The *light* gate: it
|
|
5
|
+
needs only the real ``asyncua`` wheel. It constructs ``OpcUaAdapter``
|
|
6
|
+
(construction requires asyncua but does NOT connect — ``_connect`` is
|
|
7
|
+
lazy) and confirms the ``ConformanceRunner.adapter_factory`` hook
|
|
8
|
+
accepts it. A real-server end-to-end run against a local asyncua
|
|
9
|
+
demo server is the documented calibration step in
|
|
10
|
+
``opcua-integration.yml``.
|
|
11
|
+
|
|
12
|
+
## Gating
|
|
13
|
+
|
|
14
|
+
The default ``pytest`` invocation skips this module entirely. The
|
|
15
|
+
``opcua-smoke`` job in ``.github/workflows/opcua-integration.yml`` sets
|
|
16
|
+
``URML_OPCUA_INTEGRATION=1`` and runs it.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
|
|
21
|
+
import os
|
|
22
|
+
|
|
23
|
+
import pytest
|
|
24
|
+
|
|
25
|
+
pytestmark = pytest.mark.skipif(
|
|
26
|
+
os.environ.get("URML_OPCUA_INTEGRATION") != "1",
|
|
27
|
+
reason="Set URML_OPCUA_INTEGRATION=1 to run the OPC UA live smoke (real asyncua, no server).",
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def test_real_asyncua_is_importable() -> None:
|
|
32
|
+
"""The real asyncua sync client is available under the smoke env."""
|
|
33
|
+
from asyncua.sync import Client # noqa: F401
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def test_adapter_constructs_against_real_asyncua() -> None:
|
|
37
|
+
"""OpcUaAdapter constructs against real asyncua without connecting.
|
|
38
|
+
|
|
39
|
+
Construction calls ``_require_asyncua()`` (so it needs the real
|
|
40
|
+
wheel) but must NOT open a session — ``_connect`` is lazy and only
|
|
41
|
+
fires on the first Protocol call.
|
|
42
|
+
"""
|
|
43
|
+
from urml_opcua_runtime import OpcUaAdapter
|
|
44
|
+
|
|
45
|
+
with OpcUaAdapter() as adapter:
|
|
46
|
+
assert adapter._client is None # no Protocol method called -> no session
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def test_conformance_runner_accepts_real_adapter_factory() -> None:
|
|
50
|
+
"""The ConformanceRunner accepts a real OpcUaAdapter factory.
|
|
51
|
+
|
|
52
|
+
Does NOT run the fixture suite (that needs a live OPC UA server —
|
|
53
|
+
the documented calibration step). The hook itself is under test.
|
|
54
|
+
"""
|
|
55
|
+
from urml_conformance import ConformanceRunner
|
|
56
|
+
|
|
57
|
+
from urml_opcua_runtime import OpcUaAdapter
|
|
58
|
+
|
|
59
|
+
runner = ConformanceRunner(adapter_factory=lambda: OpcUaAdapter())
|
|
60
|
+
assert runner is not None
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"""Hermetic unit tests for OpcUaAdapter — no asyncua install needed.
|
|
2
|
+
|
|
3
|
+
A fake ``asyncua.sync`` module is injected into ``sys.modules`` so
|
|
4
|
+
``_require_asyncua`` resolves and ``_connect`` runs against a
|
|
5
|
+
controllable double (the same technique px4/marine/mujoco use).
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import sys
|
|
11
|
+
from collections.abc import Iterator
|
|
12
|
+
from types import ModuleType
|
|
13
|
+
from typing import Any
|
|
14
|
+
|
|
15
|
+
import pytest
|
|
16
|
+
from urml_ros2_runtime.substrate.base import DetectionResult, ROSAdapter
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class _FakeNode:
|
|
20
|
+
def __init__(self, store: dict[str, Any]) -> None:
|
|
21
|
+
self._store = store
|
|
22
|
+
|
|
23
|
+
def call_method(self, method: str, *args: Any) -> str:
|
|
24
|
+
self._store.setdefault("calls", []).append((method, args))
|
|
25
|
+
return "ok"
|
|
26
|
+
|
|
27
|
+
def read_value(self) -> float:
|
|
28
|
+
return 7.0
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class _FakeClient:
|
|
32
|
+
def __init__(self, url: str, timeout: float = 5.0) -> None:
|
|
33
|
+
self.url = url
|
|
34
|
+
self.connected = False
|
|
35
|
+
self.disconnected = False
|
|
36
|
+
self.store: dict[str, Any] = {}
|
|
37
|
+
|
|
38
|
+
def connect(self) -> None:
|
|
39
|
+
self.connected = True
|
|
40
|
+
|
|
41
|
+
def disconnect(self) -> None:
|
|
42
|
+
self.disconnected = True
|
|
43
|
+
|
|
44
|
+
def get_node(self, nodeid: str) -> _FakeNode:
|
|
45
|
+
return _FakeNode(self.store)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@pytest.fixture
|
|
49
|
+
def fake_asyncua() -> Iterator[type[_FakeClient]]:
|
|
50
|
+
sync_mod = ModuleType("asyncua.sync")
|
|
51
|
+
sync_mod.Client = _FakeClient # type: ignore[attr-defined]
|
|
52
|
+
pkg = ModuleType("asyncua")
|
|
53
|
+
pkg.sync = sync_mod # type: ignore[attr-defined]
|
|
54
|
+
saved = {k: sys.modules.get(k) for k in ("asyncua", "asyncua.sync")}
|
|
55
|
+
sys.modules["asyncua"] = pkg
|
|
56
|
+
sys.modules["asyncua.sync"] = sync_mod
|
|
57
|
+
try:
|
|
58
|
+
yield _FakeClient
|
|
59
|
+
finally:
|
|
60
|
+
for k, v in saved.items():
|
|
61
|
+
if v is None:
|
|
62
|
+
sys.modules.pop(k, None)
|
|
63
|
+
else:
|
|
64
|
+
sys.modules[k] = v
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def test_nav_dock_grasp_measure_lifecycle(fake_asyncua: type[_FakeClient]) -> None:
|
|
68
|
+
from urml_opcua_runtime import OpcUaAdapter, OpcUaConfig
|
|
69
|
+
from urml_opcua_runtime.adapter import MethodTarget
|
|
70
|
+
|
|
71
|
+
cfg = OpcUaConfig(
|
|
72
|
+
location_to_method={"pick_bin": MethodTarget(method="ns=2;s=MoveTo", args=["pick_bin"])},
|
|
73
|
+
service_to_method={"swap_tool": MethodTarget(method="ns=2;s=SwapTool", args=["wide"])},
|
|
74
|
+
manipulation_methods={"grasp": MethodTarget(method="ns=2;s=Grip")},
|
|
75
|
+
measurement_node="ns=2;s=Force",
|
|
76
|
+
program_to_method={"pick_place_cycle": MethodTarget(method="ns=2;s=PickPlaceCycle")},
|
|
77
|
+
)
|
|
78
|
+
with OpcUaAdapter(cfg) as cell:
|
|
79
|
+
assert isinstance(cell, ROSAdapter)
|
|
80
|
+
assert cell.send_navigation_goal(location="pick_bin").success
|
|
81
|
+
miss = cell.send_navigation_goal(location="nowhere")
|
|
82
|
+
assert miss.success is False and miss.reason is not None
|
|
83
|
+
assert miss.reason.startswith("location_not_configured")
|
|
84
|
+
# RFC-0013 swap_tool rides send_docking_goal — preserved.
|
|
85
|
+
assert cell.send_docking_goal(station="tool_change_station", service="swap_tool", until="wide").success
|
|
86
|
+
assert cell.send_manipulation_goal(action="grasp").success
|
|
87
|
+
# RFC-0015 call_program -> OPC UA method node (the motivating case).
|
|
88
|
+
prog = cell.call_named_program(name="pick_place_cycle")
|
|
89
|
+
assert prog.success and prog.payload == {"value": "ok"}
|
|
90
|
+
meas = cell.take_measurement(what="force", target=None, sensor="tcp_force")
|
|
91
|
+
assert meas.success and meas.payload is not None and meas.payload["value"] == 7.0
|
|
92
|
+
assert cell.wait_passively(duration_seconds=0.1).success
|
|
93
|
+
scan = cell.run_scan(
|
|
94
|
+
area={}, pattern="grid", overlap=0.1, altitude=None, media="sensor_only", sensor=None
|
|
95
|
+
)
|
|
96
|
+
assert not scan.success and "area-scan controller" in (scan.reason or "")
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def test_unconfigured_and_unsupported_sentinels(fake_asyncua: type[_FakeClient]) -> None:
|
|
100
|
+
from urml_opcua_runtime import OpcUaAdapter, OpcUaConfig
|
|
101
|
+
|
|
102
|
+
cell = OpcUaAdapter(OpcUaConfig())
|
|
103
|
+
nores = cell.send_manipulation_goal(action="grasp")
|
|
104
|
+
assert nores.success is False
|
|
105
|
+
assert nores.reason is not None and nores.reason.startswith("manipulation_method_not_configured")
|
|
106
|
+
det: DetectionResult = cell.query_detection(object_class="widget")
|
|
107
|
+
assert det.success is False and det.reason is not None
|
|
108
|
+
assert det.reason.startswith("not_supported_on_opcua_cell")
|
|
109
|
+
prog = cell.call_named_program(name="unmapped_program")
|
|
110
|
+
assert prog.success is False and prog.reason is not None
|
|
111
|
+
assert prog.reason.startswith("program_not_configured")
|
|
112
|
+
for r in (cell.send_takeoff_goal(altitude=1.0), cell.send_land_goal(), cell.send_return_to_home_goal()):
|
|
113
|
+
assert r.success is False
|
|
114
|
+
assert r.reason is not None and r.reason.startswith("not_applicable_opcua")
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def test_missing_asyncua_is_actionable(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
118
|
+
"""Construction without the [opcua] extra raises a clear error.
|
|
119
|
+
|
|
120
|
+
Setting the sys.modules entries to None forces ``import asyncua.sync``
|
|
121
|
+
to raise ImportError deterministically, whether or not asyncua is
|
|
122
|
+
actually installed in the test environment.
|
|
123
|
+
"""
|
|
124
|
+
from urml_opcua_runtime import OpcUaAdapter
|
|
125
|
+
|
|
126
|
+
monkeypatch.setitem(sys.modules, "asyncua", None)
|
|
127
|
+
monkeypatch.setitem(sys.modules, "asyncua.sync", None)
|
|
128
|
+
with pytest.raises(RuntimeError, match=r"\[opcua\] extra"):
|
|
129
|
+
OpcUaAdapter()
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def test_conformance_runner_accepts_factory(fake_asyncua: type[_FakeClient]) -> None:
|
|
133
|
+
from urml_conformance import ConformanceRunner
|
|
134
|
+
|
|
135
|
+
from urml_opcua_runtime import OpcUaAdapter
|
|
136
|
+
|
|
137
|
+
assert ConformanceRunner(adapter_factory=lambda: OpcUaAdapter()) is not None
|