Class SubscriberBase

Inheritance Relationships

Derived Types

Class Documentation

class SubscriberBase

Base class for ROS subscribers 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

Subscriber

Subclassed by fkie_message_filters::CameraSubscriber< Translate >, fkie_message_filters::ImageSubscriber< Translate >, fkie_message_filters::Subscriber< M, Translate, A >

Public Functions

virtual ~SubscriberBase()
virtual void subscribe()

Subscribe to the configured ROS topic.

This method does nothing if no ROS topic was configured or if the subscriber is subscribed already. Cancels the effect of subscribe_on_demand(), i.e. the subscriber will remain subscribed permanently.

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

virtual void subscribe_on_demand(PublisherBase &pub)

Subscribe to the configured ROS topic whenever the given publisher is active.

This method does nothing if no ROS topic was configured. Otherwise, it will immediately subscribe or unsubscribe depending on the publisher’s current state. If the publisher becomes active or inactive, the subscriber’s state will update accordingly.

  • pub publisher

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

virtual std::string topic() const = 0

Return the subscribed topic name.

Depends on the implementation.

virtual void unsubscribe()

Unsubscribe from the configured ROS topic.

You can call subscribe() afterwards to re-subscribe to the ROS topic. This method does nothing if the subscriber is not subscribed to any ROS topic. Cancels the effect of subscribe_on_demand(), i.e. the subscriber will remain unsubscribed permanently.

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

Protected Functions

virtual bool is_configured() const = 0

Check if the subscriber is properly configured.

This virtual method must be overridden in derived classes.

Depends on the implementation.

Return values:

Add self to the list of subscribers which are controlled by a publisher.

A subscriber can be linked with one publisher only. Any previously linked publisher is unlinked first.

  • pub publisher

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

virtual void subscribe_impl() = 0

Implement how to subscribe to the configured ROS topic.

This virtual method must be overridden in derived classes to actually subscribe to a topic. It should do nothing if it is subscribed to a topic already.

Depends on the implementation.

Remove self from the list of subscribers which are controlled by a publisher.

This will not affect the current subscription state. It will only prevent further updates from the previously linked publisher.

Does not throw any exceptions.

virtual void unsubscribe_impl() = 0

Implement how to unsubscribe from the configured ROS topic.

This virtual method must be overridden in derived classes to actually unsubscribe from a topic. It should do nothing if it is not subscribed in the first place.

Depends on the implementation.