def main(): print('Start Myo for Linux') param = 0 if len(sys.argv) > 1: param = sys.argv[1] listener = PrintPoseListener() if param == 1: listener = EmgListener() myo = Myo() try: myo.connect() myo.add_listener(listener) myo.vibrate(VibrationType.SHORT) while True: x = myo.run() if x != [] or None: print(x) except KeyboardInterrupt: pass except ValueError as ex: print(ex) finally: myo.safely_disconnect() print('Finished.')
def main(): print('Myo Heating UP') # saving the pose in variable listener = PrintPoseListener() # access to myo via variable obj myo = Myo() try: # connection to myo myo.connect() # adding pose to myo myo.add_listener(listener) #vibration on start myo.vibrate(VibrationType.SHORT) #keep running until program we exit while True: myo.run() except KeyboardInterrupt: pass except ValueError as ex: print(ex) finally: myo.safely_disconnect() print('Myo App is ended.')
def main(): print("### ITECH BIYONIK-EL YAZILIMI ###\n#") print('# Myo yazilimi baslatiliyor') # HAREKET TANIMLAMA LISTENERI if(sys.argv[1] == "0"): listener = PrintPoseListener() elif(sys.argv[1] == "1"): listener = RS232Listener() # MYO NESNESI myo = Myo() try: # MYO BAGLANTI myo.connect() # LISTENER EKLEME myo.add_listener(listener) # BASLANGICTA 3 KISA TITRESIM for i in range(0,3): myo.vibrate(VibrationType.SHORT) # PROGRAM BU DONGU ICINDE CALISIR while True: # myo.run() KOMUTU : HAREKETLERI ALGILAR mPose = myo.run() # myo.run() KOMUTUNDAN "-1" DEGERI DONER ISE # YANI HAREKET DEGERI "UNKNOWN" ISE if(mPose == -1): # GUVENLI CIKIS myo.safely_disconnect() # TEKRAR BAGLANTI myo.connect() # TEKRAR LISTENER EKLE myo.add_listener(listener) # TEKRAR 3 TITRESIM for i in range(0,3): myo.vibrate(VibrationType.SHORT) # KLAVYEDEN DURDURMA except KeyboardInterrupt: pass except ValueError as ex: print(ex) except SerialException: system("usbKapat") sleep(1) system("usbAc") sleep(0.5) main() finally: # GUVENLI CIKIS myo.safely_disconnect() print('# Cikis yapildi.\n#') print("### ITECH BIYONIK-EL YAZILIMI ###")
def start(self): self.listener = PrintPoseListener(dataType=self.dataType) self.mMyo = Myo() self.getSystermType() try: self.mMyo.connect() self.mMyo.add_listener(self.listener) self.mMyo.vibrate(VibrationType.SHORT) except ValueError as ex: print(ex) # self.getTheModelFileName() self.loadModel() #导入模型 self.mMyo.vibrate(VibrationType.MEDIUM) #震动表示模型导入完成
def start(self): self.listener = PrintPoseListener(dataType=["emg"]) self.mMyo = Myo() self.setFilePath() #设置肌电数据的存储路径 self.getUserInput() #获得用户输入的信息 pygame.init() #初始化显示窗口 self.screen = pygame.display.set_mode((200, 250)) #设置显示窗口的大小 try: self.mMyo.connect() self.mMyo.add_listener(self.listener) self.mMyo.vibrate(VibrationType.SHORT) except ValueError as ex: print(ex)
def start(self): self.listener = PrintPoseListener(dataType=self.dataMode, trainType="on") self.mMyo = Myo() self.getSystermType() # self.setFilePath() #设置路径 try: self.mMyo.connect() self.mMyo.add_listener(self.listener) self.mMyo.vibrate(VibrationType.SHORT) except ValueError as ex: print(ex) self.loadModel() #导入模型 self.mMyo.vibrate(VibrationType.MEDIUM)
def main(): print('Start Myo for Linux') listener = PrintPoseListener() myo = Myo() try: myo.connect() myo.add_listener(listener) myo.vibrate(VibrationType.SHORT) while True: myo.run() except KeyboardInterrupt: pass except ValueError as ex: print(ex) finally: myo.safely_disconnect() print('Finished.')
def __init__(self): # Create the actuators self.wristServo = Servo('wrist') self.handServo = Servo('hand') # Create state variables self.handStatus = 'opened' # args can be 'opened', 'closed' self.handResetTimer = None # Used to turn off the motor after 2 seconds of inactivity self.wristResetTimer = None # Center motors (not needed) # self.openHand() # self.setWristPosition(90) # deg # Create the Myo controller sensor (with callbacks) callbacks = { 'toggleHand': self.toggleHand, 'updateWristRotation': self.updateWristRotation, 'isHandClosed': self.isHandClosed } self.myo = Myo(callbacks) # Kill the script if the myo does not connect on time. killTimer = threading.Timer(5, self.killScript) killTimer.start() # Start the Myo sensor. self.myo.connect() # Kill the kill timer killTimer.cancel() # Become slave to the myo sensor while True: self.myo.run()
def main(): rospy.loginfo('Start Myo for Linux') gesture_pub = rospy.Publisher('rover1/wheel_vel', WheelVelocity, queue_size=10) listener = PrintPoseListener() myo = Myo() try: myo.connect() myo.add_listener(listener) while True: myo.run() except KeyboardInterrupt: pass except ValueError as ex: print(ex) finally: myo.safely_disconnect() print('Finished.')
#Myo USB import sys sys.path.append('../lib/') from myo import Myo from packet import Packet import utilities import struct myo = Myo() try: myo.connect() except Exception as e: myo.safely_disconnect() raise while True: x = myo.read_attribute(0x27) #print(type(x)) print(x.getData()) #x.getD() #print(struct.unpack("8HB",x.payload)) #print(struct.unpack("<11B",x))
def main(): myMyo = Myo(callback=printData) myMyo.daemon = True myMyo.start() raw_input("Press enter to exit")
def Out(self): Myo().safely_disconnect()