mrs_lib
Various reusable classes, functions and utilities for use in MRS projects
mrs_lib::MRSTimer Class Referenceabstract

Common wrapper representing the functionality of the ros::Timer. More...

#include <timer.h>

+ Inheritance diagram for mrs_lib::MRSTimer:

Public Types

using callback_t = std::function< void(const ros::TimerEvent &)>
 

Public Member Functions

virtual void stop ()=0
 stop the timer
 
virtual void start ()=0
 start the timer
 
virtual void setPeriod (const ros::Duration &duration, const bool reset=true)=0
 set the timer period/duration More...
 
virtual void setCallback (const std::function< void(const ros::TimerEvent &)> &callback)=0
 change the callback method More...
 
virtual bool running ()=0
 returns true if callbacks should be called More...
 
 MRSTimer (const MRSTimer &)=default
 
 MRSTimer (MRSTimer &&)=default
 
MRSTimeroperator= (const MRSTimer &)=default
 
MRSTimeroperator= (MRSTimer &&)=default
 

Detailed Description

Common wrapper representing the functionality of the ros::Timer.

The implementation can then use either ros::Timer (the ROSTimer class) or threads and synchronization primitives from the C++ standard library (the ThreadTimer class). Both these variants implement the same interface.

Note
Functionality of the two implementations differs in some details.

Member Function Documentation

◆ running()

virtual bool mrs_lib::MRSTimer::running ( )
pure virtual

returns true if callbacks should be called

Returns
true if timer is running

Implemented in mrs_lib::ThreadTimer, and mrs_lib::ROSTimer.

◆ setCallback()

virtual void mrs_lib::MRSTimer::setCallback ( const std::function< void(const ros::TimerEvent &)> &  callback)
pure virtual

change the callback method

Usable e.g. for running thread with a specific parameter if you bind it using std::bind

Parameters
callbackcallback method to be called.

Implemented in mrs_lib::ThreadTimer, and mrs_lib::ROSTimer.

◆ setPeriod()

virtual void mrs_lib::MRSTimer::setPeriod ( const ros::Duration &  duration,
const bool  reset = true 
)
pure virtual

set the timer period/duration

Parameters
duration
reset

Implemented in mrs_lib::ThreadTimer, and mrs_lib::ROSTimer.


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