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

Commit

Permalink
feat(shooter): Add intake commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenheroux committed Jan 8, 2024
1 parent 1d53fd1 commit 804711d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ private void initializeShuffleboards() {
}

private void configureBindings() {
operator.leftBumper().whileTrue(shooter.intake());
operator.leftTrigger().whileTrue(shooter.smartIntake());

operator.rightBumper().whileTrue(shooter.shoot());
operator.rightTrigger().whileTrue(shooter.smartShoot());
}
Expand Down
24 changes: 20 additions & 4 deletions src/main/java/frc/robot/shooter/Shooter.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,24 +117,40 @@ public void addToShuffleboard(ShuffleboardTab tab) {
flywheel.addDouble("Flywheel Current (A)", () -> flywheelMotorValues.currentAmps);
}

public Command intake() {
return Commands.parallel(
Commands.run(() -> serializerMotor.setVoltage(SerializerConstants.INTAKE_VOLTAGE))
.finallyDo(serializerMotor::stop),
Commands.run(() -> flywheelMotor.setVoltage(FlywheelConstants.INTAKE_VOLTAGE))
.finallyDo(flywheelMotor::stop));
}

public Command smartIntake() {
return intake().until(this::isHoldingNote).unless(this::isHoldingNote);
}

public Command serialize() {
return Commands.run(() -> serializerMotor.setVoltage(SerializerConstants.SERIALIZE_VOLTAGE)).finallyDo(serializerMotor::stop);
return Commands.run(() -> serializerMotor.setVoltage(SerializerConstants.SERIALIZE_VOLTAGE))
.finallyDo(serializerMotor::stop);
}

public Command smartSerialize() {
return serialize().onlyWhile(this::isHoldingNote).onlyIf(this::isHoldingNote);
}

public Command spin() {
return Commands.run(() -> flywheelMotor.setVoltage(FlywheelConstants.SHOOT_VOLTAGE)).finallyDo(flywheelMotor::stop);
return Commands.run(() -> flywheelMotor.setVoltage(FlywheelConstants.SHOOT_VOLTAGE))
.finallyDo(flywheelMotor::stop);
}

public Command shoot() {
return Commands.deadline(Commands.waitSeconds(SerializerConstants.SHOOT_DELAY).andThen(serialize()), spin());
return Commands.deadline(
Commands.waitSeconds(SerializerConstants.SHOOT_DELAY).andThen(serialize()), spin());
}

public Command smartShoot() {
return Commands.deadline(
Commands.waitSeconds(SerializerConstants.SHOOT_DELAY).andThen(smartSerialize()), spin().onlyIf(this::isHoldingNote));
Commands.waitSeconds(SerializerConstants.SHOOT_DELAY).andThen(smartSerialize()),
spin().onlyIf(this::isHoldingNote));
}
}
12 changes: 9 additions & 3 deletions src/main/java/frc/robot/shooter/ShooterConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,14 @@ public static class SerializerConstants {
/** Radius of the serializer wheel in meters. */
public static final double RADIUS = 0.5 * Units.inchesToMeters(4.0);

/** Voltage to apply while intaking in volts. */
public static final double INTAKE_VOLTAGE = -2.0; // TODO

/** Voltage to apply while serializing in volts. */
public static final double SERIALIZE_VOLTAGE = 4.0;
public static final double SERIALIZE_VOLTAGE = 4.0; // TODO

/** Delay between starting flywheel and serializing while shooting in seconds. */
public static final double SHOOT_DELAY = 1.0;
public static final double SHOOT_DELAY = 1.0; // TODO
}

/** Constants for the flywheel motor used in the shooter subsystem. */
Expand All @@ -60,7 +63,10 @@ public static class FlywheelConstants {
/** Radius of the flywheel wheel in meters. */
public static final double RADIUS = 0.5 * Units.inchesToMeters(4.0);

/** Voltage to apply while intaking in volts. */
public static final double INTAKE_VOLTAGE = -2.0; // TODO

/** Voltage to apply while shooting in volts. */
public static final double SHOOT_VOLTAGE = 8.0;
public static final double SHOOT_VOLTAGE = 8.0; // TODO
}
}

0 comments on commit 804711d

Please sign in to comment.