6#ifndef PUBLISHER_HANDLER_H
7#define PUBLISHER_HANDLER_H
11#include <rclcpp/rclcpp.hpp>
12#include <rclcpp/node.hpp>
13#include <rclcpp/time_source.hpp>
30 rclcpp::Node::SharedPtr node;
37 rclcpp::QoS qos = rclcpp::SystemDefaultsQoS();
45 template <
class TopicType>
74 void publish(
const TopicType& msg);
81 void publish(
const std::shared_ptr<TopicType>& msg);
95 void publish(
typename TopicType::ConstSharedPtr msg);
105 rclcpp::Node::SharedPtr node_;
107 std::shared_ptr<rclcpp::Publisher<TopicType>> publisher_;
109 std::mutex mutex_publisher_;
111 std::atomic<bool> publisher_initialized_;
113 std::string address_;
115 bool throttle_ =
false;
116 double throttle_min_dt_ = 0;
118 rclcpp::Time last_time_published_;
128 template <
class TopicType>
165 PublisherHandler(
const rclcpp::Node::SharedPtr& node,
const std::string& address);
180 void publish(
const TopicType& msg);
187 void publish(
const std::shared_ptr<TopicType>& msg);
201 void publish(
typename TopicType::ConstSharedPtr msg);
211 std::shared_ptr<PublisherHandler_impl<TopicType>> impl_;
218#ifndef PUBLISHER_HANDLER_HPP
219#include <mrs_lib/impl/publisher_handler.hpp>
implementation of the publisher handler
Definition publisher_handler.h:47
unsigned int getNumSubscribers(void)
get number of subscribers
Definition publisher_handler.hpp:161
void publish(const TopicType &msg)
publish message
Definition publisher_handler.hpp:56
~PublisherHandler_impl(void)
default destructor
Definition publisher_handler.h:58
PublisherHandler_impl(void)
default constructor
Definition publisher_handler.hpp:17
user wrapper of the publisher handler implementation
Definition publisher_handler.h:130
void publish(const TopicType &msg)
publish message
Definition publisher_handler.hpp:241
PublisherHandler & operator=(const PublisherHandler &other)
operator=
Definition publisher_handler.hpp:180
~PublisherHandler(void)
generic destructor
Definition publisher_handler.h:141
unsigned int getNumSubscribers(void)
get number of subscribers
Definition publisher_handler.hpp:284
PublisherHandler(void)
generic constructor
Definition publisher_handler.h:136
All mrs_lib functions, classes, variables and definitions are contained in this namespace.
Definition attitude_converter.h:24
Definition publisher_handler.h:23
double throttle_rate
when > 0, the publisher output is limited to this rate in [Hz]
Definition publisher_handler.h:35