Go2Py_SIM/Go2Py/estimation/contact.py

16 lines
487 B
Python
Raw Normal View History

2024-04-06 03:59:21 +08:00
import numpy as np
2024-05-21 06:45:59 +08:00
2024-04-06 03:59:21 +08:00
class HysteresisContactDetector:
def __init__(self, upper_limit, lower_limit):
self.upper_limit = upper_limit
self.lower_limit = lower_limit
self.contact_state = np.zeros(4)
2024-05-21 06:45:59 +08:00
2024-04-06 03:59:21 +08:00
def update(self, contact_forces):
2024-05-21 06:45:59 +08:00
self.contact_state[np.where(contact_forces > self.upper_limit)[0]] = 1
self.contact_state[np.where(contact_forces < self.lower_limit)[0]] = 0
2024-04-06 03:59:21 +08:00
def getContactStates(self):
2024-05-21 06:45:59 +08:00
return self.contact_state