Skip to content

Commit

Permalink
remove isHopperFull sensor, and use hasGP sensor to stop both intake (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Wu-Fan-529 authored Nov 10, 2024
1 parent ee3da31 commit e081b5a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class RobotContainer {
private final Stager subStager = new Stager();
private final Drive com_Drive = new Drive(subDrivetrain, m_driverController.axis_LeftY,
m_driverController.axis_RightX);
private final IntakeGround com_IntakeGround = new IntakeGround(subIntake, subHopper);
private final IntakeGround com_IntakeGround = new IntakeGround(subIntake, subStager);
private final PrepShooter com_PrepShooter = new PrepShooter(subShooter);
private final HasGP com_StageGP = new HasGP(subStager);
private final Shoot com_Shoot = new Shoot(subStager, subShooter);
Expand All @@ -42,7 +42,7 @@ public RobotContainer() {

private void configureBindings() {
m_driverController.btn_B.whileTrue(com_IntakeGround);
m_driverController.btn_LeftBumper.whileTrue(new intakeHopper(subHopper));
m_driverController.btn_LeftBumper.whileTrue(new intakeHopper(subHopper, subStager));
m_driverController.btn_X.whileTrue(com_PrepShooter);
m_driverController.btn_A.whileTrue(com_StageGP);

Expand Down
1 change: 0 additions & 1 deletion src/main/java/frc/robot/RobotMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public static class mapControllers {
public static class mapHopper {
public static final int ORIENTATION_MOTOR = 30;
public static final int IS_GP_DETECTED_DIO = 1;
public static final int IS_HOPPER_FULL_DIO = 2;
}

public static class mapDriveTrain {
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/frc/robot/commands/IntakeGround.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
package frc.robot.commands;

import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.Hopper;
import frc.robot.subsystems.Stager;
import frc.robot.subsystems.Intake;

public class IntakeGround extends Command {
/** Creates a new IntakeGround. */
Intake globalIntake;
Hopper globalHopper;
Stager globalStager;

public IntakeGround(Intake passedIntake, Hopper passedHopper) {
public IntakeGround(Intake passedIntake, Stager passedStager) {
// Use addRequirements() here to declare subsystem dependencies.
globalIntake = passedIntake;
globalHopper = passedHopper;
globalStager = passedStager;
}

// Called when the command is initially scheduled.
Expand All @@ -28,8 +28,8 @@ public void initialize() {
// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {
// if hopper is full
if (globalHopper.isHopperFull()) {
// if Stager is full
if (globalStager.getHasGP()) {
globalIntake.setIntakeVelocity(0);
} else {
globalIntake.setIntakeVelocity(0.5);
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/frc/robot/commands/intakeHopper.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@

import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.Hopper;
import frc.robot.subsystems.Stager;

public class intakeHopper extends Command {

Hopper subHopper;
Stager subStager;

/** Creates a new intakeHopper. */
public intakeHopper(Hopper subHopper) {
public intakeHopper(Hopper subHopper, Stager subStager) {
// Use addRequirements() here to declare subsystem dependencies.
this.subHopper = subHopper;
this.subStager = subStager;

}

Expand All @@ -28,7 +31,7 @@ public void initialize() {
// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {
if (subHopper.isHopperFull()) {
if (subStager.getHasGP()) {
subHopper.setOrientationMotorNuetralOutput();
} else {
subHopper.setOrientationMotorSpeed(.5);
Expand Down
7 changes: 0 additions & 7 deletions src/main/java/frc/robot/subsystems/Hopper.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ public class Hopper extends SubsystemBase {
/** Creates a new Hopper. */
TalonFX orientationMotor;
DigitalInput isGPDetected;
DigitalInput isHopperFull;

public Hopper() {
orientationMotor = new TalonFX(RobotMap.mapHopper.ORIENTATION_MOTOR);
isGPDetected = new DigitalInput(RobotMap.mapHopper.IS_GP_DETECTED_DIO);
isHopperFull = new DigitalInput(RobotMap.mapHopper.IS_HOPPER_FULL_DIO);

}

Expand All @@ -36,11 +34,6 @@ public boolean getGamePieceHopper() {
return isGPDetected.get();
}

public boolean isHopperFull() {

return isHopperFull.get();
}

@Override
public void periodic() {

Expand Down

0 comments on commit e081b5a

Please sign in to comment.