Class MechanismGearing

java.lang.Object
yams.core.gearing.MechanismGearing

public class MechanismGearing extends Object
Mechanism gearing for conversions from the motor output to the mechanism output.

MechanismGearing combines a GearBox (and an optional Sprocket) into a single object that describes the complete power-transmission path between the motor and the mechanism. It is the primary object passed to motor-controller configuration helpers (such as SmartMotorControllerConfig) so that encoder readings can be automatically scaled to real-world mechanism positions or velocities.

Constructors available:

  • new MechanismGearing(double) single overall reduction ratio
  • new MechanismGearing(double...) one ratio per gearbox stage
  • new MechanismGearing(GearBox) pre-built GearBox
  • new MechanismGearing(GearBox, Sprocket) gearbox followed by a chain/belt stage

Example

// Simple 10:1 gearbox attached directly to the mechanism
MechanismGearing simple = new MechanismGearing(10.0);

// Two-stage gearbox (5:1 then 3:1 = 15:1 overall)
MechanismGearing twoStage = new MechanismGearing(5.0, 3.0);

// Gearbox followed by a 2:1 chain-drive sprocket stage
GearBox gearBox  = GearBox.fromTeeth(12, 60);          // 5:1
Sprocket sprocket = Sprocket.fromStages("18:36");       // 2:1
MechanismGearing combined = new MechanismGearing(gearBox, sprocket); // 10:1 overall

// Query the ratios
double rotorToMech = combined.getRotorToMechanismRatio(); // motor rotations per mechanism
rotation double mechToRotor = combined.getMechanismToRotorRatio(); // mechanism rotations per
motor rotation
  • Field Details

  • Constructor Details

    • MechanismGearing

      public MechanismGearing(double reductionRatio)
      Construct a MechanismGearing with a reduction ratio.
      Parameters:
      reductionRatio - Reduction ratio. For example, a reduction of "3:1" is 3.0; a reduction of "1:2" is 0.5.
    • MechanismGearing

      public MechanismGearing(double... reductionRatios)
      Construct a MechanismGearing with a reduction ratios.
      Parameters:
      reductionRatios - Reduction ratio. For example, a reduction of "3:1" is 3.0; a reduction of "1:2" is 0.5.
      Throws:
      NoStagesGivenException - if no reduction ratios are given.
    • MechanismGearing

      public MechanismGearing(GearBox gearBox)
      Initialize the MechanismGearing with only a GearBox attached to the mechanism motor.
      Parameters:
      gearBox - GearBox of the Mechanism.
    • MechanismGearing

      public MechanismGearing(GearBox gearBox, Sprocket sprockets)
      Initialize the MechanismGearing with a GearBox and Sprocket
      Parameters:
      gearBox - GearBox attached to the motor.
      sprockets - Sprocket attached to the gearbox.
  • Method Details

    • getRotorToMechanismRatio

      public double getRotorToMechanismRatio()
      Get the sensor to the mechanism ratio for the motor to the mechanism.
      Returns:
      OUT:IN or OUT/IN ratio to use for sensor to mechanism calculations.
    • getMechanismToRotorRatio

      public double getMechanismToRotorRatio()
      Get the mechanism rotation to sensor rotation ratio for the mechanism. AKA THE REDUCTION!
      Returns:
      IN:OUT or IN/OUT to use for mechanism to sensor calculations.
    • div

      public MechanismGearing div(double i)
      Divide the gearbox reduction ratio by i.
      Parameters:
      i - Numerator.
      Returns:
      MechanismGearing