generated from Frc5572/Java-Template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
289bc9e
commit b509274
Showing
8 changed files
with
252 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package frc.robot.subsystems.indexer; | ||
|
||
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 | ||
*/ | ||
public class Indexer extends SubsystemBase { | ||
private IndexerIO io; | ||
private IndexerInputsAutoLogged indexerAutoLogged = new IndexerInputsAutoLogged(); | ||
|
||
// 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); | ||
public Trigger noteNotInIndexer = new Trigger(() -> !getIndexerBeamBrakeStatus()); | ||
public Trigger indexerActive = new Trigger(() -> getIndexerRPM() > 0); | ||
|
||
public Indexer(IndexerIO io) { | ||
this.io = io; | ||
io.updateInputs(indexerAutoLogged); | ||
} | ||
|
||
@Override | ||
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); | ||
// } | ||
} | ||
|
||
/** | ||
* Set the power for the indexer motor | ||
* | ||
* @param percentage 0-1 power for the indexer motor | ||
*/ | ||
public void setIndexerMotor(double percentage) { | ||
Logger.recordOutput("/Intake/Indexer Percentage", percentage); | ||
io.setIndexerMotorPercentage(percentage); | ||
} | ||
|
||
/** | ||
* Get the status of the indexer beam brake. | ||
* | ||
* @return True if beam brake is broken, False if open | ||
*/ | ||
public boolean getIndexerBeamBrakeStatus() { | ||
return indexerAutoLogged.indexerBeamBrake; | ||
} | ||
|
||
|
||
public double getIndexerRPM() { | ||
return indexerAutoLogged.indexerRPM; | ||
} | ||
|
||
/** | ||
* Command to run the indexer | ||
* | ||
* @return {@link Command} to run the indexer motors | ||
*/ | ||
public Command runIndexerMotor(double speed) { | ||
return Commands.startEnd(() -> { | ||
setIndexerMotor(speed); | ||
}, () -> { | ||
setIndexerMotor(0); | ||
}, this); | ||
} | ||
} |
Oops, something went wrong.