bobbycar/logdata_visualization/analyze.py

53 lines
1.4 KiB
Python

import matplotlib.pyplot as plt
import csv
x=[]
speed_FrontL=[]
speed_FrontR=[]
speed_RearL=[]
speed_RearR=[]
fp = open('LOG00193_20210516_fixedSpeedLR_freewheelingTest.TXT')
rdr = csv.DictReader(filter(lambda row: row[0]!='#', fp))
for row in rdr:
#print(row)
x.append(float(row['cmd_FrontL']))
speed_FrontL.append(float(row['speed_FrontL']))
speed_FrontR.append(float(row['speed_FrontR']))
speed_RearL.append(float(row['speed_RearL']))
speed_RearR.append(float(row['speed_RearR']))
fp.close()
#plt.plot(x,y, label='Loaded from file!')
scattersize=5
scatteralpha=0.1
plt.scatter(x,speed_FrontL, s=scattersize, alpha=scatteralpha, label="speed_FrontL")
plt.scatter(x,speed_FrontR, s=scattersize, alpha=scatteralpha, label="speed_FrontR")
plt.scatter(x,speed_RearL, s=scattersize, alpha=scatteralpha, label="speed_RearL")
plt.scatter(x,speed_RearR, s=scattersize, alpha=scatteralpha, label="speed_RearR")
plt.xlabel('cmd')
plt.ylabel('speed')
plt.title('Interesting Graph\nCheck it out')
plt.legend()
plt.show()
'''
with open(,'r') as csvfile:
plots = csv.reader(filter(lambda row: row[0]!='#', csvfile), delimiter=',')
for row in plots:
x.append(float(row[0]))
y.append(float(row[1]))
plt.plot(x,y, label='Loaded from file!')
plt.xlabel('x')
plt.ylabel('y')
plt.title('Interesting Graph\nCheck it out')
plt.legend()
plt.show()
'''