Public Member Functions | Private Member Functions | Private Attributes | List of all members
fkie_message_filters::Publisher< M, Translate > Class Template Reference

Publish consumed data on a ROS topic. More...

#include <publisher.h>

Inheritance diagram for fkie_message_filters::Publisher< M, Translate >:
Inheritance graph
[legend]

Public Member Functions

void advertise (ros::NodeHandle &nh, const std::string &topic, uint32_t queue_size, bool latch=false, ros::CallbackQueueInterface *callback_queue=nullptr) noexcept
 Advertise ROS topic. More...
 
void advertise (ros::NodeHandle &nh, const std::string &topic, uint32_t queue_size, const ros::SubscriberStatusCallback &connect_cb, const ros::SubscriberStatusCallback &disconnect_cb=ros::SubscriberStatusCallback(), const ros::VoidConstPtr &tracked_object=ros::VoidConstPtr(), bool latch=false, ros::CallbackQueueInterface *callback_queue=nullptr) noexcept
 Advertise ROS topic with subscriber status callbacks. More...
 
virtual bool is_active () const noexcept override
 Check if the ROS publisher has at least one subscriber. More...
 
 Publisher () noexcept
 Constructs an empty publisher. More...
 
 Publisher (ros::NodeHandle &nh, const std::string &topic, uint32_t queue_size, bool latch=false, ros::CallbackQueueInterface *callback_queue=nullptr) noexcept
 Constructor that advertises the given ROS topic. More...
 
virtual std::string topic () const noexcept override
 Return the configured ROS topic. More...
 
- Public Member Functions inherited from fkie_message_filters::PublisherBase
virtual ~PublisherBase ()
 
- Public Member Functions inherited from fkie_message_filters::Sink< Translate< M >::FilterType >
Connection connect_to_source (Source< Inputs... > &src) noexcept
 Connect this sink to a source. More...
 
virtual void disconnect () noexcept override
 Disconnect from all connected sources. More...
 
void disconnect_from_all_sources () noexcept
 Disconnect from all connected sources. More...
 
virtual ~Sink ()
 
- Public Member Functions inherited from fkie_message_filters::FilterBase
virtual void reset () noexcept
 Reset filter state. More...
 
virtual ~FilterBase ()
 

Private Member Functions

virtual void receive (const typename Translate< M >::FilterType &t) noexcept override
 

Private Attributes

ros::Publisher pub_
 

Additional Inherited Members

- Public Types inherited from fkie_message_filters::Sink< Translate< M >::FilterType >
using Input = IO< Inputs... >
 Grouped input types. More...
 
- Static Public Attributes inherited from fkie_message_filters::Sink< Translate< M >::FilterType >
static constexpr std::size_t NUM_INPUTS
 Number of input arguments. More...
 
- Protected Member Functions inherited from fkie_message_filters::PublisherBase
std::tuple< boost::signals2::connection, boost::signals2::connection > link_with_subscriber (SubscriberBase &sub)
 Add a new subscriber that will be controlled by this publisher. More...
 
void update_subscriber_state ()
 Cause all linked subscribers to subscribe or unsubscribe to their ROS topics. More...
 
- Protected Member Functions inherited from fkie_message_filters::Sink< Translate< M >::FilterType >
virtual void receive (const Inputs &... in)=0
 Process incoming data. More...
 

Detailed Description

template<class M, template< typename > class Translate = RosMessageEvent>
class fkie_message_filters::Publisher< M, Translate >

Publish consumed data on a ROS topic.

This class together with the Subscriber class is the generic interface between ROS and this library. All messages which are received from the connected sources will be published on the advertised ROS topic. For maximum flexibility, you can choose one of four ways how to receive messages from your sources:

Unlike regular ROS publishers, this class can be associated with one or more subscriber instances. In that case, the subscribers will subscribe to their ROS topics only if the publisher is actively used. This is a convenient method to save processing power if the filter pipeline is used only intermittently.

See also
CameraPublisher, ImagePublisher

Definition at line 51 of file publisher.h.

Constructor & Destructor Documentation

◆ Publisher() [1/2]

template<class M , template< typename > class Translate>
fkie_message_filters::Publisher< M, Translate >::Publisher ( )
noexcept

Constructs an empty publisher.

You need to call advertise() to actually publish to a ROS topic.

Definition at line 30 of file publisher_impl.h.

◆ Publisher() [2/2]

template<class M , template< typename > class Translate>
fkie_message_filters::Publisher< M, Translate >::Publisher ( ros::NodeHandle nh,
const std::string &  topic,
uint32_t  queue_size,
bool  latch = false,
ros::CallbackQueueInterface callback_queue = nullptr 
)
noexcept

Constructor that advertises the given ROS topic.

The constructor calls advertise() for you.

Definition at line 35 of file publisher_impl.h.

Member Function Documentation

◆ advertise() [1/2]

template<class M , template< typename > class Translate>
void fkie_message_filters::Publisher< M, Translate >::advertise ( ros::NodeHandle nh,
const std::string &  topic,
uint32_t  queue_size,
bool  latch = false,
ros::CallbackQueueInterface callback_queue = nullptr 
)
noexcept

Advertise ROS topic.

All arguments are passed to the ROS client library; see the ROS documentation for further information. Calling this method will automatically unadvertise any previously advertised ROS topic.

  • nh ROS node handle to create the ROS advertisement
  • topic name of the ROS topic, subject to remapping
  • queue_size size of the ROS publishing queue
  • latch if true, the last published message remains available for later subscribers
  • callback_queue custom ROS callback queue

Definition at line 53 of file publisher_impl.h.

◆ advertise() [2/2]

template<class M , template< typename > class Translate>
void fkie_message_filters::Publisher< M, Translate >::advertise ( ros::NodeHandle nh,
const std::string &  topic,
uint32_t  queue_size,
const ros::SubscriberStatusCallback connect_cb,
const ros::SubscriberStatusCallback disconnect_cb = ros::SubscriberStatusCallback(),
const ros::VoidConstPtr tracked_object = ros::VoidConstPtr(),
bool  latch = false,
ros::CallbackQueueInterface callback_queue = nullptr 
)
noexcept

Advertise ROS topic with subscriber status callbacks.

All arguments are passed to the ROS client library; see the ROS documentation for further information. Calling this method will automatically unadvertise any previously advertised ROS topic.

  • nh ROS node handle to create the ROS advertisement
  • topic name of the ROS topic, subject to remapping
  • queue_size size of the ROS publishing queue
  • connect_cb callback that is invoked each time a new subscriber connects to the advertised topic
  • disconnect_cb callback that is invoked each time an existing subscriber disconnects from the advertised topic
  • tracked_object an associated object whose lifetime will limit the lifetime of the advertised topic
  • latch if true, the last published message remains available for later subscribers
  • callback_queue custom ROS callback queue

Definition at line 73 of file publisher_impl.h.

◆ is_active()

template<class M , template< typename > class Translate>
bool fkie_message_filters::Publisher< M, Translate >::is_active ( ) const
overridevirtualnoexcept

Check if the ROS publisher has at least one subscriber.

Implements fkie_message_filters::PublisherBase.

Definition at line 41 of file publisher_impl.h.

◆ receive()

template<class M , template< typename > class Translate>
void fkie_message_filters::Publisher< M, Translate >::receive ( const typename Translate< M >::FilterType &  t)
overrideprivatevirtualnoexcept

Definition at line 96 of file publisher_impl.h.

◆ topic()

template<class M , template< typename > class Translate>
std::string fkie_message_filters::Publisher< M, Translate >::topic ( ) const
overridevirtualnoexcept

Return the configured ROS topic.

Implements fkie_message_filters::PublisherBase.

Definition at line 47 of file publisher_impl.h.

Member Data Documentation

◆ pub_

template<class M, template< typename > class Translate = RosMessageEvent>
ros::Publisher fkie_message_filters::Publisher< M, Translate >::pub_
private

Definition at line 114 of file publisher.h.


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


fkie_message_filters
Author(s): Timo Röhling
autogenerated on Mon Feb 28 2022 22:21:44