-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
61 lines (47 loc) · 1.16 KB
/
main.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
# -*- 2oding: utf-8 -*-
import com_d as ser
import time as tm
import numpy as np
com_port =ser.com_init()
'''
import mahony_filter as mhf
filter =mhf.mahony_filter(10,0.01,1)
import madgwick_filter as mdf
filter =mdf.madgwick_filter(0.4)
'''
import ekf_filter as ekf
filter1 = ekf.ekf_filter()
import madgwick_filter as mdf
filter2 =mdf.madgwick_filter(0.1)
import time as tm
time_str = tm.strftime('%Y-%m-%d-%H-%M-%S',tm.localtime(tm.time()))
file_name='arhs-'+time_str+'.txt'
fo = open(file_name, "wb")
while 1:
data = ser.get_data(com_port)
acc=data[:3]
gyro=data[3:6]
erula_cal=data[6:]
#print acc,gyro
#tm.sleep (1)
if (filter1.init_flag ==0):
filter1.filter_init(gyro,acc)
filter1.init_flag=1
else:
data=filter1.filter_update(gyro,acc,0.001)
erual =data*180/np.pi
stra=' '
stra+=str(erual[0]) +' '
stra+=str(erual[1]) +' '
stra+=str(erual[2]) +' '
data=filter2.filter_update(gyro,acc)
erual =data*180/np.pi
stra+=str(erual[0]) +' '
stra+=str(erual[1]) +' '
stra+=str(erual[2]) +' '
stra+=str(erula_cal[0]) +' '
stra+=str(erula_cal[1]) +' '
stra+=str(erula_cal[2]) +' '
stra+='\n'
print stra
fo.write(stra);