bicycleparameters Package

main Module

class Bicycle(bicycleName, pathToData='.', forceRawCalc=False, forcePeriodCalc=False)

Bases: object

An object for a bicycle. A bicycle has parameters and can have a rider attached to it. That’s about it for now.

Methods

add_rider(riderName, reCalc=False, draw=False)

Adds the inertial effects of a rigid rider to the bicycle.

Parameters :

riderName : string

A rider name that corresponds to a folder in <pathToData>/riders/.

reCalc : boolean, optional

If true, the rider parameters will be recalculated.

draw : boolean, optional

If true, visual python will be used to draw a three dimensional image of the rider.

calculate_from_measured(forcePeriodCalc=False)

Calculates the parameters from measured data.

canonical(nominal=False)

Returns the canonical velocity and gravity independent matrices for the Whipple bicycle model linearized about the nominal configuration.

Parameters :

nominal : boolean, optional

The default is false and uarrays are returned with the calculated uncertainties. If true ndarrays are returned without uncertainties.

Returns :

M : uarray, shape(2,2)

Mass matrix.

C1 : uarray, shape(2,2)

Velocity independent damping matrix.

K0 : uarray, shape(2,2)

Gravity independent part of the stiffness matrix.

K2 : uarray, shape(2,2)

Velocity squared independent part of the stiffness matrix.

Notes

The canonical matrices complete the following equation:

M * q’’ + v * C1 * q’ + [g * K0 + v**2 * K2] * q = f

where:

q = [phi, delta] f = [Tphi, Tdelta]
phi
Bicycle roll angle.
delta
Steer angle.
Tphi
Roll torque.
Tdelta
Steer torque.
v
Bicylce speed.

If you have a flywheel defined, body D, it will completely be ignored in these results. These results are strictly for the Whipple bicycle model.

compare_bode_speeds(speeds, u, y, fig=None)

Returns a figure with the Bode plots of multiple bicycles.

Parameters :

speeds : list

A list of speeds at which to evaluate the system.

u : integer

An integer between 0 and 1 corresponding to the inputs roll torque and steer torque.

y : integer

An integer between 0 and 3 corresponding to the inputs roll angle, steer angle, roll rate, steer rate.

Returns :

fig : matplotlib.Figure instance

The Bode plot.

Notes

The phases are matched around zero degrees at with respect to the first frequency.

eig(speeds)

Returns the eigenvalues and eigenvectors of the Whipple bicycle model linearized about the nominal configuration.

Parameters :

speeds : ndarray, shape (n,) or float

The speed at which to calculate the eigenvalues.

Returns :

evals : ndarray, shape (n, 4)

eigenvalues

evecs : ndarray, shape (n, 4, 4)

eigenvectors

Notes

If you have a flywheel defined, body D, it will completely be ignored in these results. These results are strictly for the Whipple bicycle model.

plot_bicycle_geometry(show=True, pendulum=True, centerOfMass=True, inertiaEllipse=True)

Returns a figure showing the basic bicycle geometry, the centers of mass and the moments of inertia.

Notes

If the flywheel is defined, it’s center of mass corresponds to the front wheel and is not depicted in the plot.

plot_bode(speed, u, y, **kwargs)

Returns a Bode plot.

Parameters :

speed : float

The speed at which to evaluate the system.

u : integer

An integer between 0 and 1 corresponding to the inputs roll torque and steer torque.

y : integer

An integer between 0 and 3 corresponding to the inputs roll angle steer angle, roll rate, steer rate.

kwargs : keyword pairs

Any options that can be passed to dtk.bode.

Returns :

mag : ndarray, shape(1000,)

The magnitude in dB of the frequency reponse.

phase : ndarray, shape(1000,)

The phase in degress of the frequency response.

fig : matplotlib figure

The Bode plot.

plot_eigenvalues_vs_speed(speeds, fig=None, generic=False, color='black', show=False, largest=False, linestyle='-')

Returns a plot of the eigenvalues versus speed for the current benchmark parameters.

Parameters :

speeds : ndarray, shape(n,)

An array of speeds to calculate the eigenvalues at.

fig : matplotlib figure, optional

A figure to plot to.

generic : boolean

If true the lines will all be the same color and the modes will not be labeled.

color : matplotlib color

If generic is true this will be the color of the plot lines.

largest : boolean

If true, only the largest eigenvalue is plotted.

Notes

If you have a flywheel defined, body D, it will completely be ignored in these results. These results are strictly for the Whipple bicycle model.

save_parameters(filetype='text')

Saves all the parameter sets to file.

Parameters :

filetype : string, optional

  • ‘text’ : a text file with parameters as `c = 0.10+/-0.01

` :

  • ‘matlab’ : matlab .mat file
  • ‘pickle’ : python pickled dictionary
show_pendulum_photos()

Opens up the pendulum photos in eye of gnome for inspection.

This only works in Linux and if eog is installed. Maybe check pythons xdg-mime model for having this work cross platform.

state_space(speed, nominal=False)

Returns the A and B matrices for the Whipple model linearized about the upright constant velocity configuration.

Parameters :

speed : float

The speed of the bicycle.

nominal : boolean, optional

The default is false and uarrays are returned with the calculated uncertainties. If true ndarrays are returned without uncertainties.

Returns :

A : ndarray, shape(4,4)

The state matrix.

B : ndarray, shape(4,2)

The input matrix.

Notes

A and B describe the Whipple model in state space form:

x’ = A * x + B * u

where

The states are [roll angle,
steer angle, roll rate, steer rate]
The inputs are [roll torque,
steer torque]

If you have a flywheel defined, body D, it will completely be ignored in these results. These results are strictly for the Whipple bicycle model.

steer_assembly_moment_of_inertia(handlebar=True, fork=True, wheel=True, aboutSteerAxis=False, nominal=False)

Returns the inertia tensor of the steer assembly with respect to a reference frame aligned with the steer axis.

Parameters :

handlebar : boolean, optional

If true the handlebar will be included in the calculation.

fork : boolean, optional

If true the fork will be included in the calculation.

wheel : boolean, optional

If true then the wheel will be included in the calculation.

aboutSteerAxis : boolean, optional

If true the inertia tensor will be with respect to a point made from the projection of the center of mass onto the steer axis.

nominal : boolean, optional

If true the nominal values will be returned instead of a uarray.

Returns :

iAss : float

Inertia tensor of the specified steer assembly parts with respect to a reference frame aligned with the steer axis.

Notes

The 3 component is aligned with the steer axis (pointing downward), the 1 component is perpendicular to the steer axis (pointing forward) and the 2 component is perpendicular to the steer axis (pointing to the right).

This function does not currently take into account the flywheel, D, if it is defined, beware.

calculate_benchmark_from_measured(mp)

Returns the benchmark (Meijaard 2007) parameter set based on the measured data.

Parameters :

mp : dictionary

Complete set of measured data.

Returns :

par : dictionary

Benchmark bicycle parameter set.

get_parts_in_parameters(par)

Returns a list of parts in a parameter dictionary.

Parameters :

par : dictionary

Benchmark bicycle parameters.

Returns :

parts : list

Unique list of parts that contain one or more of ‘H’, ‘B’, ‘F’, ‘R’, ‘S’, ‘G’, ‘D’.

is_fork_split(mp)

Returns true if the fork was split into two parts and false if not.

Parameters :

mp : dictionary

The measured data.

Returns :

forkIsSplit : boolean

com Module

cartesian(arrays, out=None)

Generate a cartesian product of input arrays.

Parameters :

arrays : list of array-like

1-D arrays to form the cartesian product of.

out : ndarray

Array to place the cartesian product in.

Returns :

out : ndarray

2-D array of shape (M, len(arrays)) containing cartesian products formed of input arrays.

Examples

>>> cartesian(([1, 2, 3], [4, 5], [6, 7]))
array([[1, 4, 6],
       [1, 4, 7],
       [1, 5, 6],
       [1, 5, 7],
       [2, 4, 6],
       [2, 4, 7],
       [2, 5, 6],
       [2, 5, 7],
       [3, 4, 6],
       [3, 4, 7],
       [3, 5, 6],
       [3, 5, 7]])
center_of_mass(slopes, intercepts)

Returns the center of mass relative to the slopes and intercepts coordinate system.

Parameters :

slopes : ndarray, shape(n,)

The slope of every line used to calculate the center of mass.

intercepts : ndarray, shape(n,)

The intercept of every line used to calculate the center of mass.

Returns :

x : float

The abscissa of the center of mass.

y : float

The ordinate of the center of mass.

com_line(alpha, a, par, part, l1, l2)

Returns the slope and intercept for the line that passes through the part’s center of mass with reference to the benchmark bicycle coordinate system.

Parameters :

alpha : float

The angle the head tube makes with the horizontal. When looking at the bicycle from the right side this is the angle between a vector point out upwards along the steer axis and the earth horizontal with the positve direction pointing from the left to the right. If the bike is in its normal configuration this would be 90 degrees plus the steer axis tilt (lambda).

a : float

The distance from the pendulum axis to a reference point on the part, typically the wheel centers. This is positive if the point falls to the left of the axis and negative otherwise.

par : dictionary

Benchmark parameters. Must include lam, rR, rF, w

part : string

The subscript denoting which part this refers to.

l1, l2 : floats

The location of the handlebar reference point relative to the front wheel center when the fork is split. This is measured perpendicular to and along the steer axis, respectively.

Returns :

m : float

The slope of the line in the benchmark coordinate system.

b : float

The z intercept in the benchmark coordinate system.

part_com_lines(mp, par, forkIsSplit)

Returns the slopes and intercepts for all of the center of mass lines for each part.

Parameters :

mp : dictionary

Dictionary with the measured parameters.

Returns :

slopes : dictionary

Contains a list of slopes for each part.

intercepts : dictionary

Contains a list of intercepts for each part.

The slopes and intercepts lists are in order with respect to each other and :

the keyword is either ‘B’, ‘H’, ‘G’ or ‘S’ for Frame, Handlebar/Fork, :

Handlerbar, and Fork respectively. :

total_com(coordinates, masses)

Returns the center of mass of a group of objects if the indivdual centers of mass and mass is provided.

coordinates : ndarray, shape(3,n)
The rows are the x, y and z coordinates, respectively and the columns are for each object.
masses : ndarray, shape(3,)
An array of the masses of multiple objects, the order should correspond to the columns of coordinates.
Returns :

mT : float

Total mass of the objects.

cT : ndarray, shape(3,)

The x, y, and z coordinates of the total center of mass.

bicycle Module

ab_matrix(M, C1, K0, K2, v, g)

Calculate the A and B matrices for the Whipple bicycle model linearized about the upright configuration.

Parameters :

M : ndarray, shape(2,2)

The mass matrix.

C1 : ndarray, shape(2,2)

The damping like matrix that is proportional to the speed, v.

K0 : ndarray, shape(2,2)

The stiffness matrix proportional to gravity, g.

K2 : ndarray, shape(2,2)

The stiffness matrix proportional to the speed squared, v**2.

v : float

Forward speed.

g : float

Acceleration due to gravity.

Returns :

A : ndarray, shape(4,4)

State matrix.

B : ndarray, shape(4,2)

Input matrix.

The states are [roll angle, :

steer angle, roll rate, steer rate]

The inputs are [roll torque, :

steer torque]

benchmark_par_to_canonical(p)

Returns the canonical matrices of the Whipple bicycle model linearized about the upright constant velocity configuration. It uses the parameter definitions from Meijaard et al. 2007.

Parameters :

p : dictionary

A dictionary of the benchmark bicycle parameters. Make sure your units are correct, best to ue the benchmark paper’s units!

Returns :

M : ndarray, shape(2,2)

The mass matrix.

C1 : ndarray, shape(2,2)

The damping like matrix that is proportional to the speed, v.

K0 : ndarray, shape(2,2)

The stiffness matrix proportional to gravity, g.

K2 : ndarray, shape(2,2)

The stiffness matrix proportional to the speed squared, v**2.

Notes

This function handles parameters with uncertanties.

lambda_from_abc(rF, rR, a, b, c)

Returns the steer axis tilt, lamba, for the parameter set based on the offsets from the steer axis.

Parameters :

rF : float or ufloat

Front wheel radius.

rR : float or ufloat

Rear wheel radius.

a : float or ufloat

The rear wheel offset. The minimum distance from the steer axis to the center of the rear wheel.

b : float or ufloat

The front wheel offset. The minimum distance from the steer axis to the center of the front wheel.

c : float or ufloat

The steer axis distance. The distance along the steer axis between the intersection of the front and rear wheel offset lines.

sort_modes(evals, evecs)

Sort eigenvalues and eigenvectors into weave, capsize, caster modes.

Parameters :

evals : ndarray, shape (n, 4)

eigenvalues

evecs : ndarray, shape (n, 4, 4)

eigenvectors

Returns :

weave[‘evals’] : ndarray, shape (n, 2)

The eigen value pair associated with the weave mode.

weave[‘evecs’] : ndarray, shape (n, 4, 2)

The associated eigenvectors of the weave mode.

capsize[‘evals’] : ndarray, shape (n,)

The real eigenvalue associated with the capsize mode.

capsize[‘evecs’] : ndarray, shape(n, 4, 1)

The associated eigenvectors of the capsize mode.

caster[‘evals’] : ndarray, shape (n,)

The real eigenvalue associated with the caster mode.

caster[‘evecs’] : ndarray, shape(n, 4, 1)

The associated eigenvectors of the caster mode.

Notes

This only works on the standard bicycle eigenvalues, not necessarily on any general eigenvalues for the bike model (e.g. there isn’t always a distinct weave, capsize and caster). Some type of check using the derivative of the curves could make it more robust.

trail(rF, lam, fo)

Calculate the trail and mechanical trail.

Parameters :

rF : float

The front wheel radius

lam : float

The steer axis tilt (pi/2 - headtube angle). The angle between the headtube and a vertical line.

fo : float

The fork offset

Returns :

c: float :

Trail

cm: float :

Mechanical Trail

geometry Module

Solves a simple case of the two-link revolute joint inverse kinematics problem. Both output angles are positive. The simple case is taht the end of the second link lies on the x-axis.

Parameters :

L1 : float

Length of the first link.

L2 : float

Length of the second link.

D : float

Distance from the base of first link to the end of the second link.

Returns :

theta1 : float

(radians) Angle between x-axis and first link; always positive.

theta2 : float

(radians) Angle between first link and second link; always positive.

calculate_abc_geometry(h, d)

Returns the perpendicular distance geometry for the bicycle from the raw measurements.

Parameters :

h : tuple

Tuple containing the measured parameters h1-h5. (h1, h2, h3, h4, h5)

d : tuple

Tuple containing the measured parameters d1-d4 and d. (d1, d2, d3, d4, d)

Returns :

a : ufloat or float

The rear frame offset.

b : ufloat or float

The fork offset.

c : ufloat or float

The steer axis distance.

calculate_benchmark_geometry(mp, par)

Returns the wheelbase, steer axis tilt and the trail.

Parameters :

mp : dictionary

Dictionary with the measured parameters.

par : dictionary

Dictionary with the benchmark parameters.

Returns :

par : dictionary

par with the benchmark geometry added.

calculate_l1_l2(h6, h7, d5, d6, l)

Returns the distance along (l2) and perpendicular (l1) to the steer axis from the front wheel center to the handlebar reference point.

Parameters :

h6 : float

Distance from the table to the top of the front axle.

h7 : float

Distance from the table to the top of the handlebar reference circle.

d5 : float

Diameter of the front axle.

d6 : float

Diameter of the handlebar reference circle.

l : float

Outer distance from the front axle to the handlebar reference circle.

Returns :

l1 : float

The distance from the front wheel center to the handlebar reference center perpendicular to the steer axis. The positive sense is if the handlebar reference point is more forward than the front wheel center relative to the steer axis normal.

l2 : float

The distance from the front wheel center to the handlebar reference center parallel to the steer axis. The positive sense is if the handlebar reference point is above the front wheel center with reference to the steer axis.

distance_to_steer_axis(w, c, lam, point)

Returns the minimal distance from the steer axis to the given point when the bicycle is in the nominal configuration.

Parameters :

w : float or ufloat

Wheelbase.

c : float or ufloat

Trail.

lam : float or ufloat

Steer axis tilt in radians.

point : narray, shape(3,)

A point that lies in the symmetry plane of the bicycle.

Returns :

d : float or ufloat

The minimal distance from the given point to the steer axis.

fundamental_geometry_plot_data(par)

Returns the coordinates for line end points of the bicycle fundamental geometry.

Parameters :

par : dictionary

Benchmark bicycle parameters.

Returns :

x : ndarray

z : ndarray

fwheel_to_handlebar_ref(lam, l1, l2)

Returns the distance along the benchmark coordinates from the front wheel center to the handlebar reference center.

Parameters :

lam : float

Steer axis tilt.

l1, l2 : float

The distance from the front wheel center to the handlebar refernce center perpendicular to and along the steer axis.

Returns :

u1, u2 : float

point_to_line_distance(point, pointsOnLine)

Returns the minimal distance from a point to a line in three dimensional space.

Parameters :

point : ndarray, shape(3,)

The x, y, and z coordinates of a point.

pointsOnLine : ndarray, shape(3,2)

The x, y, and z coordinates of two points on a line. Rows are coordinates and columns are points.

Returns :

distance : float

The minimal distance from the line to the point.

project_point_on_line(line, point)

Returns point of projection.

Parameters :

line : tuple

Slope and intercept of the line.

point : tuple

Location of the point.

Returns :

newPoint : tuple

The location of the projected point.

vec_angle(v1, v2)

Returns the interior angle between two vectors using the dot product. Inputs do not need to be unit vectors.

Parameters :

v1 : np.array (3,1)

input vector.

v2 : np.array (3,1)

input vector.

Returns :

angle : float

(radians) interior angle between v1 and v2.

vec_project(vec, direction)

Vector projection into a plane, where the plane is defined by a normal vector.

Parameters :

vec : np.array(3,1)

vector to be projected into a plane

direction : int or np.array, shape(3,)

If int, it is one of the three orthogonal directions, (0,1 or 2) of the input vector (essentially, that component of vec is set to zero). If np.array, can be in any direction (not necessarily a coordinate direction).

Returns :

vec_out : np.array(3,1)

Projected vector.

inertia Module

combine_bike_rider(bicyclePar, riderPar)

Combines the inertia of the bicycle frame with the inertia of a rider.

Parameters :

bicyclePar : dictionary

The benchmark parameter set of a bicycle.

riderPar : dictionary

The rider’s mass, center of mass, and inertia expressed in the benchmark bicycle reference frame.

Returns :

bicyclePar : dictionary

The benchmark bicycle parameters with a rigid rider added to the bicycle frame.

compound_pendulum_inertia(m, g, l, T)

Returns the moment of inertia for an object hung as a compound pendulum.

Parameters :

m : float

Mass of the pendulum.

g : float

Acceration due to gravity.

l : float

Length of the pendulum.

T : float

The period of oscillation.

Returns :

I : float

Moment of interia of the pendulum.

inertia_components(jay, beta)

Returns the 2D orthogonal inertia tensor.

When at least three moments of inertia and their axes orientations are known relative to a common inertial frame of a planar object, the orthoganl moments of inertia relative the frame are computed.

Parameters :

jay : ndarray, shape(n,)

An array of at least three moments of inertia. (n >= 3)

beta : ndarray, shape(n,)

An array of orientation angles corresponding to the moments of inertia in jay.

Returns :

eye : ndarray, shape(3,)

Ixx, Ixz, Izz

parallel_axis(Ic, m, d)

Returns the moment of inertia of a body about a different point.

Parameters :

Ic : ndarray, shape(3,3)

The moment of inertia about the center of mass of the body with respect to an orthogonal coordinate system.

m : float

The mass of the body.

d : ndarray, shape(3,)

The distances along the three ordinates that located the new point relative to the center of mass of the body.

Returns :

I : ndarray, shape(3,3)

The moment of inertia about of the body about a point located by d.

part_inertia_tensor(par, part)

Returns an inertia tensor for a particular part for the benchmark parameter set.

Parameters :

par : dictionary

Complete Benchmark parameter set.

part : string

Either ‘B’, ‘H’, ‘F’, ‘R’, ‘G’, ‘S’, ‘D’

Returns :

I : ndarray, shape(3,3)

Inertia tensor for the part.

Notes

Parts G, S, and D are additional parts not included in the published paper on the benchmark bicycle, they are only relavant if used. See the documentation.

principal_axes(I)

Returns the principal moments of inertia and the orientation.

Parameters :

I : ndarray, shape(3,3)

An inertia tensor.

Returns :

Ip : ndarray, shape(3,)

The principal moments of inertia. This is sorted smallest to largest.

C : ndarray, shape(3,3)

The rotation matrix.

rotate_inertia_tensor(I, angle)

Returns inertia tensor rotated through angle. Only for 2D

tor_inertia(k, T)

Calculate the moment of inertia for an ideal torsional pendulm

Parameters :

k: torsional stiffness :

T: period :

Returns :

I: moment of inertia :

torsional_pendulum_stiffness(I, T)

Calculate the stiffness of a torsional pendulum with a known moment of inertia.

Parameters :

I : moment of inertia

T : period

Returns :

k : stiffness

tube_inertia(l, m, ro, ri)

Calculate the moment of inertia for a tube (or rod) where the x axis is aligned with the tube’s axis.

Parameters :

l : float

The length of the tube.

m : float

The mass of the tube.

ro : float

The outer radius of the tube.

ri : float

The inner radius of the tube. Set this to zero if it is a rod instead of a tube.

Returns :

Ix : float

Moment of inertia about tube axis.

Iy, Iz : float

Moment of inertia about normal axis.

io Module

filename_to_dict(filename)

Returns a dictionay of values based on the pendulum data file name.

load_parameter_text_file(pathToFile)

Returns a dictionary of float and/or ufloat parameters from a parameter file.

Parameters :

pathToFile : string

The path to the text file with the parameters listed in the specified format.

Returns :

parameters : dictionary

A dictionary of the values stored in the text files.

For example:: :

c = 0.08 +/- 0.01 d=0.314+/-0.002 t = 0.1+/-0.01, 0.12+/-0.02 whb = 0.5

The first item on the line must be the variable name and the second is an :

equals sign. The values to the right of the equal sign much may or may not :

contain an uncertainty designated by `+/-`. Multiple comma seperated values :

will be averaged. :

load_pendulum_mat_file(pathToFile)

Returns a dictionay containing the data from the pendulum data mat file.

remove_uncertainties(dictionary)

Returns a dictionary with the uncertainties removed.

space_out_camel_case(s, output='string')

Adds spaces to a camel case string. Failure to space out string returns the original string.

Examples

>>> space_out_camel_case('DMLSServicesOtherBSTextLLC')
'DMLS Services Other BS Text LLC'
>>> space_out_camel_case('DMLSServicesOtherBSTextLLC', output='list')
['DMLS', 'Services', 'Other', 'BS', 'Text', 'LLC']
write_parameter_text_file(pathToTxtFile, parDict)

Writes parameter set to file.

Parameters :

pathToTxtFile : string

The path to the file to write the parameters.

pardict : dictionary

A dictionary of parameters for the bicycle.

Returns :

saved : boolean

True if the file was saved and false if not.

write_periods_to_file(pathToRawFile, mp)

Writes the provided periods to file.

Parameters :

pathToRawFile : string

The path to the <bicycle name>Measured.txt file

mp : dictionary

The measured parameters dictionary. Should contain complete period data.

period Module

average_rectified_sections(data)

Returns a slice of an oscillating data vector based on the max and min of the mean of the sections created by retifiying the data.

Parameters :

data : ndarray, shape(n,)

Returns :

data : ndarray, shape(m,)

A slice where m is typically less than n.

Notes

This is a function to try to handle the fact that some of the data from the torsional pendulum had a beating like phenomena and we only want to select a section of the data that doesn’t seem to exhibit the phenomena.

calc_periods_for_files(directory, filenames, forkIsSplit)

Calculates the period for all filenames in directory.

Parameters :

directory : string

This is the path to the RawData directory.

filenames : list

List of all the mat file names in the RawData directory.

forkIsSplit : boolean

True if the fork is broken into a handlebar and fork and false if the fork and handlebar was measured together.

Returns :

periods : dictionary

Contains all the periods for the mat files in the RawData directory.

check_for_period(mp, forkIsSplit)

Returns whether the fork is split into two pieces and whether the period calculations need to happen again.

Parameters :

mp : dictionary

Dictionary the measured parameters.

forkIsSplit : boolean

True if the fork is broken into a handlebar and fork and false if the fork and handlebar was measured together.

Returns :

forcePeriodCalc : boolean

True if there wasn’t enough period data in mp, false if there was.

forkIsSplit : boolean

True if the fork is broken into a handlebar and fork and false if the fork and handlebar was measured together.

fit_goodness(ym, yp)

Calculate the goodness of fit.

Parameters :

ym : ndarray, shape(n,)

The vector of measured values.

yp : ndarry, shape(n,)

The vector of predicted values.

Returns :

rsq : float

The r squared value of the fit.

SSE : float

The error sum of squares.

SST : float

The total sum of squares.

SSR : float

The regression sum of squares.

get_period(data, sampleRate, pathToPlotFile)

Returns the period and uncertainty for data resembling a decaying oscillation.

Parameters :

data : ndarray, shape(n,)

A time series that resembles a decaying oscillation.

sampleRate : int

The frequency that data was sampled at.

pathToPlotFile : string

A path to the file to print the plots.

Returns :

T : ufloat

The period of oscillation and its uncertainty.

get_period_from_truncated(data, sampleRate, pathToPlotFile)
get_period_key(matData, forkIsSplit)

Returns a dictionary key for the period entries.

Parameters :

matData : dictionary

The data imported from a pendulum mat file.

forkIsSplit : boolean

True if the fork is broken into a handlebar and fork and false if the fork and handlebar was measured together.

Returns :

key : string

A key of the form ‘T[pendulum][part][orientation]’. For example, if it is the frame that was hung as a torsional pendulum at the second orientation angle then the key would be ‘TtB2’.

get_sample_rate(matData)

Returns the sample rate for the data.

jac_fitfunc(p, t)

Calculate the Jacobian of a decaying oscillation function.

Uses the analytical formulations of the partial derivatives.

Parameters :

p : the five parameters of the equation

t : time vector

Returns :

jac : The jacobian, the partial of the vector function with respect to the

parameters vector. A 5 x N matrix where N is the number of time steps. :

make_guess(data, sampleRate)

Returns a decent starting point for fitting the decaying oscillation function.

plot_osfit(t, ym, yf, p, rsq, T, m=None, fig=None)

Plot fitted data over the measured

Parameters :

t : ndarray (n,)

Measurement time in seconds

ym : ndarray (n,)

The measured voltage

yf : ndarray (n,)

p : ndarray (5,)

The fit parameters for the decaying osicallation fucntion

rsq : float

The r squared value of y (the fit)

T : float

The period

m : float

The maximum value to plot

Returns :

fig : the figure

select_good_data(data, percent)

Returns a slice of the data from the index at maximum value to the index at a percent of the maximum value.

Parameters :

data : ndarray, shape(1,)

This should be a decaying function.

percent : float

The percent of the maximum to clip.

This basically snips of the beginning and end of the data so that the super :

damped tails are gone and also any weirdness at the beginning. :

plot Module

compare_bode_bicycles(bikes, speed, u, y, fig=None)

Returns a figure with the Bode plots of multiple bicycles.

Parameters :

bikes : list

A list of bicycleparameters.Bicycle instances.

speed : float

The speed at which to evaluate the system.

u : integer

An integer between 0 and 1 corresponding to the inputs roll torque and steer torque.

y : integer

An integer between 0 and 3 corresponding to the inputs roll rate, steer rate, roll angle and steer angle.

Returns :

fig : matplotlib.Figure instance

The Bode plot.

Notes

The phases are matched around zero degrees at with respect to the first frequency.

plot_eigenvalues(bikes, speeds, colors=None, linestyles=None, largest=False, show=False)

Returns a figure with the eigenvalues vs speed for multiple bicycles.

Parameters :

bikes : list

A list of Bicycle objects.

speeds : ndarray, shape(n,)

An array of speeds.

colors : list

A list of matplotlib colors for each bicycle.

linestyles : list

A list of matplotlib linestyles for each bicycle.

largest : boolean

If true, only plots the largest eigenvalue.

Returns :

fig : matplotlib figure

rider Module

configure_rider(pathToRider, bicycle, bicyclePar, measuredPar, draw)

Returns the rider parameters, bicycle paramaters with a rider and a human object that is configured to sit on the bicycle.

Parameters :

pathToRider : string

Path to the rider’s data folder.

bicycle : string

The short name of the bicycle.

bicyclePar : dictionary

Contains the benchmark bicycle parameters for a bicycle.

measuredPar : dictionary

Contains the measured values of the bicycle.

draw : boolean, optional

If true, visual python will be used to draw a three dimensional image of the rider.

Returns :

riderpar : dictionary

The inertial parameters of the rider with reference to the benchmark coordinate system.

human : yeadon.human

The human object that represents the rider seated on the bicycle.

bicycleRiderPar : dictionary

The benchmark parameters of the bicycle with the rider added to the rear frame.

rider_on_bike(benchmarkPar, measuredPar, yeadonMeas, yeadonCFG, drawrider)

Returns a yeadon human configured to sit on a bicycle.

Parameters :

benchmarkPar : dictionary

A dictionary containing the benchmark bicycle parameters.

measuredPar : dictionary

A dictionary containing the raw geometric measurements of the bicycle.

yeadonMeas : str

Path to a text file that holds the 95 yeadon measurements. See yeadon documentation.

yeadonCFG : str

Path to a text file that holds configuration variables. See yeadon documentation. As of now, only ‘somersalt’ angle can be set as an input. The remaining variables are either zero or calculated in this method.

drawrider : bool

Switch to draw the rider, with vectors pointing to the desired position of the hands and feet of the rider (at the handles and bottom bracket). Requires python-visual.

Returns :

human : yeadon.Human

Human object is returned with an updated configuration. The dictionary, taken from H.CFG, has the following key’s values updated:

‘PJ1extension’ ‘J1J2flexion’ ‘CA1extension’ ‘CA1adduction’ ‘CA1rotation’ ‘A1A2extension’ ‘somersault’ ‘PK1extension’ ‘K1K2flexion’ ‘CB1extension’ ‘CB1abduction’ ‘CB1rotation’ ‘B1B2extension’

Notes

Requires that the bike object has a raw data text input file that contains the measurements necessary to situate a rider on the bike (i.e. <pathToData>/bicycles/<short name>/RawData/<short name>Measurements.txt).

yeadon_vec_to_bicycle_vec(vector, measured_bicycle_par, benchmark_bicycle_par)
Parameters :

vector : np.matrix, shape(3, 1)

A vector from the Yeadon origin to a point expressed in the Yeadon reference frame.

measured_bicycle_par : dictionary

The raw bicycle measurements.

benchmark_bicycle_par : dictionary

The Meijaard 2007 et. al parameters for this bicycle.

Returns :

vector_wrt_bike : np.matrix, shape(3, 1)

The vector from the bicycle origin to the same point above expressed in the bicycle reference frame.

tables Module

class Table(source, latex, bicycles)

A class for generating tables of the measurment and parameter data associated with a bicycle.

Methods

create_rst_table(fileName=None)

Returns a reStructuredText version of the table.

Parameters :

fileName : string

If a path to a file is given, the table will be written to that file.

Returns :

rstTable : string

reStructuredText version of the table.

generate_table_data()

Generates a list of data for a table.

generate_variable_list()
to_latex(var)

Returns a latex representation for a given variable string name.

Parameters :

var : string

One of the variable names used in the bicycleparameters package.

Returns :

latex : string

A string formatting for pretty LaTeX math print.

uround(value)

Returns a string representation of a value with an uncertainity which has been rounded to significant digits based on the uncertainty value.

Parameters :

value : ufloat

A single ufloat.

Returns :

s : string

A rounded string representation of value.

2.4563752289999+/-0.0003797273827 :

becomes :

2.4564+/-0.0004 :

This probably doesn’t work for weird cases like large uncertainties. :