Files
YAGSL/swervelib/parser/SwerveModulePhysicalCharacteristics.java

107 lines
4.5 KiB
Java
Raw Normal View History

2023-02-13 17:21:24 -06:00
package swervelib.parser;
2023-02-13 14:37:05 -06:00
2023-11-09 17:32:48 -06:00
import swervelib.parser.json.MotorConfigDouble;
2023-02-13 14:37:05 -06:00
/**
* Configuration class which stores physical characteristics shared between every swerve module.
*/
public class SwerveModulePhysicalCharacteristics
{
/**
* Current limits for the Swerve Module.
*/
public final int driveMotorCurrentLimit, angleMotorCurrentLimit;
/**
* The time it takes for the motor to go from 0 to full throttle in seconds.
*/
public final double driveMotorRampRate, angleMotorRampRate;
/**
* Wheel grip tape coefficient of friction on carpet, as described by the vendor.
*/
2023-11-09 17:32:48 -06:00
public final double wheelGripCoefficientOfFriction;
/**
* The voltage to use for the smart motor voltage compensation.
*/
public double optimalVoltage;
/**
2023-11-09 17:32:48 -06:00
* The conversion factors for the drive and angle motors, created by
* {@link swervelib.math.SwerveMath#calculateMetersPerRotation(double, double, double)} and
* {@link swervelib.math.SwerveMath#calculateDegreesPerSteeringRotation(double, double)}.
*/
2023-11-09 17:32:48 -06:00
public MotorConfigDouble conversionFactor;
2023-02-13 14:37:05 -06:00
/**
* Construct the swerve module physical characteristics.
*
2023-11-09 17:32:48 -06:00
* @param conversionFactors The conversion factors for the drive and angle motors, created by
* {@link swervelib.math.SwerveMath#calculateMetersPerRotation(double, double,
* double)} and
* {@link swervelib.math.SwerveMath#calculateDegreesPerSteeringRotation(double,
* double)}.
2023-02-13 14:37:05 -06:00
* @param wheelGripCoefficientOfFriction Wheel grip coefficient of friction on carpet given by manufacturer.
* @param optimalVoltage Optimal robot voltage.
* @param driveMotorCurrentLimit Current limit for the drive motor.
* @param angleMotorCurrentLimit Current limit for the angle motor.
* @param driveMotorRampRate The time in seconds to go from 0 to full throttle on the motor. (Prevents
* over drawing power from battery)
* @param angleMotorRampRate The time in seconds to go from 0 to full throttle on the motor. (Prevents
* overdrawing power and power loss).
*/
public SwerveModulePhysicalCharacteristics(
2023-11-09 17:32:48 -06:00
MotorConfigDouble conversionFactors,
double wheelGripCoefficientOfFriction,
double optimalVoltage,
int driveMotorCurrentLimit,
int angleMotorCurrentLimit,
double driveMotorRampRate,
2023-11-09 17:32:48 -06:00
double angleMotorRampRate)
2023-02-13 14:37:05 -06:00
{
this.wheelGripCoefficientOfFriction = wheelGripCoefficientOfFriction;
this.optimalVoltage = optimalVoltage;
2023-11-09 17:32:48 -06:00
this.conversionFactor = conversionFactors;
// Set the conversion factors to null if they are both 0.
if (conversionFactors != null)
{
if (conversionFactors.angle == 0 && conversionFactors.drive == 0)
{
this.conversionFactor = null;
}
}
2023-02-13 14:37:05 -06:00
this.driveMotorCurrentLimit = driveMotorCurrentLimit;
this.angleMotorCurrentLimit = angleMotorCurrentLimit;
this.driveMotorRampRate = driveMotorRampRate;
this.angleMotorRampRate = angleMotorRampRate;
}
/**
* Construct the swerve module physical characteristics. Assume coefficient of friction is 1.19 (taken from blue
* nitrile on carpet from Studica) and optimal voltage is 12v. Assumes the drive motor current limit is 40A, and the
* angle motor current limit is 20A.
*
2023-11-09 17:32:48 -06:00
* @param conversionFactors The conversion factors for the drive and angle motors, created by
* {@link swervelib.math.SwerveMath#calculateMetersPerRotation(double, double, double)} and
* {@link swervelib.math.SwerveMath#calculateDegreesPerSteeringRotation(double, double)}.
* @param driveMotorRampRate The time in seconds to go from 0 to full throttle on the motor. (Prevents over drawing
* power from battery)
* @param angleMotorRampRate The time in seconds to go from 0 to full throttle on the motor. (Prevents overdrawing
* power and power loss).
2023-02-13 14:37:05 -06:00
*/
public SwerveModulePhysicalCharacteristics(
2023-11-09 17:32:48 -06:00
MotorConfigDouble conversionFactors,
double driveMotorRampRate,
2023-11-09 17:32:48 -06:00
double angleMotorRampRate)
2023-02-13 14:37:05 -06:00
{
this(
2023-11-09 17:32:48 -06:00
conversionFactors,
1.19,
12,
40,
20,
driveMotorRampRate,
2023-11-09 17:32:48 -06:00
angleMotorRampRate);
2023-02-13 14:37:05 -06:00
}
}