This repository has been archived by the owner on Jan 16, 2024. It is now read-only.
-
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
8 changed files
with
106 additions
and
4 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
28 changes: 28 additions & 0 deletions
28
src/main/java/frc/robot/commands/IndexerDefaultCommand.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,28 @@ | ||
package frc.robot.commands; | ||
|
||
import edu.wpi.first.wpilibj2.command.CommandBase; | ||
import frc.robot.subsystems.indexer.Indexer; | ||
|
||
public class IndexerDefaultCommand extends CommandBase { | ||
private final Indexer indexer; | ||
|
||
|
||
public IndexerDefaultCommand (Indexer indexer) { | ||
this.indexer = indexer; | ||
addRequirements(indexer); | ||
} | ||
|
||
|
||
@Override | ||
public void initialize() {} | ||
|
||
@Override | ||
public void execute() { | ||
indexer.indexerRun(false); | ||
} | ||
|
||
@Override | ||
public boolean isFinished() { | ||
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
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 frc.robot.subsystems.indexer; | ||
|
||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
|
||
public class Indexer extends SubsystemBase { | ||
IndexerIO io; | ||
IndexerIOInputsAutoLogged inputs; | ||
|
||
public Indexer(IndexerIO io) { | ||
this.io = io; | ||
} | ||
|
||
public void indexerRun(boolean shooting) { | ||
if (shooting == true) { | ||
io.setPercent(1); | ||
} else { | ||
io.setPercent(0.2); | ||
} | ||
} | ||
|
||
@Override | ||
public void periodic() { | ||
io.updateInputs(inputs); | ||
} | ||
} |
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,13 @@ | ||
package frc.robot.subsystems.indexer; | ||
|
||
import org.littletonrobotics.junction.AutoLog; | ||
|
||
public interface IndexerIO { | ||
@AutoLog | ||
public static class IndexerIOInputs { | ||
public double velocityRotationsPerSecond; | ||
} | ||
|
||
public default void updateInputs(IndexerIOInputs inputs) {} | ||
public default void setPercent(double input) {} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/frc/robot/subsystems/indexer/IndexerIOReal.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,18 @@ | ||
package frc.robot.subsystems.indexer; | ||
|
||
import com.revrobotics.CANSparkMax; | ||
import com.revrobotics.CANSparkMaxLowLevel.MotorType; | ||
|
||
public class IndexerIOReal implements IndexerIO { | ||
CANSparkMax indexerMotor = new CANSparkMax(0, MotorType.kBrushless); | ||
|
||
@Override | ||
public void setPercent(double percentage) { | ||
indexerMotor.set(percentage); | ||
} | ||
|
||
@Override | ||
public void updateInputs(IndexerIOInputs inputs) { | ||
inputs.velocityRotationsPerSecond = indexerMotor.getEncoder().getVelocity(); | ||
} | ||
} |