Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seamless amp #63

Merged
merged 5 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.CommandScheduler;
import edu.wpi.first.wpilibj2.command.Commands;
import edu.wpi.first.wpilibj2.command.FunctionalCommand;
import edu.wpi.first.wpilibj2.command.InstantCommand;
Expand Down Expand Up @@ -427,6 +428,7 @@ private void configureModes() {
testModeChooser.addOption("Shooter Tuning", "tuning-shooter");
testModeChooser.addOption("Aimer Tuning", "tuning-aimer");
testModeChooser.addOption("Shot Tuning", "tuning-shot");
testModeChooser.addOption("Amp Tuning", "tuning-amp");

SmartDashboard.putData("Test Mode Chooser", testModeChooser);
}
Expand Down Expand Up @@ -651,6 +653,58 @@ public void testInit() {
0)))
.onFalse(new InstantCommand(() -> scoringSubsystem.setVolts(0, 0)));
break;
case "tuning-amp":
SmartDashboard.putNumber(
"Test-Mode/amp/aimerSetpointPosition",
ScoringConstants.ampAimerAngleRotations);

// Let us drive
CommandScheduler.getInstance().cancelAll();
setUpDriveWithJoysticks();

// Reset bindings
masher = new CommandXboxController(2);

// Let us intake
masher.b()
.onTrue(new InstantCommand(() -> intakeSubsystem.run(IntakeAction.INTAKE)))
.onFalse(new InstantCommand(() -> intakeSubsystem.run(IntakeAction.NONE)));

// Let us reverse intake (in case a note gets jammed during amp tuning)
masher.a()
.onTrue(new InstantCommand(() -> intakeSubsystem.run(IntakeAction.REVERSE)))
.onFalse(new InstantCommand(() -> intakeSubsystem.run(IntakeAction.NONE)));

masher.rightTrigger()
.onTrue(
new InstantCommand(
() ->
scoringSubsystem.runToPosition(
SmartDashboard.getNumber(
"Test-Mode/amp/aimerSetpointPosition",
0.0),
0)))
.onTrue(
new InstantCommand(
() ->
scoringSubsystem.setAction(
ScoringAction.TEMPORARY_SETPOINT)))
.onFalse(
new InstantCommand(
() -> scoringSubsystem.setAction(ScoringAction.OVERRIDE)));

masher.rightBumper()
.onTrue(
new InstantCommand(
() ->
scoringSubsystem.setOverrideKickerVoltsDirectly(
12.0)))
.onFalse(
new InstantCommand(
() ->
scoringSubsystem.setOverrideKickerVoltsDirectly(
0.0)));
break;
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/frc/robot/commands/ShootWithGamepad.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ public void execute() {
// ScoringAction.SHOOT will shoot when ready.
// Therefore, when shoot is pressed, check if we've transitioned to aim and then
// transition to shoot.
if (scoring.getCurrentAction() == ScoringAction.AIM) {
if (scoring.getCurrentAction() == ScoringAction.AIM
|| scoring.getCurrentAction() == ScoringAction.AMP_AIM) {
scoring.setAction(ScoringAction.SHOOT);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/constants/FieldConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public final class FieldConstants {
public static final double midfieldLowThresholdM = 5.87;
public static final double midfieldHighThresholdM = 10.72;

public static final Rotation2d ampHeading = new Rotation2d(-Math.PI / 2);
public static final Rotation2d ampHeading = new Rotation2d(Math.PI / 2);

public static final Rotation2d blueUpHeading = Rotation2d.fromRadians(0.0);
public static final Rotation2d blueDownHeading = Rotation2d.fromRadians(Math.PI);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/frc/robot/constants/ScoringConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public class ScoringConstants {

public static final double aimAngleTolerance = 0.015;

public static final double ampAimerAngleRotations = 0.14;

public static final double maxAimIntake = 0.0;
public static final double minAimIntake = 0.0;

Expand Down
17 changes: 14 additions & 3 deletions src/main/java/frc/robot/subsystems/scoring/ScoringSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,7 @@ private void prime() {
private void ampPrime() {
// shooterIo.setShooterVelocityRPM(ScoringConstants.shooterAmpVelocityRPM);
// TODO: Test this out
aimerIo.setAimAngleRot(
0.25); // This is actually in rotations and not radians, I really need to rename all
// of the aimer IO functions
aimerIo.setAimAngleRot(ScoringConstants.ampAimerAngleRotations);
if (action != ScoringAction.SHOOT && action != ScoringAction.AMP_AIM) {
state = ScoringState.IDLE;
} else if (action == ScoringAction.SHOOT) {
Expand Down Expand Up @@ -373,6 +371,14 @@ private void shoot() {

private void ampShoot() {
shooterIo.setKickerVolts(-12); // TODO: Test if this kicks note forward or backward
aimerIo.setAimAngleRot(ScoringConstants.ampAimerAngleRotations);

// Revert to amp prime after we shoot the note
// This will keep the arm up and allow the driver to drive away from the amp before the arm
// comes down
jkleiber marked this conversation as resolved.
Show resolved Hide resolved
if (action == ScoringAction.WAIT || (!hasNote() && shootTimer.get() > 1.0)) {
state = ScoringState.AMP_PRIME;
}

// I see no reason why amp should not shoot within 1 second but if it takes longer than
// that, we should probably let it
Expand Down Expand Up @@ -773,4 +779,9 @@ public boolean readyToShoot() {
public void setAimerStatorCurrentLimit(double limit) {
aimerIo.setStatorCurrentLimit(limit);
}

public void setOverrideKickerVoltsDirectly(double volts) {
/* Immediately sets kicker voltage, fully ignoring scoring state */
shooterIo.setKickerVolts(volts);
}
}
Loading