LocalGuidance
A library that generates velocity references to follow a path.
any_node::ThreadedPublisher< MessageType > Class Template Reference

#include <ThreadedPublisher.hpp>

Public Member Functions

 ThreadedPublisher (const ros::Publisher &publisher, unsigned int maxMessageBufferSize=10, bool autoPublishRos=true)
 
virtual ~ThreadedPublisher ()
 
void publish (const boost::shared_ptr< MessageType > &message)
 
void publish (const MessageType &message)
 
void shutdown ()
 
std::string getTopic () const
 
uint32_t getNumSubscribers () const
 
bool isLatched () const
 
void sendRos ()
 

Protected Member Functions

void addMessageToBuffer (const MessageType &message)
 
void notifyThread ()
 
void threadedPublish ()
 

Protected Attributes

std::mutex publisherMutex_
 
ros::Publisher publisher_
 
std::mutex messageBufferMutex_
 
std::queue< MessageType > messageBuffer_
 
unsigned int maxMessageBufferSize_ = 0
 
bool autoPublishRos_
 
std::thread thread_
 
std::mutex notifyThreadMutex_
 
std::condition_variable notifyThreadCv_
 
std::atomic< bool > notifiedThread_
 
std::atomic< bool > shutdownRequested_
 

Constructor & Destructor Documentation

template<typename MessageType >
any_node::ThreadedPublisher< MessageType >::ThreadedPublisher ( const ros::Publisher &  publisher,
unsigned int  maxMessageBufferSize = 10,
bool  autoPublishRos = true 
)
inline
template<typename MessageType >
virtual any_node::ThreadedPublisher< MessageType >::~ThreadedPublisher ( )
inlinevirtual

Member Function Documentation

template<typename MessageType >
void any_node::ThreadedPublisher< MessageType >::addMessageToBuffer ( const MessageType &  message)
inlineprotected
template<typename MessageType >
uint32_t any_node::ThreadedPublisher< MessageType >::getNumSubscribers ( ) const
inline
template<typename MessageType >
std::string any_node::ThreadedPublisher< MessageType >::getTopic ( ) const
inline
template<typename MessageType >
bool any_node::ThreadedPublisher< MessageType >::isLatched ( ) const
inline
template<typename MessageType >
void any_node::ThreadedPublisher< MessageType >::notifyThread ( )
inlineprotected
template<typename MessageType >
void any_node::ThreadedPublisher< MessageType >::publish ( const boost::shared_ptr< MessageType > &  message)
inline
template<typename MessageType >
void any_node::ThreadedPublisher< MessageType >::publish ( const MessageType &  message)
inline
template<typename MessageType >
void any_node::ThreadedPublisher< MessageType >::sendRos ( )
inline

Send all messages in the buffer.

template<typename MessageType >
void any_node::ThreadedPublisher< MessageType >::shutdown ( )
inline
template<typename MessageType >
void any_node::ThreadedPublisher< MessageType >::threadedPublish ( )
inlineprotected

Member Data Documentation

template<typename MessageType >
bool any_node::ThreadedPublisher< MessageType >::autoPublishRos_
protected
template<typename MessageType >
unsigned int any_node::ThreadedPublisher< MessageType >::maxMessageBufferSize_ = 0
protected
template<typename MessageType >
std::queue<MessageType> any_node::ThreadedPublisher< MessageType >::messageBuffer_
protected
template<typename MessageType >
std::mutex any_node::ThreadedPublisher< MessageType >::messageBufferMutex_
protected
template<typename MessageType >
std::atomic<bool> any_node::ThreadedPublisher< MessageType >::notifiedThread_
protected
template<typename MessageType >
std::condition_variable any_node::ThreadedPublisher< MessageType >::notifyThreadCv_
protected
template<typename MessageType >
std::mutex any_node::ThreadedPublisher< MessageType >::notifyThreadMutex_
protected
template<typename MessageType >
ros::Publisher any_node::ThreadedPublisher< MessageType >::publisher_
protected
template<typename MessageType >
std::mutex any_node::ThreadedPublisher< MessageType >::publisherMutex_
mutableprotected
template<typename MessageType >
std::atomic<bool> any_node::ThreadedPublisher< MessageType >::shutdownRequested_
protected
template<typename MessageType >
std::thread any_node::ThreadedPublisher< MessageType >::thread_
protected

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