module documentation

The TF facet: both transform topics, held by us, in both directions.

TF is ROS2's frame network: coordinate frames, each naming its parent, carried on /tf (moving) and /tf_static (never moving). Inward, the facet drains both topics through two ordinary subscriptions into a topology record and a tf2_ros.Buffer. It does not use tf2_ros.TransformListener, which would start a second executor and break the rule that this package owns one Node and one spinning thread. The topology is read from the messages (parent header.frame_id, child child_frame_id), geometry is looked up synchronously with Buffer.lookup_transform and no timeout (its _async variant busy-spins on the Runtime's loop), and nothing here imports rclpy.

Outward, TFFacet.broadcast publishes on the same topics. The publishers are opened by a watch that declares it broadcasts, so a Machine without outward frames never advertises /tf. Our own publisher is discounted from TFFacet.satisfied, since a subscription's matched count includes it (checked on Jazzy). The stamp is one reading of the Runtime's clock per call (opensmi.ros2.runtime.stamp). tf2_ros.StaticTransformBroadcaster is not used, because it silently drops an update for a frame it already sent. The static publisher is transient-local and the moving one volatile (TF_STATIC_QOS, TF_QOS); both are declared constants, while the subscriptions are discovered.

Class FrameLink One link of the frame network, whichever direction it is travelling.
Class TFFacet The frame network, for as long as anything is watching it.
Class TFWatch One consumer's interest in TF, and its lifetime.
Class Transform One rigid-body transform, as ROS2 spells it: a translation and a unit quaternion.
Function links Return the frame links one TFMessage carries, read off its own structure.
Function roots_of Return every frame that is somebody's parent and nobody's child, in sorted order.
Constant CHILD_FRAME_FIELD The field of one element naming the frame it describes. The parent is in its header.
Constant FRAME_FIELD The field of one header naming the parent frame. Read inward, written outward.
Constant HEADER_FIELD The field of one element carrying the parent frame and the stamp. Read inward, written outward.
Constant ROTATION_FIELD The field of one transform holding the unit quaternion.
Constant TF_DEPTH How many messages each transform subscription buffers.
Constant TF_MESSAGE_TYPE The one type both topics carry.
Constant TF_STATIC_TOPIC The topic a transform that never moves is published on, once, with transient-local QoS.
Constant TF_TOPIC The topic every moving transform in a ROS2 system is published on.
Constant TRANSFORM_CACHE How many seconds of transform history the buffer keeps (tf2's default). Composed poses are answered from it.
Constant TRANSFORM_FIELD The field of one element carrying the geometry: a translation and a rotation.
Constant TRANSFORMS_FIELD The repeated field of a TFMessage, which is what keys the frame network.
Constant TRANSLATION_FIELD The field of one transform holding metres along three axes.
Type Alias AdvertiseFunction How the facet opens a topic outward: the Runtime's own advertise.
Type Alias ClockFunction How a broadcast learns what time it is: whole seconds and nanoseconds off the ROS2 Node's own clock.
Type Alias FeedFunction How one message reaches the transform buffer: the message, and whether it arrived static.
Type Alias LookupFunction How a composed pose is asked for: a target frame and a source frame.
Type Alias SubscribeFunction How the facet opens a topic: the Runtime's own subscribe.
Class _Source One of the two transform topics, live: its subscription and the task draining it.
Class _Sources Where one declaration reads TF from, which every declaration on a Machine must share.
Function _built Return one message dataclass instance, built by field name.
Function _element_type Return the type one element of a TFMessage's repeated field is.
Function _named Return a frame id as the network keys it: text, without tf2's optional leading slash.
Function _nested_type Return the message type one field of another holds.
Function _tf_message Return the one TFMessage a list of links becomes.
Function _transform_of Return one element's transform, or None when it does not carry the shape of one.
Function _triple Return the named float fields of one nested message, or None if any is missing.
Constant _LOGGER Undocumented
def links(message: Message, *, static: bool) -> tuple[FrameLink, ...]:

Return the frame links one TFMessage carries, read off its own structure.

An element missing either name, or naming itself as its parent, is skipped: one malformed element must not end the stream.

Parameters
message:MessageOne message from /tf or /tf_static, as it crossed the seam.
static:boolWhether it arrived on the static topic.
Returns
tuple[FrameLink, ...]Undocumented
def roots_of(frames: Mapping[str, FrameLink]) -> tuple[str, ...]:

Return every frame that is somebody's parent and nobody's child, in sorted order.

The root of a TF tree is what OPC 10000-210 calls the World Frame. A well-formed tree has one; two means two trees are published into one graph.

CHILD_FRAME_FIELD: str =

The field of one element naming the frame it describes. The parent is in its header.

Value
'child_frame_id'
FRAME_FIELD: str =

The field of one header naming the parent frame. Read inward, written outward.

Value
'frame_id'
HEADER_FIELD: str =

The field of one element carrying the parent frame and the stamp. Read inward, written outward.

Value
'header'
ROTATION_FIELD: str =

The field of one transform holding the unit quaternion.

Value
'rotation'
TF_DEPTH: int =

How many messages each transform subscription buffers.

Larger than the Binding default, because /tf carries one message per publisher per control cycle. A drop here is a transform the buffer never saw.

Value
100
TF_MESSAGE_TYPE: str =

The one type both topics carry.

Value
'tf2_msgs/msg/TFMessage'
TF_STATIC_TOPIC: str =

The topic a transform that never moves is published on, once, with transient-local QoS.

Value
'/tf_static'
TF_TOPIC: str =

The topic every moving transform in a ROS2 system is published on.

Value
'/tf'
TRANSFORM_CACHE: float =

How many seconds of transform history the buffer keeps (tf2's default). Composed poses are answered from it.

Value
10.0
TRANSFORM_FIELD: str =

The field of one element carrying the geometry: a translation and a rotation.

Value
'transform'
TRANSFORMS_FIELD: str =

The repeated field of a TFMessage, which is what keys the frame network.

Value
'transforms'
TRANSLATION_FIELD: str =

The field of one transform holding metres along three axes.

Value
'translation'
AdvertiseFunction: TypeAlias =

How the facet opens a topic outward: the Runtime's own advertise.

Value
Callable[..., Awaitable[Publisher]]
ClockFunction: TypeAlias =

How a broadcast learns what time it is: whole seconds and nanoseconds off the ROS2 Node's own clock.

It sits behind the seam because a Node on simulated time is the case a wall clock gets wrong.

Value
Callable[[], tuple[int, int]]
FeedFunction: TypeAlias =

How one message reaches the transform buffer: the message, and whether it arrived static.

Value
Callable[[Message, bool], None]
LookupFunction: TypeAlias =

How a composed pose is asked for: a target frame and a source frame.

The answer comes from the cache or not at all. Synchronous and non-blocking.

Value
Callable[[str, str], Transform | None]
SubscribeFunction: TypeAlias =

How the facet opens a topic: the Runtime's own subscribe.

Value
Callable[..., Awaitable[Subscription]]
def _built(message_type: type[Message], **values: Any) -> Message:

Return one message dataclass instance, built by field name.

A message dataclass has no statically known fields, so type checkers reject naming them at a call site and accept a keyword splat.

def _element_type(message_type: type[Message]) -> type[Message]:

Return the type one element of a TFMessage's repeated field is.

Raises
UnusableMessageTypeErrorWhen the type advertised for the transform topics does not repeat a message at all, which is a robot whose tf2_msgs is not tf2_msgs.
def _named(value: object) -> str:

Return a frame id as the network keys it: text, without tf2's optional leading slash.

tf2 treats /base_link and base_link as one frame, so do we.

def _nested_type(message_type: type[Message], field: str) -> type[Message]:

Return the message type one field of another holds.

Raises
UnusableMessageTypeErrorWhen the field is not a nested message, which is the same condition as above one level down and says which level it was.
def _tf_message(message_type: type[Message], links: Sequence[FrameLink], *, seconds: int, nanoseconds: int) -> Message:

Return the one TFMessage a list of links becomes.

Built rather than stamped: ~opensmi.ros2.runtime.stamp.stamped does not descend into repeated message fields and every stamp in a TFMessage is inside one, so each stamp is written as its element is constructed. Nested types are read off the dataclass, since nothing here imports rclpy.

def _transform_of(element: object) -> Transform | None:

Return one element's transform, or None when it does not carry the shape of one.

def _triple(held: object, names: tuple[str, ...]) -> tuple[float, ...] | None:

Return the named float fields of one nested message, or None if any is missing.

_LOGGER =

Undocumented

Value
structlog.get_logger('opensmi.ros2.runtime.tf')