rclcpp
master
C++ ROS Client Library API
|
A publisher publishes messages of any type to a topic. More...
#include <publisher.hpp>
Public Types | |
using | MessageAllocatorTraits = allocator::AllocRebind< MessageT, AllocatorT > |
using | MessageAllocator = typename MessageAllocatorTraits::allocator_type |
using | MessageDeleter = allocator::Deleter< MessageAllocator, MessageT > |
using | MessageUniquePtr = std::unique_ptr< MessageT, MessageDeleter > |
using | MessageSharedPtr = std::shared_ptr< const MessageT > |
Public Types inherited from rclcpp::PublisherBase | |
using | IntraProcessManagerSharedPtr = std::shared_ptr< rclcpp::experimental::IntraProcessManager > |
Public Member Functions | |
Publisher (rclcpp::node_interfaces::NodeBaseInterface *node_base, const std::string &topic, const rclcpp::QoS &qos, const rclcpp::PublisherOptionsWithAllocator< AllocatorT > &options) | |
virtual void | post_init_setup (rclcpp::node_interfaces::NodeBaseInterface *node_base, const std::string &topic, const rclcpp::QoS &qos, const rclcpp::PublisherOptionsWithAllocator< AllocatorT > &options) |
Called post construction, so that construction may continue after shared_from_this() works. More... | |
virtual | ~Publisher () |
rclcpp::LoanedMessage< MessageT, AllocatorT > | borrow_loaned_message () |
Borrow a loaned ROS message from the middleware. More... | |
virtual void | publish (std::unique_ptr< MessageT, MessageDeleter > msg) |
Send a message to the topic for this publisher. More... | |
virtual void | publish (const MessageT &msg) |
void | publish (const rcl_serialized_message_t &serialized_msg) |
void | publish (rclcpp::LoanedMessage< MessageT, AllocatorT > &&loaned_msg) |
Publish an instance of a LoanedMessage. More... | |
std::shared_ptr< MessageAllocator > | get_allocator () const |
Public Member Functions inherited from rclcpp::PublisherBase | |
PublisherBase (rclcpp::node_interfaces::NodeBaseInterface *node_base, const std::string &topic, const rosidl_message_type_support_t &type_support, const rcl_publisher_options_t &publisher_options) | |
Default constructor. More... | |
virtual | ~PublisherBase () |
const char * | get_topic_name () const |
Get the topic that this publisher publishes on. More... | |
size_t | get_queue_size () const |
Get the queue size for this publisher. More... | |
const rmw_gid_t & | get_gid () const |
Get the global identifier for this publisher (used in rmw and by DDS). More... | |
rcl_publisher_t * | get_publisher_handle () |
Get the rcl publisher handle. More... | |
const rcl_publisher_t * | get_publisher_handle () const |
Get the rcl publisher handle. More... | |
const std::vector< std::shared_ptr< rclcpp::QOSEventHandlerBase > > & | get_event_handlers () const |
Get all the QoS event handlers associated with this publisher. More... | |
size_t | get_subscription_count () const |
Get subscription count. More... | |
size_t | get_intra_process_subscription_count () const |
Get intraprocess subscription count. More... | |
RCUTILS_WARN_UNUSED bool | assert_liveliness () const |
Manually assert that this Publisher is alive (for RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_TOPIC). More... | |
rclcpp::QoS | get_actual_qos () const |
Get the actual QoS settings, after the defaults have been determined. More... | |
bool | can_loan_messages () const |
Check if publisher instance can loan messages. More... | |
bool | operator== (const rmw_gid_t &gid) const |
Compare this publisher to a gid. More... | |
bool | operator== (const rmw_gid_t *gid) const |
Compare this publisher to a pointer gid. More... | |
void | setup_intra_process (uint64_t intra_process_publisher_id, IntraProcessManagerSharedPtr ipm) |
Implementation utility function used to setup intra process publishing after creation. More... | |
Public Member Functions inherited from std::enable_shared_from_this< PublisherBase > | |
T | enable_shared_from_this (T... args) |
T | operator= (T... args) |
T | shared_from_this (T... args) |
T | ~enable_shared_from_this (T... args) |
Protected Member Functions | |
void | do_inter_process_publish (const MessageT &msg) |
void | do_serialized_publish (const rcl_serialized_message_t *serialized_msg) |
void | do_loaned_message_publish (MessageT *msg) |
void | do_intra_process_publish (std::unique_ptr< MessageT, MessageDeleter > msg) |
std::shared_ptr< const MessageT > | do_intra_process_publish_and_return_shared (std::unique_ptr< MessageT, MessageDeleter > msg) |
Protected Member Functions inherited from rclcpp::PublisherBase | |
template<typename EventCallbackT > | |
void | add_event_handler (const EventCallbackT &callback, const rcl_publisher_event_type_t event_type) |
Protected Attributes | |
const rclcpp::PublisherOptionsWithAllocator< AllocatorT > | options_ |
Copy of original options passed during construction. More... | |
std::shared_ptr< MessageAllocator > | message_allocator_ |
MessageDeleter | message_deleter_ |
Protected Attributes inherited from rclcpp::PublisherBase | |
std::shared_ptr< rcl_node_t > | rcl_node_handle_ |
rcl_publisher_t | publisher_handle_ = rcl_get_zero_initialized_publisher() |
std::vector< std::shared_ptr< rclcpp::QOSEventHandlerBase > > | event_handlers_ |
bool | intra_process_is_enabled_ |
IntraProcessManagerWeakPtr | weak_ipm_ |
uint64_t | intra_process_publisher_id_ |
rmw_gid_t | rmw_gid_ |
Additional Inherited Members | |
Protected Types inherited from rclcpp::PublisherBase | |
using | IntraProcessManagerWeakPtr = std::weak_ptr< rclcpp::experimental::IntraProcessManager > |
A publisher publishes messages of any type to a topic.
using rclcpp::Publisher< MessageT, AllocatorT >::MessageAllocatorTraits = allocator::AllocRebind<MessageT, AllocatorT> |
using rclcpp::Publisher< MessageT, AllocatorT >::MessageAllocator = typename MessageAllocatorTraits::allocator_type |
using rclcpp::Publisher< MessageT, AllocatorT >::MessageDeleter = allocator::Deleter<MessageAllocator, MessageT> |
using rclcpp::Publisher< MessageT, AllocatorT >::MessageUniquePtr = std::unique_ptr<MessageT, MessageDeleter> |
using rclcpp::Publisher< MessageT, AllocatorT >::MessageSharedPtr = std::shared_ptr<const MessageT> |
|
inline |
|
inlinevirtual |
|
inlinevirtual |
Called post construction, so that construction may continue after shared_from_this() works.
|
inline |
Borrow a loaned ROS message from the middleware.
If the middleware is capable of loaning memory for a ROS message instance, the loaned message will be directly allocated in the middleware. If not, the message allocator of this rclcpp::Publisher instance is being used.
With a call to
publish
the LoanedMessage instance is being returned to the middleware or free'd accordingly to the allocator. If the message is not being published but processed differently, the destructor of this class will either return the message to the middleware or deallocate it via the internal allocator.
|
inlinevirtual |
Send a message to the topic for this publisher.
This function is templated on the input message type, MessageT.
[in] | msg | A shared pointer to the message to send. |
|
inlinevirtual |
|
inline |
|
inline |
Publish an instance of a LoanedMessage.
When publishing a loaned message, the memory for this ROS message will be deallocated after being published. The instance of the loaned message is no longer valid after this call.
loaned_msg | The LoanedMessage instance to be published. |
|
inline |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
protected |
Copy of original options passed during construction.
It is important to save a copy of this so that the rmw payload which it may contain is kept alive for the duration of the publisher.
|
protected |
|
protected |