def __init__(self, callbacks): # Initialize internals MyoRaw.__init__(self, None) self.callbacks = callbacks # # Initiate the history. Initially, this list has an average of something huge self.rollingHistory = deque([(1000, 1000)], Myo.HIST_LEN) self.rollingHistoryModuloCounter = 0 self.recentActivityList = deque([(1000, 1000)], Myo.FRAMES_FOR_RECENT_ACTIVITY) # These vars are used later by logic self.lastRisingEdge = 0 self.signalState = 'standby' # values can be 'standby', 'in_pulse', 'in_long_pulse' self.IMU_Enabled = False # self.startingQuaternion = None # Keep this at None when not in use self.startingRoll = None self.lastKnownCommunication = time.time( ) # Used as a watchdog to reboot script. # Set the logic triggers # EMG self.add_emg_handler(self.edge_detector) # For debugging #self.add_emg_handler(lambda unused1, unused2: print( str( time.time() ) ) ) self.add_imu_handler(self.IMUCallback) # Make sure that the script does not break self.watchCommunications()
def __init__(self, cls, tty=None): MyoRaw.__init__(self, tty) self.cls = cls self.history = deque([0] * Myo.HIST_LEN, Myo.HIST_LEN) self.history_cnt = Counter(self.history) self.add_emg_handler(self.emg_handler) self.last_pose = None self.pose_handlers = []
def __init__(self, cls, tty = None): self.locked = True self.use_lock = True self.timed = True self.lock_time = 1.0 self.time_to_lock = self.lock_time self.last_pose = -1 self.last_tick = 0 self.current_box = 0 self.last_box = 0 self.box_factor = 0.25 self.current_arm = 0 self.current_xdir = 0 self.current_gyro = None self.current_accel = None self.current_roll = 0 self.current_pitch = 0 self.current_yaw = 0 self.center_roll = 0 self.center_pitch = 0 self.center_yaw = 0 self.first_rot = 0 self.current_rot_roll = 0 self.current_rot_pitch = 0 self.current_rot_yaw = 0 self.mov_history = '' self.gest_history = '' self.act_history = '' if pmouse != None: self.x_dim, self.y_dim = pmouse.screen_size() self.mx = self.x_dim / 2 self.my = self.y_dim / 2 self.centered = 0 MyoRaw.__init__(self, tty) self.cls = cls self.history = deque([0] * Myo.HIST_LEN, Myo.HIST_LEN) self.history_cnt = Counter(self.history) self.add_emg_handler(self.emg_handler) self.add_arm_handler(self.arm_handler) self.add_imu_handler(self.imu_handler) self.add_pose_handler(self.pose_handler) self.onEMG = None self.onPoseEdge = None self.onPoseEdgeList = [] self.onLock = None self.onLockList = [] self.onUnlock = None self.onUnlockList = [] self.onPeriodic = None self.onPeriodicList = [] self.onWear = None self.onWearList = [] self.onUnwear = None self.onUnwearList = [] self.onBoxChange = None self.onBoxChangeList = []
def __init__(self, cls, tty=None): self.locked = True self.use_lock = True self.timed = True self.lock_time = 1.0 self.time_to_lock = self.lock_time self.last_pose = -1 self.last_tick = 0 self.current_box = 0 self.last_box = 0 self.box_factor = 0.25 self.current_arm = 0 self.current_xdir = 0 self.current_gyro = None self.current_accel = None self.current_roll = 0 self.current_pitch = 0 self.current_yaw = 0 self.center_roll = 0 self.center_pitch = 0 self.center_yaw = 0 self.first_rot = 0 self.current_rot_roll = 0 self.current_rot_pitch = 0 self.current_rot_yaw = 0 self.mov_history = '' self.gest_history = '' self.act_history = '' if pmouse != None: self.x_dim, self.y_dim = pmouse.screen_size() self.mx = self.x_dim / 2 self.my = self.y_dim / 2 self.centered = 0 MyoRaw.__init__(self, tty) self.add_emg_handler(self.emg_handler) self.add_arm_handler(self.arm_handler) self.add_imu_handler(self.imu_handler) self.add_pose_handler(self.pose_handler) self.onEMG = None self.onPoseEdge = None self.onPoseEdgeList = [] self.onLock = None self.onLockList = [] self.onUnlock = None self.onUnlockList = [] self.onPeriodic = None self.onPeriodicList = [] self.onWear = None self.onWearList = [] self.onUnwear = None self.onUnwearList = [] self.onBoxChange = None self.onBoxChangeList = [] return
def __init__(self, tty=None): MyoRaw.__init__(self,tty) self.add_emg_handler(self.emg_handler) self.emg = None
def __init__(self, tty=None, verbose=False): """ Initialize the Myo instance. Args: tty (str, None): tty (None, str): TTY (on Linux). You can check the list on a terminal by typing `ls /dev/tty*`. By default, it will be '/dev/ttyACM0'. verbose (bool): If True, it will print information about the state of the interface. This is let to the programmer what he / she wishes to print. """ self.verbose = verbose self.locked = True self.use_lock = True self.timed = True self.lock_time = 1.0 self.time_to_lock = self.lock_time self.last_pose = -1 self.last_tick = 0 self.current_box = 0 self.last_box = 0 self.box_factor = 0.25 self.current_arm = 0 self.current_xdir = 0 self.current_gyro = None self.current_accel = None self.current_roll = 0 self.current_pitch = 0 self.current_yaw = 0 self.center_roll = 0 self.center_pitch = 0 self.center_yaw = 0 self.first_rot = 0 self.current_rot_roll = 0 self.current_rot_pitch = 0 self.current_rot_yaw = 0 self.mov_history = '' self.gest_history = '' self.act_history = '' if pmouse is not None: self.x_dim, self.y_dim = pmouse.screen_size() self.mx = self.x_dim / 2 self.my = self.y_dim / 2 self.centered = 0 self.current_emg_values = [] self.bitmask_moving = 0 MyoRaw.__init__(self, tty=tty, verbose=verbose) self.add_emg_handler(self.emg_handler) self.add_arm_handler(self.arm_handler) self.add_imu_handler(self.imu_handler) self.add_pose_handler(self.pose_handler) self.onEMG = None self.onPoseEdge = None self.onPoseEdgeList = [] self.onLock = None self.onLockList = [] self.onUnlock = None self.onUnlockList = [] self.onPeriodic = None self.onPeriodicList = [] self.onWear = None self.onWearList = [] self.onUnwear = None self.onUnwearList = [] self.onBoxChange = None self.onBoxChangeList = [] return