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
Adds the inertial effects of a rigid rider to the bicycle.
Parameters : | riderName : string
reCalc : boolean, optional
draw : boolean, optional
|
---|
Calculates the parameters from measured data.
Returns the canonical velocity and gravity independent matrices for the Whipple bicycle model linearized about the nominal configuration.
Parameters : | nominal : boolean, optional
|
---|---|
Returns : | M : uarray, shape(2,2)
C1 : uarray, shape(2,2)
K0 : uarray, shape(2,2)
K2 : uarray, shape(2,2)
|
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]
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.
Returns a figure with the Bode plots of multiple bicycles.
Parameters : | speeds : list
u : integer
y : integer
|
---|---|
Returns : | fig : matplotlib.Figure instance
|
Notes
The phases are matched around zero degrees at with respect to the first frequency.
Returns the eigenvalues and eigenvectors of the Whipple bicycle model linearized about the nominal configuration.
Parameters : | speeds : ndarray, shape (n,) or float
|
---|---|
Returns : | evals : ndarray, shape (n, 4)
evecs : ndarray, shape (n, 4, 4)
|
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.
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.
Returns a Bode plot.
Parameters : | speed : float
u : integer
y : integer
kwargs : keyword pairs
|
---|---|
Returns : | mag : ndarray, shape(1000,)
phase : ndarray, shape(1000,)
fig : matplotlib figure
|
Returns a plot of the eigenvalues versus speed for the current benchmark parameters.
Parameters : | speeds : ndarray, shape(n,)
fig : matplotlib figure, optional
generic : boolean
color : matplotlib color
largest : boolean
|
---|
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.
Saves all the parameter sets to file.
Parameters : | filetype : string, optional
` :
|
---|
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.
Returns the A and B matrices for the Whipple model linearized about the upright constant velocity configuration.
Parameters : | speed : float
nominal : boolean, optional
|
---|---|
Returns : | A : ndarray, shape(4,4)
B : ndarray, shape(4,2)
|
Notes
A and B describe the Whipple model in state space form:
x’ = A * x + B * u
where
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.
Returns the inertia tensor of the steer assembly with respect to a reference frame aligned with the steer axis.
Parameters : | handlebar : boolean, optional
fork : boolean, optional
wheel : boolean, optional
aboutSteerAxis : boolean, optional
nominal : boolean, optional
|
---|---|
Returns : | iAss : float
|
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.
Returns the benchmark (Meijaard 2007) parameter set based on the measured data.
Parameters : | mp : dictionary
|
---|---|
Returns : | par : dictionary
|
Returns a list of parts in a parameter dictionary.
Parameters : | par : dictionary
|
---|---|
Returns : | parts : list
|
Returns true if the fork was split into two parts and false if not.
Parameters : | mp : dictionary
|
---|---|
Returns : | forkIsSplit : boolean |
Generate a cartesian product of input arrays.
Parameters : | arrays : list of array-like
out : ndarray
|
---|---|
Returns : | out : ndarray
|
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]])
Returns the center of mass relative to the slopes and intercepts coordinate system.
Parameters : | slopes : ndarray, shape(n,)
intercepts : ndarray, shape(n,)
|
---|---|
Returns : | x : float
y : float
|
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
a : float
par : dictionary
part : string
l1, l2 : floats
|
---|---|
Returns : | m : float
b : float
|
Returns the slopes and intercepts for all of the center of mass lines for each part.
Parameters : | mp : dictionary
|
---|---|
Returns : | slopes : dictionary
intercepts : dictionary
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. : |
Returns the center of mass of a group of objects if the indivdual centers of mass and mass is provided.
Returns : | mT : float
cT : ndarray, shape(3,)
|
---|
Calculate the A and B matrices for the Whipple bicycle model linearized about the upright configuration.
Parameters : | M : ndarray, shape(2,2)
C1 : ndarray, shape(2,2)
K0 : ndarray, shape(2,2)
K2 : ndarray, shape(2,2)
v : float
g : float
|
---|---|
Returns : | A : ndarray, shape(4,4)
B : ndarray, shape(4,2)
The states are [roll angle, :
The inputs are [roll torque, :
|
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
|
---|---|
Returns : | M : ndarray, shape(2,2)
C1 : ndarray, shape(2,2)
K0 : ndarray, shape(2,2)
K2 : ndarray, shape(2,2)
|
Notes
This function handles parameters with uncertanties.
Returns the steer axis tilt, lamba, for the parameter set based on the offsets from the steer axis.
Parameters : | rF : float or ufloat
rR : float or ufloat
a : float or ufloat
b : float or ufloat
c : float or ufloat
|
---|
Sort eigenvalues and eigenvectors into weave, capsize, caster modes.
Parameters : | evals : ndarray, shape (n, 4)
evecs : ndarray, shape (n, 4, 4)
|
---|---|
Returns : | weave[‘evals’] : ndarray, shape (n, 2)
weave[‘evecs’] : ndarray, shape (n, 4, 2)
capsize[‘evals’] : ndarray, shape (n,)
capsize[‘evecs’] : ndarray, shape(n, 4, 1)
caster[‘evals’] : ndarray, shape (n,)
caster[‘evecs’] : ndarray, shape(n, 4, 1)
|
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.
Calculate the trail and mechanical trail.
Parameters : | rF : float
lam : float
fo : float
|
---|---|
Returns : | c: float :
cm: float :
|
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
L2 : float
D : float
|
---|---|
Returns : | theta1 : float
theta2 : float
|
Returns the perpendicular distance geometry for the bicycle from the raw measurements.
Parameters : | h : tuple
d : tuple
|
---|---|
Returns : | a : ufloat or float
b : ufloat or float
c : ufloat or float
|
Returns the wheelbase, steer axis tilt and the trail.
Parameters : | mp : dictionary
par : dictionary
|
---|---|
Returns : | par : dictionary
|
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
h7 : float
d5 : float
d6 : float
l : float
|
---|---|
Returns : | l1 : float
l2 : float
|
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
c : float or ufloat
lam : float or ufloat
point : narray, shape(3,)
|
---|---|
Returns : | d : float or ufloat
|
Returns the coordinates for line end points of the bicycle fundamental geometry.
Parameters : | par : dictionary
|
---|---|
Returns : | x : ndarray z : ndarray |
Returns the distance along the benchmark coordinates from the front wheel center to the handlebar reference center.
Parameters : | lam : float
l1, l2 : float
|
---|---|
Returns : | u1, u2 : float |
Returns the minimal distance from a point to a line in three dimensional space.
Parameters : | point : ndarray, shape(3,)
pointsOnLine : ndarray, shape(3,2)
|
---|---|
Returns : | distance : float
|
Returns point of projection.
Parameters : | line : tuple
point : tuple
|
---|---|
Returns : | newPoint : tuple
|
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)
v2 : np.array (3,1)
|
---|---|
Returns : | angle : float
|
Vector projection into a plane, where the plane is defined by a normal vector.
Parameters : | vec : np.array(3,1)
direction : int or np.array, shape(3,)
|
---|---|
Returns : | vec_out : np.array(3,1)
|
Combines the inertia of the bicycle frame with the inertia of a rider.
Parameters : | bicyclePar : dictionary
riderPar : dictionary
|
---|---|
Returns : | bicyclePar : dictionary
|
Returns the moment of inertia for an object hung as a compound pendulum.
Parameters : | m : float
g : float
l : float
T : float
|
---|---|
Returns : | I : float
|
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,)
beta : ndarray, shape(n,)
|
---|---|
Returns : | eye : ndarray, shape(3,)
|
Returns the moment of inertia of a body about a different point.
Parameters : | Ic : ndarray, shape(3,3)
m : float
d : ndarray, shape(3,)
|
---|---|
Returns : | I : ndarray, shape(3,3)
|
Returns an inertia tensor for a particular part for the benchmark parameter set.
Parameters : | par : dictionary
part : string
|
---|---|
Returns : | I : ndarray, shape(3,3)
|
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.
Returns the principal moments of inertia and the orientation.
Parameters : | I : ndarray, shape(3,3)
|
---|---|
Returns : | Ip : ndarray, shape(3,)
C : ndarray, shape(3,3)
|
Returns inertia tensor rotated through angle. Only for 2D
Calculate the moment of inertia for an ideal torsional pendulm
Parameters : | k: torsional stiffness : T: period : |
---|---|
Returns : | I: moment of inertia : |
Calculate the stiffness of a torsional pendulum with a known moment of inertia.
Parameters : | I : moment of inertia T : period |
---|---|
Returns : | k : stiffness |
Calculate the moment of inertia for a tube (or rod) where the x axis is aligned with the tube’s axis.
Parameters : | l : float
m : float
ro : float
ri : float
|
---|---|
Returns : | Ix : float
Iy, Iz : float
|
Returns a dictionay of values based on the pendulum data file name.
Returns a dictionary of float and/or ufloat parameters from a parameter file.
Parameters : | pathToFile : string
|
---|---|
Returns : | parameters : dictionary
For example:: :
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. : |
Returns a dictionay containing the data from the pendulum data mat file.
Returns a dictionary with the uncertainties removed.
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']
Writes parameter set to file.
Parameters : | pathToTxtFile : string
pardict : dictionary
|
---|---|
Returns : | saved : boolean
|
Writes the provided periods to file.
Parameters : | pathToRawFile : string
mp : dictionary
|
---|
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,)
|
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.
Calculates the period for all filenames in directory.
Parameters : | directory : string
filenames : list
forkIsSplit : boolean
|
---|---|
Returns : | periods : dictionary
|
Returns whether the fork is split into two pieces and whether the period calculations need to happen again.
Parameters : | mp : dictionary
forkIsSplit : boolean
|
---|---|
Returns : | forcePeriodCalc : boolean
forkIsSplit : boolean
|
Calculate the goodness of fit.
Parameters : | ym : ndarray, shape(n,)
yp : ndarry, shape(n,)
|
---|---|
Returns : | rsq : float
SSE : float
SST : float
SSR : float
|
Returns the period and uncertainty for data resembling a decaying oscillation.
Parameters : | data : ndarray, shape(n,)
sampleRate : int
pathToPlotFile : string
|
---|---|
Returns : | T : ufloat
|
Returns a dictionary key for the period entries.
Parameters : | matData : dictionary
forkIsSplit : boolean
|
---|---|
Returns : | key : string
|
Returns the sample rate for the data.
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. : |
Returns a decent starting point for fitting the decaying oscillation function.
Plot fitted data over the measured
Parameters : | t : ndarray (n,)
ym : ndarray (n,)
yf : ndarray (n,) p : ndarray (5,)
rsq : float
T : float
m : float
|
---|---|
Returns : | fig : the figure |
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,)
percent : float
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. : |
---|
Returns a figure with the Bode plots of multiple bicycles.
Parameters : | bikes : list
speed : float
u : integer
y : integer
|
---|---|
Returns : | fig : matplotlib.Figure instance
|
Notes
The phases are matched around zero degrees at with respect to the first frequency.
Returns a figure with the eigenvalues vs speed for multiple bicycles.
Parameters : | bikes : list
speeds : ndarray, shape(n,)
colors : list
linestyles : list
largest : boolean
|
---|---|
Returns : | fig : matplotlib figure |
Returns the rider parameters, bicycle paramaters with a rider and a human object that is configured to sit on the bicycle.
Parameters : | pathToRider : string
bicycle : string
bicyclePar : dictionary
measuredPar : dictionary
draw : boolean, optional
|
---|---|
Returns : | riderpar : dictionary
human : yeadon.human
bicycleRiderPar : dictionary
|
Returns a yeadon human configured to sit on a bicycle.
Parameters : | benchmarkPar : dictionary
measuredPar : dictionary
yeadonMeas : str
yeadonCFG : str
drawrider : bool
|
---|---|
Returns : | human : yeadon.Human
|
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).
Parameters : | vector : np.matrix, shape(3, 1)
measured_bicycle_par : dictionary
benchmark_bicycle_par : dictionary
|
---|---|
Returns : | vector_wrt_bike : np.matrix, shape(3, 1)
|
A class for generating tables of the measurment and parameter data associated with a bicycle.
Methods
Returns a reStructuredText version of the table.
Parameters : | fileName : string
|
---|---|
Returns : | rstTable : string
|
Generates a list of data for a table.
Returns a latex representation for a given variable string name.
Parameters : | var : string
|
---|---|
Returns : | latex : string
|
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
|
---|---|
Returns : | s : string
2.4563752289999+/-0.0003797273827 : becomes : 2.4564+/-0.0004 : This probably doesn’t work for weird cases like large uncertainties. : |