-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #131 from LakotaRobotics1038/130-make-passer
- Loading branch information
Showing
14 changed files
with
174 additions
and
52 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
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
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,54 @@ | ||
package frc.robot.commands; | ||
|
||
import edu.wpi.first.wpilibj.Timer; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
import frc.robot.subsystems.Passer; | ||
import frc.robot.subsystems.Scoring; | ||
import frc.robot.subsystems.Storage; | ||
|
||
public class ShootPasserCommand extends Command { | ||
private Scoring scoring = Scoring.getInstance(); | ||
private Storage storage = Storage.getInstance(); | ||
private Passer passer = Passer.getInstance(); | ||
private Timer timer = new Timer(); | ||
private double secondsToScore = 0; | ||
|
||
public ShootPasserCommand(double secondsToScore) { | ||
this.addRequirements(scoring); | ||
this.secondsToScore = secondsToScore; | ||
} | ||
|
||
public ShootPasserCommand() { | ||
this.addRequirements(scoring); | ||
} | ||
|
||
@Override | ||
public void initialize() { | ||
timer.start(); | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
scoring.feedForPasser(); | ||
passer.shoot(); | ||
if (!storage.noteExitingStorage()) { | ||
storage.stopStorage(); | ||
} else { | ||
storage.runStorage(); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean isFinished() { | ||
return this.secondsToScore != 0 ? timer.get() > this.secondsToScore : false; | ||
} | ||
|
||
@Override | ||
public void end(boolean interrupted) { | ||
scoring.stop(); | ||
storage.stopStorage(); | ||
passer.stop(); | ||
timer.stop(); | ||
timer.reset(); | ||
} | ||
} |
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,7 @@ | ||
package frc.robot.constants; | ||
|
||
public class PasserConstants { | ||
public static final int passerMotorPort = 11; | ||
|
||
public static final double shooterSpeed = 1.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
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,61 @@ | ||
package frc.robot.subsystems; | ||
|
||
import com.revrobotics.CANSparkBase.IdleMode; | ||
import com.revrobotics.CANSparkLowLevel.MotorType; | ||
import com.revrobotics.CANSparkFlex; | ||
import com.revrobotics.RelativeEncoder; | ||
|
||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
import frc.robot.constants.NeoMotorConstants; | ||
import frc.robot.constants.PasserConstants; | ||
|
||
public class Passer extends SubsystemBase { | ||
private final CANSparkFlex passerMotor = new CANSparkFlex(PasserConstants.passerMotorPort, MotorType.kBrushless); | ||
private final RelativeEncoder passerEncoder = passerMotor.getEncoder(); | ||
|
||
private static Passer instance; | ||
|
||
/** | ||
* Creates an instance of the Passer subsystem if it does not already exist. | ||
* | ||
* @return An instance of the Passer subsystem. | ||
*/ | ||
public static Passer getInstance() { | ||
if (instance == null) { | ||
instance = new Passer(); | ||
} | ||
return instance; | ||
} | ||
|
||
private Passer() { | ||
passerMotor.restoreFactoryDefaults(); | ||
|
||
passerMotor.setIdleMode(IdleMode.kBrake); | ||
passerMotor.setSmartCurrentLimit(NeoMotorConstants.kMaxVortexCurrent); | ||
passerMotor.setInverted(true); | ||
|
||
passerMotor.burnFlash(); | ||
passerEncoder.setPosition(0); | ||
} | ||
|
||
/** | ||
* Get the encoder value of the passer encoder | ||
*/ | ||
public double getPosition() { | ||
return passerEncoder.getPosition(); | ||
} | ||
|
||
/** | ||
* Runs the passer at a constant speed | ||
*/ | ||
public void shoot() { | ||
passerMotor.set(PasserConstants.shooterSpeed); | ||
} | ||
|
||
/** | ||
* Stops the passer | ||
*/ | ||
public void stop() { | ||
passerMotor.stopMotor(); | ||
} | ||
} |
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
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