rclpy.subscription module

class rclpy.subscription.Subscription(subscription_impl: rpyutils.import_c_library.Subscription, msg_type: MsgType, topic: str, callback: Callable, callback_group: CallbackGroup, qos_profile: rclpy.qos.QoSProfile, raw: bool, event_callbacks: SubscriptionEventCallbacks)

Bases: object

Create a container for a ROS subscription.

Warning

Users should not create a subscription with this constructor, instead they should call Node.create_subscription().

Parameters:
  • subscription_implSubscription wrapping the underlying rcl_subscription_t object.

  • msg_type – The type of ROS messages the subscription will subscribe to.

  • topic – The name of the topic the subscription will subscribe to.

  • callback – A user-defined callback function that is called when a message is received by the subscription.

  • callback_group – The callback group for the subscription. If None, then the nodes default callback group is used.

  • qos_profile – The quality of service profile to apply to the subscription.

  • raw – If True, then received messages will be stored in raw binary representation.

class CallbackType(value)

Bases: Enum

An enumeration.

MessageOnly = 0
WithMessageInfo = 1
property callback
destroy()
get_publisher_count() int

Get the number of publishers that this subscription has.

property handle
property topic_name