class Runtime:
Constructor: Runtime(domain_id, node_name, namespace, stop_timeout, ...)
All ROS2 access for one Machine, which is the unit of one Domain ID.
| Method | __init__ |
Describe a Runtime without starting anything; construction touches no ROS2. |
| Method | __repr__ |
Return a representation naming the node and its Domain ID. |
| Async Method | advertise |
Advertise a ROS2 topic, and return the handle that owns the publisher. |
| Async Method | call |
Call one ROS2 service and return the response it answered with. |
| Method | default |
Return a message of a type as its generated ROS2 class constructs it, with no arguments. |
| Method | describe |
Return the goal, feedback and result message dataclasses of a ROS2 action type. |
| Method | describe |
Return the message dataclass of a ROS2 message type. |
| Method | describe |
Return the request and response message dataclasses of a ROS2 service type. |
| Method | publishers |
Return what every publisher on a topic offers, as the QoS resolver takes it. |
| Async Method | send |
Send one goal to a ROS2 action server, and return the handle that owns it. |
| Async Method | start |
Bring up the Context, the Node and the executor thread on the running loop, which stays the Runtime's. |
| Async Method | stop |
Close every open endpoint, then tear down the thread, the Node and the Context. |
| Async Method | subscribe |
Subscribe to a ROS2 topic, and return the handle that owns the subscription. |
| Property | domain |
Return the ROS2 Domain ID this Runtime is confined to. |
| Property | graph |
Return the facet answering what is on the ROS2 graph (it reads nothing until watched). |
| Property | node |
Return the name of the single rclpy Node this Runtime owns. |
| Property | parameters |
Return the facet for the parameters of ROS2 nodes (/parameter_events only while watched). |
| Property | started |
Return whether the Context, Node and executor thread are up. |
| Property | tf |
Return the facet answering where a TF frame sits (/tf is subscribed once a Binding asks). |
| Async Method | _await |
Send the goal, wait for the server's answer, and build the handle around it. |
| Async Method | _call |
Call one parameter service of a ROS2 node. |
| Method | _close |
Tear the ROS2 objects down (blocking, so called off the loop), collecting faults. |
| Async Method | _describe |
Ask one ROS2 node about one parameter (one name per call: a batch with an undeclared name answers empty). |
| Method | _destroy |
Destroy one rclpy subscription, publisher or client, and wake the executor. |
| Method | _destroy |
Destroy one rclpy action client and wake the executor so its wait set is rebuilt. |
| Method | _feed |
Put every transform of one message into the buffer, on the loop that received it. |
| Async Method | _follow |
Yield every parameter change on the graph from one /parameter_events subscription. |
| Async Method | _list |
Ask one ROS2 node what parameters it declares, recursively. |
| Method | _lookup |
Return where one frame sits in another, out of what the buffer already holds. |
| Method | _open |
Create and spin the ROS2 objects (blocking, so called off the loop). |
| Async Method | _read |
Read every name on the graph once, off the loop; this is what graph polls with. |
| Async Method | _read |
Read one parameter of one ROS2 node (one name per call, see ParameterFacet). |
| Method | _report |
Compare every publisher's type hash against our own, and warn about each new one. |
| Method | _require |
Return the Runtime's loop, or refuse because this is not it. |
| Method | _require |
Return the node, or refuse because there is none. |
| Method | _ros2 |
Return the Node's clock (not the wall clock, so right under use_sim_time) as seconds and nanoseconds. |
| Method | _wake |
Wake the executor so its wait set is rebuilt after an endpoint went away. |
| Async Method | _write |
Write a batch of parameters to one ROS2 node, with one outcome per parameter. |
| Instance Variable | _buffer |
Undocumented |
| Instance Variable | _context |
Undocumented |
| Instance Variable | _domain |
Undocumented |
| Instance Variable | _executor |
Undocumented |
| Instance Variable | _goals |
Undocumented |
| Instance Variable | _graph |
Undocumented |
| Instance Variable | _loop |
Undocumented |
| Instance Variable | _namespace |
Undocumented |
| Instance Variable | _node |
Undocumented |
| Instance Variable | _node |
Undocumented |
| Instance Variable | _parameters |
Undocumented |
| Instance Variable | _publishers |
Undocumented |
| Instance Variable | _stop |
Undocumented |
| Instance Variable | _subscriptions |
Undocumented |
| Instance Variable | _tf |
Undocumented |
| Instance Variable | _thread |
Undocumented |
| Instance Variable | _transform |
Undocumented |
int, node_name: str = 'opensmi_ros2', namespace: str | None = None, stop_timeout: float = 5.0, graph_poll_interval: float = POLL_INTERVAL, transform_cache: float = TRANSFORM_CACHE):
¶
Describe a Runtime without starting anything; construction touches no ROS2.
| Parameters | |
domainint | The ROS2 Domain ID this Runtime's Context is confined to. |
nodestr | The name of the single rclpy Node this Runtime owns. |
namespace:str | None | The ROS2 namespace for that node, or None for the root. |
stopfloat | Seconds stop waits for the executor thread. |
graphfloat | Seconds between graph reads while the graph facet is watched. |
transformfloat | Seconds of transform history the TF buffer keeps. |
str, message_type: str | type[ Message], depth: int = 10, qos: QoSProfile | None = None) -> Publisher:
¶
Advertise a ROS2 topic, and return the handle that owns the publisher.
Nothing goes on the wire until ~opensmi.ros2.runtime.publisher.Publisher.publish.
The profile is declared or defaulted, never discovered or adapted, since this call is how
a publisher on the topic comes to exist.
| Parameters | |
topic:str | The ROS2 topic name. |
messagestr | type[ | The ROS2 type name (package/Name or package/kind/Name) or an already-resolved message dataclass. |
depth:int | The ROS2 queue depth. |
qos:QoSProfile | None | The profile to offer, or None for
~opensmi.ros2.runtime.qos.DEFAULT_PROFILE. |
| Returns | |
Publisher | Undocumented |
| Raises | |
RuntimeNotStartedError | When the Runtime is not up. |
LoopAffinityError | When awaited on a loop other than the Runtime's. |
MissingInterfacePackageError | When the type's interface package is not installed. |
str, service_type: str | ServiceTypes, request: Message, server_timeout: float = 10.0, call_timeout: float = 30.0) -> Message:
¶
Call one ROS2 service and return the response it answered with.
A refusal is in the response message. Only two cases raise: nobody serving the path, and a server that took the request and never answered. They have separate timeouts so that "the robot is off" and "the robot is stuck" stay distinguishable.
| Parameters | |
service:str | The ROS2 service name. |
servicestr | ServiceTypes | The service type (package/srv/Name) or the already-resolved pair of message dataclasses. |
request:Message | The request, as an instance of the service's request message dataclass. |
serverfloat | Seconds to wait for a service server to appear on the path. |
callfloat | Seconds to wait for the answer once the request has gone. |
| Returns | |
Message | Undocumented |
| Raises | |
RuntimeNotStartedError | When the Runtime is not up. |
LoopAffinityError | When awaited on a loop other than the Runtime's. |
FieldTypeMismatchError | When a field of the request holds a value of the wrong Python type. Refused here because rclpy aborts the process. |
FieldValueOutOfRangeError | When a field of the request is past its width or bound. |
ServiceUnavailableError | When no service server answers on the path. |
ServiceCallTimeoutError | When the request went and no answer came back in time. |
MissingInterfacePackageError | When the service's interface package is absent. |
Return a message of a type as its generated ROS2 class constructs it, with no arguments.
Every field holds the default its interface definition declares, or its type's zero. Usable
before start.
| Parameters | |
messagetype[ | A message dataclass, as describe_message returns it. |
| Returns | |
Message | Undocumented |
Return the goal, feedback and result message dataclasses of a ROS2 action type.
Usable before start, so a missing interface package fails while a Component is
constructed. It lives on the Runtime so that tests can substitute a double.
| Parameters | |
actionstr | package/action/Name. |
| Returns | |
ActionTypes | Undocumented |
| Raises | |
InvalidMessageTypeNameError | When the name is not a three-part action name. |
MissingInterfacePackageError | When the interface package is not installed. |
UnusableMessageTypeError | When the package has no such action. |
Return the message dataclass of a ROS2 message type.
Usable before start.
| Parameters | |
messagestr | package/Name or package/msg/Name. |
| Returns | |
type[ | Undocumented |
| Raises | |
InvalidMessageTypeNameError | When the name is not a message name. |
MissingInterfacePackageError | When the interface package is not installed. |
UnusableMessageTypeError | When the package has no such message. |
Return the request and response message dataclasses of a ROS2 service type.
Usable before start, like describe_action.
| Parameters | |
servicestr | package/srv/Name. |
| Returns | |
ServiceTypes | Undocumented |
| Raises | |
InvalidMessageTypeNameError | When the name is not a three-part service name. |
MissingInterfacePackageError | When the interface package is not installed. |
UnusableMessageTypeError | When the package has no such service. |
Return what every publisher on a topic offers, as the QoS resolver takes it.
This reads the node's local graph cache on the loop: callers decide synchronously whether to adapt, and an await in between would let two match events spend the one bootstrap tightening twice. Returns an empty tuple when the Runtime is not up, because middleware callbacks call it during teardown.
str, action_type: str | ActionTypes, goal: Message, depth: int = 10, server_timeout: float = 10.0) -> Goal:
¶
Send one goal to a ROS2 action server, and return the handle that owns it.
The handle is returned once the server has answered the goal request. A refusal comes back as an already settled handle; only a path nobody serves raises.
| Parameters | |
action:str | The ROS2 action name. |
actionstr | ActionTypes | The action type (package/action/Name) or the already-resolved trio of message dataclasses. |
goal:Message | The goal, as an instance of the action's goal message dataclass. |
depth:int | How many feedback messages the handle buffers. |
serverfloat | Seconds to wait for an action server to appear on the path. |
| Returns | |
Goal | Undocumented |
| Raises | |
RuntimeNotStartedError | When the Runtime is not up. |
LoopAffinityError | When awaited on a loop other than the Runtime's. |
FieldTypeMismatchError | When a field of the goal holds a value of the wrong Python type. Refused here because rclpy aborts the process instead of raising. |
FieldValueOutOfRangeError | When a field of the goal is past its width or bound. |
ActionServerUnavailableError | When no action server answers on the path. |
MissingInterfacePackageError | When the action's interface package is absent. |
Bring up the Context, the Node and the executor thread on the running loop, which stays the Runtime's.
| Raises | |
RuntimeAlreadyStartedError | When the Runtime is already up. |
Close every open endpoint, then tear down the thread, the Node and the Context.
Teardown faults are returned in the outcome, not raised: the Runtime is stopped either way.
| Raises | |
RuntimeNotStartedError | When the Runtime was never started, or is already stopped. |
LoopAffinityError | When awaited on a loop other than the Runtime's. |
str, message_type: str | type[ Message], depth: int = 10, qos: QoSProfile | None = None) -> Subscription:
¶
Subscribe to a ROS2 topic, and return the handle that owns the subscription.
A declared profile is honoured exactly; a discovered one relaxes as the topic's publishers require. The call does not wait for a publisher: it opens against whatever the graph shows now, possibly nothing.
| Parameters | |
topic:str | The ROS2 topic name. |
messagestr | type[ | The ROS2 type name (package/Name or package/kind/Name) or an already-resolved message dataclass. |
depth:int | The handle's buffer size, and the ROS2 queue depth. |
qos:QoSProfile | None | The profile to request, or None to discover one: the most permissive request compatible with every publisher now, re-resolved once on the first publisher when there is none yet, and relaxed whenever the middleware reports an incompatibility. |
| Returns | |
Subscription | Undocumented |
| Raises | |
RuntimeNotStartedError | When the Runtime is not up. |
LoopAffinityError | When awaited on a loop other than the Runtime's. |
MissingInterfacePackageError | When the type's interface package is not installed. |
str, types: ActionTypes, goal: Message, sink: GoalSink, client: Any, loop: asyncio.AbstractEventLoop) -> Goal:
¶
Send the goal, wait for the server's answer, and build the handle around it.
str, service: str, service_type: str, build: Callable[ [ type[ Message]], Message]) -> Message:
¶
Call one parameter service of a ROS2 node.
| Raises | |
ServiceUnavailableError | When the node's service does not answer in time. |
ServiceCallTimeoutError | When the request went and no answer came back. |
Ask one ROS2 node about one parameter (one name per call: a batch with an undeclared name answers empty).
Put every transform of one message into the buffer, on the loop that received it.
The authority is this Runtime's node name, as a TransformListener would have written it. Nothing is raised: tf2 refuses a non-finite value or an empty frame id, and that is no reason to stop reading the topic.
Yield every parameter change on the graph from one /parameter_events subscription.
The facet demultiplexes by node. The subscription closes with the generator.
Return where one frame sits in another, out of what the buffer already holds.
Non-blocking: lookup_transform at zero time returns the latest cached transform or raises. The _async variant is avoided because awaiting its future on this loop busy-spins until another message feeds the buffer.
| Returns | |
Transform | None | The composed transform, or None when the buffer cannot complete the chain (unpublished frame, two trees that do not meet, or a link older than the cache). |
Read every name on the graph once, off the loop; this is what graph polls with.
| Raises | |
RuntimeNotStartedError | When the Runtime is not up (a poll racing teardown). |
Compare every publisher's type hash against our own, and warn about each new one.
A warning, not a refusal: a changed hash does not mean the message is undecodable.
Return the Node's clock (not the wall clock, so right under use_sim_time) as seconds and nanoseconds.
str, values: Mapping[ str, ParameterValue]) -> Mapping[ str, SetOutcome]:
¶
Write a batch of parameters to one ROS2 node, with one outcome per parameter.
Uses set_parameters, not the atomic variant, which discards the whole batch when one name is undeclared.