Skip to content
This repository has been archived by the owner on May 19, 2024. It is now read-only.

Commit

Permalink
feat(shooter): Implement charge and shoot.
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenheroux committed Jan 8, 2024
1 parent 9d50092 commit b604667
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
3 changes: 1 addition & 2 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ private void initializeShuffleboards() {
}

private void configureBindings() {
// TODO
operator.rightBumper().whileTrue(shooter.serialize()).onFalse(shooter.stopSerializing());
operator.rightBumper().whileTrue(shooter.spin()).onFalse(shooter.stopSpinning());
operator.rightTrigger().whileTrue(shooter.smartSerialize()).onFalse(shooter.stopSerializing());
}

Expand Down
25 changes: 12 additions & 13 deletions src/main/java/frc/robot/shooter/Shooter.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,6 @@ private boolean isHoldingNote() {
return beamBreakSensorValues.isBroken; // TODO debounce / filter?
}

/**
* Returns true if the shooter is not holding a note.
*
* @return true if the shooter is not holding a note.
*/
private boolean isNotHoldingNote() {
return !isHoldingNote();
}

/**
* Calculates the tangential speed of the serializer in meters per second.
*
Expand Down Expand Up @@ -120,17 +111,25 @@ public void addToShuffleboard(ShuffleboardTab tab) {
}

public Command serialize() {
return Commands.run(() -> serializerMotor.setVoltage(4));
return Commands.run(() -> serializerMotor.setVoltage(4), this);
}

public Command stopSerializing() {
return Commands.runOnce(() -> serializerMotor.setVoltage(0));
return Commands.runOnce(() -> serializerMotor.setVoltage(0), this);
}

public Command smartSerialize() {
return serialize()
.until(this::isNotHoldingNote)
.unless(this::isNotHoldingNote)
.onlyWhile(this::isHoldingNote)
.onlyIf(this::isHoldingNote)
.andThen(stopSerializing());
}

public Command spin() {
return Commands.run(() -> flywheelMotor.setVoltage(8), this);
}

public Command stopSpinning() {
return Commands.runOnce(() -> flywheelMotor.setVoltage(0), this);
}
}

0 comments on commit b604667

Please sign in to comment.