ONNX
ifire's picture
Initial mirror of NVlabs/GR00T-WholeBodyControl@087f9ac
d1e2d14 verified
Raw History Blame Contribute Delete
643 Bytes
import time
from threading import Lock
from .thread import RecurrentThread
class HZSample:
def __init__(self, interval: float = 1.0):
self.__count = 0
self.__inter = interval if interval > 0.0 else 1.0
self.__lock = Lock()
self.__thread = RecurrentThread(self.__inter, target=self.TimerFunc)
def Start(self):
self.__thread.Start()
def Sample(self):
with self.__lock:
self.__count += 1
def TimerFunc(self):
count = 0
with self.__lock:
count = self.__count
self.__count = 0
print("HZ: {}".format(count/self.__inter))