mrs_lib
Various reusable classes, functions and utilities for use in MRS projects
Loading...
Searching...
No Matches
mrs_lib::MRSTimer Class Referenceabstract

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

#include <timer_handler.h>

+ Inheritance diagram for mrs_lib::MRSTimer:

Public Types

using callback_t = std::function< void()>
 

Public Member Functions

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

Protected Attributes

rclcpp::Node::SharedPtr node_
 

Detailed Description

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

The implementation can then use either rclcpp::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::ROSTimer, and mrs_lib::ThreadTimer.

◆ setCallback()

virtual void mrs_lib::MRSTimer::setCallback ( const std::function< void()> &  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::ROSTimer, and mrs_lib::ThreadTimer.

◆ setPeriod()

virtual void mrs_lib::MRSTimer::setPeriod ( const rclcpp::Duration &  duration)
pure virtual

set the timer period/duration

Parameters
duration
reset

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

◆ start()

virtual void mrs_lib::MRSTimer::start ( )
pure virtual

start the timer

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

◆ stop()

virtual void mrs_lib::MRSTimer::stop ( )
pure virtual

stop the timer

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


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