synchros2.publisher module

class synchros2.publisher.Publisher[source]

Bases: Generic[_MessageT]

An extension of a publisher from ROS 2.

__init__(*args: Any, node: rclpy.node.Node | None = None, **kwargs: Any) None[source]

Initializes the Publisher

Parameters:
  • args – Positional arguments to pass to the Node.create_publisher function

  • node – Optional node for the underlying native subscription, defaults to the current process node.

  • kwargs – Keyword arguments to pass to the Node.create_publisher function

property matched_subscriptions: int

Gets the number subscriptions matched and linked to.

Note that in ROS 2 Humble and earlier distributions, this property relies on the number of known subscriptions for the topic subscribed as subscription matching status info is missing.

property message_type: Type[_MessageT]

Gets the type of the message subscribed.

publisher() rclpy.publisher.Publisher[source]

Returns the internal ROS 2 publisher

subscription_matches(num_subscriptions: int) rclpy.task.Future[source]

Gets a future to next publisher matching status update.

Note that in ROS 2 Humble and earlier distributions, this method relies on polling the number of known subscriptions for the topic subscribed, as publisher matching events are missing.

Parameters:

num_subscriptions – lower bound on the number of subscriptions to match.

Returns:

a future, done if the current number of subscriptions already matches the specified lower bound.