module documentation

QoS: where a profile came from, and therefore how it may be treated.

A profile is declared (written on the Binding), discovered (computed from the topic's live publishers) or defaulted (the middleware's reliable, volatile profile, for an outward endpoint with nothing declared). This is its provenance, and one rule follows: the QoS of an endpoint adapts if and only if it was discovered. Declared and defaulted profiles are honoured exactly.

Discovery picks, for each policy, the least demanding value any current publisher offers (see resolve), which is compatible with all of them regardless of order. Adaptation only ever relaxes. The one exception is the bootstrap: a topic with no publisher at init is subscribed with MOST_PERMISSIVE and re-resolved once on the first publisher it matches, since a VOLATILE request would match a TRANSIENT_LOCAL publisher and receive none of its history.

QoS is never fatal. A declared profile that clashes with a publisher is logged and reported as an event, not refused at startup, since whether the publisher is up then is a matter of timing. Queue depth is not part of a profile because it takes no part in matching.

Nothing here imports rclpy. The Policy values are the rmw policy-kind numbers.

Class Durability Whether a publisher keeps its samples for subscribers that join later.
Class EndpointInfo One endpoint on a topic, as the client library's publisher-info call reports it.
Class Liveliness How a publisher asserts that it is still alive.
Class Policy One matching policy, by the number rmw gives it.
Class Provenance Where a profile came from, and therefore whether it may be adapted.
Class QoSIncompatibility One incompatibility the middleware reported, and what this package did about it.
Class QoSNegotiation One endpoint's provenance, its current profile, and the two events that may move it.
Class QoSProfile The matching policies of one endpoint, and nothing else.
Class Reliability Whether the middleware retries a sample until it is acknowledged.
Function most_permissive Return the request that is, policy by policy, the least demanding of those given.
Function resolve Return the most permissive request compatible with every one of these publishers (discovery).
Constant DEFAULT_PROFILE The middleware's default profile (reliable, volatile, no deadline, automatic liveliness).
Constant LATCHED Transient local, for topics whose value is a fact rather than a stream (such as /tf_static).
Constant MOST_PERMISSIVE The request that matches every possible publisher and receives the least from them.
Constant SENSOR_DATA Best effort, as high-rate sensors usually publish.
Function _clashes Return every policy on which a subscriber's request cannot be served by a publisher's offer.
Function _rank Return how demanding a policy value is as a request; lower is more permissive.
Function _seconds Return a duration as the words an event text uses, instead of inf.
Constant _RANKS How demanding each enumerated policy value is, as a request.
def most_permissive(profiles: Iterable[QoSProfile]) -> QoSProfile:

Return the request that is, policy by policy, the least demanding of those given.

Adaptation relaxes with this too: combining the held profile with what the graph now resolves to is what makes it only ever move down. With nothing to combine it returns MOST_PERMISSIVE.

def resolve(endpoints: Iterable[EndpointInfo]) -> QoSProfile:

Return the most permissive request compatible with every one of these publishers (discovery).

Pure and independent of the order of the endpoints. With no publishers it returns MOST_PERMISSIVE; QoSNegotiation re-resolves once the first one appears.

DEFAULT_PROFILE =

The middleware's default profile (reliable, volatile, no deadline, automatic liveliness).

A publishing endpoint uses it when nothing was declared. Under it the only reachable mismatches are durability, which would replay stale commands to a late joiner, and deadline, a rate this package does not control.

Value
QoSProfile()
LATCHED =

Transient local, for topics whose value is a fact rather than a stream (such as /tf_static).

Value
QoSProfile(durability=Durability.TRANSIENT_LOCAL)
MOST_PERMISSIVE =

The request that matches every possible publisher and receives the least from them.

A discovered Binding with no publisher at init subscribes with it until its first match event. Left in place it would drop a latched topic's history.

Value
QoSProfile(reliability=Reliability.BEST_EFFORT,
           durability=Durability.VOLATILE,
           deadline=FOREVER,
           liveliness=Liveliness.AUTOMATIC,
           lease=FOREVER)
SENSOR_DATA =

Best effort, as high-rate sensors usually publish.

Value
QoSProfile(reliability=Reliability.BEST_EFFORT)
def _clashes(request: QoSProfile, offer: QoSProfile) -> tuple[Policy, ...]:

Return every policy on which a subscriber's request cannot be served by a publisher's offer.

Empty means the two match. A request is served when it asks for no more than the offer promises: for the three enumerations no stronger, for the two durations no shorter (checked against a live Jazzy graph). Nothing calls this at run time, since the middleware does the matching; it states the rule so tests can assert that resolve is compatible.

def _rank(value: Reliability | Durability | Liveliness) -> int:

Return how demanding a policy value is as a request; lower is more permissive.

def _seconds(value: float) -> str:

Return a duration as the words an event text uses, instead of inf.

_RANKS: dict[Reliability | Durability | Liveliness, int] =

How demanding each enumerated policy value is, as a request.

The enumerations are string-valued (not IntEnum) because TOML files name them.

Value
{Reliability.BEST_EFFORT: 0,
 Reliability.RELIABLE: 1,
 Durability.VOLATILE: 0,
 Durability.TRANSIENT_LOCAL: 1,
 Liveliness.AUTOMATIC: 0,
 Liveliness.MANUAL_BY_TOPIC: 1}