Skip to content

Commit

Permalink
IDK why this doesn't work
Browse files Browse the repository at this point in the history
  • Loading branch information
legoguy1000 committed Sep 30, 2024
1 parent 317b98d commit 6c1f5f1
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 37 deletions.
22 changes: 20 additions & 2 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@
import frc.robot.subsystems.indexer.Indexer;
import frc.robot.subsystems.indexer.IndexerIO;
import frc.robot.subsystems.indexer.IndexerIOFalcon;
import frc.robot.subsystems.indexer.IndexerIOSim;
import frc.robot.subsystems.intake.Intake;
import frc.robot.subsystems.intake.IntakeIO;
import frc.robot.subsystems.intake.IntakeIORev;
import frc.robot.subsystems.intake.IntakeIOSim;
import frc.robot.subsystems.shooter.Shooter;
import frc.robot.subsystems.shooter.ShooterIO;
import frc.robot.subsystems.shooter.ShooterVortex;
Expand Down Expand Up @@ -100,6 +102,11 @@ public class RobotContainer {
public static SimpleWidget dumpNotes =
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();

/* Controllers */
public final CommandXboxController driver = new CommandXboxController(Constants.DRIVER_ID);
private final CommandXboxController operator = new CommandXboxController(Constants.OPERATOR_ID);
Expand Down Expand Up @@ -154,8 +161,8 @@ public RobotContainer(RobotRunType runtimeType) {
case kSimulation:
s_Swerve = new Swerve(new SwerveIO() {}, cameras);
shooter = new Shooter(new ShooterIO() {});
intake = new Intake(new IntakeIO() {});
indexer = new Indexer(new IndexerIO() {});
intake = new Intake(new IntakeIOSim() {});
indexer = new Indexer(new IndexerIOSim() {});
elevatorWrist = new ElevatorWrist(new ElevatorWristIO() {}, operator);
break;
default:
Expand Down Expand Up @@ -207,6 +214,17 @@ private void configureTiggerBindings() {
this.intake.intakeActive.and(this.indexer.noteInIndexer.negate())
.and(this.elevatorWrist.elevatorAtHome.negate()).onTrue(elevatorWrist.homePosition());

this.indexer.noteInIndexer.negate().and(this.intake.noteInIntake.negate())
.onTrue(Commands.run(() -> this.haveNote.setString(noNote)));
this.indexer.noteInIndexer.and(this.intake.noteInIntake).onTrue(Commands.run(() -> {
this.haveNote.setString(Constants.LEDConstants.ALERT_COLOR.toHexString());
System.out.println(Constants.LEDConstants.ALERT_COLOR.toHexString());
}));
this.indexer.noteInIndexer.and(this.intake.noteInIntake.negate()).onTrue(Commands.run(
() -> this.haveNote.setString(Constants.LEDConstants.INDEXER_COLOR.toHexString())));
this.indexer.noteInIndexer.negate().and(this.intake.noteInIntake).onTrue(Commands
.run(() -> this.haveNote.setString(Constants.LEDConstants.INTAKE_COLOR.toHexString())));


RobotModeTriggers.autonomous().and(indexer.noteInIndexer.negate())
.and(shooter.isShooting.negate()).whileTrue(CommandFactory.intakeNote(intake, indexer));
Expand Down
16 changes: 0 additions & 16 deletions src/main/java/frc/robot/subsystems/indexer/Indexer.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@

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;
import edu.wpi.first.wpilibj2.command.button.Trigger;
import frc.robot.RobotContainer;

/**
* Intake Subsystem
Expand All @@ -20,10 +17,6 @@ public class Indexer extends SubsystemBase {
// private GenericEntry beamBrake = RobotContainer.mainDriverTab.add("Have Note", false)
// .withWidget(BuiltInWidgets.kBooleanBox).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();


public Trigger noteInIndexer = new Trigger(() -> getIndexerBeamBrakeStatus()).debounce(0.25,
Debouncer.DebounceType.kRising);
Expand All @@ -39,15 +32,6 @@ public Indexer(IndexerIO io) {
public void periodic() {
io.updateInputs(indexerAutoLogged);
Logger.processInputs("Indexer", indexerAutoLogged);
// 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 Down
29 changes: 29 additions & 0 deletions src/main/java/frc/robot/subsystems/indexer/IndexerIOSim.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package frc.robot.subsystems.indexer;

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

/**
* Intake IO Layer with real motors and sensors
*/
public class IndexerIOSim implements IndexerIO {

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

/**
* Intake IO Layer with real motors and sensors
*/
public IndexerIOSim() {

}

@Override
public void updateInputs(IndexerInputs inputs) {
inputs.indexerBeamBrake = !indexerBeamBrake.get(); // true == game piece
inputs.indexerRPM = 0;
}

@Override
public void setIndexerMotorPercentage(double percent) {}
}
19 changes: 0 additions & 19 deletions src/main/java/frc/robot/subsystems/intake/Intake.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

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.SubsystemBase;
import edu.wpi.first.wpilibj2.command.button.Trigger;
import frc.robot.RobotContainer;

/**
* Intake Subsystem
Expand All @@ -15,13 +12,6 @@ public class Intake extends SubsystemBase {
private IntakeIO io;
private IntakeInputsAutoLogged intakeAutoLogged = new IntakeInputsAutoLogged();

// private GenericEntry beamBrake = RobotContainer.mainDriverTab.add("Have Note", false)
// .withWidget(BuiltInWidgets.kBooleanBox).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();

public Trigger noteInIntake = new Trigger(() -> getintakeBeamBrakeStatus()).debounce(0.25,
Debouncer.DebounceType.kRising);
public Trigger intakeActive = new Trigger(() -> getIntakeRPM() > 0);
Expand All @@ -35,15 +25,6 @@ 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);
// }
}

/**
Expand Down
26 changes: 26 additions & 0 deletions src/main/java/frc/robot/subsystems/intake/IntakeIOSim.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package frc.robot.subsystems.intake;

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

/**
* Intake IO Layer with real motors and sensors
*/
public class IntakeIOSim implements IntakeIO {

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

/**
* Intake IO Layer with real motors and sensors
*/
public IntakeIOSim() {}

@Override
public void updateInputs(IntakeInputs inputs) {
inputs.intakeBeamBrake = !intakeBeamBrake.get(); // true == game piece
}

@Override
public void setIntakeMotorPercentage(double percent) {}
}

0 comments on commit 6c1f5f1

Please sign in to comment.