Skip to content

Commit 68fda30

Browse files
added integration proto
1 parent 7674ff4 commit 68fda30

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

python/integration.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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()

python/integration.py~

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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()

0 commit comments

Comments
 (0)