-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyoPoses.py
55 lines (47 loc) · 1.3 KB
/
MyoPoses.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from __future__ import print_function
from myo.utils import TimeInterval
import myo
import sys
import os
from funciones import send
import serial
class Listener(myo.DeviceListener):
def __init__(self):
self.interval = TimeInterval(None, 0.05)
self.acceleration = None
self.gyroscope = None
self.orientation = None
self.pose = myo.Pose.rest
self.emg_enabled = True
self.locked = False
self.rssi = None
self.emg = None
self.temp = 0
self.arduino = serial.Serial('COM9', 9600)
def on_connected(self, event):
event.device.request_rssi()
def on_pose(self, event):
self.pose = event.pose
vector = [0, 0, 0 ,0 ,0]
if self.pose == myo.Pose.fist:
vector = [80, 80, 80 ,80 ,80]
print("fist")
if self.pose == myo.Pose.rest:
vector = [0, 0, 0 ,0 ,0]
print("rest")
if self.pose == myo.Pose.wave_in:
vector = vector = [70,80,0,0,0]
print("Wave In")
if self.pose == myo.Pose.wave_out:
vector = [80,0,80,80,0]
print("Wave out")
if self.pose == myo.Pose.fingers_spread:
vector = [80,0,80,80,80]
print("Fingers Spread")
send(vector,arduino)
if __name__ == '__main__':
myo.init()
hub = myo.Hub()
listener = Listener()
while hub.run(listener.on_event, 1000):
pass