Method: Rclrb::Node#create_timer

Defined in:
lib/rclrb/node.rb

#create_timer(timer_period_sec, callback_group = nil, clock = Rclrb::RosClock, &callback) ⇒ Object

Create a new timer. The timer will be started and every timer_period_sec number of seconds the provided callback function will be called.

Parameters:

  • timer_period_sec (float): The period (s) of the timer.

  • callback (block): A user-defined callback function that is called when the timer expires.

  • callback_group (optional CallbackGroup): The callback group for the timer. If None, then the nodes default callback group is used.

  • clock (optional Clock): The clock which the timer gets time from.



128
129
130
131
132
133
134
# File 'lib/rclrb/node.rb', line 128

def create_timer(timer_period_sec, callback_group=nil, clock=Rclrb::RosClock, &callback)
  callback_group = @default_callback_group if callback_group.nil?
  handle = CApi::rcl_get_zero_initialized_timer()
  timer = Timer.new(handle, @node_handle, timer_period_sec, callback, callback_group, clock)
  @timers.append(timer)
  return timer
end