-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathread_plot.py
94 lines (58 loc) · 1.53 KB
/
read_plot.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
import matplotlib.pyplot as plt
import csv
import numpy as np
a = []
b = []
c = []
d = []
e = []
f = []
g = []
h = []
i = []
j = []
k = []
l = []
dt = 0.001 #loop frequency (time per loop)
with open('/media/varun/Work/Academics/_Spring 2019/CS 225A/cs225a_hw3/data3a.csv','r') as csvfile:
plots = csv.reader(csvfile, delimiter=',')
for row in plots:
a.append(float(row[0]))
b.append(float(row[1]))
c.append(float(row[2]))
d.append(float(row[3]))
e.append(float(row[4]))
f.append(float(row[5]))
g.append(float(row[6]))
h.append(float(row[7]))
i.append(float(row[8]))
'''
j.append(float(row[9]))
k.append(-1*float(row[9]))
'''
t = np.linspace(0,len(a)*dt,len(a),dtype=float)
plt.figure(0)
plt.subplot(2,1,1)
plt.plot(t,a, label='x')
plt.plot(t,b, label='y')
plt.plot(t,c, label='z')
plt.plot(t,d,'--', label='x_des')
plt.plot(t,e,'--' ,label='y_des')
plt.plot(t,f, '--', label='z_des')
plt.xlabel('Time [s]')
plt.ylabel('Position Operation Space [m]')
plt.title('Task Space Trajectory Tracking')
plt.legend()
plt.grid()
plt.subplot(2,1,2)
plt.plot(t,g, label='$d\phi_x$')
plt.plot(t,h,label='$d\phi_y$')
plt.plot(t,i, label='$d\phi_z$')
#plt.plot(t,j,'r', label='$ V_{max}$')
#plt.plot(t,k,'r', label='$ -V_{max}$')
plt.xlabel('Time [s]')
plt.ylabel('Angle Error [rad]')
plt.legend()
plt.grid()
plt.savefig('/media/varun/Work/Academics/_Spring 2019/CS 225A/cs225a_hw3/plot3a_v2.png')
plt.show()