Class Sprocket

java.lang.Object
yams.core.gearing.Sprocket

public class Sprocket extends Object
Sprocket class to handle calculating the conversion factor of a sprocket in your mechanism.

A Sprocket models a chain or belt drive made up of two or more sprockets/pulleys. The ratio for each stage is expressed as driver / driven (IN/OUT). A ratio less than 1.0 indicates a reduction (the driven sprocket has more teeth than the driver).

You can construct a Sprocket in several ways:

  • new Sprocket(double...) provide per-stage IN/OUT ratios directly
  • fromStages(String...) provide stages as "IN:OUT" strings

Example

// 2:1 reduction 18-tooth driver sprocket driving a 36-tooth driven sprocket
// The ratio passed is driver/driven = 18/36 = 0.5
Sprocket twoToOne = new Sprocket(18.0 / 36.0);

// Equivalent using an "IN:OUT" stage string
Sprocket fromString = Sprocket.fromStages("18:36");

// Get the input-to-output conversion factor (< 1.0 means the output spins slower)
double factor = twoToOne.getInputToOutputConversionFactor(); // 0.5
// Get the output-to-input conversion factor (the reduction ratio)
double reduction = twoToOne.getOutputToInputConversionFactor(); // 2.0
  • Constructor Details

    • Sprocket

      public Sprocket(double... sprocketReductionStage)
      Create the sprocket given the teeth of each sprocket in the chain.
      Parameters:
      sprocketReductionStage - Sprocket teeth, in the form of "IN:OUT" => IN/OUT
      Throws:
      NoStagesGivenException - if no reduction stages are given.
    • Sprocket

      public Sprocket(String[] reductionStage)
      Construct the Sprocket with the reduction stages given.
      Parameters:
      reductionStage - List of stages in the format of "IN:OUT".
      Throws:
      InvalidStageGivenException - if any stage string does not contain a ':' separator.
      NoStagesGivenException - if reductionStage is empty.
  • Method Details

    • fromStages

      public static Sprocket fromStages(String... stages)
      Construct the Sprocket with the reduction stages given.
      Parameters:
      stages - List of stages in the format of "IN:OUT".
      Returns:
      Sprocket representation
      Throws:
      InvalidStageGivenException - if any stage string does not contain a ':' separator.
      NoStagesGivenException - if no stages are given.
    • times

      public Sprocket times(double x)
      Multiply the sprocket reduction ratio by X.
      Parameters:
      x - X to multiply by.
      Returns:
      Sprocket for chaining.
    • div

      public Sprocket div(double x)
      Divide the sprocket reduction ratio by X.
      Parameters:
      x - X to divide by.
      Returns:
      Sprocket
    • getInputToOutputConversionFactor

      public double getInputToOutputConversionFactor()
      Get the conversion factor to transform the sprocket input into the sprocket output rotations.
      Returns:
      OUT/IN or OUT:IN
    • getOutputToInputConversionFactor

      public double getOutputToInputConversionFactor()
      Get the conversion factor to transform the sprocket output value into the sprocket input value.
      Returns:
      IN:OUT or IN/OUT