예제 #1
0
fuzz = 0.01  # percentage from one curve to the other to form curve threshold
resol = 5  # distance between starting commands for each
steps = 2  # percentage points to step down within each tumble
torqueList = tumList(10, 95, 30, resol, steps, 1)
brakeStrength = []
for tum in torqueList:
    brakeStrength.extend(tum)

# collect brake Data
if not os.path.exists(currdir):
    os.makedirs(currdir)
if (not os.path.exists(currdir + test + '.csv')):
    (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,
)
예제 #2
0
from collectBrakeData import collectBrakeData as collect
from arrangeBrakeData import arrangeBrakeData as arrange
import pickle
import numpy as np
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 (%)')
예제 #3
0
runs = 1  # times to do test

brakeStrength = [0, 6.8, 13.6, 20.4, 27.2, 34, 40.8, 47.6, 54.4, 62.1, 69.9,
                 77.7, 85.4, 92.2, 99.4, 100, 99.4, 92.2, 85.4, 77.7, 69.9,
                 62.1, 54.4, 47.6, 40.8, 34, 27.2, 20.4, 13.6, 6.8, 0]
brakeStrength = brakeStrength * runs

# makes folder
if not os.path.exists(currdir):
    os.makedirs(currdir)

# run collect data with parameters
if not os.path.exists(currdir + test + '.csv'):
    (data, brakeStrength) = collect(brakeStrength, currdir, test,
                                    timeLength=15, mode='warmup',
                                    testSet=16, breed=breed)

# import data from test
data = np.loadtxt(currdir + test + '.csv', delimiter=',', comments='# ')
brakeStrength = np.loadtxt(currdir + 'BrakeCommands' +
                           test + '.csv', delimiter=',', comments='# ')

# plot here
time = data[:, 0]
ax = plt.subplot(411)
ax.plot(time,
        data[:, 1],)
# plt.legend()
plt.title('Brake Command Vs. Time')
plt.ylabel('Current (%)')
예제 #4
0
# order of boundary equation in SVM
boundXL = 3

# order of polynomial fit for rising and falling curve
riseXL = 6
fallXL = 6

# makes filepath and runs test if it doesn't already exist
if not os.path.exists(currdir):
    os.makedirs(currdir)
if (overwrite or (not os.path.exists(currdir + test + '.csv'))):
    (data, brakeStrength) = collect(trials,
                                    currdir,
                                    test,
                                    atrials=atrials,
                                    timeLength=12,
                                    mode='warmup',
                                    breed=breed,
                                    stepwise=True)

# loads data from previous test
data = np.loadtxt(currdir + test + '.csv', delimiter=',', comments='# ')
brakeStrength = np.loadtxt(currdir + 'BrakeCommands' + test + '.csv',
                           delimiter=',',
                           comments='# ')

# plot figure 1 here(Raw Data)
time = data[:, 0]
ax = plt.subplot(411)
ax.plot(
    time,
예제 #5
0
# print(p1[5::-1])
# p3 = p1[-1:5:-1]
# p3 = np.append(p3,0)
# print(p3)
# print(np.polyval(p1[5::-1],74)+np.polyval(p3,74))
# Convert to Brake Commands
# print(cont.model([74.0]))
brakeStrength, labels = cont.qmodel(torqueList)
for i in range(len(brakeStrength)):
    brakeStrength[i] = min(max(brakeStrength[i], 0.0), 100.0)

print(brakeStrength)
# 1/0
# Execute Brake Commands
# What to do about wait time
(data, brakeStrength) = collect(brakeStrength, currdir, test)
compData = arrange(data, brakeStrength, currdir, test)
realTorques = compData[:, -1]
error = torqueList - realTorques
fig = plt.figure()
ax0 = fig.add_subplot(211)
# ax0.scatter(rancompData[:, 2], rancompData[:, 1], rancompData[:, 0],
#             c='b', depthshade=False)
ax0.plot(realTorques)
ax0.plot(torqueList)
plt.title('Actual Torque vs Command')
ax0.set_xlabel('Datapoint')
ax0.set_ylabel('Torque (in-lb)')
ax0.legend(('Measured Torque', 'Command'))

ax1 = fig.add_subplot(212)
예제 #6
0
        val += args[i] * data[int(i >= xPL), :]**(int(i >= xPL) + (i) % xPL)
    return val


breed = 'PG188Test'

testID = 17
currdir = 'data/' + breed + '/' + breed + str(testID) + '/'
test = breed + str(testID)
trials = 3
atrials = 0
overwrite = True
if not os.path.exists(currdir):
    os.makedirs(currdir)
if (overwrite or (not os.path.exists(currdir + test + '.csv'))):
    (data, brakeStrength) = collect(trials, currdir, test, atrials=atrials)
data = np.loadtxt(currdir + test + '.csv', delimiter=',', comments='# ')
brakeStrength = np.loadtxt(currdir + 'BrakeCommands' + test + '.csv',
                           delimiter=',',
                           comments='# ')

time = data[:, 0]
# plot here
ax = plt.subplot(411)
ax.plot(
    time,
    data[:, 1],
)
# plt.legend()
plt.title('Brake Command Vs. Time')
plt.ylabel('Current (%)')