2024-07-29 15:14:25 -05:00
|
|
|
package swervelib.parser.json.modules;
|
|
|
|
|
|
|
|
|
|
import edu.wpi.first.math.util.Units;
|
|
|
|
|
import swervelib.math.SwerveMath;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Drive motor composite JSON parse class.
|
|
|
|
|
*/
|
|
|
|
|
public class DriveConversionFactorsJson
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gear ratio for the drive motor rotations to turn the wheel 1 complete rotation.
|
|
|
|
|
*/
|
2024-12-09 23:26:04 +00:00
|
|
|
public double gearRatio;
|
2024-07-29 15:14:25 -05:00
|
|
|
/**
|
|
|
|
|
* Diameter of the wheel in inches.
|
|
|
|
|
*/
|
2024-12-09 23:26:04 +00:00
|
|
|
public double diameter;
|
2024-07-29 15:14:25 -05:00
|
|
|
/**
|
|
|
|
|
* Calculated conversion factor.
|
|
|
|
|
*/
|
2024-12-09 23:26:04 +00:00
|
|
|
public double factor = 0;
|
2024-07-29 15:14:25 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Calculate the drive conversion factor.
|
|
|
|
|
*
|
|
|
|
|
* @return Drive conversion factor, if factor isn't set.
|
|
|
|
|
*/
|
|
|
|
|
public double calculate()
|
|
|
|
|
{
|
|
|
|
|
if (factor == 0)
|
|
|
|
|
{
|
|
|
|
|
factor = SwerveMath.calculateMetersPerRotation(Units.inchesToMeters(this.diameter), this.gearRatio);
|
|
|
|
|
}
|
|
|
|
|
return factor;
|
|
|
|
|
}
|
|
|
|
|
}
|