Skip to content

Commit 236cf2a

Browse files
committed
Fixed Shooter code. Renamed all encoders to include what type of encoder they are.
1 parent 28dd8ee commit 236cf2a

3 files changed

Lines changed: 11 additions & 13 deletions

File tree

src/main/java/frc/robot/commands/shooter/ShootBall.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public ShootBall(Shooter shooter, Indexer indexer, Limelight limelight) {
4343
this.indexer = indexer;
4444
this.limelight = limelight;
4545
addRequirements(shooter, indexer);
46-
46+
4747
tab = Shuffleboard.getTab("Shooter");
4848
targetShooterVelocityEntry = tab.add("Target Shooter Velocity", Constants.SHOOTER_DEFAULT_RPM).withProperties(Map.of("min", 0)).getEntry();
4949
distanceSetPointEntry = tab.add("Shooter Distance Setpoint", Constants.HOOD_SET_POINT_DISTANCE).withProperties(Map.of("min", 0)).getEntry();

src/main/java/frc/robot/constants/Constants.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ public final class Constants {
6565

6666
public static final SimpleMotorFeedforward FEED_FORWARD = new SimpleMotorFeedforward(ksVolts, kvVoltSecondsPerMeter, kaVoltSecondsSquaredPerMeter);
6767

68-
public static int ENCODER_TICKS_PER_REVOLUTION = 8192;
68+
public static int QUADRATURE_ENCODER_TICKS_PER_REVOLUTION = 8192;
6969

7070
//Talon bits.
71-
public static int ENCODER_TICKS_PER_REVOLUTION_TALON = 8192;
71+
public static int ENCODER_TICKS_PER_REVOLUTION_FALCON = 2048; //used to be 8192. Change this to current valye for dalcon motors!!!
7272
public static int TALON_PID_LOOP_IDX = 0;
7373
public static int TALON_CONFIG_TIMOUT_MS = 30;
7474
// 1023 is output in ?? at 100% power. 20660 is velocity at 100%

src/main/java/frc/robot/util/Util.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,24 @@ private static double getEncoderTicksFromInches(int wheel_diameter, double inche
3030
double inchesPerRevolution = Math.PI * wheel_diameter;
3131

3232
double revolutions = inches / inchesPerRevolution;
33-
double ticks = revolutions * ENCODER_TICKS_PER_REVOLUTION;
33+
double ticks = revolutions * QUADRATURE_ENCODER_TICKS_PER_REVOLUTION;
3434

3535
return ticks;
3636
}
3737

38-
public static double getInchesFromEncoderTicks(double encoder_ticks) {
39-
return getInchesFromEncoderTicks(WHEEL_DIAMETER, encoder_ticks);
40-
}
4138

4239
private static double getInchesFromEncoderTicks(int wheel_diameter, double encoder_ticks) {
4340

4441
double inchesPerRevolution = Math.PI * wheel_diameter;
45-
double revolutions = encoder_ticks * ENCODER_TICKS_PER_REVOLUTION;
42+
double revolutions = encoder_ticks * QUADRATURE_ENCODER_TICKS_PER_REVOLUTION;
4643

4744
double inches = (revolutions) / (inchesPerRevolution);
4845

4946
return inches;
5047
}
5148

5249
public static double getMetersFromEncoderTicks(double ticks) {
53-
return (WHEEL_CIRCUMFERENCE_METERS / ENCODER_TICKS_PER_REVOLUTION) * ticks;
50+
return (WHEEL_CIRCUMFERENCE_METERS / QUADRATURE_ENCODER_TICKS_PER_REVOLUTION) * ticks;
5451
}
5552
public static double stepsPerDecisecToMetersPerSec(double d) {
5653
return getMetersFromEncoderTicks(d * 10);
@@ -61,11 +58,11 @@ public static double metersPerSecToStepsPerDecisec(double metersPerSec) {
6158
}
6259

6360
public static double getEncoderTicksFromMeters(double meters) {
64-
return (meters / WHEEL_CIRCUMFERENCE_METERS) * ENCODER_TICKS_PER_REVOLUTION;
61+
return (meters / WHEEL_CIRCUMFERENCE_METERS) * QUADRATURE_ENCODER_TICKS_PER_REVOLUTION;
6562
}
6663

6764
public static double getRevolutionsFromTicks(double encoder_ticks) {
68-
double revolutions = encoder_ticks / ENCODER_TICKS_PER_REVOLUTION;
65+
double revolutions = encoder_ticks / QUADRATURE_ENCODER_TICKS_PER_REVOLUTION;
6966
return revolutions;
7067
}
7168

@@ -90,15 +87,16 @@ public static double degreesToMoveHood(double ticks) {
9087
}
9188

9289
public static double ticksFromRPM(int rpm){
93-
double ticksPer100Ms = ((((rpm * ENCODER_TICKS_PER_REVOLUTION_TALON)
90+
double ticksPer100Ms = ((((rpm * ENCODER_TICKS_PER_REVOLUTION_FALCON)
9491
/SHOOTER_GEAR_RATIO)
9592
/60) //mintues to seconds
9693
/10); // seconds to 100ms
9794
return ticksPer100Ms;
9895
}
9996

10097
public static double RPMFromTicks (double ticksPer100ms) {
101-
double rpm = ticksPer100ms * 600 * SHOOTER_GEAR_RATIO / ENCODER_TICKS_PER_REVOLUTION_TALON;
98+
double rpm = ticksPer100ms * 600 * SHOOTER_GEAR_RATIO / ENCODER_TICKS_PER_REVOLUTION_FALCON;
99+
//I think we are calculating ticks per minute, not the actual RPM
102100

103101
return rpm;
104102

0 commit comments

Comments
 (0)