rclcpp  master
C++ ROS Client Library API
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
rclcpp::Publisher< MessageT, Alloc > Class Template Reference

A publisher publishes messages of any type to a topic. More...

#include <publisher.hpp>

Inheritance diagram for rclcpp::Publisher< MessageT, Alloc >:
Inheritance graph
[legend]
Collaboration diagram for rclcpp::Publisher< MessageT, Alloc >:
Collaboration graph
[legend]

Public Types

using MessageAllocTraits = allocator::AllocRebind< MessageT, Alloc >
 
using MessageAlloc = typename MessageAllocTraits::allocator_type
 
using MessageDeleter = allocator::Deleter< MessageAlloc, 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::intra_process_manager::IntraProcessManager >
 

Public Member Functions

 Publisher (rclcpp::node_interfaces::NodeBaseInterface *node_base, const std::string &topic, const rcl_publisher_options_t &publisher_options, const PublisherEventCallbacks &event_callbacks, const std::shared_ptr< MessageAlloc > &allocator)
 
virtual ~Publisher ()
 
mapped_ring_buffer::MappedRingBufferBase::SharedPtr make_mapped_ring_buffer (size_t size) const override
 Implementation utility function that creates a typed mapped ring buffer. More...
 
virtual void publish (std::unique_ptr< MessageT, MessageDeleter > msg)
 Send a message to the topic for this publisher. More...
 
virtual void publish (const std::shared_ptr< const MessageT > &msg)
 
virtual void publish (const MessageT &msg)
 
virtual void publish (const MessageT *msg)
 
void publish (const rcl_serialized_message_t &serialized_msg)
 
void publish (const rcl_serialized_message_t *serialized_msg)
 
void publish (std::shared_ptr< const rcl_serialized_message_t > serialized_msg)
 
std::shared_ptr< MessageAllocget_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_tget_gid () const
 Get the global identifier for this publisher (used in rmw and by DDS). More...
 
const rmw_gid_tget_intra_process_gid () const
 Get the global identifier for this publisher used by intra-process communication. More...
 
rcl_publisher_tget_publisher_handle ()
 Get the rcl publisher handle. More...
 
const rcl_publisher_tget_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...
 
rmw_qos_profile_t get_actual_qos () const
 Get the actual QoS settings, after the defaults have been determined. 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, const rcl_publisher_options_t &intra_process_options)
 Implementation utility function used to setup intra process publishing after creation. More...
 

Protected Member Functions

void do_inter_process_publish (const MessageT *msg)
 
void do_serialized_publish (const rcl_serialized_message_t *serialized_msg)
 
void do_intra_process_publish (uint64_t message_seq)
 
uint64_t store_intra_process_message (uint64_t publisher_id, std::shared_ptr< const MessageT > msg)
 
uint64_t store_intra_process_message (uint64_t publisher_id, 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

std::shared_ptr< MessageAllocmessage_allocator_
 
MessageDeleter message_deleter_
 
- Protected Attributes inherited from rclcpp::PublisherBase
std::shared_ptr< rcl_node_trcl_node_handle_
 
rcl_publisher_t publisher_handle_ = rcl_get_zero_initialized_publisher()
 
rcl_publisher_t intra_process_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_
 
rmw_gid_t intra_process_rmw_gid_
 

Additional Inherited Members

- Protected Types inherited from rclcpp::PublisherBase
using IntraProcessManagerWeakPtr = std::weak_ptr< rclcpp::intra_process_manager::IntraProcessManager >
 

Detailed Description

template<typename MessageT, typename Alloc = std::allocator<void>>
class rclcpp::Publisher< MessageT, Alloc >

A publisher publishes messages of any type to a topic.

Member Typedef Documentation

◆ MessageAllocTraits

template<typename MessageT, typename Alloc = std::allocator<void>>
using rclcpp::Publisher< MessageT, Alloc >::MessageAllocTraits = allocator::AllocRebind<MessageT, Alloc>

◆ MessageAlloc

template<typename MessageT, typename Alloc = std::allocator<void>>
using rclcpp::Publisher< MessageT, Alloc >::MessageAlloc = typename MessageAllocTraits::allocator_type

◆ MessageDeleter

template<typename MessageT, typename Alloc = std::allocator<void>>
using rclcpp::Publisher< MessageT, Alloc >::MessageDeleter = allocator::Deleter<MessageAlloc, MessageT>

◆ MessageUniquePtr

template<typename MessageT, typename Alloc = std::allocator<void>>
using rclcpp::Publisher< MessageT, Alloc >::MessageUniquePtr = std::unique_ptr<MessageT, MessageDeleter>

◆ MessageSharedPtr

template<typename MessageT, typename Alloc = std::allocator<void>>
using rclcpp::Publisher< MessageT, Alloc >::MessageSharedPtr = std::shared_ptr<const MessageT>

Constructor & Destructor Documentation

◆ Publisher()

template<typename MessageT, typename Alloc = std::allocator<void>>
rclcpp::Publisher< MessageT, Alloc >::Publisher ( rclcpp::node_interfaces::NodeBaseInterface node_base,
const std::string topic,
const rcl_publisher_options_t publisher_options,
const PublisherEventCallbacks event_callbacks,
const std::shared_ptr< MessageAlloc > &  allocator 
)
inline

◆ ~Publisher()

template<typename MessageT, typename Alloc = std::allocator<void>>
virtual rclcpp::Publisher< MessageT, Alloc >::~Publisher ( )
inlinevirtual

Member Function Documentation

◆ make_mapped_ring_buffer()

template<typename MessageT, typename Alloc = std::allocator<void>>
mapped_ring_buffer::MappedRingBufferBase::SharedPtr rclcpp::Publisher< MessageT, Alloc >::make_mapped_ring_buffer ( size_t  size) const
inlineoverridevirtual

Implementation utility function that creates a typed mapped ring buffer.

Reimplemented from rclcpp::PublisherBase.

◆ publish() [1/7]

template<typename MessageT, typename Alloc = std::allocator<void>>
virtual void rclcpp::Publisher< MessageT, Alloc >::publish ( std::unique_ptr< MessageT, MessageDeleter msg)
inlinevirtual

Send a message to the topic for this publisher.

This function is templated on the input message type, MessageT.

Parameters
[in]msgA shared pointer to the message to send.

◆ publish() [2/7]

template<typename MessageT, typename Alloc = std::allocator<void>>
virtual void rclcpp::Publisher< MessageT, Alloc >::publish ( const std::shared_ptr< const MessageT > &  msg)
inlinevirtual

◆ publish() [3/7]

template<typename MessageT, typename Alloc = std::allocator<void>>
virtual void rclcpp::Publisher< MessageT, Alloc >::publish ( const MessageT &  msg)
inlinevirtual

◆ publish() [4/7]

template<typename MessageT, typename Alloc = std::allocator<void>>
virtual void rclcpp::Publisher< MessageT, Alloc >::publish ( const MessageT *  msg)
inlinevirtual

◆ publish() [5/7]

template<typename MessageT, typename Alloc = std::allocator<void>>
void rclcpp::Publisher< MessageT, Alloc >::publish ( const rcl_serialized_message_t serialized_msg)
inline

◆ publish() [6/7]

template<typename MessageT, typename Alloc = std::allocator<void>>
void rclcpp::Publisher< MessageT, Alloc >::publish ( const rcl_serialized_message_t serialized_msg)
inline

◆ publish() [7/7]

template<typename MessageT, typename Alloc = std::allocator<void>>
void rclcpp::Publisher< MessageT, Alloc >::publish ( std::shared_ptr< const rcl_serialized_message_t serialized_msg)
inline

◆ get_allocator()

template<typename MessageT, typename Alloc = std::allocator<void>>
std::shared_ptr<MessageAlloc> rclcpp::Publisher< MessageT, Alloc >::get_allocator ( ) const
inline

◆ do_inter_process_publish()

template<typename MessageT, typename Alloc = std::allocator<void>>
void rclcpp::Publisher< MessageT, Alloc >::do_inter_process_publish ( const MessageT *  msg)
inlineprotected

◆ do_serialized_publish()

template<typename MessageT, typename Alloc = std::allocator<void>>
void rclcpp::Publisher< MessageT, Alloc >::do_serialized_publish ( const rcl_serialized_message_t serialized_msg)
inlineprotected

◆ do_intra_process_publish()

template<typename MessageT, typename Alloc = std::allocator<void>>
void rclcpp::Publisher< MessageT, Alloc >::do_intra_process_publish ( uint64_t  message_seq)
inlineprotected

◆ store_intra_process_message() [1/2]

template<typename MessageT, typename Alloc = std::allocator<void>>
uint64_t rclcpp::Publisher< MessageT, Alloc >::store_intra_process_message ( uint64_t  publisher_id,
std::shared_ptr< const MessageT >  msg 
)
inlineprotected

◆ store_intra_process_message() [2/2]

template<typename MessageT, typename Alloc = std::allocator<void>>
uint64_t rclcpp::Publisher< MessageT, Alloc >::store_intra_process_message ( uint64_t  publisher_id,
std::unique_ptr< MessageT, MessageDeleter msg 
)
inlineprotected

Member Data Documentation

◆ message_allocator_

template<typename MessageT, typename Alloc = std::allocator<void>>
std::shared_ptr<MessageAlloc> rclcpp::Publisher< MessageT, Alloc >::message_allocator_
protected

◆ message_deleter_

template<typename MessageT, typename Alloc = std::allocator<void>>
MessageDeleter rclcpp::Publisher< MessageT, Alloc >::message_deleter_
protected

The documentation for this class was generated from the following file: