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

rclcpp::Timer wrapper. The interface is the same as with rclcpp::Timer, except for the initialization method. More...

#include <timer_handler.h>

+ Inheritance diagram for mrs_lib::ROSTimer:
+ Collaboration diagram for mrs_lib::ROSTimer:

Public Member Functions

 ROSTimer (const rclcpp::Node::SharedPtr &node, const rclcpp::Rate &rate, const std::function< void()> &callback)
 
 ROSTimer (const mrs_lib::TimerHandlerOptions &opts, const rclcpp::Rate &rate, const std::function< void()> &callback)
 
virtual void stop () override
 stop the timer
 
virtual void start () override
 start the timer
 
virtual void setPeriod (const rclcpp::Duration &duration) override
 set the timer period/duration
 
virtual void setCallback (const std::function< void()> &callback) override
 change the callback method
 
virtual bool running () override
 returns true if callbacks should be called
 
 ROSTimer (const ROSTimer &)=delete
 
 ROSTimer (ROSTimer &&)=delete
 
ROSTimeroperator= (const ROSTimer &)=delete
 
ROSTimeroperator= (ROSTimer &&)=delete
 
- Public Member Functions inherited from mrs_lib::MRSTimer
 MRSTimer (const MRSTimer &)=default
 
 MRSTimer (MRSTimer &&)=default
 
MRSTimeroperator= (const MRSTimer &)=default
 
MRSTimeroperator= (MRSTimer &&)=default
 

Additional Inherited Members

- Public Types inherited from mrs_lib::MRSTimer
using callback_t = std::function< void()>
 
- Protected Attributes inherited from mrs_lib::MRSTimer
rclcpp::Node::SharedPtr node_
 

Detailed Description

rclcpp::Timer wrapper. The interface is the same as with rclcpp::Timer, except for the initialization method.

Member Function Documentation

◆ running()

bool mrs_lib::ROSTimer::running ( )
overridevirtual

returns true if callbacks should be called

Returns
true if timer is running

Implements mrs_lib::MRSTimer.

◆ setCallback()

void mrs_lib::ROSTimer::setCallback ( const std::function< void()> &  callback)
overridevirtual

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.

Implements mrs_lib::MRSTimer.

◆ setPeriod()

void mrs_lib::ROSTimer::setPeriod ( const rclcpp::Duration &  duration)
overridevirtual

set the timer period/duration

Parameters
duration
reset

Implements mrs_lib::MRSTimer.

◆ start()

void mrs_lib::ROSTimer::start ( )
overridevirtual

start the timer

Implements mrs_lib::MRSTimer.

◆ stop()

void mrs_lib::ROSTimer::stop ( )
overridevirtual

stop the timer

Implements mrs_lib::MRSTimer.


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