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')
        plt.close(fig)
        del fig

    M, C1, K0, K2 = trial.bicycle.canonical(nominal=True)
    rollrsq, steerrsq, fig = cbi.input_prediction(timeseries, (M, C1, K0, K2,
            allH[rider]))
    roll['Whipple'].append(rollrsq)
    steer['Whipple'].append(steerrsq)
    fig.savefig('plots/' + str(runNum) + '-whipple.png')
    plt.close(fig)
    del fig

    v = timeseries['v'].mean()
    A, B, speeds = cbi.mean_arm([rider])
    M = np.linalg.inv(B[round(v * 10)][2:, [0, 1]])
    C = -np.dot(M, A[round(v * 10)][2:, [2, 3]])
    K = -np.dot(M, A[round(v * 10)][2:, [0, 1]])
    rollrsq, steerrsq, fig = cbi.input_prediction(timeseries, (M, C, K,
            allH[rider]))
    roll['Arm'].append(rollrsq)
    steer['Arm'].append(steerrsq)
    fig.savefig('plots/' + str(runNum) + '-arm.png')
    plt.close(fig)
    del fig
    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')
        plt.close(fig)
        del fig

    M, C1, K0, K2 = trial.bicycle.canonical(nominal=True)
    rollrsq, steerrsq, fig = cbi.input_prediction(timeseries,
                                                  (M, C1, K0, K2, allH[rider]))
    roll['Whipple'].append(rollrsq)
    steer['Whipple'].append(steerrsq)
    fig.savefig('plots/' + str(runNum) + '-whipple.png')
    plt.close(fig)
    del fig

    v = timeseries['v'].mean()
    A, B, speeds = cbi.mean_arm([rider])
    M = np.linalg.inv(B[round(v * 10)][2:, [0, 1]])
    C = -np.dot(M, A[round(v * 10)][2:, [2, 3]])
    K = -np.dot(M, A[round(v * 10)][2:, [0, 1]])
    rollrsq, steerrsq, fig = cbi.input_prediction(timeseries,
                                                  (M, C, K, allH[rider]))
    roll['Arm'].append(rollrsq)
    steer['Arm'].append(steerrsq)
    fig.savefig('plots/' + str(runNum) + '-arm.png')
    plt.close(fig)
    del fig
def plot(canon, H, riders, environments, idMats):
    filename = ''
    for rider in riders:
        filename += '-' + rider
    for env in environments:
        filename += '-' + env.replace(' ', '')

    filename = '../plots/' + filename[1:]

    print filename

    v0 = 0.
    vf = 10.
    num = 100

    # identified
    iM, iC1, iK0, iK2, iH = idMats
    speeds, iAs, iBs = bicycle.benchmark_state_space_vs_speed(iM, iC1, iK0, iK2,
            v0=v0, vf=vf, num=num)
    w, v = control.eigen_vs_parameter(iAs)
    iEigenvalues, iEigenvectors = control.sort_modes(w, v)

    # whipple model (mean)
    wM, wC1, wK0, wK2, wH = cbi.mean_canon(riders, canon, H)
    speeds, wAs, wBs = bicycle.benchmark_state_space_vs_speed(wM, wC1, wK0, wK2,
            v0=v0, vf=vf, num=num)
    w, v = control.eigen_vs_parameter(wAs)
    wEigenvalues, wEigenvectors = control.sort_modes(w, v)

    # arm model (mean)
    aAs, aBs, aSpeed = cbi.mean_arm(riders)
    indices = np.int32(np.round(speeds * 10))
    w, v = control.eigen_vs_parameter(aAs[indices])
    aEigenvalues, aEigenvectors = control.sort_modes(w, v)

    # eigenvalue plot
    rlfig = cbi.plot_rlocus_parts(speeds, iEigenvalues, wEigenvalues,
            aEigenvalues)
    rlfig.savefig(filename + '-eig.png')

    # root locus
    v0 = 0.
    vf = 10.
    num = 20
    speeds, iAs, iBs = bicycle.benchmark_state_space_vs_speed(iM, iC1, iK0, iK2,
            v0=v0, vf=vf, num=num)
    iEig, null = control.eigen_vs_parameter(iAs)

    speeds, wAs, wBs = bicycle.benchmark_state_space_vs_speed(wM, wC1, wK0, wK2,
            v0=v0, vf=vf, num=num)
    wEig, null = control.eigen_vs_parameter(wAs)

    indices = np.int32(np.round(speeds * 10))
    aEig, null = control.eigen_vs_parameter(aAs[indices])
    rlcfig = cbi.plot_rlocus(speeds, iEig, wEig, aEig)
    rlcfig.savefig(filename + '-rlocus.png')

    # bode plots
    speeds = np.array([2.0, 4.0, 6.0, 9.0])
    null, iAs, iBs = bicycle.benchmark_state_space_vs_speed(iM, iC1, iK0, iK2,
            speeds)
    null, wAs, wBs = bicycle.benchmark_state_space_vs_speed(wM, wC1, wK0, wK2,
            speeds)
    figs = cbi.plot_bode(speeds, iAs, iBs, wAs, wBs, aAs, aBs)
    figs[0].savefig(filename + '-Tphi.png')
    figs[1].savefig(filename + '-Tdel.png')
iEigenvalues, iEigenvectors = control.sort_modes(w, v)

# whipple model (mean)
wM, wC1, wK0, wK2, wH = cbi.mean_canon(allRiders, canon, H)
speeds, wAs, wBs = bicycle.benchmark_state_space_vs_speed(wM,
                                                          wC1,
                                                          wK0,
                                                          wK2,
                                                          v0=v0,
                                                          vf=vf,
                                                          num=num)
w, v = control.eig_of_series(wAs)
wEigenvalues, wEigenvectors = control.sort_modes(w, v)

# arm model (mean)
aAs, aBs, aSpeed = cbi.mean_arm(allRiders)
indices = np.int32(np.round(speeds * 10))
w, v = control.eig_of_series(aAs[indices])
aEigenvalues, aEigenvectors = control.sort_modes(w, v)

rlfig = cbi.plot_rlocus_parts(speeds, iEigenvalues, wEigenvalues, aEigenvalues)
rlfig.set_size_inches(5., 5. / goldenRatio)
rlfig.savefig('../../figures/systemidentification/A-A-eig.png')
rlfig.savefig('../../figures/systemidentification/A-A-eig.pdf')

# Root locus with respect to speed.
v0 = 0.
vf = 10.
num = 20
speeds, iAs, iBs = bicycle.benchmark_state_space_vs_speed(iM,
                                                          iC1,
Exemplo n.º 5
0
# the eigenvalues and eigenvectors as a function of speed.
wM, wC1, wK0, wK2 = cbi.load_benchmark_canon(['Luke'])['Luke']
wH = cbi.lateral_force_contribution(['Luke'])['Luke']
speeds, wAs, wBs = bicycle.benchmark_state_space_vs_speed(wM,
                                                          wC1,
                                                          wK0,
                                                          wK2,
                                                          v0=v0,
                                                          vf=vf,
                                                          num=num)
w, v = control.eig_of_series(wAs)
wEigenvalues, wEigenvectors = control.sort_modes(w, v)

# Load the Arm model state space for each rider from first principles and
# generate the eigenvalues and eigenvectors as a function of speed.
aAs, aBs, aSpeed = cbi.mean_arm(['Luke'])
indices = np.int32(np.round(speeds * 10))
w, v = control.eig_of_series(aAs[indices])
aEigenvalues, aEigenvectors = control.sort_modes(w, v)

rlfig = cbi.plot_rlocus_parts(speeds, iEigenvalues, wEigenvalues, aEigenvalues)
rlfig.axes[0].set_ylabel('')
rlfig.set_size_inches(4.0, 4.0 / goldenRatio)
plt.tight_layout()
rlfig.savefig('../figures/L-P-eig.pdf')

# Root locus with respect to speed.
v0 = 0.
vf = 10.
num = 20
speeds, iAs, iBs = bicycle.benchmark_state_space_vs_speed(iM,
Exemplo n.º 6
0
w, v = control.eig_of_series(iAs)
iEigenvalues, iEigenvectors = control.sort_modes(w, v)

# Load the Whipple model M, C1, K0, K2, H from first principles and generate
# the eigenvalues and eigenvectors as a function of speed.
wM, wC1, wK0, wK2 = cbi.load_benchmark_canon(['Luke'])['Luke']
wH = cbi.lateral_force_contribution(['Luke'])['Luke']
speeds, wAs, wBs = bicycle.benchmark_state_space_vs_speed(wM, wC1, wK0, wK2,
                                                          v0=v0, vf=vf,
                                                          num=num)
w, v = control.eig_of_series(wAs)
wEigenvalues, wEigenvectors = control.sort_modes(w, v)

# Load the Arm model state space for each rider from first principles and
# generate the eigenvalues and eigenvectors as a function of speed.
aAs, aBs, aSpeed = cbi.mean_arm(['Luke'])
indices = np.int32(np.round(speeds * 10))
w, v = control.eig_of_series(aAs[indices])
aEigenvalues, aEigenvectors = control.sort_modes(w, v)

rlfig = cbi.plot_rlocus_parts(speeds, iEigenvalues, wEigenvalues,
                              aEigenvalues)
rlfig.axes[0].set_ylabel('')
rlfig.set_size_inches(4.0, 4.0 / goldenRatio)
plt.tight_layout()
rlfig.savefig('../figures/L-P-eig.pdf')

# Root locus with respect to speed.
v0 = 0.
vf = 10.
num = 20
Exemplo n.º 7
0
num = 100

# identified for all rider and all environments
iM, iC1, iK0, iK2, iH = idMat["A-A"]
speeds, iAs, iBs = bicycle.benchmark_state_space_vs_speed(iM, iC1, iK0, iK2, v0=v0, vf=vf, num=num)
w, v = control.eig_of_series(iAs)
iEigenvalues, iEigenvectors = control.sort_modes(w, v)

# whipple model (mean)
wM, wC1, wK0, wK2, wH = cbi.mean_canon(allRiders, canon, H)
speeds, wAs, wBs = bicycle.benchmark_state_space_vs_speed(wM, wC1, wK0, wK2, v0=v0, vf=vf, num=num)
w, v = control.eig_of_series(wAs)
wEigenvalues, wEigenvectors = control.sort_modes(w, v)

# arm model (mean)
aAs, aBs, aSpeed = cbi.mean_arm(allRiders)
indices = np.int32(np.round(speeds * 10))
w, v = control.eig_of_series(aAs[indices])
aEigenvalues, aEigenvectors = control.sort_modes(w, v)

rlfig = cbi.plot_rlocus_parts(speeds, iEigenvalues, wEigenvalues, aEigenvalues)
rlfig.set_size_inches(5.0, 5.0 / goldenRatio)
rlfig.savefig("../../figures/systemidentification/A-A-eig.png")
rlfig.savefig("../../figures/systemidentification/A-A-eig.pdf")

# Root locus with respect to speed.
v0 = 0.0
vf = 10.0
num = 20
speeds, iAs, iBs = bicycle.benchmark_state_space_vs_speed(iM, iC1, iK0, iK2, v0=v0, vf=vf, num=num)
iEig, null = control.eig_of_series(iAs)