-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e37a026
commit 698ea15
Showing
5 changed files
with
121 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package frc.robot.commands; | ||
|
||
import java.util.function.BooleanSupplier; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
import frc.robot.subsystems.intake.IntakeBase; | ||
|
||
public class IntakeBaseCommand extends Command { | ||
IntakeBase intake; | ||
BooleanSupplier rightBumper; | ||
BooleanSupplier leftBumper; | ||
public IntakeBaseCommand(IntakeBase intake, BooleanSupplier rightBumper, BooleanSupplier leftBumper) { | ||
this.intake = intake; | ||
this.rightBumper = rightBumper; | ||
this.leftBumper = leftBumper; | ||
|
||
addRequirements(intake); | ||
} | ||
@Override | ||
public void initialize() { | ||
intake.disable(); | ||
} | ||
|
||
|
||
@Override | ||
public void execute() { | ||
// Turns off motors if No/All bumpers | ||
if ((rightBumper.getAsBoolean() && leftBumper.getAsBoolean()) || (rightBumper.getAsBoolean() == false && leftBumper.getAsBoolean() == false)) { | ||
// Disable the intake motors | ||
intake.disable(); | ||
|
||
} else if (rightBumper.getAsBoolean()) { // Motors on (IN) if right bumper pressed | ||
intake.setSpeed(1); | ||
|
||
// Enable motors, It has to be called regularly for voltage compensation to work properly | ||
intake.enable(); | ||
} else if (leftBumper.getAsBoolean()) { // Motors on (Out) if right bumper pressed | ||
intake.setSpeed(-1); | ||
|
||
// Enable motors, It has to be called regularly for voltage compensation to work properly | ||
intake.enable(); | ||
} else { // Disable the intake motors | ||
intake.disable(); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package frc.robot.subsystems.intake; | ||
|
||
public interface Intake { | ||
/** | ||
* Disable the speed of the motor for the intake. | ||
*/ | ||
public default void disable() {} | ||
|
||
/** | ||
* Enable the speed of the motor for the intake. | ||
*/ | ||
public default void enable() {} | ||
|
||
/** | ||
* Set the speed of the motor for the intake. | ||
* | ||
* @param speed The speed to set. Value should be between -1.0 and 1.0. | ||
*/ | ||
public default void setSpeed(double speed) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package frc.robot.subsystems.intake; | ||
|
||
import edu.wpi.first.wpilibj.motorcontrol.MotorController; | ||
import edu.wpi.first.wpilibj.motorcontrol.Spark; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
|
||
public class IntakeBase extends SubsystemBase implements Intake { | ||
private final MotorController IntakeMotor; | ||
|
||
private double voltage; | ||
|
||
public IntakeBase() { | ||
IntakeMotor = new Spark(0); | ||
voltage = 0; | ||
} | ||
|
||
@Override | ||
public void disable() { | ||
voltage = 0; | ||
IntakeMotor.setVoltage(voltage); | ||
} | ||
|
||
@Override | ||
public void enable() { | ||
IntakeMotor.setVoltage(voltage); | ||
} | ||
|
||
@Override | ||
//Sets the voltage to 5.0 times speed. the speed value is -1 1 | ||
public void setSpeed(double speed) { | ||
voltage = 5.0 * speed; | ||
} | ||
} |