mirror of
https://github.com/BroncBotz3481/YAGSL
synced 2026-06-19 06:21:40 +00:00
Added overridable configuration options in module json
This commit is contained in:
@@ -48,6 +48,10 @@ public class SwerveModuleConfiguration
|
||||
* Angle volt-meter-per-second.
|
||||
*/
|
||||
public double angleKV;
|
||||
/**
|
||||
* The integrated encoder pulse per revolution.
|
||||
*/
|
||||
public double angleMotorEncoderPulsePerRevolution = 0;
|
||||
/**
|
||||
* Swerve module location relative to the robot.
|
||||
*/
|
||||
@@ -68,19 +72,21 @@ public class SwerveModuleConfiguration
|
||||
/**
|
||||
* Construct a configuration object for swerve modules.
|
||||
*
|
||||
* @param driveMotor Drive {@link SwerveMotor}.
|
||||
* @param angleMotor Angle {@link SwerveMotor}
|
||||
* @param absoluteEncoder Absolute encoder {@link SwerveAbsoluteEncoder}.
|
||||
* @param angleOffset Absolute angle offset to 0.
|
||||
* @param absoluteEncoderInverted Absolute encoder inverted.
|
||||
* @param angleMotorInverted State of inversion of the angle motor.
|
||||
* @param driveMotorInverted Drive motor inverted.
|
||||
* @param xMeters Module location in meters from the center horizontally.
|
||||
* @param yMeters Module location in meters from center vertically.
|
||||
* @param anglePIDF Angle PIDF configuration.
|
||||
* @param velocityPIDF Velocity PIDF configuration.
|
||||
* @param maxSpeed Maximum speed in meters per second.
|
||||
* @param physicalCharacteristics Physical characteristics of the swerve module.
|
||||
* @param driveMotor Drive {@link SwerveMotor}.
|
||||
* @param angleMotor Angle {@link SwerveMotor}
|
||||
* @param absoluteEncoder Absolute encoder {@link SwerveAbsoluteEncoder}.
|
||||
* @param angleOffset Absolute angle offset to 0.
|
||||
* @param absoluteEncoderInverted Absolute encoder inverted.
|
||||
* @param angleMotorInverted State of inversion of the angle motor.
|
||||
* @param driveMotorInverted Drive motor inverted.
|
||||
* @param xMeters Module location in meters from the center horizontally.
|
||||
* @param yMeters Module location in meters from center vertically.
|
||||
* @param anglePIDF Angle PIDF configuration.
|
||||
* @param velocityPIDF Velocity PIDF configuration.
|
||||
* @param maxSpeed Maximum speed in meters per second.
|
||||
* @param physicalCharacteristics Physical characteristics of the swerve module.
|
||||
* @param angleMotorEncoderPulsePerRevolution The encoder pulse per revolution for the angle motor encoder.
|
||||
* @param angleMotorFreeSpeedRPM The free speed RPM of the angle motor.
|
||||
*/
|
||||
public SwerveModuleConfiguration(
|
||||
SwerveMotor driveMotor,
|
||||
@@ -95,7 +101,9 @@ public class SwerveModuleConfiguration
|
||||
SwerveModulePhysicalCharacteristics physicalCharacteristics,
|
||||
boolean absoluteEncoderInverted,
|
||||
boolean driveMotorInverted,
|
||||
boolean angleMotorInverted)
|
||||
boolean angleMotorInverted,
|
||||
double angleMotorEncoderPulsePerRevolution,
|
||||
double angleMotorFreeSpeedRPM)
|
||||
{
|
||||
this.driveMotor = driveMotor;
|
||||
this.angleMotor = angleMotor;
|
||||
@@ -111,9 +119,10 @@ public class SwerveModuleConfiguration
|
||||
this.angleKV =
|
||||
calculateAngleKV(
|
||||
physicalCharacteristics.optimalVoltage,
|
||||
physicalCharacteristics.angleMotorFreeSpeedRPM,
|
||||
angleMotorFreeSpeedRPM,
|
||||
physicalCharacteristics.angleGearRatio);
|
||||
this.physicalCharacteristics = physicalCharacteristics;
|
||||
this.angleMotorEncoderPulsePerRevolution = angleMotorEncoderPulsePerRevolution;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -156,7 +165,9 @@ public class SwerveModuleConfiguration
|
||||
physicalCharacteristics,
|
||||
false,
|
||||
false,
|
||||
false);
|
||||
false,
|
||||
physicalCharacteristics.angleEncoderPulsePerRotation,
|
||||
physicalCharacteristics.angleMotorFreeSpeedRPM);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -187,9 +198,9 @@ public class SwerveModuleConfiguration
|
||||
? calculateMetersPerRotation(
|
||||
physicalCharacteristics.wheelDiameter,
|
||||
physicalCharacteristics.driveGearRatio,
|
||||
physicalCharacteristics.driveEncoderPulsePerRotation)
|
||||
angleMotorEncoderPulsePerRevolution)
|
||||
: calculateDegreesPerSteeringRotation(
|
||||
physicalCharacteristics.angleGearRatio,
|
||||
physicalCharacteristics.angleEncoderPulsePerRotation);
|
||||
angleMotorEncoderPulsePerRevolution);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class SwerveModulePhysicalCharacteristics
|
||||
*/
|
||||
public final int driveEncoderPulsePerRotation;
|
||||
/**
|
||||
* Angle motor encoder pulse per rotation. 1 if integrated encoder.
|
||||
* Angle motor encoder pulse per rotation. 1 for Neo encoder. 2048 for Falcons.
|
||||
*/
|
||||
public final int angleEncoderPulsePerRotation;
|
||||
/**
|
||||
|
||||
@@ -38,7 +38,15 @@ public class ModuleJson
|
||||
/**
|
||||
* Absolute encoder inversion state.
|
||||
*/
|
||||
public boolean absoluteEncoderInverted = false;
|
||||
public boolean absoluteEncoderInverted = false;
|
||||
/**
|
||||
* The angle encoder pulse per revolution override. 1 for Neo encoder. 2048 for Falcons.
|
||||
*/
|
||||
public double angleEncoderPulsePerRevolution = 0;
|
||||
/**
|
||||
* Angle motor free speed RPM.
|
||||
*/
|
||||
public double angleMotorFreeSpeedRPM = 0;
|
||||
/**
|
||||
* The location of the swerve module from the center of the robot in inches.
|
||||
*/
|
||||
@@ -82,6 +90,9 @@ public class ModuleJson
|
||||
physicalCharacteristics,
|
||||
absoluteEncoderInverted,
|
||||
inverted.drive,
|
||||
inverted.angle);
|
||||
inverted.angle,
|
||||
angleEncoderPulsePerRevolution == 0 ? physicalCharacteristics.angleEncoderPulsePerRotation
|
||||
: angleEncoderPulsePerRevolution,
|
||||
angleMotorFreeSpeedRPM == 0 ? physicalCharacteristics.angleMotorFreeSpeedRPM : angleMotorFreeSpeedRPM);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user