This pull request adds the VariableGearboxPlugin, which uses piecewise cubic Hermite splines to support arbitrary smooth input-output relationships between the input and output angles of a gearbox. This includes the plugin, an example world, a test, and some added API's to ODE to support this feature.
The ODE gearbox joint currently supports joint constraints of the form angle1 = -ratio * angle2. In order to support arbitrary constraint profiles, reference angles are added to the linear constraint: angle1 - refAngle1 = -ratio * (angle2 - refAngle2). Then at each time step, the smooth input-output curve is linearized at the current joint state to compute refAngle1, refAngle2, and ratio and solved. API's for setting the refAngle's are added to ODE, which can be accessed via SetParam / GetParam in the physics Joint interface. Tests are added for these new API's to the joint_spawn test.
The VariableGearboxPlugin is a ModelPlugin that takes a gearbox_joint_name parameter and multiple x_y_dydx parameters. The x_y_dydx parameters specify points and slopes on the input-output curve. The snippet below is copied from variable_gearbox_plugin.world. Documentation of the spline math is provided in the code.
x: angle of input joint
y: angle of output joint
dy/dx: instantaneous gear ratio of change in output / change in input.
The example world uses the demo_joint_types model, which has a pendulum connected via a gearbox to a flywheel. This plugin shifts the gear ratio from a low speed of the flywheel to a high speed as the pendulum swings.
To aid in visualizing the splines produced by this plugin, I've created an ipython notebook with some plotting functions and uploaded it to a gist. It includes plots of the input-output relationship used in the example world