mrs_lib
Various reusable classes, functions and utilities for use in MRS projects
Loading...
Searching...
No Matches
mrs_lib::Publisher< MessageType > Class Template Reference

Wrapper for rclcpp::Publisher. More...

#include <publisher.hpp>

Public Member Functions

 Publisher (const PublisherOptions &options, std::string_view topic_name)
 construct a publisher using the specified options.
void publish (const MessageType &msg)
 Publish a message.
void publish (std::unique_ptr< MessageType > msg)
 Publish a message.
std::string get_topic_name () const
 Returns the resolved (full) name of the topic handled by this publisher.
std::string get_unresolved_topic_name () const
 Returns the unresolved name of the topic handled by this publisher.
size_t get_subscriber_count () const
 Get number of subscribers on the published topic.

Detailed Description

template<class MessageType>
class mrs_lib::Publisher< MessageType >

Wrapper for rclcpp::Publisher.

Template Parameters
MessageTypeType of the message to publish.

Constructor & Destructor Documentation

◆ Publisher()

template<class MessageType>
mrs_lib::Publisher< MessageType >::Publisher ( const PublisherOptions & options,
std::string_view topic_name )

construct a publisher using the specified options.

Parameters
optionsConfiguration of the publisher.
topic_nameName of the topic to publish to.

Member Function Documentation

◆ get_subscriber_count()

template<class MessageType>
size_t mrs_lib::Publisher< MessageType >::get_subscriber_count ( ) const
nodiscard

Get number of subscribers on the published topic.

Returns
The number of subscribers.

◆ get_topic_name()

template<class MessageType>
std::string mrs_lib::Publisher< MessageType >::get_topic_name ( ) const
nodiscard

Returns the resolved (full) name of the topic handled by this publisher.

Returns
The name of the handled topic.

◆ get_unresolved_topic_name()

template<class MessageType>
std::string mrs_lib::Publisher< MessageType >::get_unresolved_topic_name ( ) const
nodiscard

Returns the unresolved name of the topic handled by this publisher.

Returns
The name of the handled topic.

◆ publish() [1/2]

template<class MessageType>
void mrs_lib::Publisher< MessageType >::publish ( const MessageType & msg)

Publish a message.

Parameters
msgMessage to publish.

◆ publish() [2/2]

template<class MessageType>
void mrs_lib::Publisher< MessageType >::publish ( std::unique_ptr< MessageType > msg)

Publish a message.

Parameters
msgMessage to publish.

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