diff --git a/tasks/lesson2-indexer-task/simgui-ds.json b/tasks/lesson2-indexer-task/simgui-ds.json index 69b1a3c..c25a842 100644 --- a/tasks/lesson2-indexer-task/simgui-ds.json +++ b/tasks/lesson2-indexer-task/simgui-ds.json @@ -2,28 +2,20 @@ "keyboardJoysticks": [ { "axisConfig": [ + {}, + {}, { - "decKey": 65, - "incKey": 68 - }, - { - "decKey": 87, - "incKey": 83 - }, - { - "decKey": 69, "decayRate": 0.0, - "incKey": 82, "keyRate": 0.009999999776482582 } ], "axisCount": 3, "buttonCount": 4, "buttonKeys": [ - 90, - 88, - 67, - 86 + 81, + 87, + 69, + 82 ], "povConfig": [ { @@ -53,10 +45,10 @@ "axisCount": 2, "buttonCount": 4, "buttonKeys": [ - 77, - 44, - 46, - 47 + 65, + 83, + 68, + 70 ], "povCount": 0 }, @@ -92,6 +84,13 @@ "robotJoysticks": [ { "guid": "Keyboard0" + }, + { + "guid": "Keyboard1" + }, + {}, + { + "guid": "Keyboard2" } ] } diff --git a/tasks/lesson2-indexer-task/src/main/java/frc/robot/RobotContainer.java b/tasks/lesson2-indexer-task/src/main/java/frc/robot/RobotContainer.java index 1500ca0..27d6304 100644 --- a/tasks/lesson2-indexer-task/src/main/java/frc/robot/RobotContainer.java +++ b/tasks/lesson2-indexer-task/src/main/java/frc/robot/RobotContainer.java @@ -22,6 +22,7 @@ public RobotContainer() { private void configureBindings() { // TODO: Bind indexForSeconds(1.5) to joystick button 1 + joystick.button(1).onTrue(indexer.indexForSeconds(1.5)); } public Command getAutonomousCommand() { diff --git a/tasks/lesson2-indexer-task/src/main/java/frc/robot/subsystems/Indexer.java b/tasks/lesson2-indexer-task/src/main/java/frc/robot/subsystems/Indexer.java index e89f0e5..2322a3f 100644 --- a/tasks/lesson2-indexer-task/src/main/java/frc/robot/subsystems/Indexer.java +++ b/tasks/lesson2-indexer-task/src/main/java/frc/robot/subsystems/Indexer.java @@ -4,10 +4,13 @@ package frc.robot.subsystems; +import edu.wpi.first.wpilibj2.command.Command; +import edu.wpi.first.wpilibj2.command.Commands; import edu.wpi.first.wpilibj2.command.SubsystemBase; public class Indexer extends SubsystemBase { // TODO: Add indexing state variable here + boolean indexing; /** Creates a new Indexer subsystem. */ public Indexer() {} @@ -15,11 +18,13 @@ public Indexer() {} /** Starts the indexing process. */ public void startIndexing() { // TODO: Set indexing state to true + indexing = true; } /** Stops the indexing process. */ public void stopIndexing() { // TODO: Set indexing state to false + indexing = false; } /** @@ -29,10 +34,16 @@ public void stopIndexing() { */ public boolean isIndexing() { // TODO: Return indexing state - return false; + return indexing; } // TODO: Implement indexForSeconds() command factory + public Command indexForSeconds(double seconds) { + return Commands.runOnce(() -> startIndexing()) + .andThen(Commands.waitSeconds(seconds)) + .andThen(Commands.runOnce(() -> stopIndexing())); + } + @Override public void periodic() {