Beispiel #1
0
import struct

import myo

from adafruit_motorkit import MotorKit
mkit = Motorkit()
stepper_position = 0

from adafruit_motor import stepper

from adafruit_servokit import ServoKit
skit = ServoKit(channels=16,address=0x41)
num_motor = 5

#Initialize Myo object
m = myo.Myo(myo.NNClassifier(), sys.argv[1] if len(sys.argv) >= 2 else None)
    
m.add_raw_pose_handler(print)

m.connect()

loop_num = 0

var = 1 
while var == 1 :
    m.run()
    loop_num = loop_num+1;
    pos = m.last_pose
    #print(m.last_pose)
    #print(loop_num)
    
Beispiel #2
0
        self.emg = (0, ) * 8

    def __call__(self, emg, moving):
        self.emg = emg
        if self.recording >= 0:
            self.m.cls.store_data(self.recording, emg)


if __name__ == '__main__':
    if HAVE_PYGAME:
        pygame.init()
        w, h = 800, 320
        scr = pygame.display.set_mode((w, h))
        font = pygame.font.Font(None, 30)

    m = myo.Myo(myo.NNClassifier(),
                sys.argv[1] if len(sys.argv) >= 2 else None)
    hnd = EMGHandler(m)
    m.add_emg_handler(hnd)
    m.connect()

    try:
        while True:
            m.run()

            #print(hnd.emg)

            r = m.history_cnt.most_common(1)[0][0]

            if HAVE_PYGAME:
                for ev in pygame.event.get():