urml-marine-runtime 0.5.3__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.
@@ -0,0 +1,115 @@
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 and distribution records (RFC-0710) ---
101
+ # This repository holds no outreach or distribution state. Target lists,
102
+ # message drafts, ledgers and their derived databases live in the Licensor's
103
+ # private archive. These patterns keep a stray local copy out of a commit.
104
+ outreach/
105
+ examples/lighthouses/
106
+ tools/outreach_app/
107
+ tools/outreach.db
108
+ tools/.outreach.db
109
+
110
+ # Local Claude Code settings (per-machine; permission rules, etc.). Not committed.
111
+ .claude/settings.json
112
+ .claude/settings.local.json
113
+
114
+ # Claude Code session worktrees (`claude -w <name>`); see AGENTS.md "Parallel sessions".
115
+ .claude/worktrees/
@@ -0,0 +1,127 @@
1
+ Business Source License 1.1
2
+
3
+ Parameters
4
+
5
+ Licensor: Yahalomik Ltd.
6
+
7
+ Licensed Work: URML (Universal Robot Language): the
8
+ specification, reference runtimes, validator, LLM
9
+ bridge, MCP server, conformance suite, tools and
10
+ examples in this repository, in every version
11
+ released after 0.4.x and in all source published
12
+ here on or after 2026-11-22.
13
+ The Licensed Work is (c) 2026 Yahalomik Ltd.
14
+
15
+ Releases up to and including 0.4.x, and source
16
+ published before 2026-11-22, were released under
17
+ the Apache License, Version 2.0 and remain under it.
18
+ Files that carry their own LICENSE file (for
19
+ example examples/gopigo3/) are under that license.
20
+
21
+ Additional Use Grant: You may make non-production use of the Licensed
22
+ Work. Non-production use includes research,
23
+ teaching and coursework, evaluation and
24
+ proof-of-concept work, development and testing,
25
+ simulation, and personal projects that are not
26
+ offered or sold to others.
27
+
28
+ Any other use, including operating robots in a
29
+ commercial or business setting, shipping the
30
+ Licensed Work in a product, or offering it as a
31
+ service, requires a commercial license from the
32
+ Licensor: sales@urml.dev
33
+
34
+ Change Date: Four years from the date each version of the
35
+ Licensed Work is first publicly released.
36
+
37
+ Versions first publicly released with a Change
38
+ Date of two years, including 0.5.0, 0.5.1 and
39
+ 0.5.2, and source published here from 2026-11-22
40
+ until this four-year Change Date was first
41
+ published here, keep it: two years from the date
42
+ each was first publicly released.
43
+
44
+ Change License: Apache License, Version 2.0
45
+
46
+ For information about alternative licensing arrangements for the Licensed
47
+ Work, please contact sales@urml.dev.
48
+
49
+ Notice
50
+
51
+ The Business Source License (this document, or the "License") is not an Open
52
+ Source license. However, the Licensed Work will eventually be made available
53
+ under an Open Source License, as stated in this License.
54
+
55
+ License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
56
+ "Business Source License" is a trademark of MariaDB Corporation Ab.
57
+
58
+ -----------------------------------------------------------------------------
59
+
60
+ Business Source License 1.1
61
+
62
+ Terms
63
+
64
+ The Licensor hereby grants you the right to copy, modify, create derivative
65
+ works, redistribute, and make non-production use of the Licensed Work. The
66
+ Licensor may make an Additional Use Grant, above, permitting limited
67
+ production use.
68
+
69
+ Effective on the Change Date, or the fourth anniversary of the first publicly
70
+ available distribution of a specific version of the Licensed Work under this
71
+ License, whichever comes first, the Licensor hereby grants you rights under
72
+ the terms of the Change License, and the rights granted in the paragraph
73
+ above terminate.
74
+
75
+ If your use of the Licensed Work does not comply with the requirements
76
+ currently in effect as described in this License, you must purchase a
77
+ commercial license from the Licensor, its affiliated entities, or authorized
78
+ resellers, or you must refrain from using the Licensed Work.
79
+
80
+ All copies of the original and modified Licensed Work, and derivative works
81
+ of the Licensed Work, are subject to this License. This License applies
82
+ separately for each version of the Licensed Work and the Change Date may vary
83
+ for each version of the Licensed Work released by Licensor.
84
+
85
+ You must conspicuously display this License on each original or modified copy
86
+ of the Licensed Work. If you receive the Licensed Work in original or
87
+ modified form from a third party, the terms and conditions set forth in this
88
+ License apply to your use of that work.
89
+
90
+ Any use of the Licensed Work in violation of this License will automatically
91
+ terminate your rights under this License for the current and all other
92
+ versions of the Licensed Work.
93
+
94
+ This License does not grant you any right in any trademark or logo of
95
+ Licensor or its affiliates (provided that you may use a trademark or logo of
96
+ Licensor as expressly required by this License).
97
+
98
+ TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
99
+ AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
100
+ EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
101
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
102
+ TITLE.
103
+
104
+ MariaDB hereby grants you permission to use this License’s text to license
105
+ your works, and to refer to it using the trademark “Business Source License”,
106
+ as long as you comply with the Covenants of Licensor below.
107
+
108
+ Covenants of Licensor
109
+
110
+ In consideration of the right to use this License’s text and the “Business
111
+ Source License” name and trademark, Licensor covenants to MariaDB, and to all
112
+ other recipients of the licensed work to be provided by Licensor:
113
+
114
+ 1. To specify as the Change License the GPL Version 2.0 or any later version,
115
+ or a license that is compatible with GPL Version 2.0 or a later version,
116
+ where “compatible” means that software provided under the Change License can
117
+ be included in a program with software provided under GPL Version 2.0 or a
118
+ later version. Licensor may specify additional Change Licenses without
119
+ limitation.
120
+
121
+ 2. To either: (a) specify an additional grant of rights to use that does not
122
+ impose any additional restriction on the right granted in this License, as
123
+ the Additional Use Grant; or (b) insert the text “None”.
124
+
125
+ 3. To specify a Change Date.
126
+
127
+ 4. Not to modify this License in any other way.
@@ -0,0 +1,96 @@
1
+ Metadata-Version: 2.5
2
+ Name: urml-marine-runtime
3
+ Version: 0.5.3
4
+ Summary: Underwater-vehicle reference runtime for URML — BlueROV2 / ArduSub via MAVLink.
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
+ License-File: LICENSE
11
+ Keywords: ardusub,bluerov,mavlink,robotics,rov,runtime,underwater,urml
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: Other/Proprietary License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Scientific/Engineering
20
+ Requires-Python: >=3.11
21
+ Requires-Dist: pydantic<3,>=2.6
22
+ Requires-Dist: pyyaml<7,>=6.0
23
+ Requires-Dist: urml-ros2-runtime>=0.5.3
24
+ Requires-Dist: urml-validator>=0.5.3
25
+ Provides-Extra: dev
26
+ Requires-Dist: mypy>=1.10; extra == 'dev'
27
+ Requires-Dist: pytest-cov>=5; extra == 'dev'
28
+ Requires-Dist: pytest>=8; extra == 'dev'
29
+ Requires-Dist: ruff>=0.5; extra == 'dev'
30
+ Provides-Extra: marine
31
+ Requires-Dist: pymavlink<3,>=2.4; extra == 'marine'
32
+ Description-Content-Type: text/markdown
33
+
34
+ <p align="center">
35
+ <a href="https://urml.dev"><img src="https://urml.dev/favicon.svg" alt="URML" width="72" height="72"></a>
36
+ </p>
37
+
38
+ <p align="center">
39
+ A small, opinionated, human-readable language for describing robot intent.
40
+ </p>
41
+
42
+ <p align="center">
43
+ <a href="https://urml.dev"><b>urml.dev</b></a>
44
+ </p>
45
+
46
+ ---
47
+
48
+ # urml-marine-runtime
49
+
50
+ **Underwater-vehicle reference runtime for URML** — `BlueRovAdapter` for **BlueROV2 / ArduSub**, via MAVLink.
51
+
52
+ ArduSub speaks MAVLink exactly like PX4, so this adapter mirrors `PX4Adapter`: lazy `pymavlink`, **no ROS 2 dependency**, a lazily-opened cached connection, failures returned not raised. It is the underwater analog of the PX4 no-ROS proof, and it activates the `underwater_thrusters` `mobility.drive_type` that already exists in the v0.1 manifest schema (so **no RFC is needed** — unlike legged/biped, which needed RFC-0009).
53
+
54
+ ## Method coverage
55
+
56
+ | URML primitive | v0.1 |
57
+ |---|---|
58
+ | `move_to` / `hover` | `SET_POSITION_TARGET_LOCAL_NED` to a configured waypoint (location → north/east/depth) |
59
+ | `wait` | timed hold |
60
+ | `measure` | `SCALED_PRESSURE` (depth) / `BATTERY_STATUS` telemetry |
61
+ | `wait_for` | MAVLink message subscribe-once with predicate |
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
+ `grasp`/`release`, `dock`, `detect`, `capture`, `speak`, `listen` return `not_supported_on_bare_rov` (a manipulator/perception payload pairs via a companion). The drone trio `take_off`/`land`/`return_to_home` return `not_applicable_underwater` — honest: a submersible does not take off or land.
66
+
67
+ ## Install / use
68
+
69
+ ```bash
70
+ pip install -e reference/marine-runtime[marine] # installs pymavlink
71
+ ```
72
+
73
+ ```python
74
+ from urml_marine_runtime import BlueRovAdapter, MarineConfig
75
+ with BlueRovAdapter(MarineConfig(connection_url="udp:127.0.0.1:14550")) as rov:
76
+ assert rov.send_navigation_goal(pose={"north": 5.0, "east": 0.0, "depth": 3.0}).success
77
+ ```
78
+
79
+ ## Status
80
+
81
+ **v0.1 (this release):**
82
+ - `BlueRovAdapter` + `MarineConfig` (MAVLink, no ROS). `bluerov_marine` manifest exercises `drive_type: underwater_thrusters`; `conformance/fixtures/marine/` survey fixture verified through the runner.
83
+ - Hermetic unit tests: navigation (configured + unmapped), measure, scan (not supported), lifecycle, the not-supported / not-applicable-underwater sentinels, the missing-`[marine]`-extra error, the conformance hook; no pymavlink install required.
84
+ - Gated `.github/workflows/marine-integration.yml`: `marine-smoke` (real pymavlink), `marine-arm64-build` (the Jetson-class QEMU signal), and `marine-sitl-e2e` against ArduSub SITL (first run is a calibration run by design — the established px4/ros2 convention).
85
+
86
+ **Follow-ups (not yet):**
87
+ - Manipulator-payload companion (BlueROV + arm) wiring; a survey-pattern `scan` (waypoints with a capture at each one); until then `scan` returns not-supported.
88
+
89
+ ## Core Commitment
90
+
91
+ This runtime is licensed under the 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.
92
+
93
+ ## Related documents
94
+
95
+ - [`/reference/px4-runtime/`](../px4-runtime/) — the MAVLink sibling whose structure this mirrors.
96
+ - [`/conformance/`](../../conformance/) — the test suite that decides conformance.
@@ -0,0 +1,63 @@
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-marine-runtime
16
+
17
+ **Underwater-vehicle reference runtime for URML** — `BlueRovAdapter` for **BlueROV2 / ArduSub**, via MAVLink.
18
+
19
+ ArduSub speaks MAVLink exactly like PX4, so this adapter mirrors `PX4Adapter`: lazy `pymavlink`, **no ROS 2 dependency**, a lazily-opened cached connection, failures returned not raised. It is the underwater analog of the PX4 no-ROS proof, and it activates the `underwater_thrusters` `mobility.drive_type` that already exists in the v0.1 manifest schema (so **no RFC is needed** — unlike legged/biped, which needed RFC-0009).
20
+
21
+ ## Method coverage
22
+
23
+ | URML primitive | v0.1 |
24
+ |---|---|
25
+ | `move_to` / `hover` | `SET_POSITION_TARGET_LOCAL_NED` to a configured waypoint (location → north/east/depth) |
26
+ | `wait` | timed hold |
27
+ | `measure` | `SCALED_PRESSURE` (depth) / `BATTERY_STATUS` telemetry |
28
+ | `wait_for` | MAVLink message subscribe-once with predicate |
29
+ | `report` | structured record to a local sink (no cloud) |
30
+ | `scan` | documented not-supported result: no area-scan controller (a scan is waypoints plus a capture at each one) |
31
+
32
+ `grasp`/`release`, `dock`, `detect`, `capture`, `speak`, `listen` return `not_supported_on_bare_rov` (a manipulator/perception payload pairs via a companion). The drone trio `take_off`/`land`/`return_to_home` return `not_applicable_underwater` — honest: a submersible does not take off or land.
33
+
34
+ ## Install / use
35
+
36
+ ```bash
37
+ pip install -e reference/marine-runtime[marine] # installs pymavlink
38
+ ```
39
+
40
+ ```python
41
+ from urml_marine_runtime import BlueRovAdapter, MarineConfig
42
+ with BlueRovAdapter(MarineConfig(connection_url="udp:127.0.0.1:14550")) as rov:
43
+ assert rov.send_navigation_goal(pose={"north": 5.0, "east": 0.0, "depth": 3.0}).success
44
+ ```
45
+
46
+ ## Status
47
+
48
+ **v0.1 (this release):**
49
+ - `BlueRovAdapter` + `MarineConfig` (MAVLink, no ROS). `bluerov_marine` manifest exercises `drive_type: underwater_thrusters`; `conformance/fixtures/marine/` survey fixture verified through the runner.
50
+ - Hermetic unit tests: navigation (configured + unmapped), measure, scan (not supported), lifecycle, the not-supported / not-applicable-underwater sentinels, the missing-`[marine]`-extra error, the conformance hook; no pymavlink install required.
51
+ - Gated `.github/workflows/marine-integration.yml`: `marine-smoke` (real pymavlink), `marine-arm64-build` (the Jetson-class QEMU signal), and `marine-sitl-e2e` against ArduSub SITL (first run is a calibration run by design — the established px4/ros2 convention).
52
+
53
+ **Follow-ups (not yet):**
54
+ - Manipulator-payload companion (BlueROV + arm) wiring; a survey-pattern `scan` (waypoints with a capture at each one); until then `scan` returns not-supported.
55
+
56
+ ## Core Commitment
57
+
58
+ This runtime is licensed under the 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.
59
+
60
+ ## Related documents
61
+
62
+ - [`/reference/px4-runtime/`](../px4-runtime/) — the MAVLink sibling whose structure this mirrors.
63
+ - [`/conformance/`](../../conformance/) — the test suite that decides conformance.
@@ -0,0 +1,78 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.27"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "urml-marine-runtime"
7
+ version = "0.5.3"
8
+ description = "Underwater-vehicle reference runtime for URML — BlueROV2 / ArduSub via MAVLink."
9
+ readme = "README.md"
10
+ license = { text = "BUSL-1.1" }
11
+ requires-python = ">=3.11"
12
+ authors = [{ name = "URML Maintainers" }]
13
+ keywords = ["robotics", "underwater", "rov", "bluerov", "ardusub", "mavlink", "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.3",
28
+ "urml-ros2-runtime>=0.5.3",
29
+ ]
30
+
31
+ [project.optional-dependencies]
32
+ # ArduSub speaks MAVLink, same as PX4 — pymavlink is a normal PyPI
33
+ # wheel. Installing urml-marine-runtime[marine] gives everything
34
+ # BlueRovAdapter needs against a real BlueROV2 or ArduSub SITL. No ROS
35
+ # dependency (this is the underwater analog of PX4Adapter's no-ROS
36
+ # proof). pymavlink is imported lazily, so the module loads on every
37
+ # host.
38
+ marine = [
39
+ "pymavlink>=2.4,<3",
40
+ ]
41
+ dev = [
42
+ "pytest>=8",
43
+ "pytest-cov>=5",
44
+ "ruff>=0.5",
45
+ "mypy>=1.10",
46
+ ]
47
+
48
+ [project.urls]
49
+ Homepage = "https://github.com/urml-dev/URML"
50
+ Repository = "https://github.com/urml-dev/URML"
51
+ Issues = "https://github.com/urml-dev/URML/issues"
52
+
53
+ [tool.hatch.build.targets.wheel]
54
+ packages = ["src/urml_marine_runtime"]
55
+
56
+ [tool.ruff]
57
+ line-length = 120
58
+ target-version = "py311"
59
+ src = ["src", "tests"]
60
+
61
+ [tool.ruff.lint]
62
+ select = ["E", "F", "W", "I", "B", "UP", "N", "ANN", "RUF"]
63
+ ignore = ["ANN401"]
64
+
65
+ [tool.ruff.lint.per-file-ignores]
66
+ "tests/*" = ["ANN"]
67
+
68
+ [tool.mypy]
69
+ strict = true
70
+ python_version = "3.11"
71
+ plugins = ["pydantic.mypy"]
72
+ mypy_path = "src"
73
+ packages = ["urml_marine_runtime"]
74
+
75
+ [tool.pytest.ini_options]
76
+ minversion = "8.0"
77
+ testpaths = ["tests"]
78
+ addopts = ["-q", "--strict-markers"]
@@ -0,0 +1,21 @@
1
+ """urml_marine_runtime — underwater-vehicle reference runtime for URML.
2
+
3
+ BlueRovAdapter (+ MarineConfig, load_marine_config)
4
+ BlueROV2 / ArduSub via MAVLink (pymavlink). No ROS 2 dependency —
5
+ the underwater analog of PX4Adapter's no-ROS proof. Activates the
6
+ `underwater_thrusters` mobility.drive_type (already in the v0.1
7
+ schema). pymavlink is imported lazily (the [marine] extra), so this
8
+ module loads on every host.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ from urml_marine_runtime._version import __version__
14
+ from urml_marine_runtime.adapter import BlueRovAdapter, MarineConfig, load_marine_config
15
+
16
+ __all__ = [
17
+ "BlueRovAdapter",
18
+ "MarineConfig",
19
+ "__version__",
20
+ "load_marine_config",
21
+ ]
@@ -0,0 +1,3 @@
1
+ """Package version. Bumped per release."""
2
+
3
+ __version__ = "0.5.3"
@@ -0,0 +1,326 @@
1
+ """BlueRovAdapter — BlueROV2 / ArduSub underwater vehicle, via MAVLink.
2
+
3
+ ArduSub speaks MAVLink, exactly like PX4, so this adapter mirrors
4
+ :class:`PX4Adapter`: lazy ``pymavlink``, **no ROS 2 dependency**, a
5
+ lazily-opened cached connection, failures returned not raised. It is
6
+ the underwater analog of the PX4 no-ROS proof, and it activates the
7
+ ``underwater_thrusters`` ``mobility.drive_type`` (already in the v0.1
8
+ manifest schema — no RFC needed).
9
+
10
+ ## v0.1 method coverage
11
+
12
+ Supported (mapped to MAVLink against ArduSub's GUIDED mode):
13
+
14
+ - ``move_to`` / ``hover`` → ``SET_POSITION_TARGET_LOCAL_NED`` to a
15
+ configured waypoint (location → north/east/depth via
16
+ :class:`MarineConfig`); ``hover`` is a zero-velocity hold (ArduSub
17
+ position/depth hold).
18
+ - ``wait`` → timed hold.
19
+ - ``measure`` → telemetry (``SCALED_PRESSURE`` depth, ``BATTERY_STATUS``).
20
+ - ``wait_for`` → MAVLink message-stream subscribe-once with a predicate.
21
+ - ``report`` → structured record to a local sink (no cloud — manifesto).
22
+ - ``scan`` → documented not-supported result: this adapter does not
23
+ expand an area into waypoints or capture along them.
24
+
25
+ Not supported on a bare ROV (returned, not raised): ``grasp`` /
26
+ ``release`` (needs a manipulator payload — a follow-up companion),
27
+ ``dock``, ``detect``, ``capture``, ``speak``, ``listen``; and the
28
+ drone trio ``take_off`` / ``land`` / ``return_to_home`` are
29
+ ``not_applicable_underwater``.
30
+ """
31
+
32
+ from __future__ import annotations
33
+
34
+ from contextlib import suppress
35
+ from typing import Any, Literal
36
+
37
+ import yaml
38
+ from pydantic import BaseModel, ConfigDict, Field
39
+ from urml_ros2_runtime.substrate.base import (
40
+ ProgramCallResult,
41
+ unsupported_program_call,
42
+ CaptureResult,
43
+ DetectionResult,
44
+ ListenResult,
45
+ ManipulationResult,
46
+ MeasurementResult,
47
+ NavigationResult,
48
+ ScanResult,
49
+ SubstrateResult,
50
+ WaitResult,
51
+ )
52
+
53
+ from urml_marine_runtime._version import __version__
54
+
55
+ __all__ = ["BlueRovAdapter", "MarineConfig", "__version__", "load_marine_config"]
56
+
57
+ _NOT_SUPPORTED = (
58
+ "not_supported_on_bare_rov: a bare BlueROV2 has no {capability}. Pair it "
59
+ "with a manipulator/perception payload companion adapter for full "
60
+ "coverage; the URML program, manifest, and validator are unchanged."
61
+ )
62
+ _NOT_UNDERWATER = "not_applicable_underwater: {capability} has no meaning for a submersible."
63
+
64
+
65
+ class Waypoint(BaseModel):
66
+ """A local-NED-ish underwater waypoint. ``depth`` is metres below surface (positive down)."""
67
+
68
+ model_config = ConfigDict(extra="forbid")
69
+
70
+ north: float = 0.0
71
+ east: float = 0.0
72
+ depth: float = 0.0
73
+
74
+
75
+ class MarineConfig(BaseModel):
76
+ """Deployment-side BlueROV2 / ArduSub connection config."""
77
+
78
+ model_config = ConfigDict(extra="forbid")
79
+
80
+ connection_url: str = Field(
81
+ default="udp:127.0.0.1:14550",
82
+ description="pymavlink connection string. ArduSub SITL: 'udp:127.0.0.1:14550'.",
83
+ )
84
+ system_id: int = 255
85
+ component_id: int = 1
86
+ heartbeat_timeout_seconds: float = 5.0
87
+ location_to_waypoint: dict[str, Waypoint] = Field(default_factory=dict)
88
+
89
+ def resolve_location(self, name: str) -> Waypoint | None:
90
+ return self.location_to_waypoint.get(name)
91
+
92
+
93
+ def load_marine_config(path: str) -> MarineConfig:
94
+ """Parse a ``marine_adapter.yaml`` file into a :class:`MarineConfig`."""
95
+ with open(path, encoding="utf-8") as fh:
96
+ data = yaml.safe_load(fh) or {}
97
+ if not isinstance(data, dict):
98
+ raise ValueError(f"marine-config file {path} did not contain a YAML mapping at the top level.")
99
+ return MarineConfig.model_validate(data)
100
+
101
+
102
+ def _require_pymavlink() -> Any:
103
+ """Lazy-import pymavlink with a clear error when missing."""
104
+ try:
105
+ from pymavlink import mavutil # type: ignore[import-not-found,unused-ignore]
106
+ except ImportError as exc:
107
+ raise RuntimeError(
108
+ "pymavlink is not installed. BlueRovAdapter requires the [marine] extra.\n"
109
+ " Install with: pip install urml-marine-runtime[marine]"
110
+ ) from exc
111
+ return mavutil
112
+
113
+
114
+ class BlueRovAdapter:
115
+ """BlueROV2 / ArduSub adapter implementing the URML ROSAdapter Protocol."""
116
+
117
+ BRAND = "bluerov"
118
+
119
+ def __init__(self, config: MarineConfig | None = None) -> None:
120
+ self._mavutil = _require_pymavlink()
121
+ self._config = config or MarineConfig()
122
+ self._conn: Any = None
123
+ self._reports: list[dict[str, Any]] = []
124
+ self._closed = False
125
+
126
+ def _connect(self) -> Any:
127
+ if self._conn is not None:
128
+ return self._conn
129
+ conn = self._mavutil.mavlink_connection(
130
+ self._config.connection_url,
131
+ source_system=self._config.system_id,
132
+ source_component=self._config.component_id,
133
+ )
134
+ conn.wait_heartbeat(timeout=self._config.heartbeat_timeout_seconds)
135
+ self._conn = conn
136
+ return conn
137
+
138
+ def close(self) -> None:
139
+ if self._closed:
140
+ return
141
+ if self._conn is not None:
142
+ with suppress(Exception):
143
+ self._conn.close()
144
+ self._closed = True
145
+
146
+ def __enter__(self) -> BlueRovAdapter:
147
+ return self
148
+
149
+ def __exit__(self, *_: object) -> None:
150
+ self.close()
151
+
152
+ # ------------------------------------------------------------------
153
+ # Supported
154
+ # ------------------------------------------------------------------
155
+
156
+ def send_navigation_goal(
157
+ self,
158
+ *,
159
+ location: str | None = None,
160
+ pose: dict[str, float] | None = None,
161
+ frame: str | None = None,
162
+ carrying: dict[str, Any] | None = None,
163
+ speed: float | None = None,
164
+ ) -> NavigationResult:
165
+ if location is None and pose is None:
166
+ return NavigationResult(success=False, reason="send_navigation_goal called without location or pose")
167
+ if location is not None:
168
+ wp = self._config.resolve_location(location)
169
+ if wp is None:
170
+ return NavigationResult(
171
+ success=False,
172
+ reason=f"location_not_configured: {location!r} is declared in the "
173
+ "manifest but not mapped to a waypoint in marine_adapter.yaml.",
174
+ )
175
+ target = {"north": wp.north, "east": wp.east, "depth": wp.depth}
176
+ else:
177
+ target = dict(pose or {})
178
+ conn = self._connect()
179
+ conn.mav.set_position_target_local_ned_send(
180
+ 0, conn.target_system, conn.target_component, 1, 0b0000111111111000,
181
+ target.get("north", 0.0), target.get("east", 0.0), target.get("depth", 0.0),
182
+ 0, 0, 0, 0, 0, 0, 0, 0,
183
+ )
184
+ return NavigationResult(success=True, final_pose=target, frame=frame or "ned")
185
+
186
+ def wait_passively(self, *, duration_seconds: float) -> SubstrateResult:
187
+ self._connect()
188
+ return SubstrateResult(success=True)
189
+
190
+ def take_measurement(self, *, what: str, target: str | None, sensor: str | None) -> MeasurementResult:
191
+ conn = self._connect()
192
+ msg = conn.recv_match(type=["SCALED_PRESSURE", "BATTERY_STATUS"], blocking=True, timeout=5)
193
+ value = float(getattr(msg, "press_abs", getattr(msg, "battery_remaining", 0.0))) if msg else None
194
+ return MeasurementResult(success=True, payload={"value": value, "what": what})
195
+
196
+ def wait_for_condition(
197
+ self,
198
+ *,
199
+ kind: Literal["event", "signal", "input", "sensor_threshold"],
200
+ name: str | None,
201
+ input_mode: str | None,
202
+ threshold: dict[str, Any] | None,
203
+ timeout_seconds: float | None,
204
+ ) -> WaitResult:
205
+ conn = self._connect()
206
+ msg = conn.recv_match(blocking=True, timeout=timeout_seconds or 5)
207
+ return WaitResult(success=True, timed_out=msg is None, payload=None)
208
+
209
+ def emit_report(
210
+ self,
211
+ *,
212
+ to: str,
213
+ facts: dict[str, Any],
214
+ attachments: list[str] | None,
215
+ status: Literal["success", "partial", "failure"],
216
+ severity: Literal["info", "notice", "warning", "error"],
217
+ ) -> SubstrateResult:
218
+ self._reports.append({"to": to, "status": status, "severity": severity, "facts": facts})
219
+ return SubstrateResult(success=True)
220
+
221
+ def run_scan(
222
+ self,
223
+ *,
224
+ area: dict[str, Any],
225
+ pattern: Literal["serpentine", "spiral", "grid", "adaptive"],
226
+ overlap: float,
227
+ altitude: float | None,
228
+ media: Literal["photo", "video", "sensor_only"],
229
+ sensor: str | None,
230
+ ) -> ScanResult:
231
+ # A scan is waypoints plus a capture at each one, and this adapter
232
+ # does neither. Reporting success would claim an area was covered
233
+ # when nothing moved.
234
+ return ScanResult(success=False, reason=_NOT_SUPPORTED.format(capability="area-scan controller"))
235
+
236
+ # ------------------------------------------------------------------
237
+ # Not supported on a bare ROV
238
+ # ------------------------------------------------------------------
239
+
240
+ def send_manipulation_goal(
241
+ self,
242
+ *,
243
+ action: Literal["grasp", "release"],
244
+ target: dict[str, Any] | None = None,
245
+ force_n: float | None = None,
246
+ approach: Literal["top", "side", "front", "auto"] = "auto",
247
+ release_mode: Literal["drop", "place", "hand_to_user"] | None = None,
248
+ release_at: dict[str, Any] | str | None = None,
249
+ arm: str | None = None,
250
+ grasp_type: str | None = None,
251
+ target_motion: str | None = None,
252
+ ) -> ManipulationResult:
253
+ return ManipulationResult(success=False, reason=_NOT_SUPPORTED.format(capability="manipulator"))
254
+
255
+ def send_docking_goal(self, *, station: str, service: str, until: str | None = None) -> NavigationResult:
256
+ return NavigationResult(success=False, reason=_NOT_SUPPORTED.format(capability="docking station"))
257
+
258
+ def query_detection(
259
+ self,
260
+ *,
261
+ object_class: str,
262
+ attributes: dict[str, Any] | None = None,
263
+ where_near: str | None = None,
264
+ where_within: float | None = None,
265
+ ) -> DetectionResult:
266
+ return DetectionResult(success=False, reason=_NOT_SUPPORTED.format(capability="onboard detection"))
267
+
268
+ def capture_media(
269
+ self,
270
+ *,
271
+ media: Literal["photo", "video"],
272
+ target: str | None,
273
+ duration_seconds: float | None,
274
+ attributes: dict[str, Any] | None,
275
+ camera: str | None = None,
276
+ ) -> CaptureResult:
277
+ return CaptureResult(success=False, reason=_NOT_SUPPORTED.format(capability="recordable camera"))
278
+
279
+ def emit_speech(
280
+ self,
281
+ *,
282
+ utterance: str,
283
+ locale: str | None,
284
+ style: Literal["notice", "warning", "conversational"],
285
+ interrupt: bool,
286
+ ) -> SubstrateResult:
287
+ return SubstrateResult(success=False, reason=_NOT_SUPPORTED.format(capability="speaker"))
288
+
289
+ def acquire_speech(
290
+ self,
291
+ *,
292
+ prompt: str | None,
293
+ locale: str | None,
294
+ timeout_seconds: float | None,
295
+ expected: Literal["free_form", "confirmation", "choice"],
296
+ choices: list[str] | None,
297
+ ) -> ListenResult:
298
+ return ListenResult(success=False, reason=_NOT_SUPPORTED.format(capability="microphone"))
299
+
300
+ def send_takeoff_goal(self, *, altitude: float, climb_rate: float | None = None) -> NavigationResult:
301
+ return NavigationResult(success=False, reason=_NOT_UNDERWATER.format(capability="take_off"))
302
+
303
+ def send_land_goal(
304
+ self,
305
+ *,
306
+ at: str | None = None,
307
+ precision: Literal["standard", "precise"] = "standard",
308
+ ) -> NavigationResult:
309
+ return NavigationResult(success=False, reason=_NOT_UNDERWATER.format(capability="land"))
310
+
311
+ def send_return_to_home_goal(
312
+ self,
313
+ *,
314
+ speed: float | None = None,
315
+ altitude: float | None = None,
316
+ ) -> NavigationResult:
317
+ return NavigationResult(success=False, reason=_NOT_UNDERWATER.format(capability="return_to_home"))
318
+
319
+ def call_named_program(
320
+ self,
321
+ *,
322
+ name: str,
323
+ args: dict[str, Any] | None = None,
324
+ ) -> ProgramCallResult:
325
+ """``call_program``: this substrate exposes no named programs (RFC-0015)."""
326
+ return unsupported_program_call('marine')
File without changes
@@ -0,0 +1,119 @@
1
+ """Hermetic unit tests for BlueRovAdapter — no pymavlink install needed.
2
+
3
+ A fake ``pymavlink`` package is injected into ``sys.modules`` so
4
+ ``_require_pymavlink`` resolves and ``_connect`` runs against a
5
+ controllable double (the same technique px4-runtime uses).
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import sys
11
+ from collections.abc import Iterator
12
+ from types import ModuleType, SimpleNamespace
13
+ from typing import Any
14
+
15
+ import pytest
16
+ from urml_ros2_runtime.substrate.base import ManipulationResult, NavigationResult, ROSAdapter
17
+
18
+
19
+ class _FakeMav:
20
+ def __init__(self) -> None:
21
+ self.sent: list[tuple[Any, ...]] = []
22
+
23
+ def set_position_target_local_ned_send(self, *args: Any) -> None:
24
+ self.sent.append(args)
25
+
26
+
27
+ class _FakeConn:
28
+ def __init__(self) -> None:
29
+ self.target_system = 1
30
+ self.target_component = 1
31
+ self.mav = _FakeMav()
32
+ self.closed = False
33
+
34
+ def wait_heartbeat(self, timeout: float = 0.0) -> object:
35
+ return object()
36
+
37
+ def recv_match(self, **kw: Any) -> Any:
38
+ return SimpleNamespace(press_abs=1013.0, battery_remaining=88.0)
39
+
40
+ def close(self) -> None:
41
+ self.closed = True
42
+
43
+
44
+ @pytest.fixture
45
+ def fake_pymavlink() -> Iterator[_FakeConn]:
46
+ conn = _FakeConn()
47
+ mavutil = ModuleType("pymavlink.mavutil")
48
+ mavutil.mavlink_connection = lambda url, source_system=255, source_component=1: conn # type: ignore[attr-defined]
49
+ pkg = ModuleType("pymavlink")
50
+ pkg.mavutil = mavutil # type: ignore[attr-defined]
51
+ saved = {k: sys.modules.get(k) for k in ("pymavlink", "pymavlink.mavutil")}
52
+ sys.modules["pymavlink"] = pkg
53
+ sys.modules["pymavlink.mavutil"] = mavutil
54
+ try:
55
+ yield conn
56
+ finally:
57
+ for k, v in saved.items():
58
+ if v is None:
59
+ sys.modules.pop(k, None)
60
+ else:
61
+ sys.modules[k] = v
62
+
63
+
64
+ def test_navigation_measure_scan_lifecycle(fake_pymavlink: _FakeConn) -> None:
65
+ from urml_marine_runtime import BlueRovAdapter, MarineConfig
66
+ from urml_marine_runtime.adapter import Waypoint
67
+
68
+ cfg = MarineConfig(location_to_waypoint={"reef_a": Waypoint(north=10.0, east=2.0, depth=5.0)})
69
+ with BlueRovAdapter(cfg) as rov:
70
+ assert isinstance(rov, ROSAdapter)
71
+ ok = rov.send_navigation_goal(location="reef_a")
72
+ assert ok.success and ok.final_pose == {"north": 10.0, "east": 2.0, "depth": 5.0}
73
+ assert fake_pymavlink.mav.sent, "a position-target MAVLink message was sent"
74
+ miss = rov.send_navigation_goal(location="nowhere")
75
+ assert miss.success is False and miss.reason is not None
76
+ assert miss.reason.startswith("location_not_configured")
77
+ assert rov.wait_passively(duration_seconds=0.1).success
78
+ meas = rov.take_measurement(what="depth", target=None, sensor=None)
79
+ assert meas.success and meas.payload is not None and meas.payload["value"] == 1013.0
80
+ scan = rov.run_scan(
81
+ area={}, pattern="serpentine", overlap=0.1, altitude=None, media="sensor_only", sensor=None
82
+ )
83
+ assert not scan.success and "area-scan controller" in (scan.reason or "")
84
+ assert fake_pymavlink.closed is True
85
+
86
+
87
+ def test_unsupported_and_underwater_sentinels(fake_pymavlink: _FakeConn) -> None:
88
+ from urml_marine_runtime import BlueRovAdapter
89
+
90
+ rov = BlueRovAdapter()
91
+ bare: ManipulationResult = rov.send_manipulation_goal(action="grasp")
92
+ assert bare.success is False
93
+ assert bare.reason is not None and bare.reason.startswith("not_supported_on_bare_rov")
94
+ for r in (rov.send_takeoff_goal(altitude=1.0), rov.send_land_goal(), rov.send_return_to_home_goal()):
95
+ assert r.success is False
96
+ assert r.reason is not None and r.reason.startswith("not_applicable_underwater")
97
+
98
+
99
+ def test_missing_pymavlink_is_actionable(monkeypatch: pytest.MonkeyPatch) -> None:
100
+ """Construction without the [marine] extra raises a clear error.
101
+
102
+ Setting the sys.modules entry to None forces ``import pymavlink`` to
103
+ raise ImportError deterministically, whether or not pymavlink is
104
+ actually installed in the test environment.
105
+ """
106
+ from urml_marine_runtime import BlueRovAdapter
107
+
108
+ monkeypatch.setitem(sys.modules, "pymavlink", None)
109
+ monkeypatch.setitem(sys.modules, "pymavlink.mavutil", None)
110
+ with pytest.raises(RuntimeError, match=r"\[marine\] extra"):
111
+ BlueRovAdapter()
112
+
113
+
114
+ def test_conformance_runner_accepts_factory(fake_pymavlink: _FakeConn) -> None:
115
+ from urml_conformance import ConformanceRunner
116
+
117
+ from urml_marine_runtime import BlueRovAdapter
118
+
119
+ assert ConformanceRunner(adapter_factory=lambda: BlueRovAdapter()) is not None