Class TimerBase

Inheritance Relationships

Derived Type

Class Documentation

class 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.

Subclassed by agnocast::GenericTimer< FunctorT >

Public Functions

virtual ~TimerBase()
inline AGNOCAST_PUBLIC void cancel ()
inline AGNOCAST_PUBLIC bool is_canceled ()
AGNOCAST_PUBLIC void reset ()
AGNOCAST_PUBLIC std::chrono::nanoseconds time_until_trigger ()
inline void set_timer_info(std::weak_ptr<TimerInfo> timer_info)
void 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).

Parameters:

period – New firing period.

Throws:

std::runtime_error – If the underlying TimerInfo has been unregistered.

virtual AGNOCAST_PUBLIC bool is_steady () const =0

Return whether this timer uses a steady clock.

Returns:

True if the clock is steady.

virtual AGNOCAST_PUBLIC rclcpp::Clock::SharedPtr get_clock () const =0

Get the clock associated with this timer.

Returns:

Shared pointer to the clock.

virtual void execute_callback() = 0

Protected Functions

inline TimerBase(uint32_t timer_id, [[maybe_unused]] std::chrono::nanoseconds period)

Protected Attributes

uint32_t timer_id_
std::weak_ptr<TimerInfo> timer_info_
std::atomic<bool> canceled_