import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D import RiseFallSVM as svm from BrakeController import Controller from xyFit import * test = 'PG188Test9.csv' trials = 100 atrials = 350 (data, BrakeStrength) = collect(trials, test, atrials=atrials) data = np.loadtxt('data/' + test, delimiter=',', comments='# ') BrakeStrength = np.loadtxt('data/BrakeCommands' + test, delimiter=',', comments='# ') compData = arrange(data, BrakeStrength, test) # plt.plot(BrakeStrength) # plt.show() # compData = np.loadtxt('data/Comp' + test, delimiter=',', comments='#') # fig = plt.figure() # ax0 = fig.add_subplot(111, projection='3d') # print(np.shape(compData)) # ax0.scatter(compData[:, 0], compData[:, 1], compData[:, 2], # c=compData[:, 0] - compData[:, 1], depthshade=False) # plt.title('Brake Commands Vs. Torque') # ax0.set_xlabel('Brake Command (%)') # ax0.set_ylabel(' Prev Brake Command (%)') # ax0.set_zlabel('Torque (in-lb)') # ax0 = fig.add_subplot(111, projection='3d')
(data, brakeStrength) = collect(brakeStrength, currdir, test, timeLength=10, mode='warmup', breed=breed, stepwise=True) data = np.loadtxt(currdir + test + '.csv', delimiter=',', comments='# ') brakeStrength = np.loadtxt(currdir + 'BrakeCommands' + test + '.csv', delimiter=',', comments='# ') # arrange brake Data compData = arrange( data, brakeStrength, currdir, test, ) # import curve information with open(paramdir + 'curveP.pickle', 'rb') as g: (riseP, fallP) = pickle.load(g) tumInd = 0 toFallTable = [] toRiseTable = [] # parse data into sets of tumbles based on index for tum in torqueList: # use curve information to determine linear points dna_pts = []
# plt.legend() plt.title('Speed Vs. Time') plt.ylabel('Speed (%)') plt.xlabel('Time(s)') ax2 = plt.subplot(414) ax2.plot(time, data[:, 5]) plt.title('Motor Tenp Vs. Time') plt.ylabel('Temp (Celsius)') plt.xlabel('Time(s)') plt.savefig(currdir + test + 'figure1.png') # plt.show() # analyze but don't convert compData = arrange(data, brakeStrength, currdir, test, convert=False) avgCurrent = compData[:, -1] # load lake Placid data placidData = np.genfromtxt('data/ActualPlacidData.csv', delimiter=',') placidData[0, 0] = 1.13 placidData = np.tile(placidData, (runs, 1)) # do square root fit p, cov = curve_fit( itoT, avgCurrent, placidData[:, 0], [-121, 0.0111 * np.sqrt(40160000), 900000000 / 40160000]) # print parameters print(p)