synchros2.graph module

synchros2.graph.ensure_num_publishers(node: rclpy.node.Node, topic_name: str, num_publishers: int, timeout_sec: float | None = None, *, poll_period_sec: float = 0.1) int[source]

Returns the number of publishers on a topic.

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

Parameters:
  • node – A ROS 2 node

  • topic_name – The name of the topic to check

  • num_publishers – The lower bound on the number of publishers to match.

  • timeout_sec – A timeout on how long to wait for the lower bound to be satisfied

  • poll_period_sec – The period for polling the count

Returns:

The number of publishers

synchros2.graph.ensure_num_publishers_async(node: rclpy.node.Node, topic_name: str, num_publishers: int, *, poll_period_sec: float = 0.1) rclpy.task.Future[source]

Returns a future to the number of publishers on a topic.

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

Parameters:
  • node – A ROS 2 node

  • topic_name – The name of the topic to check

  • num_publishers – The lower bound on the number of publishers to match.

  • timeout_sec – A timeout on how long to wait for the lower bound to be satisfied

  • poll_period_sec – The period for polling the count

Returns:

A future to the number of publishers

synchros2.graph.ensure_num_subscriptions(node: rclpy.node.Node, topic_name: str, num_subscriptions: int, timeout_sec: float | None = None, *, poll_period_sec: float = 0.1) int[source]

Returns the number of subscriptions on a topic.

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

Parameters:
  • node – A ROS 2 node

  • topic_name – The name of the topic to check

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

  • timeout_sec – A timeout on how long to wait for the lower bound to be satisfied

  • poll_period_sec – The period for polling the count

Returns:

The number of subscriptions

synchros2.graph.ensure_num_subscriptions_async(node: rclpy.node.Node, topic_name: str, num_subscriptions: int, *, poll_period_sec: float = 0.1) rclpy.task.Future[source]

Returns a future to the number of subscriptions on a topic.

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

Parameters:
  • node – A ROS 2 node

  • topic_name – The name of the topic to check

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

  • timeout_sec – A timeout on how long to wait for the lower bound to be satisfied

  • poll_period_sec – The period for polling the count

Returns:

A future to the number of publishers