Class PublisherBase

Inheritance Relationships

Derived Types

Class Documentation

class PublisherBase

Base class for ROS publishers in a filter pipeline.

ROS subscribers and publishers can act as sources and sinks in the message filter library. This class provides some basic functionality for on-demand subscriptions.

See also

Publisher

Subclassed by fkie_message_filters::CameraPublisher< Translate >, fkie_message_filters::ImagePublisher< Translate >, fkie_message_filters::Publisher< M, Translate, A >

Public Functions

virtual ~PublisherBase()
virtual bool is_active() const = 0

Check if the publisher is active.

Returns true if the number of subscribers is greater than zero. The result of the function is used to subscribe or unsubscribe linked subscribers on demand.

Does not throw any exceptions.

template<class NodeT, typename std::enable_if_t< !std::is_convertible_v< NodeT, rclcpp::node_interfaces::NodeGraphInterface::SharedPtr >, bool >> FKIE_MF_BEGIN_ABI_NAMESPACE void start_monitor (NodeT &&node) noexcept
virtual std::string topic() const = 0

Return advertised topic name.

Depends on the implementation.

Protected Functions

Add a new subscriber that will be controlled by this publisher.

  • sub the subscriber

    Propagates exceptions raised by the implementation of the abstract class methods.

Returns:

two connection objects for the signal to enable and disable the linked subscriber

void shutdown_monitor() noexcept

Shutdown monitoring thread for the number of subscribers.

This function is called automatically when the publisher object is destroyed.

void start_monitor(const rclcpp::node_interfaces::NodeGraphInterface::SharedPtr &node_graph_interface) noexcept

Start monitoring thread for the number of subscribers.

This is needed in ROS 2 because there is no longer a dedicated callback for created publishers.

Does not throw any exceptions.

template<class NodeT, typename std::enable_if_t<!std::is_convertible_v<NodeT, rclcpp::node_interfaces::NodeGraphInterface::SharedPtr>, bool> = true>
void start_monitor(NodeT &&node) noexcept

Start monitoring thread for the number of subscribers.

This is needed in ROS 2 because there is no longer a dedicated callback for created publishers.

void update_subscriber_state()

Cause all linked subscribers to subscribe or unsubscribe to their ROS topics.

This will check the return value of is_active() to determine if the publisher is active, and then call SubscriberBase::subscribe_impl() or SubscriberBase::unsubscribe_impl() accordingly.

Propagates exceptions raised by the implementation of the abstract class methods.