urml-opcua-runtime 0.5.2__py3-none-any.whl
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/__init__.py +23 -0
- urml_opcua_runtime/_version.py +3 -0
- urml_opcua_runtime/adapter.py +336 -0
- urml_opcua_runtime/config.py +77 -0
- urml_opcua_runtime/py.typed +0 -0
- urml_opcua_runtime-0.5.2.dist-info/METADATA +102 -0
- urml_opcua_runtime-0.5.2.dist-info/RECORD +8 -0
- urml_opcua_runtime-0.5.2.dist-info/WHEEL +4 -0
|
@@ -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
|
|
@@ -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,8 @@
|
|
|
1
|
+
urml_opcua_runtime/__init__.py,sha256=9riZ2qswAqpleL52gNt9jWBIaxWGhttEhCv2u9VZMV4,849
|
|
2
|
+
urml_opcua_runtime/_version.py,sha256=wirsV7Pr4mdRTPYyy-xTH2cUbgmNbAtlfBk_dmsOTGU,66
|
|
3
|
+
urml_opcua_runtime/adapter.py,sha256=vFAeZyakFUapxxwdLKak1OT8R7UJ0fmsnrilvwdTdak,12902
|
|
4
|
+
urml_opcua_runtime/config.py,sha256=rl_yXsXRjVMwks78qE2Evrmha-JOZl_L4Jw0-ybLAxk,3283
|
|
5
|
+
urml_opcua_runtime/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
urml_opcua_runtime-0.5.2.dist-info/METADATA,sha256=MYqNHQ4cNe0Y9weISB-FYNFlioBZ00DHZmwVw1aiJ4U,5686
|
|
7
|
+
urml_opcua_runtime-0.5.2.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
8
|
+
urml_opcua_runtime-0.5.2.dist-info/RECORD,,
|