Skip to content

Commit 3f590c0

Browse files
committed
format
1 parent d8c837b commit 3f590c0

File tree

4 files changed

+81
-95
lines changed

4 files changed

+81
-95
lines changed

tools/trace.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
11
import matplotlib.pyplot as pl
22
import csv
33

4-
54
tauList = []
65
tauDotList = []
76
qList = []
87
qDotList = []
98
uList = []
10-
119
''' position '''
1210
path = '../_build/cpp/results.csv'
1311

14-
with open(path,'r') as dataFile:
12+
with open(path, 'r') as dataFile:
1513
reader = csv.reader(dataFile)
1614
i = 0
1715
for row in reader:
18-
if i ==1:
16+
if i == 1:
1917
tauList.append(float(row[0]))
2018
tauDotList.append(float(row[1]))
2119
qList.append(float(row[2]))
2220
qDotList.append(float(row[3]))
2321
uList.append((float(row[4])))
24-
if i==0:
22+
if i == 0:
2523
i = 1
2624

2725
fig1 = pl.figure()
@@ -48,4 +46,3 @@
4846
ax2.grid()
4947

5048
pl.show()
51-

tools/traceBench.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,20 @@
66
qList = []
77
qDotList = []
88
uList = []
9-
109
''' position '''
1110
path = '../_build/cpp/resultsBench.csv'
1211

13-
with open(path,'r') as dataFile:
12+
with open(path, 'r') as dataFile:
1413
reader = csv.reader(dataFile)
1514
i = 0
1615
for row in reader:
17-
if i ==1:
16+
if i == 1:
1817
tauList.append(float(row[0]))
1918
tauDotList.append(float(row[1]))
2019
qList.append(float(row[2]))
2120
qDotList.append(float(row[3]))
2221
uList.append((float(row[4])))
23-
if i==0:
22+
if i == 0:
2423
i = 1
2524

2625
fig1 = pl.figure()
@@ -50,24 +49,23 @@
5049

5150
pl.ion()
5251

53-
5452
while 1:
5553
tauList = []
5654
tauDotList = []
5755
qList = []
5856
qDotList = []
5957
uList = []
60-
with open(path,'r') as dataFile:
58+
with open(path, 'r') as dataFile:
6159
reader = csv.reader(dataFile)
6260
i = 0
6361
for row in reader:
64-
if i ==1:
62+
if i == 1:
6563
tauList.append(float(row[0]))
6664
tauDotList.append(float(row[1]))
6765
qList.append(float(row[2]))
6866
qDotList.append(float(row[3]))
6967
uList.append((float(row[4])))
70-
if i==0:
68+
if i == 0:
7169
i = 1
7270

7371
ax1.plot(tauList)
@@ -86,4 +84,3 @@
8684
ax2.grid()
8785

8886
pl.draw()
89-

tools/traceMPC.py

Lines changed: 56 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import matplotlib.pyplot as pl
22
import csv
33

4-
54
tauList = []
65
tauDotList = []
76
qList = []
@@ -19,60 +18,58 @@
1918
qListList = []
2019
qDotListList = []
2120
uListList = []
22-
2321
''' position '''
2422
path = '../_build/cpp/resultsMPC.csv'
25-
T=5;
26-
N = 30;
27-
28-
29-
with open(path,'r') as dataFile:
23+
T = 5
24+
N = 30
25+
26+
with open(path, 'r') as dataFile:
3027
reader = csv.reader(dataFile)
3128
i = 0
3229
j = -1
3330
for row in reader:
34-
if i ==2:
35-
if(j<T):
36-
tauList.append(float(row[0]))
37-
tauDotList.append(float(row[1]))
38-
qList.append(float(row[2]))
39-
qDotList.append(float(row[3]))
40-
uList.append((float(row[4])))
41-
j+=1
42-
else:
43-
tauListList.append(tauList)
44-
tauDotListList.append(tauDotList)
45-
qListList.append(qList)
46-
qDotListList.append(qDotList)
47-
uListList.append(uList)
48-
tauList = [float(row[0])]
49-
tauDotList = [float(row[1])]
50-
qList = [float(row[2])]
51-
qDotList = [float(row[3])]
52-
uList = [float(row[4])]
53-
j = 0
54-
if i==1:
55-
i = 2
56-
if i==0:
57-
T = int(row[0])
58-
N = int(row[1]) - 1
59-
i = 1
60-
31+
if i == 2:
32+
if (j < T):
33+
tauList.append(float(row[0]))
34+
tauDotList.append(float(row[1]))
35+
qList.append(float(row[2]))
36+
qDotList.append(float(row[3]))
37+
uList.append((float(row[4])))
38+
j += 1
39+
else:
40+
tauListList.append(tauList)
41+
tauDotListList.append(tauDotList)
42+
qListList.append(qList)
43+
qDotListList.append(qDotList)
44+
uListList.append(uList)
45+
tauList = [float(row[0])]
46+
tauDotList = [float(row[1])]
47+
qList = [float(row[2])]
48+
qDotList = [float(row[3])]
49+
uList = [float(row[4])]
50+
j = 0
51+
if i == 1:
52+
i = 2
53+
if i == 0:
54+
T = int(row[0])
55+
N = int(row[1]) - 1
56+
i = 1
57+
6158
for i in range(N):
62-
finaltauList.append(tauListList[i][0])
63-
finaltauDotList.append(tauDotListList[i][0])
64-
finalqList.append(qListList[i][0])
65-
finalqDotList.append(qDotListList[i][0])
66-
finaluList.append(uListList[i][0])
59+
finaltauList.append(tauListList[i][0])
60+
finaltauDotList.append(tauDotListList[i][0])
61+
finalqList.append(qListList[i][0])
62+
finalqDotList.append(qDotListList[i][0])
63+
finaluList.append(uListList[i][0])
6764

68-
#~ print len(tauListList[0])
69-
#~ print len(tauListList[1])
70-
#~ print len(tauListList[2])
71-
#~ print len(tauListList[3])
72-
#~ print tauListList[0]
73-
#~ print tauListList[1]
74-
#~ print tauListList[2]
75-
#~ print tauListList[3]
65+
# print len(tauListList[0])
66+
# print len(tauListList[1])
67+
# print len(tauListList[2])
68+
# print len(tauListList[3])
69+
# print tauListList[0]
70+
# print tauListList[1]
71+
# print tauListList[2]
72+
# print tauListList[3]
7673

7774
fig1 = pl.figure()
7875
fig2 = pl.figure()
@@ -83,23 +80,22 @@
8380
dx1 = fig1.add_subplot(224)
8481
ax2 = fig2.add_subplot(111)
8582

86-
for i in range(0,N,20):
87-
ax1.plot(range(i,i+T+1,1),tauListList[i])
88-
bx1.plot(range(i,i+T+1,1),tauDotListList[i])
89-
cx1.plot(range(i,i+T+1,1),qListList[i])
90-
dx1.plot(range(i,i+T+1,1),qDotListList[i])
91-
ax2.plot(range(i,i+T+1,1),uListList[i])
92-
93-
ax1.plot(finaltauList,'g+')
94-
bx1.plot(finaltauDotList,'g+')
95-
cx1.plot(finalqList,'g+')
96-
dx1.plot(finalqDotList,'g+')
97-
ax2.plot(finaluList,'g+')
83+
for i in range(0, N, 20):
84+
ax1.plot(range(i, i + T + 1, 1), tauListList[i])
85+
bx1.plot(range(i, i + T + 1, 1), tauDotListList[i])
86+
cx1.plot(range(i, i + T + 1, 1), qListList[i])
87+
dx1.plot(range(i, i + T + 1, 1), qDotListList[i])
88+
ax2.plot(range(i, i + T + 1, 1), uListList[i])
89+
90+
ax1.plot(finaltauList, 'g+')
91+
bx1.plot(finaltauDotList, 'g+')
92+
cx1.plot(finalqList, 'g+')
93+
dx1.plot(finalqDotList, 'g+')
94+
ax2.plot(finaluList, 'g+')
9895

9996
ax1.grid()
10097
bx1.grid()
10198
cx1.grid()
10299
dx1.grid()
103100
ax2.grid()
104101
pl.show()
105-

tools/traceTest.py

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
1-
from matplotlib.pyplot import *
2-
import numpy as np
31
import csv
4-
2+
from matplotlib import pyplot as plt
53
''' position '''
64
path1 = '../_build/examples/temperature_control/results1.csv'
75
path2 = '../_build/examples/temperature_control/results2.csv'
86

97
names = []
108
data = []
119

12-
with open(path1,'r') as dataFile1:
10+
with open(path1, 'r') as dataFile1:
1311
reader = csv.reader(dataFile1)
1412
i = 0
1513
for row in reader:
16-
if i ==2:
14+
if i == 2:
1715
for j in range(len(names)):
1816
data[j].append(float(row[j]))
19-
if i==1:
17+
if i == 1:
2018
T = int(row[0])
2119
S_NB = int(row[1])
2220
C_NB = int(row[2])
2321
for j in range(len(names)):
2422
data.append([])
2523
i = 2
26-
if i==0:
24+
if i == 0:
2725
for name in row:
2826
names.append(name)
2927
i = 1
@@ -59,20 +57,18 @@
5957
if i==0:
6058
i = 1'''
6159

62-
fig1 = figure()
60+
fig1 = plt.figure()
6361
for i in range(S_NB):
64-
subplot(int(S_NB/2)+1,2,int(i+1))
65-
plot(data[i])
66-
title(names[i])
67-
grid()
62+
plt.subplot(int(S_NB / 2) + 1, 2, int(i + 1))
63+
plt.plot(data[i])
64+
plt.title(names[i])
65+
plt.grid()
6866

69-
70-
fig2 = figure()
67+
fig2 = plt.figure()
7168
for i in range(C_NB):
72-
subplot(int(C_NB/2)+1,2,int(i+1))
73-
plot(data[i+S_NB])
74-
title(names[i+S_NB])
75-
grid()
76-
69+
plt.subplot(int(C_NB / 2) + 1, 2, int(i + 1))
70+
plt.plot(data[i + S_NB])
71+
plt.title(names[i + S_NB])
72+
plt.grid()
7773

78-
show()
74+
plt.show()

0 commit comments

Comments
 (0)