Update to swervelib 2024.5.0.0

This commit is contained in:
thenetworkgrinch
2024-07-29 15:14:25 -05:00
parent a64d1d3215
commit 89e4163951
120 changed files with 1420 additions and 439 deletions

View File

@@ -1,6 +1,9 @@
package swervelib.parser.json;
import swervelib.parser.SwerveModulePhysicalCharacteristics;
import swervelib.parser.json.modules.ConversionFactorsJson;
import swervelib.telemetry.Alert;
import swervelib.telemetry.Alert.AlertType;
/**
* {@link swervelib.parser.SwerveModulePhysicalCharacteristics} parsed data. Used to configure the SwerveModule.
@@ -14,23 +17,27 @@ public class PhysicalPropertiesJson
* {@link swervelib.math.SwerveMath#calculateDegreesPerSteeringRotation(double, double)} for angle motors or
* {@link swervelib.math.SwerveMath#calculateMetersPerRotation(double, double, double)} for drive motors.
*/
public MotorConfigDouble conversionFactor = new MotorConfigDouble(0, 0);
public MotorConfigDouble conversionFactor = new MotorConfigDouble(0, 0);
/**
* Conversion Factors composition. Auto-calculates the conversion factors.
*/
public ConversionFactorsJson conversionFactors = new ConversionFactorsJson();
/**
* The current limit in AMPs to apply to the motors.
*/
public MotorConfigInt currentLimit = new MotorConfigInt(40, 20);
public MotorConfigInt currentLimit = new MotorConfigInt(40, 20);
/**
* The minimum number of seconds to take for the motor to go from 0 to full throttle.
*/
public MotorConfigDouble rampRate = new MotorConfigDouble(0.25, 0.25);
public MotorConfigDouble rampRate = new MotorConfigDouble(0.25, 0.25);
/**
* The grip tape coefficient of friction on carpet. Used to calculate the practical maximum acceleration.
*/
public double wheelGripCoefficientOfFriction = 1.19;
public double wheelGripCoefficientOfFriction = 1.19;
/**
* The voltage to use for the smart motor voltage compensation, default is 12.
*/
public double optimalVoltage = 12;
public double optimalVoltage = 12;
/**
* Create the physical characteristics based off the parsed data.
@@ -39,6 +46,28 @@ public class PhysicalPropertiesJson
*/
public SwerveModulePhysicalCharacteristics createPhysicalProperties()
{
// Setup deprecation notice.
// if (conversionFactor.drive != 0 && conversionFactor.angle != 0 && conversionFactors.isDriveEmpty() &&
// conversionFactors.isAngleEmpty())
// {
// new Alert("Configuration",
// "\n'conversionFactor': {'drive': " + conversionFactor.drive + ", 'angle': " + conversionFactor.angle +
// "} \nis deprecated, please use\n" +
// "'conversionFactors': {'drive': {'factor': " + conversionFactor.drive + "}, 'angle': {'factor': " +
// conversionFactor.angle + "} }",
// AlertType.ERROR_TRACE).set(true);
// }
if (!conversionFactors.isAngleEmpty())
{
conversionFactor.angle = conversionFactors.angle.calculate();
}
if (!conversionFactors.isDriveEmpty())
{
conversionFactor.drive = conversionFactors.drive.calculate();
}
return new SwerveModulePhysicalCharacteristics(
conversionFactor,
wheelGripCoefficientOfFriction,