-
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 #16 from frc-4931/Intake
Intake
- Loading branch information
Showing
7 changed files
with
225 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package frc.robot.subsystems; | ||
|
||
import com.revrobotics.CANSparkLowLevel; | ||
import com.revrobotics.CANSparkMax; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
|
||
public class Conveyor extends SubsystemBase{ | ||
private CANSparkMax conveyMotor1; | ||
private CANSparkMax conveyMotor2; | ||
private boolean isRunning; | ||
private static final CANSparkLowLevel.MotorType kMotorType = CANSparkLowLevel.MotorType.kBrushless; | ||
|
||
public Conveyor() { | ||
isRunning = false; | ||
conveyMotor1 = new CANSparkMax(12, kMotorType); | ||
conveyMotor2 = new CANSparkMax(13, kMotorType); | ||
} | ||
/** | ||
* to be used by RobotContainer. will toggle shooter | ||
* @param speed | ||
* @return | ||
*/ | ||
public Command toggle(double speed) { | ||
return this.runOnce(() -> { isRunning = !(isRunning); makeSpeed(speed);}); | ||
} | ||
/** | ||
* stops the motors | ||
*/ | ||
public void stop() { | ||
isRunning = false; | ||
makeSpeed(0); | ||
} | ||
/** | ||
* moves up to shooter | ||
* @param speed | ||
*/ | ||
public void run(double speed) { | ||
isRunning = true; | ||
makeSpeed(speed); | ||
} | ||
/** | ||
* sets the speed of both motors, only accesable in this class | ||
* speed shall NEVER exceed domain (-1,1) | ||
* @param speed | ||
*/ | ||
private void makeSpeed(double speed) { | ||
if(isRunning) { | ||
conveyMotor1.set(speed); | ||
conveyMotor2.set(speed); | ||
} | ||
else { | ||
conveyMotor1.set(0); | ||
conveyMotor2.set(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,54 @@ | ||
package frc.robot.subsystems; | ||
|
||
import com.revrobotics.CANSparkLowLevel; | ||
import com.revrobotics.CANSparkMax; | ||
import com.revrobotics.SparkPIDController; | ||
|
||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
|
||
|
||
public class Intake extends SubsystemBase { | ||
private boolean isOn; | ||
private final CANSparkMax intakeMotor; | ||
private final CANSparkMax intakeMotor2; | ||
private static final CANSparkLowLevel.MotorType kMotorType = CANSparkLowLevel.MotorType.kBrushless; | ||
/** | ||
* Constructer | ||
* starts off | ||
*/ | ||
public Intake() { | ||
isOn = false; | ||
intakeMotor = new CANSparkMax(9 , kMotorType); | ||
intakeMotor2 = new CANSparkMax(14, kMotorType); | ||
} | ||
public Command toggle(double speed) { | ||
return this.runOnce(() -> {isOn = !(isOn); setSpeed(speed);}); | ||
} | ||
public void turnOn(double speed) { | ||
isOn = true; | ||
setSpeed(speed); | ||
} | ||
|
||
public void turnOff(double speed) { | ||
isOn = false; | ||
setSpeed(0); | ||
} | ||
/** | ||
* Speed Should NEVER exceed the domain (-1,1) | ||
* @param speed | ||
*/ | ||
private void setSpeed(double speed) { | ||
if(isOn) { | ||
intakeMotor.set(speed); | ||
intakeMotor2.set(speed*-1); | ||
} | ||
else { | ||
intakeMotor.set(0); | ||
intakeMotor2.set(0);} | ||
|
||
|
||
SmartDashboard.putBoolean("Intake", isOn); | ||
} | ||
} |
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,85 @@ | ||
package frc.robot.subsystems; | ||
|
||
import com.revrobotics.CANSparkLowLevel; | ||
import com.revrobotics.CANSparkMax; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
|
||
public class Shooter extends SubsystemBase{ | ||
private CANSparkMax shootMotor1; | ||
private CANSparkMax shootMotor2; | ||
private boolean isRunning; | ||
private boolean isFast; | ||
private static final CANSparkLowLevel.MotorType kMotorType = CANSparkLowLevel.MotorType.kBrushless; | ||
|
||
public Shooter() { | ||
isRunning = false; | ||
isFast = false; | ||
shootMotor1 = new CANSparkMax(10, kMotorType); | ||
shootMotor2 = new CANSparkMax(11, kMotorType); | ||
} | ||
/** | ||
* to be used by RobotContainer. will toggle shooter | ||
* @param speed | ||
* @return | ||
*/ | ||
public Command toggleSlow(double speed) { | ||
return this.runOnce(() -> {isFast = false; isRunning = !(isRunning); makeSpeed(speed);}); | ||
} | ||
/** | ||
* to be used by RobotContainer. will also toggle shooter, but faster | ||
* @param speed | ||
* @return | ||
*/ | ||
public Command toggleFast(double speed) { | ||
return this.runOnce(() -> {isFast = true; isRunning = !(isRunning); makeSpeed(speed);}); | ||
} | ||
/** | ||
* stops the motors | ||
*/ | ||
public void stop() { | ||
isRunning = false; | ||
makeSpeed(0); | ||
} | ||
/** | ||
* Ideal for amp | ||
* @param speed | ||
*/ | ||
public void runSlow(double speed) { | ||
isRunning = true; | ||
isFast = false; | ||
makeSpeed(speed); | ||
} | ||
/** | ||
* better for shooting upward and outward | ||
* @param speed | ||
*/ | ||
public void runFast(double speed) { | ||
isRunning = true; | ||
isFast = true; | ||
makeSpeed(speed); | ||
} | ||
/** | ||
* sets the speed of both motors, only accesable in this class | ||
* speed shall NEVER exceed domain (-1,1) | ||
* @param speed | ||
*/ | ||
private void makeSpeed(double speed) { | ||
if(isRunning) { | ||
if(isFast) { | ||
shootMotor1.set(speed); | ||
shootMotor2.set(speed); | ||
} | ||
else { | ||
shootMotor1.set(speed/2); | ||
shootMotor2.set(speed/2); | ||
} | ||
} | ||
else { | ||
shootMotor1.set(0); | ||
shootMotor2.set(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