Skip to content

Commit

Permalink
fix syntax errors
Browse files Browse the repository at this point in the history
  • Loading branch information
legoguy1000 committed Oct 14, 2024
1 parent 51c8a10 commit 5d60e08
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 31 deletions.
1 change: 1 addition & 0 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ public static final class LEDConstants {
public static final Color INTAKE_COLOR = Color.kGreen;
public static final Color INDEXER_COLOR = Color.kPurple;
public static final Color ALERT_COLOR = Color.kWhite;
public static final Color NO_NOTE_COLOR = Color.kBlack;
}

}
42 changes: 23 additions & 19 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import frc.robot.subsystems.intake.Intake;
import frc.robot.subsystems.intake.IntakeIO;
import frc.robot.subsystems.intake.IntakeIOFalcon;
import frc.robot.subsystems.intake.IntakeSim;
import frc.robot.subsystems.shooter.Shooter;
import frc.robot.subsystems.shooter.ShooterIO;
import frc.robot.subsystems.shooter.ShooterVortex;
Expand Down Expand Up @@ -98,9 +99,9 @@ public class RobotContainer {
RobotContainer.mainDriverTab.add("Auto - Dump Notes", false).withWidget("Toggle Switch")
.withProperties(Map.of()).withPosition(7, 7).withSize(3, 1);

private String noNote = Color.kBlack.toHexString();
private GenericEntry haveNote = RobotContainer.mainDriverTab.add("Have Note", noNote)
.withWidget("Single Color View").withPosition(9, 4).withSize(3, 2).getEntry();
// private String noNote = Color.kBlack.toHexString();
// private GenericEntry haveNote = RobotContainer.mainDriverTab.add("Have Note", noNote)
// .withWidget("Single Color View").withPosition(9, 4).withSize(3, 2).getEntry();

/* Controllers */
public final CommandXboxController driver = new CommandXboxController(Constants.DRIVER_ID);
Expand Down Expand Up @@ -141,7 +142,7 @@ public RobotContainer(RobotRunType runtimeType) {
case kSimulation:
s_Swerve = new Swerve(new SwerveIO() {}, cameras);
shooter = new Shooter(new ShooterIO() {});
intake = new Intake(new IntakeIO() {});
intake = new Intake(new IntakeSim());
elevatorWrist = new ElevatorWrist(new ElevatorWristIO() {}, operator);
break;
default:
Expand Down Expand Up @@ -173,37 +174,40 @@ public RobotContainer(RobotRunType runtimeType) {
* Configure Trigger Bindings
*/
private void configureTiggerBindings() {
this.indexer.noteInIndexer.negate().and(this.intake.noteInIntake.negate())
.onTrue(Commands.runOnce(() -> this.haveNote.setString(noNote)).ignoringDisable(true));
// No Note
this.intake.noteInIndexer.negate().and(this.intake.noteInIntake.negate())
.onTrue(Commands.runOnce(
() -> intake.haveNote.setString(Constants.LEDConstants.NO_NOTE_COLOR.toHexString()))
.ignoringDisable(true));
// Flash LEDs Purple when note in indexer
this.indexer.noteInIndexer.and(this.intake.noteInIntake.negate())
this.intake.noteInIndexer.and(this.intake.noteInIntake.negate())
.onTrue(new FlashingLEDColor(leds, Constants.LEDConstants.INDEXER_COLOR).withTimeout(3))
.onTrue(Commands.runOnce(() -> {
this.haveNote.setString(Constants.LEDConstants.INDEXER_COLOR.toHexString());
intake.haveNote.setString(Constants.LEDConstants.INDEXER_COLOR.toHexString());
}).ignoringDisable(true));
// Flash LEDs Green when note in Intake
this.intake.noteInIntake.and(this.indexer.noteInIndexer.negate())
this.intake.noteInIntake.and(this.intake.noteInIndexer.negate())
.onTrue(new FlashingLEDColor(leds, Constants.LEDConstants.INTAKE_COLOR).withTimeout(3))
.onTrue(Commands.runOnce(() -> {
this.haveNote.setString(Constants.LEDConstants.INTAKE_COLOR.toHexString());
intake.haveNote.setString(Constants.LEDConstants.INTAKE_COLOR.toHexString());
}).ignoringDisable(true));
// Flash LEDs White when note in indexer AND intake at the same time
this.intake.noteInIntake.and(this.indexer.noteInIndexer)
this.intake.noteInIntake.and(this.intake.noteInIndexer)
.whileTrue(new FlashingLEDColor(leds, Constants.LEDConstants.ALERT_COLOR))
.onTrue(Commands.runOnce(() -> {
this.haveNote.setString(Constants.LEDConstants.ALERT_COLOR.toHexString());
intake.haveNote.setString(Constants.LEDConstants.ALERT_COLOR.toHexString());
}).ignoringDisable(true));
// Automatically move elevator and wrist to home position after note is spit in AMP mode
OperatorState.isAmpMode.and(OperatorState.isManualMode.negate())
.and(this.indexer.noteInIndexer.negate().debounce(1))
.and(this.intake.noteInIndexer.negate().debounce(1))
.onTrue(elevatorWrist.homePosition());
// Automatically move elevator and wrist to home position when intaking and don't have a
// note
this.intake.intakeActive.and(this.indexer.noteInIndexer.negate())
this.intake.intakeActive.and(this.intake.noteInIndexer.negate())
.and(this.elevatorWrist.elevatorAtHome.negate()).onTrue(elevatorWrist.homePosition());

RobotModeTriggers.autonomous().and(indexer.noteInIndexer.negate())
.and(shooter.isShooting.negate()).whileTrue(CommandFactory.intakeNote(intake, indexer));
RobotModeTriggers.autonomous().and(intake.noteInIndexer.negate())
.and(shooter.isShooting.negate()).whileTrue(CommandFactory.intakeNote(intake));
}

/**
Expand All @@ -221,7 +225,7 @@ private void configureButtonBindings() {
driver.rightTrigger().whileTrue(CommandFactory.newIntakeCommand(intake, elevatorWrist));
// intake backward
driver.leftTrigger().and(elevatorWrist.wristReverseOutakeLimit)
.whileTrue(CommandFactory.runIntakeMotorNonStop(intake, -1, -.20));
.whileTrue(intake.runIntakeMotorNonStop(-1, -.20));

/* Operator Buttons */
// spit note currently in robot through shooter
Expand All @@ -245,7 +249,7 @@ private void configureButtonBindings() {
// set shooter to home preset position
operator.y().onTrue(elevatorWrist.homePosition());
operator.y().and(elevatorWrist.elevatorAtAmp).and(intake.noteInIndexer)
.onTrue(CommandFactory.runIntakeMotorNonStop(intake, 0, -0.2).withTimeout(2.0)
.onTrue(intake.runIntakeMotorNonStop(0, -0.2).withTimeout(2.0)
.until(intake.noteNotInIndexer.debounce(.5)));

// increment once through states list to next state
Expand All @@ -260,7 +264,7 @@ private void configureButtonBindings() {
.onTrue(elevatorWrist.homePosition());
// run action based on current state as incremented through operator states list
operator.a().and(OperatorState.isSpeakerMode).whileTrue(elevatorWrist.speakerPreset());
operator.a().and(OperatorState.isAmpMode).and(this.indexer.noteInIndexer)
operator.a().and(OperatorState.isAmpMode).and(this.intake.noteInIndexer)
.whileTrue(elevatorWrist.ampPosition());
operator.a().and(OperatorState.isShootWhileMoveMode).and(s_Swerve.seeAprilTag)
.whileTrue(new ShootWhileMoving(s_Swerve, driver, () -> s_Swerve.getPose(),
Expand Down
28 changes: 16 additions & 12 deletions src/main/java/frc/robot/subsystems/intake/Intake.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import org.littletonrobotics.junction.Logger;
import edu.wpi.first.math.filter.Debouncer;
import edu.wpi.first.networktables.GenericEntry;
import edu.wpi.first.wpilibj.util.Color;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Commands;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
Expand All @@ -20,9 +19,13 @@ public class Intake extends SubsystemBase {

public Trigger noteInIntake = new Trigger(() -> getintakeBeamBrakeStatus()).debounce(0.25,
Debouncer.DebounceType.kRising);
public Trigger noteInIndexer = new Trigger(() -> getIndexerBeamBrakeStatus()).debounce(0.25,
Debouncer.DebounceType.kRising);
public Trigger noteNotInIndexer = new Trigger(() -> !getIndexerBeamBrakeStatus());
public Trigger intakeActive = new Trigger(() -> getIntakeRPM() > 0);
private String noNote = Color.kBlack.toHexString();
private GenericEntry haveNote = RobotContainer.mainDriverTab.add("Have Note", noNote)

public GenericEntry haveNote = RobotContainer.mainDriverTab
.add("Have Note", Constants.LEDConstants.NO_NOTE_COLOR.toHexString())
.withWidget("Single Color View").withPosition(9, 4).withSize(3, 2).getEntry();

public Intake(IntakeIO io) {
Expand All @@ -34,15 +37,15 @@ public Intake(IntakeIO io) {
public void periodic() {
io.updateInputs(intakeAutoLogged);
Logger.processInputs("Intake", intakeAutoLogged);
if (getIndexerBeamBrakeStatus() && getintakeBeamBrakeStatus()) {
haveNote.setString(Constants.LEDConstants.ALERT_COLOR.toHexString());
} else if (getIndexerBeamBrakeStatus()) {
haveNote.setString(Constants.LEDConstants.INDEXER_COLOR.toHexString());
} else if (getintakeBeamBrakeStatus()) {
haveNote.setString(Constants.LEDConstants.INTAKE_COLOR.toHexString());
} else {
haveNote.setString(noNote);
}
// if (getIndexerBeamBrakeStatus() && getintakeBeamBrakeStatus()) {
// haveNote.setString(Constants.LEDConstants.ALERT_COLOR.toHexString());
// } else if (getIndexerBeamBrakeStatus()) {
// haveNote.setString(Constants.LEDConstants.INDEXER_COLOR.toHexString());
// } else if (getintakeBeamBrakeStatus()) {
// haveNote.setString(Constants.LEDConstants.INTAKE_COLOR.toHexString());
// } else {
// haveNote.setString(noNote);
// }
}

/**
Expand All @@ -67,6 +70,7 @@ public void setIndexerMotor(double percentage) {

public double getIntakeRPM() {
return intakeAutoLogged.intakeRPM;
}

/**
* Get the status of the indexer beam brake.
Expand Down
27 changes: 27 additions & 0 deletions src/main/java/frc/robot/subsystems/intake/IntakeSim.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package frc.robot.subsystems.intake;

import edu.wpi.first.wpilibj.DigitalInput;
import frc.robot.Constants;

public class IntakeSim implements IntakeIO {

private final DigitalInput indexerBeamBrake =
new DigitalInput(Constants.IntakeConstants.INDEXER_BEAM_BRAKE_DIO_PORT);
private final DigitalInput intakeBeamBrake =
new DigitalInput(Constants.IntakeConstants.INTAKE_BEAM_BRAKE_DIO_PORT);

public IntakeSim() {}

@Override
public void updateInputs(IntakeInputs inputs) {
// inputs.intakeSupplyVoltage = intakeMotorLeft.getBusVoltage();
// inputs.intakeAmps = intakeMotorLeft.getOutputCurrent();
// inputs.intakeRPM = intakeRelativeEnc.getVelocity();
// inputs.indexerSupplyVoltage = indexerMotor.getSupplyVoltage().getValueAsDouble();
// inputs.indexerMotorVoltage = indexerMotor.getMotorVoltage().getValueAsDouble();
// inputs.indexerAmps = indexerMotor.getSupplyCurrent().getValueAsDouble();
// inputs.indexerRPM = indexerMotor.getVelocity().getValueAsDouble();
inputs.indexerBeamBrake = !indexerBeamBrake.get(); // true == game piece
inputs.intakeBeamBrake = !intakeBeamBrake.get(); // true == game piece
}
}

0 comments on commit 5d60e08

Please sign in to comment.