Skip to content

Commit

Permalink
auto delay widget
Browse files Browse the repository at this point in the history
  • Loading branch information
kirbt committed Mar 20, 2024
1 parent e23c881 commit e8eb7f0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/main/java/frc/team2412/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ public void autonomousInit() {
// Checks if FMS is attatched and enables joystick warning if true
DriverStation.silenceJoystickConnectionWarning(!DriverStation.isFMSAttached());
// System.out.println(AutoLogic.getSelected() != null);
if (AutoLogic.getSelected() != null) {
AutoLogic.getSelected().schedule();
if (AutoLogic.getSelectedAuto() != null) {
AutoLogic.getSelectedAuto().schedule();
}
}

Expand Down
13 changes: 11 additions & 2 deletions src/main/java/frc/team2412/robot/util/auto/AutoLogic.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.math.util.Units;
import edu.wpi.first.networktables.GenericEntry;
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
Expand Down Expand Up @@ -135,6 +136,7 @@ public static enum StartPosition {
new WaitCommand(1.5),
new InstantCommand(() -> controls.vibrateDriveController(0.0)));

// shuffleboard
private static ShuffleboardTab tab = Shuffleboard.getTab("Match");

private static SendableChooser<StartPosition> startPositionChooser =
Expand All @@ -144,6 +146,8 @@ public static enum StartPosition {
private static SendableChooser<Integer> gameObjects = new SendableChooser<Integer>();
private static SendableChooser<Boolean> isVision = new SendableChooser<Boolean>();

private static GenericEntry autoDelayEntry;

// methods

public static Command registerAuto(String autoName, Command command, String... primaryPathNames) {
Expand Down Expand Up @@ -227,6 +231,7 @@ public static void initShuffleBoard() {
tab.add("Launch Type", isVision).withPosition(8, 1);
tab.add("Game Objects", gameObjects).withPosition(9, 1);
tab.add("Available Auto Variants", availableAutos).withPosition(8, 2).withSize(2, 1);
autoDelayEntry = tab.add("Auto Delay", 0).withPosition(8, 3).withSize(1, 1).getEntry();

isVision.onChange(AutoLogic::filterAutos);
startPositionChooser.onChange(AutoLogic::filterAutos);
Expand Down Expand Up @@ -262,7 +267,11 @@ public static void filterAutos(Boolean isVision) {
filterAutos(gameObjects.getSelected());
}

public static Command getSelected() {
return availableAutos.getSelected().getAutoCommand();
// get auto

public static Command getSelectedAuto() {
return Commands.sequence(
Commands.waitSeconds(autoDelayEntry.getDouble(0)),
availableAutos.getSelected().getAutoCommand());
}
}

0 comments on commit e8eb7f0

Please sign in to comment.