-
Notifications
You must be signed in to change notification settings - Fork 2
/
chkimu.py
100 lines (96 loc) · 3.41 KB
/
chkimu.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# -*- coding: utf-8 -*-
"""
Created on Fri Apr 17 12:52:14 2020
@author: Mocki
E-mail : [email protected]
TO : Art is piece of luxury
"""
import matplotlib.pyplot as plt
from glv import *
class ChkData():
def __init__(self,imu_data):
self.imu_chk = imu_data
self.intv = imu_data.intv
def plot_timef(self,dtype):
fig = plt.figure(figsize=(10,6))
ax = fig.add_subplot(111)
if dtype == "ACC":
X = self.imu_chk.imu_mat("TIM")
Y = self.imu_chk.imu_mat("ACC")
ax.plot(X,Y[:,0],label="ax")
ax.plot(X,Y[:,1],label="ay")
ax.plot(X,Y[:,2],label="az")
ax.legend(loc="best")
elif dtype == "GYO":
X = self.imu_chk.imu_mat("TIM")
Y = self.imu_chk.imu_mat("GYO")
ax.plot(X,Y[:,0],label="gx")
ax.plot(X,Y[:,1],label="gy")
ax.plot(X,Y[:,2],label="gz")
ax.legend(loc="best")
elif dtype == "ALL":
X = self.imu_chk.imu_mat("TIM")
Y = self.imu_chk.imu_mat("ALL")[:,1:]
ax.plot(X,Y[:,0],label="gx")
ax.plot(X,Y[:,1],label="gy")
ax.plot(X,Y[:,2],label="gz")
ax.plot(X,Y[:,3],label="ax")
ax.plot(X,Y[:,4],label="ay")
ax.plot(X,Y[:,5],label="az")
ax.legend(loc="best")
else:
raise Exception("Wrong dtype[%s]." % dtype)
def plot_epoch(self,dtype):
fig = plt.figure(figsize=(10,6))
ax = fig.add_subplot(111)
if dtype == "ACC":
X = self.imu_chk.imu_mat("TIM");X -= X[0]
Y = self.imu_chk.imu_mat("ACC")
ax.plot(X,Y[:,0],label="ax")
ax.plot(X,Y[:,1],label="ay")
ax.plot(X,Y[:,2],label="az")
ax.legend(loc="best")
elif dtype == "GYO":
X = self.imu_chk.imu_mat("TIM");X -= X[0]
Y = self.imu_chk.imu_mat("GYO")
ax.plot(X,Y[:,0],label="gx")
ax.plot(X,Y[:,1],label="gy")
ax.plot(X,Y[:,2],label="gz")
ax.legend(loc="best")
elif dtype == "ALL":
X = self.imu_chk.imu_mat("TIM");X -= X[0]
Y = self.imu_chk.imu_mat("ALL")[:,1:]
ax.plot(X,Y[:,0],label="gx")
ax.plot(X,Y[:,1],label="gy")
ax.plot(X,Y[:,2],label="gz")
ax.plot(X,Y[:,3],label="ax")
ax.plot(X,Y[:,4],label="ay")
ax.plot(X,Y[:,5],label="az")
ax.legend(loc="best")
else:
raise Exception("Wrong dtype[%s]." % dtype)
class Chkalg():
def __init__(self,alg_mat):
self.alg_mat = alg_mat
def plot(self,ptype):
fig = plt.figure(figsize=(10,6))
if ptype == "A":
ax = fig.add_subplot(111)
X = self.alg_mat[:,0]
Y = self.alg_mat[:,1] * R2D
elif ptype == "B":
ax = fig.add_subplot(111)
X = self.alg_mat[:,0]
Y = self.alg_mat[:,2] * R2D
elif ptype == "F":
ax = fig.add_subplot(111)
X = self.alg_mat[:,0]
Y = self.alg_mat[:,3] * R2D
elif ptype == "ALL":
ax = fig.add_subplot(111)
X = self.alg_mat[:,0]
Y = self.alg_mat[:,1:] * R2D
ax.plot(X,Y[:,0],label="alpha")
ax.plot(X,Y[:,1],label="theta")
ax.plot(X,Y[:,2],label="fi")
ax.legend(loc="best")