- class rclpy.publisher.Publisher(publisher_impl: rpyutils.import_c_library.Publisher, msg_type: MsgType, topic: str, qos_profile: rclpy.qos.QoSProfile, event_callbacks: PublisherEventCallbacks, callback_group: CallbackGroup)
Create a container for a ROS publisher.
Users should not create a publisher with this constuctor, instead they should call
A publisher is used as a primary means of communication in a ROS system by publishing messages on a ROS topic.
publisher_impl – Publisher wrapping the underlying
msg_type – The type of ROS messages the publisher will publish.
topic – The name of the topic the publisher will publish to.
qos_profile – The quality of service profile to apply to the publisher.
- assert_liveliness() None
Manually assert that this Publisher is alive.
If the QoS Liveliness policy is set to MANUAL_BY_TOPIC, the application must call this at least as often as
- get_subscription_count() int
Get the amount of subscribers that this publisher has.
- property handle
- publish(msg: MsgType | bytes) None
Send a message to the topic for the publisher.
msg – The ROS message to publish.
TypeError if the type of the passed message isn’t an instance of the provided type when the publisher was constructed.
- property topic_name: str
- wait_for_all_acked(timeout: rclpy.duration.Duration = rclpy.duration.Duration) bool
Wait until all published message data is acknowledged or until the timeout elapses.
If the timeout is negative then this function will block indefinitely until all published message data is acknowledged. If the timeout is 0 then it will check if all published message has been acknowledged without waiting. If the timeout is greater than 0 then it will return after that period of time has elapsed or all published message data is acknowledged. This function only waits for acknowledgments if the publisher’s QOS profile is RELIABLE. Otherwise this function will immediately return true.
timeout – the duration to wait for all published message data to be acknowledged.
true if all published message data is acknowledged before the timeout, otherwise false.
- 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)
Create a container for a ROS subscription.
Users should not create a subscription with this constructor, instead they should call
Subscriptionwrapping the underlying
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.
- property callback
- get_publisher_count() int
Get the number of publishers that this subscription has.
- property handle
- property topic_name