Skip to content

Instantly share code, notes, and snippets.

@rpicatoste
Created November 23, 2017 13:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rpicatoste/31346638060e3fb9baf7da4f0614725d to your computer and use it in GitHub Desktop.
Save rpicatoste/31346638060e3fb9baf7da4f0614725d to your computer and use it in GitHub Desktop.
#%%
import pickle
import numpy as np
import matplotlib.pyplot as plt
server_log_filename = 'C:\workspace\shared_vm\server_pid_log_0.pkl'
with open(server_log_filename, 'rb') as f:
log = pickle.load(f)
throttle_t = []
throttle_data = []
brake_t = []
brake_data = []
for sample in log:
if 'throttle' in sample[2].keys():
throttle_t.append( sample[0] )
throttle_data.append( sample[2]['throttle'] )
if 'brake' in sample[2].keys():
brake_t.append( sample[0] )
brake_data.append( sample[2]['brake'] )
throttle_t = np.array( throttle_t, np.float32 )
throttle_data = np.array( throttle_data, np.float32 )
brake_t = np.array( brake_t, np.float32 )
brake_data = np.array( brake_data, np.float32 )
#%%
plt.figure#(1, figsize = (16,12))
#plt.subplot(311)
plt.plot(throttle_t, throttle_data, 'x', brake_t, brake_data)
plt.ylabel('throttle')
plt.yticks(np.arange(np.min(throttle_data), np.max(throttle_data), 0.1))
#plt.subplot(312)
#plt.plot(timestamp, unfilt_pid_output)
#plt.ylabel('unfilt_pid_output')
#
#plt.subplot(313)
#plt.plot(timestamp, delta_time)
#plt.ylabel('delta_time')
#plt.show()
plt.figure(2)
plt.plot(throttle_t[1:], 1000.*(throttle_t[1:] - throttle_t[:-1]))
plt.title('Time between throttle messages sent')
#plt.ylabel('ms')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment