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.

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

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

Parameters:
riderNamestring

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

reCalcboolean, optional

If true, the rider parameters will be recalculated.

drawboolean, 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:
nominalboolean, optional

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

Returns:
Muarray, shape(2,2)

Mass matrix.

C1uarray, shape(2,2)

Velocity independent damping matrix.

K0uarray, shape(2,2)

Gravity independent part of the stiffness matrix.

K2uarray, 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:
speedslist

A list of speeds at which to evaluate the system.

uinteger

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

yinteger

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

Returns:
figmatplotlib.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:
speedsarray_like, shape (n,) or float

The speed at which to calculate the eigenvalues.

Returns:
evalsndarray, shape (n, 4)

eigenvalues

evecsndarray, 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.

Parameters:
showboolean, optional

If true matplotlib.pyplot.show() will be called before exiting the function.

pendulumboolean, optional

If true the axes of the torsional pendulum will be displayed (only useful if raw measurement data is availabe).

centerOfMassboolean, optional

If true the mass center of each rigid body will be displayed.

inertiaEllipseboolean optional

If true inertia ellipses for each rigid body will be displayed.

Returns:
figmatplotlib.pyplot.Figure

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:
speedfloat

The speed at which to evaluate the system.

uinteger

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

yinteger

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

kwargskeyword pairs

Any options that can be passed to dtk.bode.

Returns:
magndarray, shape(1000,)

The magnitude in dB of the frequency reponse.

phasendarray, shape(1000,)

The phase in degress of the frequency response.

figmatplotlib figure

The Bode plot.

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

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

Parameters:
speedsndarray, shape(n,)

An array of speeds to calculate the eigenvalues at.

figmatplotlib figure, optional

A figure to plot to.

genericboolean

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

colormatplotlib color

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

largestboolean

If true, only the largest eigenvalue is plotted.

gridboolean, optional

If true, displays a grid on the plot.

show_legend: boolean, optional

If true, displays a legend describing the different parts of the solution shown.

Returns:
figmatpolib.pyplot.Figure

The figure.

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:
filetypestring, 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:
speedfloat

The speed of the bicycle.

nominalboolean, optional

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

Returns:
Andarray, shape(4,4)

The state matrix.

Bndarray, 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:
handlebarboolean, optional

If true the handlebar will be included in the calculation.

forkboolean, optional

If true the fork will be included in the calculation.

wheelboolean, optional

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

aboutSteerAxisboolean, 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.

nominalboolean, optional

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

Returns:
iAssfloat

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:
mpdictionary

Complete set of measured data.

Returns:
pardictionary

Benchmark bicycle parameter set.

get_parts_in_parameters(par)

Returns a list of parts in a parameter dictionary.

Parameters:
pardictionary

Benchmark bicycle parameters.

Returns:
partslist

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:
mpdictionary

The measured data.

Returns:
forkIsSplitboolean