def main(): myo.init(sdk_path='./myo-sdk-win-0.9.0/') hub = myo.Hub() listener = myo.ApiDeviceListener() with hub.run_in_background(listener.on_event): print("Waiting for a Myo to connect ...") device = listener.wait_for_single_device(2) if not device: print("No Myo connected after 2 seconds.") return print("Hello, Myo! Requesting RSSI ...") device.request_rssi() while hub.running and device.connected and not device.rssi: print("Waiting for RRSI...") time.sleep(0.001) print("RSSI:", device.rssi) print("Goodbye, Myo!")
X.append(np.asarray(event.emg)) #print(X) def on_orientation(self, event): #print("Orientation:", event.orientation.x, event.orientation.y, event.orientation.z, event.orientation.w) with self.lock: self.ori_data_queue.append(event.orientation) def get_ori_data(self): with self.lock: return list(self.ori_data_queue) myo.init() hub = myo.Hub() feed = myo.ApiDeviceListener() listener = Listener() with hub.run_in_background(listener.on_event): status = 9999 sleep(1) myX = [] req_iter = 20 train_1 = [] train_2 = [] train_3 = [] train_4 = [] train_5 = [] #ges1 = ['Rock', 'Paper', 'Scissors', 'Lizard', 'Spock'] #ges2 = ['channel 1', 'channel 2', 'channel 3', 'channel 4', 'channel 5'] ges3 = ['手掌張開', '手掌往右擺', '手掌往左擺', '握拳', '放鬆']
def on_orientation(self, event): with self.lock: if status: ORI.append([event.timestamp, event.orientation]) ACC.append([event.timestamp, event.acceleration]) GYR.append([event.timestamp, event.gyroscope]) def get_ori_data(self): with self.lock: return list(self.ori_data_queue) init() hub = Hub() device_listener = libmyo.ApiDeviceListener() gesture_listener = GestureListener() def check_samples_rate(warm_up_iteration=5, record_time=1): """ Check the sample rat of the myo armbands. Should be run before collecting data. :param warm_up_iteration:int, default 5 The iterations fo processing the warm up :param record_time:int, default 1 The record time :return: None """ print("Check samples rate - Start") sum_emg, sum_imu = 0, 0 print("Warm up")