File tree 2 files changed +54
-0
lines changed
2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change
1
+ import os
2
+ import numpy as np
3
+ from scipy import integrate as spi
4
+ from pylab import *
5
+
6
+ acc = []
7
+ t = arange (0 , 10.24 , 0.01 )
8
+
9
+ fn = os .path .join (os .path .dirname (os .path .realpath (__file__ )), 'data' )
10
+ print fn
11
+ with open (fn ) as f :
12
+ data = f .readlines ()
13
+
14
+ for value in data :
15
+ value_acc = ((int (value )- 128 )/ 30.0 )* 9.81 #calibration
16
+ acc .append (value_acc )
17
+
18
+ dist = spi .cumtrapz (acc , t )
19
+
20
+ plt .figure (1 )
21
+ plt .plot (acc )
22
+ plt .plot (dist )
23
+ #plt.xlabel('t[s]')
24
+ #plt.ylabel('acc [g]')
25
+ #plt.title('acceleration in x-direction')
26
+ #plt.legend(['acc'], loc = 'lower right')
27
+ plt .show ()
Original file line number Diff line number Diff line change
1
+ import os
2
+ import numpy as np
3
+ from scipy import integrate as spi
4
+ from pylab import *
5
+
6
+ acc = []
7
+ t=arange(0, 10.24, 0.01)
8
+
9
+ fn = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data')
10
+ print fn
11
+ with open(fn) as f:
12
+ data = f.readlines()
13
+
14
+ for value in data:
15
+ value_acc = ((int(value)-128)/30.0)*9.81
16
+ acc.append(value_acc)
17
+
18
+ dist = spi.cumtrapz(acc, t)
19
+
20
+ plt.figure(1)
21
+ plt.plot(acc)
22
+ plt.plot(dist)
23
+ #plt.xlabel('t[s]')
24
+ #plt.ylabel('acc [g]')
25
+ #plt.title('acceleration in x-direction')
26
+ #plt.legend(['acc'], loc = 'lower right')
27
+ plt.show()
You can’t perform that action at this time.
0 commit comments