-
Notifications
You must be signed in to change notification settings - Fork 3
/
visualization.py
220 lines (180 loc) · 7.09 KB
/
visualization.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
import matplotlib.pyplot as plt
from mpl_toolkits import mplot3d
import json
import numpy as np
colors = ["blue", "orange", "green", "red", "purple", "brown", "pink", "gray", "olive", "cyan"]
# input parameters
name = 'log01_eval'
# name = './ignore_stored_data/all_data_bad_comparison'
from_lap = 0
to_lap = 20
# visualization
with open('%s' % name, 'r') as f:
data = json.load(f)
print('Number of datapoints: %s' % len(data['time']))
keys = list(data.keys())
for key in keys:
data[key] = np.array(data[key])
data_lap = {}
keys = list(data.keys())
for key in keys:
data_lap[key] = np.array(data[key][np.bitwise_and(from_lap <= data['lap_n'], data['lap_n'] <= to_lap)])
data_lap['w'] = data_lap['w'].squeeze().T
plt.plot(data_lap['time'], data_lap['w'][0], label='0.5')
plt.plot(data_lap['time'], data_lap['w'][1], label='0.6')
plt.plot(data_lap['time'], data_lap['w'][2], label='0.9')
plt.plot(data_lap['time'], data_lap['w'][3], label='1.1')
# plt.plot(data_lap['time'], data_lap['w'][4], label='1.1')
plt.legend()
plt.show()
# np.array(data['time'])[np.array(data['lap_n']) == 1.0]
plt.plot(data_lap['time'], data_lap['vx'])
plt.plot(data_lap['time'], data_lap['v_ref'])
plt.ylabel('speed [m/s]')
plt.xlabel('time [s]')
plt.show()
plt.plot(data_lap['time'], data_lap['tracking_error'])
plt.ylabel('tracking error')
plt.xlabel('time')
# ax.set_zlabel('vx [m/s]')
# ax.set_aspect('equalxy', adjustable='datalim')
plt.show()
# np.array(data['time'])[np.array(data['lap_n']) == 1.0]
ax = plt.figure().add_subplot()
color_arr = []
for i in range(len(data_lap['x'])):
# color_arr.append(data_lap['true_mu'][i])
color_arr.append(data_lap['w2'][i])
# scat = ax.scatter(data_lap['x'], data_lap['y'], cmap='plasma', marker='o', c=color_arr) # , cmap='coolwarm', vmin=0, vmax=1.0
scat = ax.scatter(data_lap['x'], data_lap['y'], cmap='coolwarm', marker='o', c=color_arr, vmin=0, vmax=1.0) # , cmap='coolwarm', vmin=0, vmax=1.0
plt.colorbar(scat)
plt.ylabel('y [m]')
plt.xlabel('x [m]')
plt.show()
ax = plt.figure().add_subplot()
color_arr = []
for i in range(len(data_lap['x'])):
color_arr.append(data_lap['true_mu'][i])
# color_arr.append(data_lap['w2'][i])
# scat = ax.scatter(data_lap['x'], data_lap['y'], cmap='plasma', marker='o', c=color_arr) # , cmap='coolwarm', vmin=0, vmax=1.0
scat = ax.scatter(data_lap['x'], data_lap['y'], cmap='coolwarm', marker='o', c=color_arr, vmin=0, vmax=1.0) # , cmap='coolwarm', vmin=0, vmax=1.0
plt.colorbar(scat)
plt.ylabel('y [m]')
plt.xlabel('x [m]')
plt.show()
# exit()
plt.plot(data_lap['x'], data_lap['y'])
plt.plot(data_lap['x_gt'], data_lap['y_gt'])
plt.ylabel('y [m]')
plt.xlabel('x [m]')
plt.show()
ax = plt.figure().add_subplot(projection='3d')
ax.scatter(data_lap['x'], data_lap['y'], data_lap['vx_var'], marker='o')
plt.ylabel('vx var')
plt.xlabel('time')
ax.set_zlabel('ax variance [m/s/s]')
ax.set_aspect('equalxy', adjustable='datalim')
plt.show()
# ax = plt.figure().add_subplot(projection='3d')
plt.scatter(data_lap['time'], data_lap['vx_var'], marker='o')
plt.ylabel('vx var')
plt.xlabel('time')
# plt.set_zlabel('ax variance [m/s/s]')
# plt.set_aspect('equalxy', adjustable='datalim')
plt.show()
# # ax = plt.figure().add_subplot(projection='3d')
# plt.scatter(data_lap['time'], data_lap['wsf_s'], marker='o')
# plt.ylabel('slip')
# plt.xlabel('time')
# # ax.set_zlabel('slip ratio')
# # ax.set_aspect('equalxy', adjustable='datalim')
# plt.show()
#
# plt.scatter(data_lap['time'], data_lap['wsf'], marker='o')
# plt.scatter(data_lap['time'], data_lap['wsf2'], marker='o')
# plt.scatter(data_lap['time'], data_lap['wsf3'], marker='o')
# plt.scatter(data_lap['time'], data_lap['wsf4'], marker='o')
# plt.ylabel('wheel speeds [rad/s]')
# plt.xlabel('time')
# # ax.set_zlabel('slip ratio')
# # ax.set_aspect('equalxy', adjustable='datalim')
# plt.show()
# ax = plt.figure().add_subplot(projection='3d')
plt.scatter(data_lap['time'], data_lap['vx'], marker='o')
plt.ylabel('vx')
plt.xlabel('time')
# ax.set_zlabel('vx [m/s]')
# ax.set_aspect('equalxy', adjustable='datalim')
plt.show()
# np.array(data['time'])[np.array(data['lap_n']) == 1.0]
# ax = plt.figure().add_subplot(projection='3d')
plt.scatter(data_lap['time'], data_lap['vy_var'], marker='o')
plt.ylabel('vy var')
plt.xlabel('time')
# ax.set_zlabel('ay variance [m/s/s]')
# ax.set_aspect('equalxy', adjustable='datalim')
plt.show()
# exit()
# np.array(data['time'])[np.array(data['lap_n']) == 1.0]
ax = plt.figure().add_subplot(projection='3d')
ax.scatter(data_lap['x'], data_lap['y'], data_lap['theta_var'], marker='o')
plt.ylabel('y [m]')
plt.xlabel('x [m]')
ax.set_zlabel('yaw rate change variance [rad/s/s]')
ax.set_aspect('equalxy', adjustable='datalim')
plt.show()
# np.array(data['time'])[np.array(data['lap_n']) == 1.0]
ax = plt.figure().add_subplot(projection='3d')
ax.scatter(data_lap['x'], data_lap['y'], data_lap['tracking_error'], marker='o')
plt.ylabel('y [m]')
plt.xlabel('x [m]')
ax.set_zlabel('tracking error [m]')
ax.set_aspect('equalxy', adjustable='datalim')
plt.show()
plt.plot(data_lap['time'], data_lap['vx_mean'], label='prediction')
plt.plot(data_lap['time'], data_lap['true_vx'], label='ground truth')
plt.legend(['prediction', 'ground truth'])
plt.fill_between(data_lap['time'], data_lap['vx_mean'] - data_lap['vx_var'], data_lap['vx_mean'] + data_lap['vx_var'], alpha=0.5)
plt.ylabel('ax')
plt.xlabel('time [s]')
plt.show()
plt.plot(data_lap['time'], data_lap['vy_mean'], label='prediction')
plt.plot(data_lap['time'], data_lap['true_vy'], label='ground truth')
plt.legend(['prediction', 'ground truth'])
plt.fill_between(data_lap['time'], data_lap['vy_mean'] - data_lap['vy_var'], data_lap['vy_mean'] + data_lap['vy_var'], alpha=0.5)
plt.ylabel('ay')
plt.xlabel('time [s]')
plt.show()
plt.plot(data_lap['time'], data_lap['theta_mean'], label='prediction')
plt.plot(data_lap['time'], data_lap['true_yaw_rate'], label='ground truth')
plt.legend(['prediction', 'ground truth'])
plt.fill_between(data_lap['time'], data_lap['theta_mean'] - data_lap['theta_var'], data_lap['theta_mean'] + data_lap['theta_var'], alpha=0.5)
plt.ylabel('yaw rate')
plt.xlabel('time [s]')
plt.show()
plt.plot(data_lap['time'], data_lap['wsf_mean'], label='prediction')
plt.plot(data_lap['time'], data_lap['true_wsf'], label='ground truth')
plt.legend(['prediction', 'ground truth'])
# plt.fill_between(data_lap['time'], data_lap['theta_mean'] - data_lap['theta_var'], data_lap['theta_mean'] + data_lap['theta_var'], alpha=0.5)
plt.ylabel('wsf')
plt.xlabel('time [s]')
plt.show()
plt.plot(data_lap['time'], data_lap['wsr_mean'], label='prediction')
plt.plot(data_lap['time'], data_lap['true_wsr'], label='ground truth')
plt.legend(['prediction', 'ground truth'])
# plt.fill_between(data_lap['time'], data_lap['theta_mean'] - data_lap['theta_var'], data_lap['theta_mean'] + data_lap['theta_var'], alpha=0.5)
plt.ylabel('wsr')
plt.xlabel('time [s]')
plt.show()
plt.plot(data_lap['time'], data_lap['vx_var'])
plt.ylabel('ax var')
plt.xlabel('time [s]')
plt.show()
plt.plot(data_lap['time'], data_lap['vy_var'])
plt.ylabel('ay var')
plt.xlabel('time [s]')
plt.show()
plt.plot(data_lap['time'], data_lap['theta_var'])
plt.ylabel('yaw rate var')
plt.xlabel('time [s]')
plt.show()