Skip to content

Commit 9a4ed19

Browse files
committed
Test functions made for.. testing
1 parent 1664ca7 commit 9a4ed19

File tree

1 file changed

+49
-2
lines changed

1 file changed

+49
-2
lines changed

src/main/java/frc/robot/Robot.java

+49-2
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,54 @@ public void robotInit() {
143143
NetworkTableInstance.getDefault().getTable("limelight").getEntry("camMode").setNumber(0); //Sets the Limelight as a Vision Proccesor
144144
NetworkTableInstance.getDefault().getTable("TalonPi").getEntry("alliance").setString("red");
145145
}
146-
146+
147+
/** This function is called once when test mode is enabled. */
148+
@Override
149+
public void testInit() {
150+
SmartDashboard.putNumber("Target RPM", 0);
151+
SmartDashboard.putNumber("Target Velocity", 0);
152+
SmartDashboard.putNumber("Target Angle", 0);
153+
}
154+
155+
/** This function is called periodically during test mode. */
156+
@Override
157+
public void testPeriodic() {
158+
double[][] shooterCalculations = getLimelightData();
159+
if(shooterCalculations != null) {
160+
SmartDashboard.putNumber("Distance: ",shooterCalculations[0][0]);
161+
SmartDashboard.putNumber("Shooter Angle: ",shooterCalculations[0][1]);
162+
SmartDashboard.putNumber("Ideal Ball Velocity :",shooterCalculations[0][2]);
163+
SmartDashboard.putNumber("Limelight H-Angle: ",shooterCalculations[1][0]);
164+
SmartDashboard.putNumber("Limelight V-Angle: ",shooterCalculations[1][1]);
165+
SmartDashboard.putNumber("Limelight Latency: ",shooterCalculations[1][2]);
166+
SmartDashboard.putNumber("Flywheel RPM: ", shooterFly.getSelectedSensorVelocity()/4 * 2048);
167+
SmartDashboard.putNumber("Current Angle", gyro.getRoll());
168+
}
169+
170+
double targetrpm = SmartDashboard.getNumber("Target RPM", 0);
171+
double targetvelocity = SmartDashboard.getNumber("Target Velocity", 0);
172+
double targetangle = SmartDashboard.getNumber("Target Angle", 0);
173+
174+
if (controller.getRightBumper()) { // sets shooter to the target rpm to test PID loop
175+
shooterFly.set(ControlMode.Velocity, 4*targetrpm*2048); //TODO: Gear ratio multiplier MIGHT HAVE TO MULTIPLY BY 2048- will test later
176+
}
177+
178+
else if (controller.getLeftBumper()) { // sets shooter to the target velocity for ball shooting
179+
double rpm = getRPM(targetvelocity, 1);
180+
shooterFly.set(ControlMode.Velocity, rpm);
181+
}
182+
183+
if (controller.getXButton()) { // actuates hood to the proper angle
184+
if ((gyro.getRoll() > targetangle + 5) && !upperShooterLimit.get()) { // TODO: Adjust degrees of freedom +- 5
185+
hood.set(ControlMode.PercentOutput, 0.1);
186+
ready = false;
187+
}
188+
else if ((gyro.getRoll() < targetangle-5) && !lowerShooterLimit.get()) {
189+
hood.set(ControlMode.PercentOutput, -0.1);
190+
ready = false;
191+
}
192+
}
193+
}
147194

148195
@Override
149196
public void autonomousInit() {
@@ -320,7 +367,7 @@ public void fire() {
320367
if (!intakeLimit.get()) {
321368
wrist.set(ControlMode.PercentOutput, 0.75);
322369
}
323-
shooterFly.set(ControlMode.Velocity, 4*rpm); //TODO: Gear ratio multiplier MIGHT HAVE TO MULTIPLY BY 2048- will test later
370+
shooterFly.set(ControlMode.Velocity, 4*rpm*2048); //TODO: Gear ratio multiplier MIGHT HAVE TO MULTIPLY BY 2048- will test later
324371
if ((gyro.getRoll() > idealAngle + 5) && !upperShooterLimit.get()) { // TODO: Adjust degrees of freedom +- 5
325372
hood.set(ControlMode.PercentOutput, 0.1);
326373
ready = false;

0 commit comments

Comments
 (0)