GR00T-WholeBodyControl / external_dependencies /unitree_sdk2_python /unitree_sdk2py /utils /timerfd.py
Download external_dependencies/unitree_sdk2_python/unitree_sdk2py/utils/timerfd.py from chibifire/GR00T-WholeBodyControl: direct link, hf CLI and curl.
- Browser
- Download file 1.32 kB
-
https://huggingface.co/chibifire/GR00T-WholeBodyControl/resolve/main/external_dependencies/unitree_sdk2_python/unitree_sdk2py/utils/timerfd.py
- Command line
-
hf download hf://chibifire/GR00T-WholeBodyControl/external_dependencies/unitree_sdk2_python/unitree_sdk2py/utils/timerfd.py
-
curl -L -o timerfd.py https://huggingface.co/chibifire/GR00T-WholeBodyControl/resolve/main/external_dependencies/unitree_sdk2_python/unitree_sdk2py/utils/timerfd.py
1.32 kB
| import math | |
| import ctypes | |
| from .clib_lookup import CLIBLookup | |
| class timespec(ctypes.Structure): | |
| _fields_ = [("sec", ctypes.c_long), ("nsec", ctypes.c_long)] | |
| __slots__ = [name for name,type in _fields_] | |
| def from_seconds(cls, secs): | |
| c = cls() | |
| c.seconds = secs | |
| return c | |
| def seconds(self): | |
| return self.sec + self.nsec / 1000000000 | |
| def seconds(self, secs): | |
| x, y = math.modf(secs) | |
| self.sec = int(y) | |
| self.nsec = int(x * 1000000000) | |
| class itimerspec(ctypes.Structure): | |
| _fields_ = [("interval", timespec),("value", timespec)] | |
| __slots__ = [name for name,type in _fields_] | |
| def from_seconds(cls, interval, value): | |
| spec = cls() | |
| spec.interval.seconds = interval | |
| spec.value.seconds = value | |
| return spec | |
| # function timerfd_create | |
| timerfd_create = CLIBLookup("timerfd_create", ctypes.c_int, (ctypes.c_long, ctypes.c_int)) | |
| # function timerfd_settime | |
| timerfd_settime = CLIBLookup("timerfd_settime", ctypes.c_int, (ctypes.c_int, ctypes.c_int, ctypes.POINTER(itimerspec), ctypes.POINTER(itimerspec))) | |
| # function timerfd_gettime | |
| timerfd_gettime = CLIBLookup("timerfd_gettime", ctypes.c_int, (ctypes.c_int, ctypes.POINTER(itimerspec))) | |