import sys
sys.path.append('..')
from load_paths import read
import cPickle
import numpy as np
import matplotlib.pyplot as plt
import bicycledataprocessor as bdp
from canonicalbicycleid import canonical_bicycle_id as cbi

with open(read('pathToGoodRuns')) as f:
    goodRuns = cPickle.load(f)

with open(read('pathToIdMat')) as f:
    idMat = cPickle.load(f)

dataset = bdp.DataSet()

roll = {k : [] for k in idMat.keys() + ['Whipple', 'Arm']}
steer = {k : [] for k in idMat.keys() + ['Whipple', 'Arm']}

allH = cbi.lateral_force_contribution(['Charlie', 'Jason', 'Luke'])

for runNum in goodRuns:
    trial = bdp.Run(runNum, dataset, filterFreq=15.)
    rider = trial.metadata['Rider']
    timeseries = cbi.benchmark_time_series(trial, subtractMean=True)
    for k, model in idMat.items():
        rollrsq, steerrsq, fig = cbi.input_prediction(timeseries, model)
        roll[k].append(rollrsq)
        steer[k].append(steerrsq)
        fig.savefig('plots/' + str(runNum) + '-' + k + '.png')
import sys
sys.path.append('..')
from load_paths import read
import cPickle
import numpy as np
import matplotlib.pyplot as plt
import bicycledataprocessor as bdp
from canonicalbicycleid import canonical_bicycle_id as cbi

with open(read('pathToGoodRuns')) as f:
    goodRuns = cPickle.load(f)

with open(read('pathToIdMat')) as f:
    idMat = cPickle.load(f)

dataset = bdp.DataSet()

roll = {k: [] for k in idMat.keys() + ['Whipple', 'Arm']}
steer = {k: [] for k in idMat.keys() + ['Whipple', 'Arm']}

allH = cbi.lateral_force_contribution(['Charlie', 'Jason', 'Luke'])

for runNum in goodRuns:
    trial = bdp.Run(runNum, dataset, filterFreq=15.)
    rider = trial.metadata['Rider']
    timeseries = cbi.benchmark_time_series(trial, subtractMean=True)
    for k, model in idMat.items():
        rollrsq, steerrsq, fig = cbi.input_prediction(timeseries, model)
        roll[k].append(rollrsq)
        steer[k].append(steerrsq)
        fig.savefig('plots/' + str(runNum) + '-' + k + '.png')
Ejemplo n.º 3
0
subDat = dat.subset(**subDef)

# whipple model
speedRange = np.linspace(0.0, 10.0, num=50)
whipple = model.Whipple("Charlie").matrices(speedRange)

# arm model
m = loadmat("../../data/extensions/armsAB-Charlie.mat", squeeze_me=True)  # this is charlie at 101 speeds

inputMats = np.zeros((101, 4, 2))
for i, B in enumerate(m["inputMatrices"]):
    inputMats[i] = B[:, 1:]

# best identified model
with open(read("pathToIdMat")) as f:
    idMat = cPickle.load(f)

M, C1, K0, K2, H = idMat["L-P"]
speeds = np.linspace(0, 10, num=50)
As = np.zeros((len(speeds), 4, 4))
Bs = np.zeros((len(speeds), 4, 2))

for i, v in enumerate(speeds):
    A, BT = dtk.bicycle.benchmark_state_space(M, C1, K0, K2, v, 9.81)
    As[i] = A
    BF = np.dot(BT[2:, :], H)
    Bs[i] = np.hstack((BT[:, 1].reshape(4, 1), np.vstack((np.zeros((2, 1)), BF))))

# A matrix box plot
nBins = 25
import sys
sys.path.append('..')
from load_paths import read

import os
import cPickle
import numpy as np
import pandas
import bicycledataprocessor as bdp

# load in the raw results
with open(read('pathToGoodRuns')) as f:
    goodRuns = cPickle.load(f)

with open('rollFitPercent.p') as f:
    rollFit = cPickle.load(f)

with open('steerFitPercent.p') as f:
    steerFit = cPickle.load(f)

# get the rider, environment, maneuver, duration so we can sort by them
dataset = bdp.DataSet()
dataset.open()

runTable = dataset.database.root.runTable
taskTable = dataset.database.root.taskTable

runIds = [bdp.database.run_id_string(r) for r in goodRuns]

rider = []
environment = []
#!/usr/env python

# Compare the frequency response of the identified models

import sys
sys.path.append('..')
from load_paths import read
import cPickle

import numpy as np
import matplotlib.pyplot as plt
from dtk import bicycle, control

pathToIdMat = read('pathToIdMat')

with open(pathToIdMat) as f:
    idMat = cPickle.load(f)

inputNames = ['$T_\phi$', '$T_\delta$']
stateNames = ['$\phi$', '$\delta$', '$\dot{\phi}$', '$\dot{\delta}$']
outputNames = ['$\phi$', '$\delta$']

C = np.array([[1.0, 0.0, 0.0, 0.0],
              [0.0, 1.0, 0.0, 0.0]])
D = np.array([[0.0, 0.0],
              [0.0, 0.0]])


speeds = [2.0, 5.5, 9.0]

linestyles = ['-'] * 3 + ['--'] * 3 + ['-.'] * 3 + [':'] * 3
subDat = dat.subset(**subDef)

# whipple model
speedRange = np.linspace(0.0, 10.0, num=50)
whipple = model.Whipple('Charlie').matrices(speedRange)

# arm model
m = loadmat('../../data/extensions/armsAB-Charlie.mat', squeeze_me=True) # this is charlie at 101 speeds

inputMats = np.zeros((101, 4, 2))
for i, B in enumerate(m['inputMatrices']):
    inputMats[i] = B[:, 1:]

# best identified model
with open(read('pathToIdMat')) as f:
    idMat = cPickle.load(f)

M, C1, K0, K2, H = idMat['L-P']
speeds = np.linspace(0, 10, num=50)
As = np.zeros((len(speeds), 4, 4))
Bs = np.zeros((len(speeds), 4, 2))

for i, v in enumerate(speeds):
    A, BT = dtk.bicycle.benchmark_state_space(M, C1, K0, K2, v, 9.81)
    As[i] = A
    BF = np.dot(BT[2:, :], H)
    Bs[i] = np.hstack((BT[:, 1].reshape(4,1), np.vstack((np.zeros((2,1)), BF))))

# A matrix box plot
nBins = 25
import sys

sys.path.append("..")
from load_paths import read

import os
import cPickle
import numpy as np
import pandas
import bicycledataprocessor as bdp

# load in the raw results
with open(read("pathToGoodRuns")) as f:
    goodRuns = cPickle.load(f)

with open("rollFitPercent.p") as f:
    rollFit = cPickle.load(f)

with open("steerFitPercent.p") as f:
    steerFit = cPickle.load(f)

# get the rider, environment, maneuver, duration so we can sort by them
dataset = bdp.DataSet()
dataset.open()

runTable = dataset.database.root.runTable
taskTable = dataset.database.root.taskTable

runIds = [bdp.database.run_id_string(r) for r in goodRuns]

rider = []
Ejemplo n.º 8
0
from dtk import bicycle, control
from canonicalbicycleid import canonical_bicycle_id as cbi

goldenRatio = (1.0 + np.sqrt(5.0)) / 2.0
params = {
    "axes.labelsize": 10,
    "axes.grid": False,
    "text.fontsize": 10,
    "legend.fontsize": 8,
    "xtick.labelsize": 8,
    "ytick.labelsize": 8,
    "text.usetex": True,
}
plt.rcParams.update(params)

pathToIdMat = read("pathToIdMat")

with open(pathToIdMat) as f:
    idMat = cPickle.load(f)

# First create all of the plots for the model identified from all riders and
# all environments.
allRiders = ["Charlie", "Jason", "Luke"]
# load M, C1, K0, K2 for each rider
canon = cbi.load_benchmark_canon(allRiders)
# load the H lateral force vector for each rider
H = cbi.lateral_force_contribution(allRiders)

# Eigenvalues versus speed plot.
v0 = 0.0
vf = 10.0
Ejemplo n.º 9
0
m = loadmat('../../data/extensions/armsAB-Charlie.mat', squeeze_me=True) # this is charlie at 101 speeds

inputMats = zeros((101, 4, 1))
for i, B in enumerate(m['inputMatrices']):
    inputMats[i] = B[:, 1].reshape(4, 1)

for lab, ax in coefPlot.axes.items():
    row, col = int(lab[-2]), int(lab[-1])
    if lab[0] == 'a':
        ax.plot(m['speed'], m['stateMatrices'][:, row - 1, col - 1], 'r')
    elif lab[0] == 'b':
        ax.plot(m['speed'], inputMats[:, row - 1, col - 1], 'r')

# now add the model identified from the runs with Luke on the Pavilion floor
# with the canonical realization
with open(read('pathToIdMat')) as f:
    idMat = cPickle.load(f)

M, C1, K0, K2, H = idMat['L-P']
speeds = linspace(0, 10, num=50)
As = zeros((len(speeds), 4, 4))
Bs = zeros((len(speeds), 4, 1))

for i, v in enumerate(speeds):
    A, B = dtk.bicycle.benchmark_state_space(M, C1, K0, K2, v, 9.81)
    As[i] = A
    Bs[i] = B[:, 1].reshape(4, 1)

for lab, ax in coefPlot.axes.items():
    row, col = int(lab[-2]), int(lab[-1])
    if lab[0] == 'a':