module documentation

The one field-selection mechanism: include and exclude globs over ROS2 field paths.

Every Binding that narrows a message uses it; it is a pure function of a message dataclass.

  • A pattern is tested against a leaf and against each of its ancestors, so exclude=("pose",) removes every field under pose.
  • Exclude wins. Include narrows first, exclude removes after.
  • A pattern that matches nothing is fatal, as is a selection that leaves no field.

Patterns are fnmatch globs matched against the whole path, with / an ordinary character: * crosses levels, so */position/* reaches a position at any depth. A repeated message field (sequence<PoseStamped>) is a leaf: it can be selected by name, but nothing inside it can.

Class FieldSelection Which fields of a message type a Binding exposes.
Function field_paths Return every field path a message type reaches, in ROS2 declaration order.
Function resolve_selection Return the field paths that survive a selection, interior paths included.
Constant SEPARATOR What joins a field path, and what a UA variable name is joined with.
Function _ancestors_or_self Return a, a/b, a/b/c for a/b/c: the path and everything carrying it.
Function _matched Return whether a pattern matches this path or any path it hangs below.
Function _require_every_pattern_matches Refuse a declaration carrying a pattern that matches no path of this message type.
Function _require_renames_to_be_rendered Refuse a rename of a path the Binding does not render.
Function _walk Yield every path below a message type, paired with whether it is a leaf.
def field_paths(message_type: type[Message]) -> tuple[str, ...]:

Return every field path a message type reaches, in ROS2 declaration order.

Interior paths are included, so pose appears beside pose/position/x.

def resolve_selection(message_type: type[Message], selection: FieldSelection) -> frozenset[str]:

Return the field paths that survive a selection, interior paths included.

Raises
FieldSelectionErrorWhen a declared pattern matches no path of the type.
FieldSelectionErrorWhen nothing survives.
FieldSelectionErrorWhen rename names a path that is not rendered: unknown or removed.
SEPARATOR: str =

What joins a field path, and what a UA variable name is joined with.

Value
'/'
def _ancestors_or_self(path: str) -> tuple[str, ...]:

Return a, a/b, a/b/c for a/b/c: the path and everything carrying it.

def _matched(path: str, patterns: Iterable[str]) -> bool:

Return whether a pattern matches this path or any path it hangs below.

def _require_every_pattern_matches(message_type: type[Message], selection: FieldSelection, paths: Sequence[str]):

Refuse a declaration carrying a pattern that matches no path of this message type.

def _require_renames_to_be_rendered(message_type: type[Message], selection: FieldSelection, rendered: set[str]):

Refuse a rename of a path the Binding does not render.

def _walk(message_type: type[Message], prefix: str) -> Iterator[tuple[str, bool]]:

Yield every path below a message type, paired with whether it is a leaf.