generated from StuyPulse/Phil
-
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.
- Loading branch information
Showing
5 changed files
with
175 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
src/main/java/com/stuypulse/robot/commands/launcher/LauncherHoldSpeed.java
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,25 @@ | ||
package com.stuypulse.robot.commands.launcher; | ||
|
||
import com.stuypulse.robot.subsystems.launcher.Launcher; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
|
||
public class LauncherHoldSpeed extends Command { | ||
|
||
private final Launcher launcher; | ||
private final Number launcherSpeed; | ||
|
||
public LauncherHoldSpeed(Number launcherSpeed) { | ||
launcher = Launcher.getInstance(); | ||
this.launcherSpeed = launcherSpeed; | ||
|
||
addRequirements(launcher); | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
launcher.setFeederSpeed(0); | ||
launcher.setLaunchSpeed(launcherSpeed); | ||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/com/stuypulse/robot/commands/launcher/LauncherIntakeNote.java
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,19 @@ | ||
package com.stuypulse.robot.commands.launcher; | ||
|
||
import com.stuypulse.robot.subsystems.launcher.Launcher; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
|
||
public class LauncherIntakeNote extends Command { | ||
Launcher launcher; | ||
|
||
public LauncherIntakeNote() { | ||
launcher = Launcher.getInstance(); | ||
addRequirements(launcher); | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
launcher.intake(); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/com/stuypulse/robot/commands/launcher/LauncherLaunch.java
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,25 @@ | ||
package com.stuypulse.robot.commands.launcher; | ||
|
||
import com.stuypulse.robot.subsystems.launcher.Launcher; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
|
||
public class LauncherLaunch extends Command { | ||
|
||
private final Launcher launcher; | ||
private final Number feederSpeed; | ||
private final Number launcherSpeed; | ||
|
||
public LauncherLaunch(Number feederSpeed, Number launcherSpeed) { | ||
this.launcherSpeed = launcherSpeed; | ||
this.feederSpeed = feederSpeed; | ||
|
||
launcher = Launcher.getInstance(); | ||
addRequirements(launcher); | ||
} | ||
|
||
@Override | ||
public void initialize() { | ||
launcher.launch(feederSpeed, launcherSpeed); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/com/stuypulse/robot/commands/launcher/LauncherStop.java
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 com.stuypulse.robot.commands.launcher; | ||
|
||
import com.stuypulse.robot.subsystems.launcher.Launcher; | ||
|
||
import edu.wpi.first.wpilibj2.command.InstantCommand; | ||
|
||
public class LauncherStop extends InstantCommand{ | ||
Launcher launcher; | ||
|
||
public LauncherStop() { | ||
launcher = Launcher.getInstance(); | ||
addRequirements(launcher); | ||
} | ||
|
||
@Override | ||
public void initialize() { | ||
launcher.stop(); | ||
} | ||
|
||
} |
86 changes: 86 additions & 0 deletions
86
src/main/java/com/stuypulse/robot/subsystems/launcher/Launcher.java
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,86 @@ | ||
package com.stuypulse.robot.subsystems.launcher; | ||
|
||
import com.revrobotics.CANSparkMax; | ||
import com.revrobotics.CANSparkLowLevel.MotorType; | ||
import com.stuypulse.robot.constants.Settings; | ||
import com.stuypulse.robot.constants.Motors; | ||
import com.stuypulse.robot.constants.Ports; | ||
|
||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
|
||
public class Launcher extends SubsystemBase { | ||
|
||
private static final Launcher instance; | ||
|
||
static { | ||
instance = new Launcher(); | ||
} | ||
|
||
public static Launcher getInstance() { | ||
return instance; | ||
} | ||
|
||
private final CANSparkMax feeder; | ||
private final CANSparkMax launcher; | ||
|
||
public Launcher() { | ||
feeder = new CANSparkMax(20, MotorType.kBrushless); | ||
launcher = new CANSparkMax(21, MotorType.kBrushless); | ||
|
||
Motors.Shooter.LEFT_SHOOTER.configure(feeder); | ||
Motors.Shooter.LEFT_SHOOTER.configure(launcher); | ||
|
||
} | ||
|
||
//********** SETTERS ********** | ||
public void setLaunchSpeed(Number speed) { | ||
launcher.set(speed.doubleValue()); | ||
} | ||
|
||
public void setFeederSpeed(Number speed) { | ||
feeder.set(speed.doubleValue()); | ||
} | ||
|
||
public void stop() { | ||
setLaunchSpeed(0); | ||
setFeederSpeed(0); | ||
} | ||
|
||
public void intake() { | ||
launcher.set(-.8); | ||
feeder.set(0); | ||
} | ||
|
||
public void launch(Number feederSpeed, Number launcherSpeed) { | ||
launcher.set(launcherSpeed.doubleValue()); | ||
feeder.set(feederSpeed.doubleValue()); | ||
} | ||
|
||
//********** GETTERS **********// | ||
public double getLauncherVelocity() { | ||
return launcher.getEncoder().getVelocity(); | ||
} | ||
|
||
public double getFeederVelocity() { | ||
return feeder.getEncoder().getVelocity(); | ||
} | ||
|
||
public double getLauncherSpeed() { | ||
return launcher.getAppliedOutput(); | ||
} | ||
|
||
public double getFeederSpeed() { | ||
return feeder.getAppliedOutput(); | ||
} | ||
|
||
@Override | ||
public void periodic() { | ||
SmartDashboard.putNumber("Launcher/Launcher Velocity", getLauncherVelocity()); | ||
SmartDashboard.putNumber("Launcher/Feeder Velocity", getFeederVelocity()); | ||
|
||
SmartDashboard.putNumber("Launcher/Launcher Output Speed", getLauncherSpeed()); | ||
SmartDashboard.putNumber("Launcher/Feeder Output Speed", getFeederSpeed()); | ||
|
||
} | ||
} |