Call a callback without a timer

asked 2021-04-06 05:45:02 -0500

Julie96 gravatar image

updated 2021-04-06 08:37:50 -0500

I'm trying to find a solution to be able to create and call a callback from elsewhere inside my node spinned when I want in ROS2 (currently the alternative I found is to create a timer (see below), and then destroy this timer inside its callback but I'm sure there is a better solution)

def MyNode(Node):
    def __init__(self):
      self.execute_once_when_I_want = self.create_timer(1, self.execute_once_callback)

    def self.execute_once_when_I_want(self):
      if (my_condition is True):
edit retag flag offensive close merge delete