OpenSMI-ROS2 0.1.0__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.
Files changed (89) hide show
  1. opensmi/ros2/__init__.py +89 -0
  2. opensmi/ros2/__main__.py +11 -0
  3. opensmi/ros2/cli.py +143 -0
  4. opensmi/ros2/py.typed +0 -0
  5. opensmi/ros2/runtime/__init__.py +67 -0
  6. opensmi/ros2/runtime/_decode.py +101 -0
  7. opensmi/ros2/runtime/_encode.py +102 -0
  8. opensmi/ros2/runtime/_parser.py +147 -0
  9. opensmi/ros2/runtime/errors.py +141 -0
  10. opensmi/ros2/runtime/goal.py +232 -0
  11. opensmi/ros2/runtime/graph.py +288 -0
  12. opensmi/ros2/runtime/guard.py +213 -0
  13. opensmi/ros2/runtime/interface.py +140 -0
  14. opensmi/ros2/runtime/messages/__init__.py +503 -0
  15. opensmi/ros2/runtime/messages/industrial_msgs.py +62 -0
  16. opensmi/ros2/runtime/messages/industrial_msgs.pyi +159 -0
  17. opensmi/ros2/runtime/messages/motoros2_interfaces.py +79 -0
  18. opensmi/ros2/runtime/messages/motoros2_interfaces.pyi +307 -0
  19. opensmi/ros2/runtime/messages/neo_msgs2.py +55 -0
  20. opensmi/ros2/runtime/messages/neo_msgs2.pyi +138 -0
  21. opensmi/ros2/runtime/messages/neo_srvs2.py +72 -0
  22. opensmi/ros2/runtime/messages/neo_srvs2.pyi +224 -0
  23. opensmi/ros2/runtime/outcomes.py +103 -0
  24. opensmi/ros2/runtime/parameters.py +723 -0
  25. opensmi/ros2/runtime/publisher.py +125 -0
  26. opensmi/ros2/runtime/qos.py +394 -0
  27. opensmi/ros2/runtime/runtime.py +1171 -0
  28. opensmi/ros2/runtime/selection.py +150 -0
  29. opensmi/ros2/runtime/stamp.py +100 -0
  30. opensmi/ros2/runtime/subscription.py +354 -0
  31. opensmi/ros2/runtime/tf.py +714 -0
  32. opensmi/ros2/server/__init__.py +148 -0
  33. opensmi/ros2/server/access.py +109 -0
  34. opensmi/ros2/server/bindings/__init__.py +92 -0
  35. opensmi/ros2/server/bindings/_base.py +154 -0
  36. opensmi/ros2/server/bindings/action.py +133 -0
  37. opensmi/ros2/server/bindings/keyed.py +127 -0
  38. opensmi/ros2/server/bindings/lifecycle.py +131 -0
  39. opensmi/ros2/server/bindings/method.py +130 -0
  40. opensmi/ros2/server/bindings/monitoring.py +109 -0
  41. opensmi/ros2/server/bindings/parameter.py +133 -0
  42. opensmi/ros2/server/bindings/publisher.py +192 -0
  43. opensmi/ros2/server/bindings/registry.py +95 -0
  44. opensmi/ros2/server/bindings/tf.py +256 -0
  45. opensmi/ros2/server/browse_names.py +94 -0
  46. opensmi/ros2/server/component.py +334 -0
  47. opensmi/ros2/server/config.py +493 -0
  48. opensmi/ros2/server/containers.py +191 -0
  49. opensmi/ros2/server/drivers.py +421 -0
  50. opensmi/ros2/server/errors.py +159 -0
  51. opensmi/ros2/server/events.py +406 -0
  52. opensmi/ros2/server/introspection.py +850 -0
  53. opensmi/ros2/server/keyed.py +749 -0
  54. opensmi/ros2/server/lifecycle.py +238 -0
  55. opensmi/ros2/server/limits.py +66 -0
  56. opensmi/ros2/server/loader.py +977 -0
  57. opensmi/ros2/server/machine.py +225 -0
  58. opensmi/ros2/server/method.py +307 -0
  59. opensmi/ros2/server/mirror.py +582 -0
  60. opensmi/ros2/server/mutation.py +992 -0
  61. opensmi/ros2/server/nodesets/Opc.Ua.SmartFactory.ROS2.NodeSet2.xml +85 -0
  62. opensmi/ros2/server/nodesets/__init__.py +18 -0
  63. opensmi/ros2/server/nodesets/smart_factory_ros2.py +26 -0
  64. opensmi/ros2/server/parameters.py +704 -0
  65. opensmi/ros2/server/projection.py +1176 -0
  66. opensmi/ros2/server/projections/__init__.py +41 -0
  67. opensmi/ros2/server/projections/scope.py +222 -0
  68. opensmi/ros2/server/provenance.py +121 -0
  69. opensmi/ros2/server/publisher.py +781 -0
  70. opensmi/ros2/server/recipes.py +514 -0
  71. opensmi/ros2/server/required.py +633 -0
  72. opensmi/ros2/server/skill.py +363 -0
  73. opensmi/ros2/server/spatial.py +283 -0
  74. opensmi/ros2/server/startup.py +626 -0
  75. opensmi/ros2/server/status.py +107 -0
  76. opensmi/ros2/server/structures.py +135 -0
  77. opensmi/ros2/server/transforms/__init__.py +39 -0
  78. opensmi/ros2/server/transforms/conversions.py +58 -0
  79. opensmi/ros2/server/transforms/filing.py +340 -0
  80. opensmi/ros2/server/transforms/mirror.py +462 -0
  81. opensmi/ros2/server/transforms/outward.py +180 -0
  82. opensmi/ros2/server/transforms/records.py +195 -0
  83. opensmi/ros2/server/transforms/spatial.py +154 -0
  84. opensmi_ros2-0.1.0.dist-info/METADATA +183 -0
  85. opensmi_ros2-0.1.0.dist-info/RECORD +89 -0
  86. opensmi_ros2-0.1.0.dist-info/WHEEL +5 -0
  87. opensmi_ros2-0.1.0.dist-info/entry_points.txt +2 -0
  88. opensmi_ros2-0.1.0.dist-info/licenses/LICENSES/MIT.txt +18 -0
  89. opensmi_ros2-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,41 @@
1
+ # SPDX-FileCopyrightText: 2026 Technologie-Initiative SmartFactory KL e.V.
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+
5
+ """The shipped catalogue: the curation this package brings, as data.
6
+
7
+ A list of recipe literals (:mod:`opensmi.ros2.server.recipes`) ahead of the generic walk. The record
8
+ of which ROS2 types in scope each one answers for is in :mod:`opensmi.ros2.server.projections.scope`
9
+ and is not re-exported here.
10
+
11
+ The list is short on purpose. A ``uint8[]`` field already reaches a client as a ``ByteString`` under
12
+ the walk, so a blob over one would change nothing. The walk gets a signed bulk buffer wrong (a
13
+ million-element array of ``SByte``), and a plain ``ByteString`` would misreport it as large positive
14
+ numbers. That is the occupancy grid, the one shipped entry. A diagnostic status needs no entry
15
+ either: the walk renders its key-value list as an array of a derived structure.
16
+ Anything else a deployment wants is one literal in its own Component.
17
+ """
18
+
19
+ from __future__ import annotations
20
+
21
+ from typing import TYPE_CHECKING, Final
22
+
23
+ from opensmi.ros2.server.recipes import GENERIC_REGISTRY, Blob
24
+
25
+ if TYPE_CHECKING:
26
+ from opensmi.ros2.server.projection import Projection
27
+
28
+ __all__ = ["DEFAULT_REGISTRY", "SHIPPED"]
29
+
30
+ SHIPPED: Final[tuple[Projection, ...]] = (
31
+ # `int8[]` cells: the signedness is published as a DataType a client can discover.
32
+ Blob("nav_msgs/msg/OccupancyGrid", field="data"),
33
+ )
34
+ """The curation this package ships, ahead of the generic walk and behind anything registered."""
35
+
36
+ DEFAULT_REGISTRY: Final = GENERIC_REGISTRY.extended(SHIPPED)
37
+ """What a Machine renders through until it registers curation of its own.
38
+
39
+ A Machine's registry extends this with the application's entries, and a Component's extends the
40
+ Machine's, so two Components can render one message type differently.
41
+ """
@@ -0,0 +1,222 @@
1
+ # SPDX-FileCopyrightText: 2026 Technologie-Initiative SmartFactory KL e.V.
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+
5
+ """What is in scope, and how each type in it is rendered.
6
+
7
+ Every ROS2 type in :data:`SCOPE` is classified in :data:`CLASSIFIED` with one of four verdicts, and
8
+ a CI job checks the record against a live ROS2 installation in both directions: an unclassified type
9
+ fails the build, and so does a classification that no longer matches what the registry does. The
10
+ check runs from the ROS2 side only, because most of what the framework resolves (device health,
11
+ counters, identification, the state machines) has no ROS2 source.
12
+
13
+ * :data:`WALK`: the generic field-walk renders it.
14
+ * :data:`CURATED`: a shipped Projection renders it, because the walk would get it wrong.
15
+ * :data:`KEYED`: it repeats a message whose elements a client browses, so a
16
+ :class:`~opensmi.ros2.server.bindings.KeyedBinding` makes them members of their own. The walk
17
+ could also render it, as one array of a derived structure. A diagnostic id is a thing
18
+ to subscribe to, and a waypoint is a value in a list.
19
+ * :data:`EMPTY`: it has no fields and renders nothing. ``std_msgs/msg/Empty`` is the request of
20
+ every no-argument service, so refusing it would stop a Machine over a correct declaration.
21
+
22
+ The ``std_msgs`` multi-arrays and ``sensor_msgs/msg/PointCloud2`` are :data:`KEYED` even though
23
+ their ``data`` suits a blob, because their ``layout/dim`` and ``fields`` are lists somebody wants to
24
+ read one at a time. A deployment binds the bulk buffer with its own
25
+ :class:`~opensmi.ros2.server.recipes.Blob` and excludes ``fields``.
26
+
27
+ ``rcl_interfaces`` is absent on purpose. Its one type used here, ``ParameterValue``, never reaches
28
+ OPC UA: a ROS2-parameter declaration names one typed field of the union and gets a scalar
29
+ (:mod:`opensmi.ros2.server.parameters`). Vendor packages are not listed either, since no shipped
30
+ Projection covers a vendor type. The first one that does should bring its package into this record.
31
+ """
32
+
33
+ from __future__ import annotations
34
+
35
+ from typing import TYPE_CHECKING, Final
36
+
37
+ if TYPE_CHECKING:
38
+ from collections.abc import Mapping
39
+
40
+ __all__ = ["CLASSIFIED", "CORE", "CURATED", "EMPTY", "KEYED", "SCOPE", "WALK"]
41
+
42
+ WALK: Final = "the generic field-walk renders it"
43
+ """The verdict of a type the walk renders correctly."""
44
+
45
+ CURATED: Final = "a shipped Projection renders it"
46
+ """The verdict of a type this package curates because the walk would get it wrong."""
47
+
48
+ KEYED: Final = "it repeats a message whose elements are nodes of their own"
49
+ """The verdict of a type whose elements a client browses individually."""
50
+
51
+ EMPTY: Final = "it has no fields, so there is nothing to render"
52
+ """The verdict of a message with no fields."""
53
+
54
+ SCOPE: Final[tuple[str, ...]] = (
55
+ "builtin_interfaces",
56
+ "std_msgs",
57
+ "geometry_msgs",
58
+ "sensor_msgs",
59
+ "nav_msgs",
60
+ "diagnostic_msgs",
61
+ "actionlib_msgs",
62
+ "shape_msgs",
63
+ "stereo_msgs",
64
+ "trajectory_msgs",
65
+ "visualization_msgs",
66
+ )
67
+ """The interface packages whose message types must all be classified.
68
+
69
+ These are ``ros2/common_interfaces`` plus ``builtin_interfaces``.
70
+ """
71
+
72
+ CORE: Final[tuple[str, ...]] = ("std_msgs", "geometry_msgs", "sensor_msgs", "nav_msgs")
73
+ """The packages the completeness check refuses to run without.
74
+
75
+ Without this, an image with none of them would pass by checking nothing.
76
+ """
77
+
78
+ CLASSIFIED: Final[Mapping[str, str]] = {
79
+ # -- builtin_interfaces ----------------------------------------------------------------------
80
+ "builtin_interfaces/msg/Duration": WALK,
81
+ "builtin_interfaces/msg/Time": WALK,
82
+ # -- std_msgs --------------------------------------------------------------------------------
83
+ "std_msgs/msg/Bool": WALK,
84
+ "std_msgs/msg/Byte": WALK,
85
+ "std_msgs/msg/ByteMultiArray": KEYED,
86
+ "std_msgs/msg/Char": WALK,
87
+ "std_msgs/msg/ColorRGBA": WALK,
88
+ "std_msgs/msg/Empty": EMPTY,
89
+ "std_msgs/msg/Float32": WALK,
90
+ "std_msgs/msg/Float32MultiArray": KEYED,
91
+ "std_msgs/msg/Float64": WALK,
92
+ "std_msgs/msg/Float64MultiArray": KEYED,
93
+ "std_msgs/msg/Header": WALK,
94
+ "std_msgs/msg/Int16": WALK,
95
+ "std_msgs/msg/Int16MultiArray": KEYED,
96
+ "std_msgs/msg/Int32": WALK,
97
+ "std_msgs/msg/Int32MultiArray": KEYED,
98
+ "std_msgs/msg/Int64": WALK,
99
+ "std_msgs/msg/Int64MultiArray": KEYED,
100
+ "std_msgs/msg/Int8": WALK,
101
+ "std_msgs/msg/Int8MultiArray": KEYED,
102
+ "std_msgs/msg/MultiArrayDimension": WALK,
103
+ "std_msgs/msg/MultiArrayLayout": KEYED,
104
+ "std_msgs/msg/String": WALK,
105
+ "std_msgs/msg/UInt16": WALK,
106
+ "std_msgs/msg/UInt16MultiArray": KEYED,
107
+ "std_msgs/msg/UInt32": WALK,
108
+ "std_msgs/msg/UInt32MultiArray": KEYED,
109
+ "std_msgs/msg/UInt64": WALK,
110
+ "std_msgs/msg/UInt64MultiArray": KEYED,
111
+ "std_msgs/msg/UInt8": WALK,
112
+ "std_msgs/msg/UInt8MultiArray": KEYED,
113
+ # -- geometry_msgs ---------------------------------------------------------------------------
114
+ "geometry_msgs/msg/Accel": WALK,
115
+ "geometry_msgs/msg/AccelStamped": WALK,
116
+ "geometry_msgs/msg/AccelWithCovariance": WALK,
117
+ "geometry_msgs/msg/AccelWithCovarianceStamped": WALK,
118
+ "geometry_msgs/msg/Inertia": WALK,
119
+ "geometry_msgs/msg/InertiaStamped": WALK,
120
+ "geometry_msgs/msg/Point": WALK,
121
+ "geometry_msgs/msg/Point32": WALK,
122
+ "geometry_msgs/msg/PointStamped": WALK,
123
+ "geometry_msgs/msg/Polygon": KEYED,
124
+ "geometry_msgs/msg/PolygonInstance": KEYED,
125
+ "geometry_msgs/msg/PolygonInstanceStamped": KEYED,
126
+ "geometry_msgs/msg/PolygonStamped": KEYED,
127
+ "geometry_msgs/msg/Pose": WALK,
128
+ "geometry_msgs/msg/Pose2D": WALK,
129
+ "geometry_msgs/msg/PoseArray": KEYED,
130
+ "geometry_msgs/msg/PoseStamped": WALK,
131
+ "geometry_msgs/msg/PoseWithCovariance": WALK,
132
+ "geometry_msgs/msg/PoseWithCovarianceStamped": WALK,
133
+ "geometry_msgs/msg/Quaternion": WALK,
134
+ "geometry_msgs/msg/QuaternionStamped": WALK,
135
+ "geometry_msgs/msg/Transform": WALK,
136
+ "geometry_msgs/msg/TransformStamped": WALK,
137
+ "geometry_msgs/msg/Twist": WALK,
138
+ "geometry_msgs/msg/TwistStamped": WALK,
139
+ "geometry_msgs/msg/TwistWithCovariance": WALK,
140
+ "geometry_msgs/msg/TwistWithCovarianceStamped": WALK,
141
+ "geometry_msgs/msg/Vector3": WALK,
142
+ "geometry_msgs/msg/Vector3Stamped": WALK,
143
+ "geometry_msgs/msg/VelocityStamped": WALK,
144
+ "geometry_msgs/msg/VelocityWithCovarianceStamped": WALK,
145
+ "geometry_msgs/msg/Wrench": WALK,
146
+ "geometry_msgs/msg/WrenchStamped": WALK,
147
+ # -- sensor_msgs -----------------------------------------------------------------------------
148
+ "sensor_msgs/msg/BatteryState": WALK,
149
+ "sensor_msgs/msg/CameraInfo": WALK,
150
+ "sensor_msgs/msg/ChannelFloat32": WALK,
151
+ "sensor_msgs/msg/CompressedImage": WALK,
152
+ "sensor_msgs/msg/FluidPressure": WALK,
153
+ "sensor_msgs/msg/Illuminance": WALK,
154
+ "sensor_msgs/msg/Image": WALK,
155
+ "sensor_msgs/msg/Imu": WALK,
156
+ "sensor_msgs/msg/JointState": WALK,
157
+ "sensor_msgs/msg/Joy": WALK,
158
+ "sensor_msgs/msg/JoyFeedback": WALK,
159
+ "sensor_msgs/msg/JoyFeedbackArray": KEYED,
160
+ "sensor_msgs/msg/LaserEcho": WALK,
161
+ "sensor_msgs/msg/LaserScan": WALK,
162
+ "sensor_msgs/msg/MagneticField": WALK,
163
+ "sensor_msgs/msg/MultiDOFJointState": KEYED,
164
+ "sensor_msgs/msg/MultiEchoLaserScan": KEYED,
165
+ "sensor_msgs/msg/NavSatFix": WALK,
166
+ "sensor_msgs/msg/NavSatStatus": WALK,
167
+ "sensor_msgs/msg/PointCloud": KEYED,
168
+ "sensor_msgs/msg/PointCloud2": KEYED,
169
+ "sensor_msgs/msg/PointField": WALK,
170
+ "sensor_msgs/msg/Range": WALK,
171
+ "sensor_msgs/msg/RegionOfInterest": WALK,
172
+ "sensor_msgs/msg/RelativeHumidity": WALK,
173
+ "sensor_msgs/msg/Temperature": WALK,
174
+ "sensor_msgs/msg/TimeReference": WALK,
175
+ # -- nav_msgs --------------------------------------------------------------------------------
176
+ "nav_msgs/msg/Goals": KEYED,
177
+ "nav_msgs/msg/GridCells": KEYED,
178
+ "nav_msgs/msg/MapMetaData": WALK,
179
+ "nav_msgs/msg/OccupancyGrid": CURATED,
180
+ "nav_msgs/msg/Odometry": WALK,
181
+ "nav_msgs/msg/Path": KEYED,
182
+ "nav_msgs/msg/Trajectory": KEYED,
183
+ "nav_msgs/msg/TrajectoryPoint": WALK,
184
+ # -- diagnostic_msgs -------------------------------------------------------------------------
185
+ "diagnostic_msgs/msg/DiagnosticArray": KEYED,
186
+ # An array's statuses are members a client browses; a status's key-value pairs are an array.
187
+ "diagnostic_msgs/msg/DiagnosticStatus": KEYED,
188
+ "diagnostic_msgs/msg/KeyValue": WALK,
189
+ # -- actionlib_msgs --------------------------------------------------------------------------
190
+ "actionlib_msgs/msg/GoalID": WALK,
191
+ "actionlib_msgs/msg/GoalStatus": WALK,
192
+ "actionlib_msgs/msg/GoalStatusArray": KEYED,
193
+ # -- shape_msgs ------------------------------------------------------------------------------
194
+ "shape_msgs/msg/Mesh": KEYED,
195
+ "shape_msgs/msg/MeshTriangle": WALK,
196
+ "shape_msgs/msg/Plane": WALK,
197
+ "shape_msgs/msg/SolidPrimitive": KEYED,
198
+ # -- stereo_msgs -----------------------------------------------------------------------------
199
+ "stereo_msgs/msg/DisparityImage": WALK,
200
+ # -- trajectory_msgs -------------------------------------------------------------------------
201
+ "trajectory_msgs/msg/JointTrajectory": KEYED,
202
+ "trajectory_msgs/msg/JointTrajectoryPoint": WALK,
203
+ "trajectory_msgs/msg/MultiDOFJointTrajectory": KEYED,
204
+ "trajectory_msgs/msg/MultiDOFJointTrajectoryPoint": KEYED,
205
+ # -- visualization_msgs ----------------------------------------------------------------------
206
+ "visualization_msgs/msg/ImageMarker": KEYED,
207
+ "visualization_msgs/msg/InteractiveMarker": KEYED,
208
+ "visualization_msgs/msg/InteractiveMarkerControl": KEYED,
209
+ "visualization_msgs/msg/InteractiveMarkerFeedback": WALK,
210
+ "visualization_msgs/msg/InteractiveMarkerInit": KEYED,
211
+ "visualization_msgs/msg/InteractiveMarkerPose": WALK,
212
+ "visualization_msgs/msg/InteractiveMarkerUpdate": KEYED,
213
+ "visualization_msgs/msg/Marker": KEYED,
214
+ "visualization_msgs/msg/MarkerArray": KEYED,
215
+ "visualization_msgs/msg/MenuEntry": WALK,
216
+ "visualization_msgs/msg/MeshFile": WALK,
217
+ "visualization_msgs/msg/UVCoordinate": WALK,
218
+ }
219
+ """Every message type in :data:`SCOPE`, and what renders it.
220
+
221
+ Each type has its own line, so a type added upstream fails the check instead of joining silently.
222
+ """
@@ -0,0 +1,121 @@
1
+ # SPDX-FileCopyrightText: 2026 Technologie-Initiative SmartFactory KL e.V.
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+
5
+ """The per-Binding provenance entry: what one endpoint asked for, and why it is asking that.
6
+
7
+ QoS has no status variable. A profile is a fact about how this server is attached to the robot, so
8
+ it is listed on the read-only introspection surface as a value object. The mirrors build
9
+ one entry per Binding and the introspection Component lists them. A profile is declared (a
10
+ contract), discovered (adapts) or defaulted (what an outward endpoint gets when nobody said
11
+ otherwise), which is the first thing to check when a topic is silent.
12
+
13
+ Provenance attaches to an endpoint. Monitoring, Keyed and
14
+ publishing Bindings hold one endpoint each and are listed by Binding name. The TF Binding's
15
+ subscriptions and publisher belong to the Machine, so they are not listed yet; their profiles are
16
+ :data:`~opensmi.ros2.runtime.tf.TF_QOS` and :data:`~opensmi.ros2.runtime.tf.TF_STATIC_QOS`.
17
+ """
18
+
19
+ from __future__ import annotations
20
+
21
+ from dataclasses import dataclass
22
+ from typing import TYPE_CHECKING, Final, Protocol
23
+
24
+ if TYPE_CHECKING:
25
+ from collections.abc import Sequence
26
+
27
+ from opensmi.ros2.runtime.qos import Provenance, QoSIncompatibility, QoSProfile
28
+
29
+ __all__ = ["QOS_INCOMPATIBLE", "BindingQoS", "QoSEndpoint", "qos_clash_text"]
30
+
31
+ QOS_INCOMPATIBLE: Final = "QOS_INCOMPATIBLE"
32
+ """What a Binding reports when the middleware refuses a publisher over a QoS policy.
33
+
34
+ A discovered profile relaxes and the event is a warning. A declared one does not move, so the event
35
+ is an error. The text names the policy, what was asked for and what happened next. Both mirrors
36
+ raise it, because a Keyed Binding attaches to a topic as a Monitoring one does.
37
+ """
38
+
39
+
40
+ class QoSEndpoint(Protocol):
41
+ """A ROS2 endpoint, as a provenance entry reads it: a profile and where it came from.
42
+
43
+ Both Runtime handles satisfy it. It is the smaller of the two surfaces: a Subscription also
44
+ carries incompatibilities and a Publisher has none, so those are passed in separately.
45
+ """
46
+
47
+ @property
48
+ def qos(self) -> QoSProfile:
49
+ """Return the profile this endpoint is asking for, or offering, right now."""
50
+ ...
51
+
52
+ @property
53
+ def qos_provenance(self) -> Provenance:
54
+ """Return where that profile came from."""
55
+ ...
56
+
57
+
58
+ @dataclass(frozen=True, slots=True, kw_only=True)
59
+ class BindingQoS:
60
+ """What one Binding's ROS2 endpoint is asking for, and where that came from.
61
+
62
+ :ivar binding: The name of the Binding, which is what a client browses it by.
63
+ :ivar path: The ROS2 topic the endpoint is on.
64
+ :ivar profile: The profile in effect right now. For a discovered subscription this may differ
65
+ from the one it opened with.
66
+ :ivar provenance: Where that profile came from, and therefore whether it can still move.
67
+ :ivar adaptations: How many times an incompatibility has moved the profile. Non-zero means the
68
+ Binding discovered its profile and had to give something up.
69
+ :ivar last_incompatibility: The most recent clash reported on this topic, or ``None``. Kept
70
+ because the event that announced it is gone if nobody was subscribed.
71
+ """
72
+
73
+ binding: str
74
+ path: str
75
+ profile: QoSProfile
76
+ provenance: Provenance
77
+ adaptations: int
78
+ last_incompatibility: QoSIncompatibility | None = None
79
+
80
+ @classmethod
81
+ def of(
82
+ cls,
83
+ binding: str,
84
+ path: str,
85
+ endpoint: QoSEndpoint,
86
+ incompatibilities: Sequence[QoSIncompatibility] = (),
87
+ ) -> BindingQoS:
88
+ """Return the entry for one live endpoint, read off the handle every time.
89
+
90
+ The adaptation count is derived from the incompatibilities, so the two cannot disagree.
91
+ """
92
+ return cls(
93
+ binding=binding,
94
+ path=path,
95
+ profile=endpoint.qos,
96
+ provenance=endpoint.qos_provenance,
97
+ adaptations=sum(1 for each in incompatibilities if each.adapted is not None),
98
+ last_incompatibility=incompatibilities[-1] if incompatibilities else None,
99
+ )
100
+
101
+ def __str__(self) -> str:
102
+ """Return the one line an operator reads: the Binding, its profile and its provenance."""
103
+ adapted = f", adapted {self.adaptations} time(s)" if self.adaptations else ""
104
+ return f"{self.binding} ({self.path}): {self.provenance.value} {self.profile}{adapted}"
105
+
106
+
107
+ def qos_clash_text(path: str, incompatibility: QoSIncompatibility) -> str:
108
+ """Return the human half of a :data:`QOS_INCOMPATIBLE` event: what clashed, and what followed.
109
+
110
+ One function, because both mirrors raise the same event and it should read the same on both.
111
+ """
112
+ adapted = incompatibility.adapted
113
+ answer = (
114
+ f"the subscription relaxed to {adapted}"
115
+ if adapted is not None
116
+ else f"the {incompatibility.provenance.value} profile stands and that publisher is not received"
117
+ )
118
+ return (
119
+ f"a publisher on {path} offers QoS this subscription cannot accept on "
120
+ f"{incompatibility.policy.name}; it was asking for {incompatibility.request}, and {answer}"
121
+ )