Added simple conversion factor calculation

This commit is contained in:
thenetworkgrinch
2024-01-18 17:54:43 -06:00
parent dcc6bd8471
commit dd2f187861
108 changed files with 192 additions and 116 deletions

View File

@@ -35,6 +35,20 @@ public class SwerveMath
return (Math.PI * wheelDiameter) / (driveGearRatio * pulsePerRotation);
}
/**
* Calculate the meters per rotation for the integrated encoder. Calculation: (PI * WHEEL DIAMETER IN METERS) / (GEAR
* RATIO)
*
* @param wheelDiameter Wheel diameter in meters.
* @param driveGearRatio The gear ratio of the drive motor.
* @return Meters per rotation for the drive motor.
*/
public static double calculateMetersPerRotation(
double wheelDiameter, double driveGearRatio)
{
return calculateMetersPerRotation(wheelDiameter, driveGearRatio, 1);
}
/**
* Normalize an angle to be within 0 to 360.
*
@@ -98,6 +112,19 @@ public class SwerveMath
return 360 / (angleGearRatio * pulsePerRotation);
}
/**
* Calculate the degrees per steering rotation for the integrated encoder. Encoder conversion values. Drive converts
* motor rotations to linear wheel distance and steering converts motor rotations to module azimuth.
*
* @param angleGearRatio The gear ratio of the steering motor.
* @return Degrees per steering rotation for the angle motor.
*/
public static double calculateDegreesPerSteeringRotation(
double angleGearRatio)
{
return calculateDegreesPerSteeringRotation(angleGearRatio, 1);
}
/**
* Calculate the maximum angular velocity.
*