-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPython_KneeVarus.py
74 lines (57 loc) · 1.43 KB
/
Python_KneeVarus.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import serial
import numpy
import matplotlib.pyplot as plt
from drawnow import *
import threading
tempF = []
tempF2 = []
tempD = []
pressure = []
arduinoData = serial.Serial('COM17',115200)
arduinoData2 = serial.Serial('COM18',115200)
plt.ion()
cnt=0
def makeFig():
plt.ylim(-180,180)
plt.title('Angle of the knee joint')
plt.grid('True')
plt.ylabel('angle')
plt.plot(tempD,'r-',label='degrees')
plt.legend(loc='upper left')
temp=0
temp2=0
def drawFig():
while True:
drawnow(makeFig)
plt.pause(.001)
def data1take():
global temp
while True:
dataArray = arduinoData.readline()
temp = float(dataArray)
def data2take():
global temp2
while True:
dataArray2 = arduinoData2.readline()
temp2 = float(dataArray2)
#def datadifftake():
# while True:
t2=threading.Thread(target=data1take)
t2.start()
t3=threading.Thread(target=data2take)
t3.start()
t1=threading.Thread(target=drawFig)
t1.start()
while True:
while(arduinoData.inWaiting()==0):
pass
# dataArray = arduinoData.split('.')
tempd =180-(temp+temp2)
# P = float( dataArray[1])
tempD.append(tempd)
print(str(tempd)+str('\t')+str(temp)+str('\t')+str(temp2))
# pressure.append(p)
cnt=cnt+1
if(cnt>50):
tempD.pop(0)
# pressure.pop(0)