FKIE Message Filters
Improved filters for processing ROS messages
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
fkie_message_filters::PublisherBase Class Referenceabstract

Base class for ROS publishers in a filter pipeline. More...

#include <fkie_message_filters/publisher_base.hpp>

Inheritance diagram for fkie_message_filters::PublisherBase:
Inheritance graph
[legend]

Public Member Functions

virtual bool is_active () const =0
 Check if the publisher is active.
 
virtual std::string topic () const =0
 Return advertised topic name.
 

Protected Member Functions

std::tuple< Connection, Connectionlink_with_subscriber (SubscriberBase &sub)
 Add a new subscriber that will be controlled by this publisher.
 
void shutdown_monitor () noexcept
 Shutdown monitoring thread for the number of subscribers.
 
void start_monitor (const rclcpp::Node::SharedPtr &node) noexcept
 Start monitoring thread for the number of subscribers.
 
void update_subscriber_state ()
 Cause all linked subscribers to subscribe or unsubscribe to their ROS topics.
 

Detailed Description

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

Member Function Documentation

◆ is_active()

virtual bool fkie_message_filters::PublisherBase::is_active ( ) const
pure virtual

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.

Exceptions
Does not throw any exceptions.

Implemented in fkie_message_filters::CameraPublisher< Translate >, fkie_message_filters::ImagePublisher< Translate >, and fkie_message_filters::Publisher< M, Translate >.

◆ link_with_subscriber()

std::tuple< Connection, Connection > fkie_message_filters::PublisherBase::link_with_subscriber ( SubscriberBase sub)
protected

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

  • sub the subscriber
    Returns
    two connection objects for the signal to enable and disable the linked subscriber
    Exceptions
    Propagates exceptions raised by the implementation of the abstract class methods.

◆ shutdown_monitor()

void fkie_message_filters::PublisherBase::shutdown_monitor ( )
protectednoexcept

Shutdown monitoring thread for the number of subscribers.

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

◆ start_monitor()

void fkie_message_filters::PublisherBase::start_monitor ( const rclcpp::Node::SharedPtr &  node)
protectednoexcept

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.

Exceptions
Does not throw any exceptions.

◆ topic()

virtual std::string fkie_message_filters::PublisherBase::topic ( ) const
pure virtual

◆ update_subscriber_state()

void fkie_message_filters::PublisherBase::update_subscriber_state ( )
protected

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.

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

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