-
Notifications
You must be signed in to change notification settings - Fork 12
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
Showing
15 changed files
with
493 additions
and
17 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,50 @@ | ||
package frc.robot.commands; | ||
|
||
import edu.wpi.first.wpilibj.XboxController; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
import frc.robot.subsystems.IndexerSubsystem; | ||
|
||
public class AmpCommand extends Command { | ||
|
||
private final IndexerSubsystem indexerSubsystem; | ||
|
||
private final XboxController xboxController; | ||
|
||
private boolean reversed = false; | ||
|
||
|
||
/** | ||
* Moves the indexer to the amp | ||
* @param indexerSubsystem The instance of {@link IndexerSubsystem} | ||
* @param controller An instance of {@link XboxController} | ||
*/ | ||
public AmpCommand(IndexerSubsystem indexerSubsystem, XboxController controller) { | ||
this.indexerSubsystem = indexerSubsystem; | ||
this.xboxController = controller; | ||
addRequirements(indexerSubsystem); | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
if (indexerSubsystem.isCenter() && !reversed) { | ||
indexerSubsystem.rotateAllWheelsPercent(0.5); | ||
} else { | ||
reversed = true; | ||
} | ||
|
||
if (reversed && !indexerSubsystem.isTop()) { | ||
indexerSubsystem.rotateAllWheelsPercent(-0.5); | ||
} else if (reversed && indexerSubsystem.isTop()) { | ||
indexerSubsystem.moveIndexerToPos(160); | ||
} | ||
|
||
if (xboxController.getRightBumper() && indexerSubsystem.isIndexerRotated()) { | ||
indexerSubsystem.rotateAllWheelsPercent(-0.5); | ||
} | ||
} | ||
|
||
@Override | ||
public void end(boolean interrupted) { | ||
indexerSubsystem.rotateAllWheelsPercent(0); | ||
} | ||
} |
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,43 @@ | ||
package frc.robot.commands; | ||
|
||
import edu.wpi.first.wpilibj.XboxController; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
import frc.robot.subsystems.IndexerSubsystem; | ||
|
||
public class AmpCommand2 extends Command { | ||
private final IndexerSubsystem indexerSubsystem; | ||
|
||
private final XboxController xboxController; | ||
|
||
/** | ||
* Second Amp command to go straight to amp position from intake, we cannot change to speaker mode if we use this command | ||
* @param indexerSubsystem Instance of {@link IndexerSubsystem} | ||
*/ | ||
public AmpCommand2(IndexerSubsystem indexerSubsystem, XboxController xboxController) { | ||
this.indexerSubsystem = indexerSubsystem; | ||
this.xboxController = xboxController; | ||
|
||
addRequirements(indexerSubsystem); | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
if (!indexerSubsystem.isTop()) { | ||
indexerSubsystem.rotateMotorPercent(IndexerSubsystem.IndexerMotors.WHEEL_1, 0.4); | ||
indexerSubsystem.rotateMotorPercent(IndexerSubsystem.IndexerMotors.WHEEL_2, -0.4); | ||
} else { | ||
indexerSubsystem.moveIndexerToPos(160); | ||
|
||
} | ||
if (xboxController.getRightBumper() && indexerSubsystem.isIndexerRotated()) { | ||
indexerSubsystem.rotateAllWheelsPercent(-0.5); | ||
} | ||
} | ||
|
||
@Override | ||
public void end(boolean interrupted) { | ||
indexerSubsystem.rotateAllWheelsPercent(0); | ||
} | ||
|
||
|
||
} |
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,30 @@ | ||
package frc.robot.commands; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
import frc.robot.subsystems.IndexerSubsystem; | ||
|
||
public class BaseCommand extends Command { | ||
private final IndexerSubsystem indexerSubsystem; | ||
|
||
/** | ||
* Reset indexer to default pos | ||
* @param indexerSubsystem Instance of {@link IndexerSubsystem} | ||
*/ | ||
public BaseCommand(IndexerSubsystem indexerSubsystem) { | ||
this.indexerSubsystem = indexerSubsystem; | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
if (indexerSubsystem.getIndexerAngle() > Math.PI/6) { | ||
indexerSubsystem.moveIndexerToPos(10); | ||
} else { | ||
indexerSubsystem.rotateMotorVolts(IndexerSubsystem.IndexerMotors.INDEXER_ROTATE, 0.0); | ||
} | ||
} | ||
|
||
@Override | ||
public void end(boolean interrupted) { | ||
indexerSubsystem.rotateMotorVolts(IndexerSubsystem.IndexerMotors.INDEXER_ROTATE, 0.0); | ||
} | ||
} |
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,40 @@ | ||
package frc.robot.commands; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
import frc.robot.subsystems.IndexerSubsystem; | ||
import frc.robot.subsystems.IntakeSubsystem; | ||
|
||
public class IntakeCommand extends Command { | ||
private final IntakeSubsystem intakeSubsystem; | ||
|
||
private final IndexerSubsystem indexerSubsystem; | ||
|
||
/** | ||
* Command to run the intake | ||
* @param intakeSubsystem The instance of {@link IntakeSubsystem} | ||
* @param indexerSubsystem The instance of {@link IndexerSubsystem} (needed for limebreak detection to stop intake motor) | ||
*/ | ||
public IntakeCommand(IntakeSubsystem intakeSubsystem, IndexerSubsystem indexerSubsystem) { | ||
this.intakeSubsystem = intakeSubsystem; | ||
this.indexerSubsystem = indexerSubsystem; | ||
|
||
addRequirements(intakeSubsystem, indexerSubsystem); | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
if (!indexerSubsystem.isCenter()) { | ||
intakeSubsystem.setSpeed(.9); | ||
indexerSubsystem.rotateAllWheelsPercent(.9); | ||
} else { | ||
intakeSubsystem.setSpeed(0); | ||
indexerSubsystem.rotateAllWheelsPercent(0); | ||
} | ||
} | ||
|
||
@Override | ||
public void end(boolean interrupted) { | ||
intakeSubsystem.setSpeed(0); | ||
indexerSubsystem.rotateAllWheelsPercent(0); | ||
} | ||
} |
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,30 @@ | ||
package frc.robot.commands; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
import frc.robot.subsystems.IndexerSubsystem; | ||
|
||
public class SpeakerCommand extends Command { | ||
|
||
private final IndexerSubsystem indexerSubsystem; | ||
|
||
/** | ||
* Command to shoot for the speaker once there is a note in the intake | ||
* @param indexerSubsystem Instance of {@link IndexerSubsystem} | ||
*/ | ||
|
||
public SpeakerCommand(IndexerSubsystem indexerSubsystem) { | ||
this.indexerSubsystem = indexerSubsystem; | ||
|
||
addRequirements(indexerSubsystem); | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
indexerSubsystem.rotateAllWheelsPercent(1); | ||
} | ||
|
||
@Override | ||
public void end(boolean interrupted) { | ||
indexerSubsystem.rotateAllWheelsPercent(0); | ||
} | ||
} |
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,28 @@ | ||
package frc.robot.commands; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
import frc.robot.subsystems.ShooterSubsystem; | ||
|
||
public class SpinUpCommand extends Command { | ||
private final ShooterSubsystem shooterSubsystem; | ||
|
||
/** | ||
* Command to spin up the shooter | ||
* @param shooterSubsystem Instance of {@link ShooterSubsystem} | ||
*/ | ||
public SpinUpCommand(ShooterSubsystem shooterSubsystem) { | ||
this.shooterSubsystem = shooterSubsystem; | ||
|
||
addRequirements(shooterSubsystem); | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
shooterSubsystem.setSpeed(6000); | ||
} | ||
|
||
@Override | ||
public void end(boolean interrupted) { | ||
shooterSubsystem.setSpeed(0); | ||
} | ||
} |
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,24 @@ | ||
package frc.robot.constants; | ||
|
||
import edu.wpi.first.math.controller.ArmFeedforward; | ||
import edu.wpi.first.math.trajectory.TrapezoidProfile; | ||
|
||
public class IndexerConstants { | ||
public final static int wheel1ID = 11; | ||
public final static int wheel2ID = 12; | ||
public final static int wheel3ID = 13; | ||
public final static int indexerRotateID = 14; | ||
|
||
public final static int centerLimebreakID = 10; | ||
public final static int topLimebreakID = 9; | ||
|
||
public final static double indexerP = 3.0; | ||
public final static double indexerI = 0.0; | ||
public final static double indexerD = 0.0; | ||
|
||
public final static TrapezoidProfile.Constraints indexerTrapezoidProfile = | ||
new TrapezoidProfile.Constraints(Math.PI * 3, Math.PI * 5); | ||
|
||
public final static ArmFeedforward indexerFF = new ArmFeedforward(0.13, 0.5, 0.00); | ||
|
||
} |
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,15 @@ | ||
package frc.robot.constants; | ||
|
||
import edu.wpi.first.math.controller.ArmFeedforward; | ||
import edu.wpi.first.math.controller.SimpleMotorFeedforward; | ||
|
||
public class ShooterConstants { | ||
public static final double shooterP = 0.02; | ||
public static final double shooterI = 0.01; | ||
public static final double shooterD = 0.0; | ||
|
||
public static final SimpleMotorFeedforward shooterFF = new SimpleMotorFeedforward(0.05, 0.0179, 0.0008); | ||
|
||
|
||
|
||
} |
Oops, something went wrong.