Skip to content

Commit bf14457

Browse files
committed
Updated the isVoltageClose method for every subsystem
1 parent a4b0e50 commit bf14457

File tree

8 files changed

+36
-32
lines changed

8 files changed

+36
-32
lines changed

src/main/java/frc/robot/subsystems/groundIntake/GroundIntake.java

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package frc.robot.subsystems.groundIntake;
22

33
import org.littletonrobotics.junction.networktables.LoggedDashboardNumber;
4+
import org.littletonrobotics.junction.AutoLogOutput;
45
import org.littletonrobotics.junction.Logger;
56

67

@@ -48,13 +49,10 @@ public void periodic() {
4849
Logger.recordOutput("GroundIntake/GIntakeMotorConnected", inputs.velocityRadsPerSec != 0);
4950
}
5051

51-
//Check if the actual voltage is close to the desired voltage
52-
public boolean isVoltageClose(double setVoltage, double tolerance) {
53-
// Calculate the absolute difference between the desired and applied voltages
52+
@AutoLogOutput(key = "GroundIntake/Close")
53+
public boolean isVoltageClose(double setVoltage) {
5454
double voltageDifference = Math.abs(setVoltage - inputs.appliedVoltage);
55-
56-
// Check if the absolute difference is within the tolerance
57-
return voltageDifference <= tolerance;
55+
return voltageDifference <= GroundIntakeConstants.GROUND_INTAKE_TOLERANCE;
5856
}
5957

6058
public void setVoltage(double voltage) {
@@ -63,8 +61,7 @@ public void setVoltage(double voltage) {
6361
} else {
6462
io.setVoltage(voltage);
6563
}
66-
67-
Logger.recordOutput('GroundIntake/Close', isVoltageClose(voltage, 1));
64+
isVoltageClose(voltage);
6865
}
6966

7067
public void setBrake(boolean brake) {

src/main/java/frc/robot/subsystems/groundIntake/GroundIntakeConstants.java

+1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ public static class GroundIntakePhysicalConstants {
2525
public static final double GROUND_INTAKE_IN_VOLTAGE = 9.2;
2626
public static final double GROUND_INTAKE_WEAK_IN_VOLTAGE = 4.5;
2727
public static final double GROUND_INTAKE_OUT_VOLTAGE = -9;
28+
public static final double GROUND_INTAKE_TOLERANCE = 1;
2829
}

src/main/java/frc/robot/subsystems/indexer/Indexer.java

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package frc.robot.subsystems.indexer;
22

33
import org.littletonrobotics.junction.networktables.LoggedDashboardNumber;
4+
import org.littletonrobotics.junction.AutoLogOutput;
45
import org.littletonrobotics.junction.Logger;
56

67

@@ -43,13 +44,10 @@ public Indexer (IndexerIO io) {
4344
logD = new LoggedDashboardNumber("Intake/D", io.getD());
4445
}
4546

46-
//Check if the actual voltage is close to the desired voltage
47-
public boolean isVoltageClose(double setVoltage, double tolerance) {
48-
// Calculate the absolute difference between the desired and applied voltages
47+
@AutoLogOutput(key = "Indexer/Close")
48+
public boolean isVoltageClose(double setVoltage) {
4949
double voltageDifference = Math.abs(setVoltage - inputs.appliedVoltage);
50-
51-
// Check if the absolute difference is within the tolerance
52-
return voltageDifference <= tolerance;
50+
return voltageDifference <= IndexerConstants.INDEXER_TOLERANCE;
5351
}
5452

5553
public void periodic() {
@@ -105,7 +103,7 @@ public void setVoltage(double voltage) {
105103
} else {
106104
io.setVoltage(voltage);
107105
}
108-
Logger.recordOutput('Indexer/Close', isVoltageClose(voltage, 1));
106+
isVoltageClose(voltage);
109107
}
110108

111109
public void setBrake(boolean brake) {

src/main/java/frc/robot/subsystems/indexer/IndexerConstants.java

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public static class IndexerPhysicalConstants {
4040
public static final double INDEXER_IN_VOLTAGE = 8;
4141
public static final double INDEXER_IN_VOLTAGE_WEAK = 4.2;
4242
public static final double INDEXER_OUT_VOLTAGE = -2;
43+
public static final double INDEXER_TOLERANCE = 1;
4344

4445
public static final double SHOOTER_UNJAM_TIME = 0.2;
4546

src/main/java/frc/robot/subsystems/pivotArm/PivotArm.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package frc.robot.subsystems.pivotArm;
22

3+
import frc.robot.subsystems.pivotArm.PivotArmConstants;
4+
35
import static edu.wpi.first.units.Units.Second;
46
import static edu.wpi.first.units.Units.Seconds;
57
import static edu.wpi.first.units.Units.Volts;
@@ -9,6 +11,7 @@
911

1012
import java.util.function.DoubleSupplier;
1113

14+
import org.littletonrobotics.junction.AutoLogOutput;
1215
import org.littletonrobotics.junction.Logger;
1316
import org.littletonrobotics.junction.networktables.LoggedDashboardNumber;
1417

@@ -134,13 +137,10 @@ public void setBrake(boolean brake) {
134137
io.setBrake(brake);
135138
}
136139

137-
//Check if the actual voltage is close to the desired voltage
138-
public boolean isVoltageClose(double setVoltage, double tolerance) {
139-
// Calculate the absolute difference between the desired and applied voltages
140-
double voltageDifference = Math.abs(setVoltage - inputs.appliedVoltage);
141-
142-
// Check if the absolute difference is within the tolerance
143-
return voltageDifference <= tolerance;
140+
@AutoLogOutput(key = "PivotArm/Close")
141+
public boolean isVoltageClose(double setVoltage) {
142+
double voltageDifference = Math.abs(setVoltage - inputs.appliedVolts);
143+
return voltageDifference <= PivotArmConstants.PIVOT_ARM_TOLERANCE;
144144
}
145145

146146
public void setVoltage(double motorVolts) {
@@ -156,7 +156,7 @@ public void setVoltage(double motorVolts) {
156156
} else {
157157
io.setVoltage(motorVolts);
158158
}
159-
Logger.recordOutput('PivotArm/Close', isVoltageClose(voltage, 1));
159+
isVoltageClose(motorVolts);
160160
}
161161

162162
public void move(double speed) {

src/main/java/frc/robot/subsystems/pivotArm/PivotArmConstants.java

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public class PivotArmConstants {
3131

3232
public static final double RAMP_RATE = 0.5;
3333
public static final double STEP_VOLTAGE = 3.0;
34+
public static final double PIVOT_ARM_TOLERANCE = 1.0;
3435

3536
public static class PivotArmSimConstants {
3637
public static final double[] kPivotSimPID = { 15, 0, 0, 0 };

src/main/java/frc/robot/subsystems/shooter/Shooter.java

+14-9
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import org.littletonrobotics.junction.AutoLogOutput;
1313
import org.littletonrobotics.junction.Logger;
14+
import org.littletonrobotics.junction.networktables.LoggedDashboardBoolean;
1415

1516
import static frc.robot.subsystems.shooter.ShooterConstants.*;
1617

@@ -60,13 +61,17 @@ public Shooter(ShooterIO io) {
6061
shooterIO.setRightPID(rightkP.get(), rightkI.get(), rightkD.get());
6162
}
6263

63-
//Check if the actual voltage is close to the desired voltage
64-
public boolean isVoltageClose(double setVoltage, double tolerance) {
65-
// Calculate the absolute difference between the desired and applied voltages
66-
double voltageDifference = Math.abs(setVoltage - inputs.appliedVoltage);
67-
68-
// Check if the absolute difference is within the tolerance
69-
return voltageDifference <= tolerance;
64+
@AutoLogOutput(key = "Shooter/CloseRight")
65+
public boolean isVoltageRightClose(double setVoltage) {
66+
double voltageDifference = Math.abs(setVoltage - shooterInputs.rightFlywheelAppliedVolts);
67+
return voltageDifference <= SHOOTER_TOLERANCE;
68+
}
69+
70+
@AutoLogOutput(key = "Shooter/CloseLeft")
71+
public boolean isVoltageLeftClose(double setVoltage) {
72+
double voltageDifference = Math.abs(setVoltage - shooterInputs.leftFlywheelAppliedVolts);
73+
return voltageDifference <= SHOOTER_TOLERANCE;
74+
}
7075

7176

7277
@Override
@@ -183,8 +188,8 @@ public void setVoltage(DoubleSupplier leftVoltage, DoubleSupplier rightVoltage){
183188
} else {
184189
shooterIO.setVoltage(leftMotorVoltage, rightMotorVoltage);
185190
}
186-
}
187-
Logger.recordOutput('Shooter/Close', isVoltageClose(voltage, 1));
191+
isVoltageLeftClose(leftVoltage.getAsDouble());
192+
isVoltageRightClose(rightVoltage.getAsDouble());
188193
}
189194

190195
public void setVoltage(double volts){

src/main/java/frc/robot/subsystems/shooter/ShooterConstants.java

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ public class ShooterConstants {
77
public static final double SHOOTER_UNJAM_VOLTAGE = -0.5;
88

99
public static final double SHOOTER_FULL_VOLTAGE = 11;
10+
public static final double SHOOTER_TOLERANCE = 1.0;
1011

1112
public static class ShooterSimConstants {
1213
public static final double RIGHT_MOTOR_MIN_SPEED = 0;

0 commit comments

Comments
 (0)