mirror of
https://github.com/BroncBotz3481/YAGSL
synced 2026-06-26 07:01:39 +00:00
Updated YAGSL to next-gen
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
package swervelib.parser.json;
|
||||
|
||||
import edu.wpi.first.math.util.Units;
|
||||
import swervelib.parser.SwerveModulePhysicalCharacteristics;
|
||||
import swervelib.telemetry.SwerveDriveTelemetry;
|
||||
|
||||
/**
|
||||
* {@link swervelib.parser.SwerveModulePhysicalCharacteristics} parsed data. Used to configure the SwerveModule.
|
||||
@@ -10,18 +8,13 @@ import swervelib.telemetry.SwerveDriveTelemetry;
|
||||
public class PhysicalPropertiesJson
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Wheel diameter in inches.
|
||||
* Conversion factor applied to the motor controllers PID loops. Can be calculated with
|
||||
* {@link swervelib.math.SwerveMath#calculateDegreesPerSteeringRotation(double, double)} for angle motors or
|
||||
* {@link swervelib.math.SwerveMath#calculateMetersPerRotation(double, double, double)} for drive motors.
|
||||
*/
|
||||
public double wheelDiameter;
|
||||
/**
|
||||
* Gear ratio for the motors, number of times the motor has to spin before the wheel rotates a single time.
|
||||
*/
|
||||
public MotorConfigDouble gearRatio;
|
||||
/**
|
||||
* Encoder pulse per rotation for non-integrated encoders. 1 for integrated encoders.
|
||||
*/
|
||||
public MotorConfigInt encoderPulsePerRotation = new MotorConfigInt(1, 1);
|
||||
public MotorConfigDouble conversionFactor;
|
||||
/**
|
||||
* The current limit in AMPs to apply to the motors.
|
||||
*/
|
||||
@@ -35,106 +28,25 @@ public class PhysicalPropertiesJson
|
||||
*/
|
||||
public double wheelGripCoefficientOfFriction = 1.19;
|
||||
/**
|
||||
* Angle motor kV used for second order kinematics to tune the feedforward, this variable should be adjusted so that
|
||||
* your drive train does not drift towards the direction you are rotating while you translate. Default value is 0. If
|
||||
* robot arcs while translating and rotating negate this.
|
||||
* The voltage to use for the smart motor voltage compensation, default is 12.
|
||||
*/
|
||||
public double moduleFeedForwardClosedLoop = SwerveDriveTelemetry.isSimulation ? 0.33 : 0;
|
||||
/**
|
||||
* DEPRECATED: No longer needed, tune {@link PhysicalPropertiesJson#moduleFeedForwardClosedLoop} instead.
|
||||
*/
|
||||
public double angleMotorFreeSpeedRPM = 0;
|
||||
public double optimalVoltage = 12;
|
||||
|
||||
/**
|
||||
* Create the physical characteristics based off the parsed data.
|
||||
*
|
||||
* @param optimalVoltage Optimal voltage to compensate for and use to calculate drive motor feedforward.
|
||||
* @return {@link SwerveModulePhysicalCharacteristics} based on parsed data.
|
||||
*/
|
||||
public SwerveModulePhysicalCharacteristics createPhysicalProperties(double optimalVoltage)
|
||||
public SwerveModulePhysicalCharacteristics createPhysicalProperties()
|
||||
{
|
||||
return new SwerveModulePhysicalCharacteristics(
|
||||
gearRatio.drive,
|
||||
gearRatio.angle,
|
||||
Units.inchesToMeters(wheelDiameter),
|
||||
conversionFactor,
|
||||
wheelGripCoefficientOfFriction,
|
||||
optimalVoltage,
|
||||
currentLimit.drive,
|
||||
currentLimit.angle,
|
||||
rampRate.drive,
|
||||
rampRate.angle,
|
||||
encoderPulsePerRotation.drive,
|
||||
encoderPulsePerRotation.angle,
|
||||
moduleFeedForwardClosedLoop);
|
||||
rampRate.angle);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to store doubles for motor configuration.
|
||||
*/
|
||||
class MotorConfigDouble
|
||||
{
|
||||
|
||||
/**
|
||||
* Drive motor.
|
||||
*/
|
||||
public double drive;
|
||||
/**
|
||||
* Angle motor.
|
||||
*/
|
||||
public double angle;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public MotorConfigDouble()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*
|
||||
* @param angle Angle data.
|
||||
* @param drive Drive data.
|
||||
*/
|
||||
public MotorConfigDouble(double angle, double drive)
|
||||
{
|
||||
this.angle = angle;
|
||||
this.drive = drive;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to store ints for motor configuration.
|
||||
*/
|
||||
class MotorConfigInt
|
||||
{
|
||||
|
||||
/**
|
||||
* Drive motor.
|
||||
*/
|
||||
public int drive;
|
||||
/**
|
||||
* Angle motor.
|
||||
*/
|
||||
public int angle;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public MotorConfigInt()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Default constructor with values.
|
||||
*
|
||||
* @param drive Drive data.
|
||||
* @param angle Angle data.
|
||||
*/
|
||||
public MotorConfigInt(int drive, int angle)
|
||||
{
|
||||
this.angle = angle;
|
||||
this.drive = drive;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user