Package org.chsrobotics.lib.util
Class GearRatioHelper
java.lang.Object
org.chsrobotics.lib.util.GearRatioHelper
Simple utility representing a gear ratio.
-
Constructor Summary
ConstructorsConstructorDescriptionGearRatioHelper
(double ratioInputToOutput) Creates a gear ratio helper from a double ratio of input to output.GearRatioHelper
(double inputRatio, double outputRatio) Constructs a GearRatioHelper. -
Method Summary
Modifier and TypeMethodDescriptiondouble
inputFromOutput
(double outputSide) Returns how far the "input" side of the mechanism will have travelled if the "output" has travelled the indicated angular distance.double
outputFromInput
(double inputSide) Returns how far the "output" side of the mechanism will have travelled if the "input" has travelled the indicated angular distance.double
Returns the gear ratio as input/output.double
Returns the gear ratio as output/input.
-
Constructor Details
-
GearRatioHelper
Constructs a GearRatioHelper.The parameters indicate the "input" and "output" sides of the mechanism. The input is typically where the motor is.
The measurements of the parameters can be of many types that relate the motion of one side to the other, as long as they're consistent. For example, radius, circumference, number of gear teeth, angular distance per angular distance of the other, and more, are all valid parameters.
A higher output ratio than input ratio is a reduction (lower speed, higher torque).
A higher input ratio than output ratio is a step-up (higher speed, lower torque).
- Parameters:
inputRatio
- The measurement of the "input" side (usually where the motor is)outputRatio
- The measurement of the "output" side (usually on the other side of a gearbox or series of pulleys from the motor)- Throws:
InvalidParameterException
- If the input or output ratio(s) are less than zero.
-
GearRatioHelper
public GearRatioHelper(double ratioInputToOutput) Creates a gear ratio helper from a double ratio of input to output.- Parameters:
ratioInputToOutput
- The ratio as input/output.
-
-
Method Details
-
toDoubleRatioInputToOutput
public double toDoubleRatioInputToOutput()Returns the gear ratio as input/output.- Returns:
- The double ratio as input/output.
-
toDoubleRatioOutputToInput
public double toDoubleRatioOutputToInput()Returns the gear ratio as output/input.- Returns:
- The double ratio as output/input.
-
outputFromInput
public double outputFromInput(double inputSide) Returns how far the "output" side of the mechanism will have travelled if the "input" has travelled the indicated angular distance.- Parameters:
inputSide
- The angular distance travelled by the *input* side.- Returns:
- The angular distance travelled by the *output* side.
-
inputFromOutput
public double inputFromOutput(double outputSide) Returns how far the "input" side of the mechanism will have travelled if the "output" has travelled the indicated angular distance.- Parameters:
outputSide
- The angular distance travelled by the *output* side.- Returns:
- The angular distance travelled by the *output* side.
-