Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 17 additions & 18 deletions tasks/lesson2-indexer-task/simgui-ds.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down Expand Up @@ -53,10 +45,10 @@
"axisCount": 2,
"buttonCount": 4,
"buttonKeys": [
77,
44,
46,
47
65,
83,
68,
70
],
"povCount": 0
},
Expand Down Expand Up @@ -92,6 +84,13 @@
"robotJoysticks": [
{
"guid": "Keyboard0"
},
{
"guid": "Keyboard1"
},
{},
{
"guid": "Keyboard2"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,27 @@

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() {}

/** 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;
}

/**
Expand All @@ -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() {
Expand Down