rclcpp  master
C++ ROS Client Library API
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
rclcpp::publisher::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::Publisher< MessageT, Alloc >:
rclcpp::publisher::PublisherBase

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 >
 
- Public Types inherited from rclcpp::publisher::PublisherBase
using StoreMessageCallbackT = std::function< uint64_t(uint64_t, void *, const std::type_info &)>
 

Public Member Functions

 Publisher (rclcpp::node_interfaces::NodeBaseInterface *node_base, const std::string &topic, const rcl_publisher_options_t &publisher_options, const std::shared_ptr< MessageAlloc > &allocator)
 
virtual ~Publisher ()
 
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< MessageT > &msg)
 
virtual void publish (std::shared_ptr< const MessageT > msg)
 
virtual void publish (const MessageT &msg)
 
virtual void publish (const MessageT *msg)
 
std::shared_ptr< MessageAllocget_allocator () const
 
- Public Member Functions inherited from rclcpp::publisher::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...
 
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, StoreMessageCallbackT callback, 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)
 

Protected Attributes

std::shared_ptr< MessageAllocmessage_allocator_
 
MessageDeleter message_deleter_
 
- Protected Attributes inherited from rclcpp::publisher::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()
 
uint64_t intra_process_publisher_id_
 
StoreMessageCallbackT store_intra_process_message_
 
rmw_gid_t rmw_gid_
 
rmw_gid_t intra_process_rmw_gid_
 

Detailed Description

template<typename MessageT, typename Alloc = std::allocator<void>>
class rclcpp::publisher::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::Publisher< MessageT, Alloc >::MessageAllocTraits = allocator::AllocRebind<MessageT, Alloc>

◆ MessageAlloc

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

◆ MessageDeleter

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

◆ MessageUniquePtr

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

Constructor & Destructor Documentation

◆ Publisher()

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

◆ ~Publisher()

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

Member Function Documentation

◆ publish() [1/5]

template<typename MessageT, typename Alloc = std::allocator<void>>
virtual void rclcpp::publisher::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/5]

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

◆ publish() [3/5]

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

◆ publish() [4/5]

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

◆ publish() [5/5]

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

◆ get_allocator()

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

◆ do_inter_process_publish()

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

Member Data Documentation

◆ message_allocator_

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

◆ message_deleter_

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

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