1212
1313/** This drive implementation is for Talon SRXs driving brushed motors (e.g. CIMS) with encoders. */
1414public class DriveIOReal implements DriveIO {
15- private static final double ticksPerRevolution = 1440 ;
15+ private static final double ticksPerRevolution = TICKS_PER_REVOLUTION ;
1616
1717 private final TalonSRX leftLeader = new TalonSRX (LEFT_LEADER_CAN_ID );
1818 private final TalonSRX leftFollower = new TalonSRX (LEFT_FOLLOWER_CAN_ID );
@@ -22,9 +22,9 @@ public class DriveIOReal implements DriveIO {
2222 public DriveIOReal () {
2323 var config = new TalonSRXConfiguration ();
2424 config .peakCurrentLimit = CURRENT_LIMIT ;
25- config .continuousCurrentLimit = CURRENT_LIMIT - 15 ;
25+ config .continuousCurrentLimit = CURRENT_LIMIT - ( int ) CURRENT_LIMIT_OFFSET ;
2626 config .peakCurrentDuration = 250 ;
27- config .voltageCompSaturation = 12.0 ;
27+ config .voltageCompSaturation = VOLTAGE_COMPENSATION ;
2828 config .primaryPID .selectedFeedbackSensor = FeedbackDevice .QuadEncoder ;
2929
3030 leftLeader .configAllSettings (config );
@@ -47,7 +47,7 @@ public void updateInputs(DriveIOInputs inputs) {
4747 Units .rotationsToRadians (
4848 leftLeader .getSelectedSensorVelocity ()
4949 / ticksPerRevolution
50- * 10.0 ); // Raw units are ticks per 100ms :(
50+ * SENSOR_VELOCITY_CONVERSION ); // Raw units are ticks per 100ms :(
5151 inputs .leftAppliedVolts = leftLeader .getMotorOutputVoltage ();
5252 inputs .leftCurrentAmps =
5353 new double [] {leftLeader .getStatorCurrent (), leftFollower .getStatorCurrent ()};
@@ -58,7 +58,7 @@ public void updateInputs(DriveIOInputs inputs) {
5858 Units .rotationsToRadians (
5959 rightLeader .getSelectedSensorVelocity ()
6060 / ticksPerRevolution
61- * 10.0 ); // Raw units are ticks per 100ms :(
61+ * SENSOR_VELOCITY_CONVERSION ); // Raw units are ticks per 100ms :(
6262 inputs .rightAppliedVolts = rightLeader .getMotorOutputVoltage ();
6363 inputs .rightCurrentAmps =
6464 new double [] {rightLeader .getStatorCurrent (), rightFollower .getStatorCurrent ()};
@@ -67,8 +67,8 @@ public void updateInputs(DriveIOInputs inputs) {
6767 @ Override
6868 public void setVoltage (double leftVolts , double rightVolts ) {
6969 // OK to just divide by 12 because voltage compensation is enabled
70- leftLeader .set (TalonSRXControlMode .PercentOutput , leftVolts / 12.0 );
71- rightLeader .set (TalonSRXControlMode .PercentOutput , rightVolts / 12.0 );
70+ leftLeader .set (TalonSRXControlMode .PercentOutput , leftVolts / VOLTAGE_COMPENSATION );
71+ rightLeader .set (TalonSRXControlMode .PercentOutput , rightVolts / VOLTAGE_COMPENSATION );
7272 }
7373
7474 @ Override
@@ -79,15 +79,15 @@ public void setVelocity(
7979 TalonSRXControlMode .Velocity ,
8080 Units .radiansToRotations (leftRadPerSec )
8181 * ticksPerRevolution
82- / 10.0 , // Raw units are ticks per 100ms :(
82+ / SENSOR_VELOCITY_CONVERSION , // Raw units are ticks per 100ms :(
8383 DemandType .ArbitraryFeedForward ,
84- leftFFVolts / 12.0 );
84+ leftFFVolts / VOLTAGE_COMPENSATION );
8585 rightLeader .set (
8686 TalonSRXControlMode .Velocity ,
8787 Units .radiansToRotations (rightRadPerSec )
8888 * ticksPerRevolution
89- / 10.0 , // Raw units are ticks per 100ms :(
89+ / SENSOR_VELOCITY_CONVERSION , // Raw units are ticks per 100ms :(
9090 DemandType .ArbitraryFeedForward ,
91- rightFFVolts / 12.0 );
91+ rightFFVolts / VOLTAGE_COMPENSATION );
9292 }
9393}
0 commit comments