module documentation

The Runtime: the sole owner of ROS2 access for one Machine.

This is the only module in the package that imports rclpy. One Runtime owns one rclpy Context on its own Domain ID, one Node and one executor thread. There is no registry and no process global, so two Machines on two Domain IDs run in one process without discovering each other.

No rclpy type crosses this interface. Every operation is async and must be awaited on the loop Runtime.start ran on (otherwise it raises LoopAffinityError). Callbacks that rclpy invokes on the executor thread only hop to the loop with call_soon_threadsafe; decoding and buffering happen there. Blocking rclpy calls run through asyncio.to_thread. QoS adaptation lives here too (see opensmi.ros2.runtime.qos).

Class Runtime All ROS2 access for one Machine, which is the unit of one Domain ID.
Class _AdaptiveSubscription One topic's QoS negotiation, and the rclpy subscription it is currently expressed as.
Function _by_name Return one of rclpy's name-and-types lists as the mapping a snapshot holds.
Function _duration_of Return a number of seconds as the rclpy duration a QoS policy takes.
Function _faults_from Run one teardown step, returning a fault line instead of raising, so a failed step cannot keep the Context up.
Function _our_profile Return what one endpoint offers; anything not modelled reads as the most permissive value.
Function _own_type_hash Return the type hash of this node's own subscription on a topic (what the dataclass was built against).
Function _policy_of Return the policy an incompatibility event named; an unmodelled kind is Policy.INVALID, not an exception.
Function _rclpy_profile Return one of our profiles as the rclpy object an endpoint is created with, joined with its depth.
Function _refuse_an_unserved_action Refuse a goal for a path no action server answers on.
Function _refuse_an_unserved_service Refuse a call on a path no service server answers on.
Function _require_the_payload_type Refuse a payload that is not the message dataclass its ROS2 path takes.
Async Function _resolved Await an rclpy future (not awaitable, completes on the executor thread) on the Runtime's loop.
Function _seconds_of Return an rclpy duration as seconds, with both spellings of no duration as FOREVER.
Function _snapshot_of Return every topic, service and action on the graph, with the types on each name.
Constant _DURABILITY Undocumented
Constant _DURABILITY_IN Undocumented
Constant _INFINITE_NANOSECONDS How a live Jazzy graph reports an infinite duration (INT64_MAX); a fresh profile says zero. Both mean FOREVER.
Constant _LIVELINESS This package's policy values in rclpy's vocabulary (SYSTEM_DEFAULT is never requested).
Constant _LIVELINESS_IN The same read backwards, by the integer a publisher reports.
Constant _LOGGER Undocumented
Constant _RELIABILITY Undocumented
Constant _RELIABILITY_IN Undocumented
Constant _UNKNOWN_TYPE_HASH Undocumented
def _by_name(listed: Iterable[tuple[str, list[str]]]) -> dict[str, tuple[str, ...]]:

Return one of rclpy's name-and-types lists as the mapping a snapshot holds.

def _duration_of(seconds: float) -> Duration:

Return a number of seconds as the rclpy duration a QoS policy takes.

def _faults_from(what: str, step: Callable[[], object]) -> Iterable[str]:

Run one teardown step, returning a fault line instead of raising, so a failed step cannot keep the Context up.

def _our_profile(profile: Any) -> QoSProfile:

Return what one endpoint offers; anything not modelled reads as the most permissive value.

def _own_type_hash(node: rclpy.node.Node, topic: str) -> str | None:

Return the type hash of this node's own subscription on a topic (what the dataclass was built against).

def _policy_of(kind: Any) -> Policy:

Return the policy an incompatibility event named; an unmodelled kind is Policy.INVALID, not an exception.

def _rclpy_profile(profile: QoSProfile, depth: int) -> rclpy.qos.QoSProfile:

Return one of our profiles as the rclpy object an endpoint is created with, joined with its depth.

def _refuse_an_unserved_action(action: str, server_timeout: float):

Refuse a goal for a path no action server answers on.

def _refuse_an_unserved_service(service: str, server_timeout: float):

Refuse a call on a path no service server answers on.

def _require_the_payload_type(what: str, path: str, payload: Message, expected: type[Message], type_name: str):

Refuse a payload that is not the message dataclass its ROS2 path takes.

Raises
TypeErrorWhen the payload is not an instance of the expected dataclass.
async def _resolved(future: Any, loop: asyncio.AbstractEventLoop) -> Any:

Await an rclpy future (not awaitable, completes on the executor thread) on the Runtime's loop.

def _seconds_of(duration: Any) -> float:

Return an rclpy duration as seconds, with both spellings of no duration as FOREVER.

def _snapshot_of(node: rclpy.node.Node) -> GraphSnapshot:

Return every topic, service and action on the graph, with the types on each name.

A topic only this node subscribes to is included; match events, not this poll, say whether anything publishes on it.

_DURABILITY =

Undocumented

Value
{Durability.TRANSIENT_LOCAL: rclpy.qos.DurabilityPolicy.TRANSIENT_LOCAL,
 Durability.VOLATILE: rclpy.qos.DurabilityPolicy.VOLATILE}
_DURABILITY_IN =

Undocumented

Value
{int(theirs): ours for ours, theirs in _DURABILITY.items()}
_INFINITE_NANOSECONDS: int =

How a live Jazzy graph reports an infinite duration (INT64_MAX); a fresh profile says zero. Both mean FOREVER.

Value
9223372036854775807
_LIVELINESS =

This package's policy values in rclpy's vocabulary (SYSTEM_DEFAULT is never requested).

Value
{Liveliness.MANUAL_BY_TOPIC: rclpy.qos.LivelinessPolicy.MANUAL_BY_TOPIC,
 Liveliness.AUTOMATIC: rclpy.qos.LivelinessPolicy.AUTOMATIC}
_LIVELINESS_IN =

The same read backwards, by the integer a publisher reports.

SYSTEM_DEFAULT, UNKNOWN and BEST_AVAILABLE are absent and fall through to the most permissive value, so an offer we cannot interpret never makes us ask for more than it.

Value
{int(theirs): ours for ours, theirs in _LIVELINESS.items()}
_LOGGER =

Undocumented

Value
structlog.get_logger('opensmi.ros2.runtime.runtime')
_RELIABILITY =

Undocumented

Value
{Reliability.RELIABLE: rclpy.qos.ReliabilityPolicy.RELIABLE,
 Reliability.BEST_EFFORT: rclpy.qos.ReliabilityPolicy.BEST_EFFORT}
_RELIABILITY_IN =

Undocumented

Value
{int(theirs): ours for ours, theirs in _RELIABILITY.items()}
_UNKNOWN_TYPE_HASH: str =

Undocumented

Value
'INVALID'