generated from SciBorgs/Hydrogen
-
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
9 changed files
with
125 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.sciborgs1155.robot.scoral; | ||
|
||
public class NoScoral implements ScoralIO { | ||
|
||
@Override | ||
public void setPower(double power) {} | ||
|
||
@Override | ||
public boolean beambreak() { | ||
return false; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/org/sciborgs1155/robot/scoral/RealScoral.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,30 @@ | ||
package org.sciborgs1155.robot.scoral; | ||
|
||
import static org.sciborgs1155.robot.Ports.Scoral.*; | ||
|
||
import com.revrobotics.spark.SparkLowLevel.MotorType; | ||
import com.revrobotics.spark.SparkMax; | ||
import edu.wpi.first.wpilibj.DigitalInput; | ||
|
||
public class RealScoral implements ScoralIO { | ||
|
||
private final SparkMax topMotor; | ||
private final SparkMax bottomMotor; | ||
|
||
private final DigitalInput beambreak; | ||
|
||
public RealScoral() { | ||
topMotor = new SparkMax(TOP_ROLLER, MotorType.kBrushed); | ||
bottomMotor = new SparkMax(BOTTOM_ROLLER, MotorType.kBrushed); | ||
|
||
beambreak = new DigitalInput(BEAMBREAK); | ||
} | ||
|
||
@Override | ||
public void setPower(double power) {} | ||
|
||
@Override | ||
public boolean beambreak() { | ||
return beambreak.get(); | ||
} | ||
} |
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,39 @@ | ||
package org.sciborgs1155.robot.scoral; | ||
|
||
import static org.sciborgs1155.robot.scoral.ScoralConstants.*; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
import org.sciborgs1155.robot.Robot; | ||
|
||
public class Scoral extends SubsystemBase { | ||
|
||
private ScoralIO scoral; | ||
|
||
public Scoral(ScoralIO scoral) { | ||
this.scoral = scoral; | ||
} | ||
|
||
public static Scoral create() { | ||
return Robot.isReal() ? new Scoral(new RealScoral()) : new Scoral(new SimScoral()); | ||
} | ||
|
||
public static Scoral none() { | ||
return new Scoral(new NoScoral()); | ||
} | ||
|
||
/** Runs the motor to outtake, as in pushing out, a coral. */ | ||
public Command outtake() { | ||
return run(() -> scoral.setPower(POWER)); | ||
} | ||
|
||
/** Runs the motor to intake, as in pulling in, a coral. */ | ||
public Command intake() { | ||
return run(() -> scoral.setPower(-POWER)); | ||
} | ||
|
||
/** Returns the value of the beambreak. */ | ||
public boolean beambreak() { | ||
return scoral.beambreak(); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/org/sciborgs1155/robot/scoral/ScoralConstants.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,5 @@ | ||
package org.sciborgs1155.robot.scoral; | ||
|
||
public class ScoralConstants { | ||
public static final double POWER = 0.5; | ||
} |
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,8 @@ | ||
package org.sciborgs1155.robot.scoral; | ||
|
||
public interface ScoralIO { | ||
|
||
void setPower(double power); | ||
|
||
boolean beambreak(); | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/org/sciborgs1155/robot/scoral/SimScoral.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,12 @@ | ||
package org.sciborgs1155.robot.scoral; | ||
|
||
public class SimScoral implements ScoralIO { | ||
|
||
@Override | ||
public void setPower(double power) {} | ||
|
||
@Override | ||
public boolean beambreak() { | ||
return false; | ||
} | ||
} |
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