Class SmartMath
java.lang.Object
yams.core.math.SmartMath
SmartMath class to handle math operations.
Provides static utility methods for common FRC drivetrain and gearing calculations:
- sensorToMechanismRatio multiplies a chain of gear-stage ratios to produce the overall sensor-to-mechanism ratio used by motor controller configuration.
- gearBox multiplies a chain of gear-stage ratios to produce the rotor-to-mechanism gear ratio (MECHANISM_ROTATIONS / ROTOR_ROTATIONS).
Example
// Single-stage 10:1 reduction sensor on motor shaft
double sensorRatio = SmartMath.sensorToMechanismRatio(10.0);
// Two-stage gearbox: 5:1 first stage, 4:1 second stage → overall 20:1
double gearRatio = SmartMath.gearBox(5.0, 4.0);
// Three-stage gearbox: 3:1, 4:1, 5:1 → overall 60:1
double complexGearRatio = SmartMath.gearBox(3.0, 4.0, 5.0);
-
Method Summary
Modifier and TypeMethodDescriptionstatic doublegearBox(double... stages) Create the gear ratio based off of the stages in the gear box.static doublesensorToMechanismRatio(double... stages) Create the sensor to mechanism ratio.
-
Method Details
-
sensorToMechanismRatio
public static double sensorToMechanismRatio(double... stages) Create the sensor to mechanism ratio.- Parameters:
stages- stages between the motor and output shaft.- Returns:
- sensor to mechanism ratio.
- Throws:
NoStagesGivenException- ifstagesis empty.
-
gearBox
public static double gearBox(double... stages) Create the gear ratio based off of the stages in the gear box.- Parameters:
stages- stages between the motor and output shaft.- Returns:
- rotor rotations to mechanism ratio in the form of MECHANISM_ROTATIONS/ROTOR_ROTATIONS or ROTOR_ROTATIONS:MECHANISM_ROTATIONS
- Throws:
NoStagesGivenException- ifstagesis empty.
-