SignalLogger
A library for signal logging.
signal_logger_ros::LogElementRos< ValueType_ > Class Template Reference

Log element for ros logging. More...

#include <LogElementRos.hpp>

Inheritance diagram for signal_logger_ros::LogElementRos< ValueType_ >:
Inheritance graph

Public Member Functions

 LogElementRos (const ValueType_ *const ptr, const signal_logger::BufferType bufferType, const std::size_t bufferSize, const std::string &name, const std::string &unit, const std::size_t divider, const signal_logger::LogElementAction action, std::stringstream *headerStream, std::stringstream *dataStream, ros::NodeHandle *nh, const std::shared_ptr< rosbag::Bag > &bagWriter)
 
virtual ~LogElementRos ()
 Destructor. More...
 
void saveDataToLogFile (const signal_logger::TimeElement &times, unsigned int nrCollectDataCalls, signal_logger::LogFileType type=signal_logger::LogFileType::BINARY) override
 Save Data to file. More...
 
void publishData (const signal_logger::TimeElement &time, unsigned int nrCollectDataCalls) override
 Reads buffer and publishes data via ros. More...
 
void update () override
 Update the element, shutdown/advertise the ros publisher. More...
 
void cleanup () override
 Cleanup the element (shutdown ros publisher) More...
 
- Public Member Functions inherited from signal_logger_std::LogElementStd< ValueType_ >
 LogElementStd (const ValueType_ *const ptr, const signal_logger::BufferType bufferType, const std::size_t bufferSize, const std::string &name, const std::string &unit, const std::size_t divider, const signal_logger::LogElementAction action, std::stringstream *textStream, std::stringstream *binaryStream)
 
virtual ~LogElementStd ()
 Destructor. More...
 
void saveDataToLogFile (const signal_logger::TimeElement &times, unsigned int nrCollectDataCalls, signal_logger::LogFileType type) override
 Save Data to file. More...
 
- Public Member Functions inherited from signal_logger::LogElementBase< ValueType_ >
 LogElementBase (const ValueType_ *const ptr, const BufferType bufferType, const std::size_t bufferSize, const std::string &name, const std::string &unit, const std::size_t divider, const LogElementAction action)
 
 LogElementBase (const ValueType_ *const ptr, const BufferType bufferType, const std::size_t bufferSize, const LogElementOptions &options)
 
virtual ~LogElementBase ()
 Destructor. More...
 
void collectData () overridefinal
 Data collection is not element specific. More...
 
virtual void copy ()
 Stores a copy of the current buffer, file is saved from this. More...
 
virtual void reset () override
 Reset logger element called before logger start. More...
 
const LogElementOptionsgetCopyOptions () const
 
const LogElementOptionsgetOptions () const
 
LogElementOptionsgetOptions ()
 
const BufferInterfacegetBuffer () const
 
BufferInterfacegetBuffer ()
 
std::mutex & acquireMutex () const
 
bool isEnabled () const
 
void setIsEnabled (const bool isEnabled)
 
virtual std::type_index getType () const
 
vector_type< ValueType_ > readNewValues ()
 Expose readNewValues function of buffer. More...
 
template<typename V = ValueType_>
const Buffer< V > & getTimeBufferCopy (typename std::enable_if< std::is_same< TimestampPair, V >::value >::type *=0) const
 
template<typename V = ValueType_>
const Buffer< V > & getTimeBuffer (typename std::enable_if< std::is_same< TimestampPair, V >::value >::type *=0) const
 
- Public Member Functions inherited from signal_logger::LogElementInterface
 LogElementInterface ()
 Default constructor. More...
 
virtual ~LogElementInterface ()
 Destructor. More...
 

Protected Attributes

ros::NodeHandle * nh_
 ros nodehandle More...
 
const std::shared_ptr< rosbag::Bag > & bagWriter_
 bag writer More...
 
ros::Publisher pub_
 ros publisher More...
 
std::atomic_bool wasPublished_
 published before More...
 
std::mutex publishMutex_
 publisher mutex More...
 
MsgTypePtr msg_
 message pointer More...
 
MsgTypePtr msgSave_
 
- Protected Attributes inherited from signal_logger_std::LogElementStd< ValueType_ >
std::stringstream * textStream_
 Text stream. More...
 
std::stringstream * binaryStream_
 Binary stream. More...
 
- Protected Attributes inherited from signal_logger::LogElementBase< ValueType_ >
Buffer< ValueType_ > buffer_
 Buffer (threadsafe) More...
 
LogElementOptions options_
 Options of the log element. More...
 
std::atomic_bool isEnabled_
 Indicates if log element is currently active. More...
 
std::mutex mutex_
 Mutex protecting element. More...
 
Buffer< ValueType_ > bufferCopy_
 Buffer copy (actually the buffer is moved during saving) More...
 
LogElementOptions optionsCopy_
 Options copy of the log element. More...
 
std::mutex mutexCopy_
 Mutex protecting element copy. More...
 

Private Types

using MsgType = typename traits::slr_msg_traits< ValueType_ >::msgtype
 convinience typedefs More...
 
using MsgTypePtr = boost::shared_ptr< MsgType >
 

Additional Inherited Members

Detailed Description

template<typename ValueType_>
class signal_logger_ros::LogElementRos< ValueType_ >

Log element for ros logging.

Member Typedef Documentation

template<typename ValueType_ >
using signal_logger_ros::LogElementRos< ValueType_ >::MsgType = typename traits::slr_msg_traits<ValueType_>::msgtype
private

convinience typedefs

template<typename ValueType_ >
using signal_logger_ros::LogElementRos< ValueType_ >::MsgTypePtr = boost::shared_ptr<MsgType>
private

Constructor & Destructor Documentation

template<typename ValueType_ >
signal_logger_ros::LogElementRos< ValueType_ >::LogElementRos ( const ValueType_ *const  ptr,
const signal_logger::BufferType  bufferType,
const std::size_t  bufferSize,
const std::string &  name,
const std::string &  unit,
const std::size_t  divider,
const signal_logger::LogElementAction  action,
std::stringstream *  headerStream,
std::stringstream *  dataStream,
ros::NodeHandle *  nh,
const std::shared_ptr< rosbag::Bag > &  bagWriter 
)
inline

Constructor

Parameters
ptrpointer to the log var
bufferTypebuffer type of the log var
bufferSizebuffer size of the log var
namename of the log var
unitunit of the log var
dividerlog_freq = ctrl_freq/divider
actionsave, publish or save and publish
headerStreamstring stream for log file header
dataStreamtype of the buffer
nhros nodehandle for the ros publisher
bagWriterreference to the bagfile writer object
saveToBagflag if elemt shall be save to bag
template<typename ValueType_ >
virtual signal_logger_ros::LogElementRos< ValueType_ >::~LogElementRos ( )
inlinevirtual

Destructor.

Member Function Documentation

template<typename ValueType_ >
void signal_logger_ros::LogElementRos< ValueType_ >::cleanup ( )
inlineoverridevirtual

Cleanup the element (shutdown ros publisher)

Reimplemented from signal_logger::LogElementBase< ValueType_ >.

template<typename ValueType_ >
void signal_logger_ros::LogElementRos< ValueType_ >::publishData ( const signal_logger::TimeElement time,
unsigned int  nrCollectDataCalls 
)
inlineoverridevirtual

Reads buffer and publishes data via ros.

Reimplemented from signal_logger::LogElementBase< ValueType_ >.

template<typename ValueType_ >
void signal_logger_ros::LogElementRos< ValueType_ >::saveDataToLogFile ( const signal_logger::TimeElement times,
unsigned int  nrCollectDataCalls,
signal_logger::LogFileType  type = signal_logger::LogFileType::BINARY 
)
inlineoverridevirtual

Save Data to file.

Reimplemented from signal_logger::LogElementBase< ValueType_ >.

template<typename ValueType_ >
void signal_logger_ros::LogElementRos< ValueType_ >::update ( )
inlineoverridevirtual

Update the element, shutdown/advertise the ros publisher.

Reimplemented from signal_logger::LogElementBase< ValueType_ >.

Member Data Documentation

template<typename ValueType_ >
const std::shared_ptr<rosbag::Bag>& signal_logger_ros::LogElementRos< ValueType_ >::bagWriter_
protected

bag writer

template<typename ValueType_ >
MsgTypePtr signal_logger_ros::LogElementRos< ValueType_ >::msg_
protected

message pointer

template<typename ValueType_ >
MsgTypePtr signal_logger_ros::LogElementRos< ValueType_ >::msgSave_
protected
template<typename ValueType_ >
ros::NodeHandle* signal_logger_ros::LogElementRos< ValueType_ >::nh_
protected

ros nodehandle

template<typename ValueType_ >
ros::Publisher signal_logger_ros::LogElementRos< ValueType_ >::pub_
protected

ros publisher

template<typename ValueType_ >
std::mutex signal_logger_ros::LogElementRos< ValueType_ >::publishMutex_
protected

publisher mutex

template<typename ValueType_ >
std::atomic_bool signal_logger_ros::LogElementRos< ValueType_ >::wasPublished_
protected

published before


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