rclcpp  master
C++ ROS Client Library API
Public Member Functions | List of all members
rclcpp::GenericPublisher Class Reference

Publisher for serialized messages whose type is not known at compile time. More...

#include <generic_publisher.hpp>

Inheritance diagram for rclcpp::GenericPublisher:
Inheritance graph
[legend]
Collaboration diagram for rclcpp::GenericPublisher:
Collaboration graph
[legend]

Public Member Functions

template<typename AllocatorT = std::allocator<void>>
 GenericPublisher (rclcpp::node_interfaces::NodeBaseInterface *node_base, std::shared_ptr< rcpputils::SharedLibrary > ts_lib, const std::string &topic_name, const std::string &topic_type, const rclcpp::QoS &qos, const rclcpp::PublisherOptionsWithAllocator< AllocatorT > &options)
 Constructor. More...
 
virtual ~GenericPublisher ()=default
 
void publish (const rclcpp::SerializedMessage &message)
 Publish a rclcpp::SerializedMessage. More...
 
- 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...
 
std::shared_ptr< rcl_publisher_tget_publisher_handle ()
 Get the rcl publisher handle. More...
 
std::shared_ptr< 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...
 
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...
 
std::vector< rclcpp::NetworkFlowEndpointget_network_flow_endpoints () const
 Get network flow endpoints. More...
 
- Public Member Functions inherited from std::enable_shared_from_this< PublisherBase >
enable_shared_from_this (T... args)
 
operator= (T... args)
 
shared_from_this (T... args)
 
~enable_shared_from_this (T... args)
 

Additional Inherited Members

- Public Types inherited from rclcpp::PublisherBase
using IntraProcessManagerSharedPtr = std::shared_ptr< rclcpp::experimental::IntraProcessManager >
 
- Protected Types inherited from rclcpp::PublisherBase
using IntraProcessManagerWeakPtr = std::weak_ptr< rclcpp::experimental::IntraProcessManager >
 
- 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)
 
void default_incompatible_qos_callback (QOSOfferedIncompatibleQoSInfo &info) const
 
- Protected Attributes inherited from rclcpp::PublisherBase
std::shared_ptr< rcl_node_trcl_node_handle_
 
std::shared_ptr< rcl_publisher_tpublisher_handle_
 
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_
 

Detailed Description

Publisher for serialized messages whose type is not known at compile time.

Since the type is not known at compile time, this is not a template, and the dynamic library containing type support information has to be identified and loaded based on the type name.

It does not support intra-process handling.

Constructor & Destructor Documentation

◆ GenericPublisher()

template<typename AllocatorT = std::allocator<void>>
rclcpp::GenericPublisher::GenericPublisher ( rclcpp::node_interfaces::NodeBaseInterface node_base,
std::shared_ptr< rcpputils::SharedLibrary >  ts_lib,
const std::string topic_name,
const std::string topic_type,
const rclcpp::QoS qos,
const rclcpp::PublisherOptionsWithAllocator< AllocatorT > &  options 
)
inline

Constructor.

In order to properly publish to a topic, this publisher needs to be added to the node_topic_interface of the node passed into this constructor.

See also
rclcpp::Node::create_generic_publisher() or rclcpp::create_generic_publisher() for creating an instance of this class and adding it to the node_topic_interface.
Parameters
node_basePointer to parent node's NodeBaseInterface
ts_libType support library, needs to correspond to topic_type
topic_nameTopic name
topic_typeTopic type
qosQoS settings
callbackCallback for new messages of serialized form
optionsPublisher options. Not all publisher options are currently respected, the only relevant options for this publisher are event_callbacks, use_default_callbacks, and callback_group.

◆ ~GenericPublisher()

virtual rclcpp::GenericPublisher::~GenericPublisher ( )
virtualdefault

Member Function Documentation

◆ publish()

void rclcpp::GenericPublisher::publish ( const rclcpp::SerializedMessage message)

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