Skip to content

TimerBase#

agnocast::TimerBase#

Base class for Agnocast timers providing periodic callback execution. Defines the common interface for all timer types, including callback execution, clock access, and period storage.


set_period()#

void TimerBase::set_period(std::chrono::nanoseconds period)

Update the timer's period. Aligned with rcl_timer_exchange_period: the already-scheduled next firing keeps its time; only subsequent firings adopt the new period. Throws on an invalidated timer (rcl's equivalent is RCL_RET_TIMER_INVALID).

Parameter Description
period New firing period.

is_steady()#

bool TimerBase::is_steady() const

Return whether this timer uses a steady clock.

Returns True if the clock is steady.

set_on_reset_callback()#

void TimerBase::set_on_reset_callback(std::function<void(size_t)> callback)

Sets a callback to be invoked each time the timer is reset. This function aligns with rclcpp::set_on_reset_callback. For extended details regarding best practices (e.g., keeping the callback non-blocking), please refer to the rclcpp documentation. This function is thread-safe. Calling it again will override any previously set callback.

Parameter Description
callback The functor to be called at reset. It receives the number of times the timer has been reset as an argument.

clear_on_reset_callback()#

void TimerBase::clear_on_reset_callback()

Clear the callback registered for reset timer.


get_clock()#

rclcpp::Clock::SharedPtr TimerBase::get_clock() const

Get the clock associated with this timer.

Returns Shared pointer to the clock.