rclcpp  master
C++ ROS Client Library API
Public Member Functions | Protected Attributes | List of all members
rclcpp::TimerBase Class Referenceabstract

#include <timer.hpp>

Inheritance diagram for rclcpp::TimerBase:
Inheritance graph
[legend]
Collaboration diagram for rclcpp::TimerBase:
Collaboration graph
[legend]

Public Member Functions

 TimerBase (Clock::SharedPtr clock, std::chrono::nanoseconds period, rclcpp::Context::SharedPtr context)
 
 ~TimerBase ()
 
void cancel ()
 
bool is_canceled ()
 Return the timer cancellation state. More...
 
void reset ()
 
virtual void execute_callback ()=0
 
std::shared_ptr< const rcl_timer_tget_timer_handle ()
 
std::chrono::nanoseconds time_until_trigger ()
 Check how long the timer has until its next scheduled callback. More...
 
virtual bool is_steady ()=0
 Is the clock steady (i.e. is the time between ticks constant?) More...
 
bool is_ready ()
 Check if the timer is ready to trigger the callback. More...
 

Protected Attributes

Clock::SharedPtr clock_
 
std::shared_ptr< rcl_timer_ttimer_handle_
 

Constructor & Destructor Documentation

◆ TimerBase()

rclcpp::TimerBase::TimerBase ( Clock::SharedPtr  clock,
std::chrono::nanoseconds  period,
rclcpp::Context::SharedPtr  context 
)
explicit

◆ ~TimerBase()

rclcpp::TimerBase::~TimerBase ( )

Member Function Documentation

◆ cancel()

void rclcpp::TimerBase::cancel ( )

◆ is_canceled()

bool rclcpp::TimerBase::is_canceled ( )

Return the timer cancellation state.

Returns
true if the timer has been cancelled, false otherwise
Exceptions
std::runtime_errorif the rcl_get_error_state returns 0
RCLErrorBasesome child class exception based on ret

◆ reset()

void rclcpp::TimerBase::reset ( )

◆ execute_callback()

virtual void rclcpp::TimerBase::execute_callback ( )
pure virtual

◆ get_timer_handle()

std::shared_ptr<const rcl_timer_t> rclcpp::TimerBase::get_timer_handle ( )

◆ time_until_trigger()

std::chrono::nanoseconds rclcpp::TimerBase::time_until_trigger ( )

Check how long the timer has until its next scheduled callback.

Returns
A std::chrono::duration representing the relative time until the next callback.

◆ is_steady()

virtual bool rclcpp::TimerBase::is_steady ( )
pure virtual

◆ is_ready()

bool rclcpp::TimerBase::is_ready ( )

Check if the timer is ready to trigger the callback.

This function expects its caller to immediately trigger the callback after this function, since it maintains the last time the callback was triggered.

Returns
True if the timer needs to trigger.

Member Data Documentation

◆ clock_

Clock::SharedPtr rclcpp::TimerBase::clock_
protected

◆ timer_handle_

std::shared_ptr<rcl_timer_t> rclcpp::TimerBase::timer_handle_
protected

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