Skip to content

Commit

Permalink
Intake subsystem/command edits
Browse files Browse the repository at this point in the history
  • Loading branch information
audreypj committed Sep 18, 2024
1 parent e1077e8 commit 516fa1c
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 51 deletions.
8 changes: 3 additions & 5 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,9 @@ public static final class Ports {
}

public static final class Modes {
public static final IntakePowers INTAKE = new IntakePowers(.95, .75);
public static final IntakePowers HOLD = new IntakePowers(0, 0d);
public static final IntakePowers REVERSE = new IntakePowers(-.5, -.5);
public static final IntakePowers SHOOT_SPEAKER = new IntakePowers(0, 0.7);
public static final IntakePowers SHOOT_AMP = new IntakePowers(0, -1);
public static final IntakePowers INTAKE = new IntakePowers(.95);
public static final IntakePowers HOLD = new IntakePowers(0);
public static final IntakePowers REVERSE = new IntakePowers(-.5);
}

public static final boolean IS_BEAMBREAK = true;
Expand Down
13 changes: 6 additions & 7 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@
import frc.robot.autonomous.HeadingAngle;
import frc.robot.autonomous.HeadingTargetLock;
import frc.robot.commands.AccelNoteCommand;
import frc.robot.commands.AdvancedIntakeCommand;
import frc.robot.commands.IntakeCommand;
import frc.robot.commands.DefaultDriveCommand;
import frc.robot.commands.DefenseModeCommand;
import frc.robot.commands.HaltDriveCommandsCommand;
import frc.robot.commands.HeightCommand;
import frc.robot.commands.IntakeCommand;
import frc.robot.commands.MaintainShooterCommand;
import frc.robot.commands.OuttakeCommand;
import frc.robot.commands.PivotAngleCommand;
Expand Down Expand Up @@ -131,7 +130,7 @@ public RobotContainer() {

// reigster commands for pathplanner
NamedCommands.registerCommand(
"IntakeCommand", new IntakeCommand(intakeSubsystem, shooterSubsystem, pivotSubsystem));
"IntakeCommand", new IntakeCommand(intakeSubsystem, shooterSubsystem, pivotSubsystem, elevatorSubsystem));
NamedCommands.registerCommand("ShootCommand", new ShootCommand(shooterSubsystem));
NamedCommands.registerCommand(
"ShooterRampUpCommand",
Expand Down Expand Up @@ -347,11 +346,11 @@ private void configureButtonBindings() {
// INTAKE
anthony
.leftBumper()
.onTrue(new AdvancedIntakeCommand(intakeSubsystem, shooterSubsystem, pivotSubsystem));
.onTrue(new IntakeCommand(intakeSubsystem, shooterSubsystem, pivotSubsystem, elevatorSubsystem));

jacob
.leftBumper()
.onTrue(new AdvancedIntakeCommand(intakeSubsystem, shooterSubsystem, pivotSubsystem));
.onTrue(new IntakeCommand(intakeSubsystem, shooterSubsystem, pivotSubsystem, elevatorSubsystem));

// SHOOT
anthony
Expand All @@ -360,7 +359,7 @@ private void configureButtonBindings() {
new AccelNoteCommand(shooterSubsystem)
.andThen(new ShootCommand(shooterSubsystem))
.andThen(
new AdvancedIntakeCommand(intakeSubsystem, shooterSubsystem, pivotSubsystem)));
new IntakeCommand(intakeSubsystem, shooterSubsystem, pivotSubsystem, elevatorSubsystem)));

// SHOOT OVERRIDE
jacob
Expand Down Expand Up @@ -419,7 +418,7 @@ private void configureButtonBindings() {
? -Setpoints.SOURCE_DEGREES
: Setpoints.SOURCE_DEGREES)
.alongWith(
new AdvancedIntakeCommand(intakeSubsystem, shooterSubsystem, pivotSubsystem)));
new IntakeCommand(intakeSubsystem, shooterSubsystem, pivotSubsystem, elevatorSubsystem)));

// NOTE TO SHOOTER OR SERIALIZER
anthony
Expand Down
23 changes: 0 additions & 23 deletions src/main/java/frc/robot/commands/AdvancedIntakeCommand.java

This file was deleted.

10 changes: 7 additions & 3 deletions src/main/java/frc/robot/commands/IntakeCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package frc.robot.commands;

import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.ElevatorSubsystem;
import frc.robot.subsystems.IntakeSubsystem;
import frc.robot.subsystems.IntakeSubsystem.IntakeMode;
import frc.robot.subsystems.PivotSubsystem;
Expand All @@ -16,16 +17,19 @@ public class IntakeCommand extends Command {
IntakeSubsystem intakeSubsystem;
ShooterSubsystem shooterSubsystem;
PivotSubsystem pivotSubsystem;
ElevatorSubsystem elevatorSubsystem;

/** Creates a new IntakeCommand. */
public IntakeCommand(
IntakeSubsystem intakeSubsystem,
ShooterSubsystem shooterSubsystem,
PivotSubsystem pivotSubsystem) {
PivotSubsystem pivotSubsystem,
ElevatorSubsystem elevatorSubsystem) {
this.intakeSubsystem = intakeSubsystem;
this.shooterSubsystem = shooterSubsystem;
this.pivotSubsystem = pivotSubsystem;
addRequirements(intakeSubsystem, shooterSubsystem, pivotSubsystem);
this.elevatorSubsystem = elevatorSubsystem;
addRequirements(intakeSubsystem, shooterSubsystem, pivotSubsystem, elevatorSubsystem);
// Use addRequirements() here to declare subsystem dependencies.
// addRequirements(intakeSubsystem, shooterSubsystem, pivotSubsystem);
}
Expand All @@ -36,6 +40,7 @@ public void initialize() {
pivotSubsystem.setTargetDegrees(20);
intakeSubsystem.setIntakeMode(IntakeMode.INTAKE);
shooterSubsystem.setShooterMode(ShooterMode.INTAKE);
elevatorSubsystem.setTargetHeight(0);
}

// Called every time the scheduler runs while the command is scheduled.
Expand All @@ -47,7 +52,6 @@ public void execute() {}
public void end(boolean interrupted) {
intakeSubsystem.setIntakeMode(IntakeSubsystem.IntakeMode.HOLD);
shooterSubsystem.setShooterMode(ShooterMode.IDLE);
shooterSubsystem.haltAccelerator();
}

// Returns true when the command should end.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/commands/TransferNoteCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public TransferNoteCommand(
} else if (shooterSubsystem.isShooterBeamBreakSensorTriggered()) {
addCommands(
new UnloadShooterCommand(shooterSubsystem, pivotSubsystem, elevatorSubsystem)
.andThen(new IntakeCommand(intakeSubsystem, shooterSubsystem, pivotSubsystem)));
.andThen(new IntakeCommand(intakeSubsystem, shooterSubsystem, pivotSubsystem, elevatorSubsystem)));
}
}
}
16 changes: 4 additions & 12 deletions src/main/java/frc/robot/subsystems/IntakeSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,22 @@ public class IntakeSubsystem extends SubsystemBase {
private final TalonFX intakeMotor;
private final ShuffleboardTab tab = Shuffleboard.getTab("Intake");
private IntakeMode intakeMode;
private IntakeMode pastMode;
private double timeSincePenaltyHazard;
private boolean pastPenalty;

public enum IntakeMode {
INTAKE(Intake.Modes.INTAKE),
HOLD(Intake.Modes.HOLD),
REVERSE(Intake.Modes.REVERSE),
SHOOT_SPEAKER(Intake.Modes.SHOOT_SPEAKER),
SHOOT_AMP(Intake.Modes.SHOOT_AMP);
REVERSE(Intake.Modes.REVERSE);

public final IntakePowers modePowers;
public final IntakePowers modePowers; // rename to modePower

private IntakeMode(IntakePowers modePowers) {
this.modePowers = modePowers;
}
}

public record IntakePowers(double intakeSpeed, double serializerSpeed) {
public IntakePowers(double intakeSpeed, double serializerSpeed) {
public record IntakePowers(double intakeSpeed) {
public IntakePowers(double intakeSpeed) {
this.intakeSpeed = intakeSpeed;
this.serializerSpeed = serializerSpeed;
}
}

Expand All @@ -53,8 +47,6 @@ public IntakeSubsystem() {

intakeMode = IntakeMode.HOLD;

timeSincePenaltyHazard = 7;

if (Config.SHOW_SHUFFLEBOARD_DEBUG_DATA) {
tab.addDouble("intake voltage", () -> intakeMotor.getMotorVoltage().getValueAsDouble());
tab.addString("Current Mode", () -> intakeMode.toString());
Expand Down

0 comments on commit 516fa1c

Please sign in to comment.