def latch_timer(self, step_name, tmr_id, duration, cb, oneshot=False):
step_dict = self.get_step_dict(step_name)
def handle_evt(evt):
if self.step == step_name:
cb(evt)
timers = step_dict.get('timers', {})
# Shutdown old timer with same ID if it exists
timer = timers.get(tmr_id, None)
if timer and timer.is_alive(): timer.shutdown()
timer = rospy.Timer(duration, handle_evt, oneshot=oneshot)
timers[tmr_id] = timer
评论列表
文章目录