From 52215ac2c9179a29a03975492bafb3524df5fdec Mon Sep 17 00:00:00 2001 From: lucy Date: Wed, 28 Feb 2024 17:30:40 -0800 Subject: [PATCH 1/9] logging restructure Moving stuff around lol smile --- src/main/java/frc/team2412/robot/Robot.java | 5 + .../robot/subsystems/IntakeSubsystem.java | 111 ++++++------------ .../robot/subsystems/LauncherSubsystem.java | 27 ++--- 3 files changed, 50 insertions(+), 93 deletions(-) diff --git a/src/main/java/frc/team2412/robot/Robot.java b/src/main/java/frc/team2412/robot/Robot.java index 2a755a36..db475ed7 100644 --- a/src/main/java/frc/team2412/robot/Robot.java +++ b/src/main/java/frc/team2412/robot/Robot.java @@ -36,6 +36,7 @@ public static Robot getInstance() { return instance; } + private static final boolean debugMode = true; private final RobotType robotType; public Controls controls; public Subsystems subsystems; @@ -178,4 +179,8 @@ public RobotType getRobotType() { public boolean isCompetition() { return getRobotType() == RobotType.COMPETITION; } + + public static boolean isDebugMode() { + return debugMode; + } } diff --git a/src/main/java/frc/team2412/robot/subsystems/IntakeSubsystem.java b/src/main/java/frc/team2412/robot/subsystems/IntakeSubsystem.java index 02981ceb..53ff10e8 100644 --- a/src/main/java/frc/team2412/robot/subsystems/IntakeSubsystem.java +++ b/src/main/java/frc/team2412/robot/subsystems/IntakeSubsystem.java @@ -13,6 +13,7 @@ import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab; import edu.wpi.first.wpilibj2.command.SubsystemBase; +import frc.team2412.robot.Robot; import java.util.Map; public class IntakeSubsystem extends SubsystemBase { @@ -48,79 +49,25 @@ public class IntakeSubsystem extends SubsystemBase { private final DigitalInput feederSensor; // Shuffleboard + + private final ShuffleboardTab shuffleboardTab = Shuffleboard.getTab("Intake"); // speed private final GenericEntry setIntakeInSpeedEntry = - Shuffleboard.getTab("Intake") + shuffleboardTab .addPersistent("Intake in speed - ", INTAKE_IN_SPEED) .withSize(2, 1) .withProperties(Map.of("Min", -1, "Max", 1)) .getEntry(); private final GenericEntry setIndexInSpeedEntry = - Shuffleboard.getTab("Intake") - .add("Index in speed - ", INDEX_UPPER_IN_SPEED) - .withSize(1, 1) - .getEntry(); + shuffleboardTab.add("Index in speed - ", INDEX_UPPER_IN_SPEED).withSize(1, 1).getEntry(); private final GenericEntry setFeederInSpeedEntry = - Shuffleboard.getTab("Intake") - .add("Feeder in speed - ", FEEDER_IN_SPEED) - .withSize(1, 1) - .getEntry(); - - // temperature - private final GenericEntry intakeMotorFrontTemp = - Shuffleboard.getTab("Intake") - .add("Front Intake temp", 0) - .withSize(1, 1) - .withWidget(BuiltInWidgets.kTextView) - .getEntry(); - - private final GenericEntry intakeMotorBackTemp = - Shuffleboard.getTab("Intake") - .add("Back Intake temp", 0) - .withSize(1, 1) - .withWidget(BuiltInWidgets.kTextView) - .getEntry(); - - private final GenericEntry intakeMotorLeftTemp = - Shuffleboard.getTab("Intake") - .add("Left Intake temp", 0) - .withSize(1, 1) - .withWidget(BuiltInWidgets.kTextView) - .getEntry(); - - private final GenericEntry intakeMotorRightTemp = - Shuffleboard.getTab("Intake") - .add("Right Intake temp", 0) - .withSize(1, 1) - .withWidget(BuiltInWidgets.kTextView) - .getEntry(); - - private final GenericEntry indexMotorUpperTemp = - Shuffleboard.getTab("Intake") - .add("Upper Index temp", 0) - .withSize(1, 1) - .withWidget(BuiltInWidgets.kTextView) - .getEntry(); - - private final GenericEntry ingestMotorTemp = - Shuffleboard.getTab("Intake") - .add("Ingest temp", 0) - .withSize(1, 1) - .withWidget(BuiltInWidgets.kTextView) - .getEntry(); - - private final GenericEntry feederMotorTemp = - Shuffleboard.getTab("Intake") - .add("Feeder temp", 0) - .withSize(1, 1) - .withWidget(BuiltInWidgets.kTextView) - .getEntry(); + shuffleboardTab.add("Feeder in speed - ", FEEDER_IN_SPEED).withSize(1, 1).getEntry(); // sensor override private final GenericEntry sensorOverride = - Shuffleboard.getTab("Intake") + shuffleboardTab .add("Override Sensors", false) .withSize(1, 1) .withWidget(BuiltInWidgets.kTextView) @@ -142,9 +89,7 @@ public IntakeSubsystem() { resetMotors(); - ShuffleboardTab shuffleboardTab = Shuffleboard.getTab("Intake"); - shuffleboardTab.addBoolean("Index Sensor - ", this::indexSensorHasNote).withSize(1, 1); - shuffleboardTab.addBoolean("Feeder Sensor - ", this::feederSensorHasNote).withSize(1, 1); + initShuffleboard(); } private void configureMotor(CANSparkBase motor, int currentLimit, boolean invert) { @@ -241,17 +186,37 @@ public boolean getSensorOverride() { return sensorOverride.getBoolean(false); } - @Override - public void periodic() { - intakeMotorFrontTemp.setDouble(intakeMotorFront.getMotorTemperature()); - intakeMotorBackTemp.setDouble(intakeMotorBack.getMotorTemperature()); - intakeMotorRightTemp.setDouble(intakeMotorRight.getMotorTemperature()); - intakeMotorLeftTemp.setDouble(intakeMotorLeft.getMotorTemperature()); + // logging - ingestMotorTemp.setDouble(ingestMotor.getMotorTemperature()); - - indexMotorUpperTemp.setDouble(indexMotorUpper.getMotorTemperature()); + public void initShuffleboard() { + if (Robot.isDebugMode()) { + shuffleboardTab + .addDouble("Front Intake Motor Temp", () -> intakeMotorFront.getMotorTemperature()) + .withSize(1, 1) + .withWidget(BuiltInWidgets.kTextView); + shuffleboardTab + .addDouble("Back Intake Motor Temp", () -> intakeMotorBack.getMotorTemperature()) + .withSize(1, 1) + .withWidget(BuiltInWidgets.kTextView); + shuffleboardTab + .addDouble("Left Intake Motor Temp", () -> intakeMotorLeft.getMotorTemperature()) + .withSize(1, 1) + .withWidget(BuiltInWidgets.kTextView); + shuffleboardTab + .addDouble("Right Intake Motor Temp", () -> intakeMotorRight.getMotorTemperature()) + .withSize(1, 1) + .withWidget(BuiltInWidgets.kTextView); + shuffleboardTab + .addDouble("Ingest Motor Temp", () -> ingestMotor.getMotorTemperature()) + .withSize(1, 1) + .withWidget(BuiltInWidgets.kTextView); + shuffleboardTab + .addDouble("Index Motor Temp", () -> feederMotor.getMotorTemperature()) + .withSize(1, 1) + .withWidget(BuiltInWidgets.kTextView); - feederMotorTemp.setDouble(feederMotor.getMotorTemperature()); + shuffleboardTab.addBoolean("Index Sensor - ", this::indexSensorHasNote).withSize(1, 1); + shuffleboardTab.addBoolean("Feeder Sensor - ", this::feederSensorHasNote).withSize(1, 1); + } } } diff --git a/src/main/java/frc/team2412/robot/subsystems/LauncherSubsystem.java b/src/main/java/frc/team2412/robot/subsystems/LauncherSubsystem.java index aa89188a..ddc13f90 100644 --- a/src/main/java/frc/team2412/robot/subsystems/LauncherSubsystem.java +++ b/src/main/java/frc/team2412/robot/subsystems/LauncherSubsystem.java @@ -16,6 +16,7 @@ import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; import edu.wpi.first.wpilibj2.command.SubsystemBase; import frc.team2412.robot.Hardware; +import frc.team2412.robot.Robot; import frc.team2412.robot.util.SparkPIDWidget; import java.util.Map; @@ -67,10 +68,6 @@ public class LauncherSubsystem extends SubsystemBase { private GenericEntry launcherAngleSpeedEntry; - private GenericEntry launcherTopFlywheelTemp; - - private GenericEntry launcherBottomFlyWheelTemp; - private GenericEntry launcherIsAtSpeed; // Constructors @@ -231,13 +228,6 @@ public void setAngleSpeed(double Speed) { } private void initShuffleboard() { - launcherBottomFlyWheelTemp = - Shuffleboard.getTab("Launcher") - .add("bottom Flywheel temp", 0) - .withSize(2, 1) - .withWidget(BuiltInWidgets.kTextView) - .withPosition(0, 3) - .getEntry(); launcherIsAtSpeed = Shuffleboard.getTab("Launcher") @@ -246,13 +236,6 @@ private void initShuffleboard() { .withWidget(BuiltInWidgets.kBooleanBox) .withPosition(0, 2) .getEntry(); - launcherTopFlywheelTemp = - Shuffleboard.getTab("Launcher") - .add("top Flywheel temp", 0) - .withSize(2, 1) - .withWidget(BuiltInWidgets.kTextView) - .withPosition(2, 3) - .getEntry(); launcherAngleSpeedEntry = Shuffleboard.getTab("Launcher") .add("Launcher angle Speed", 0) @@ -282,6 +265,7 @@ private void initShuffleboard() { .withProperties(Map.of("Min", -MAX_FREE_SPEED_RPM, "Max", MAX_FREE_SPEED_RPM)) .withPosition(5, 0) .getEntry(); + if (Robot.isDebugMode()) {} Shuffleboard.getTab("Launcher") .add(new SparkPIDWidget(launcherAngleOnePIDController, "launcherAnglePID")) .withPosition(2, 0); @@ -293,6 +277,11 @@ private void initShuffleboard() { Shuffleboard.getTab("Launcher") .add(new SparkPIDWidget(launcherBottomPIDController, "launcherBottomPID")) .withPosition(1, 0); + + Shuffleboard.getTab("Launcher") + .addDouble("Bottom FlyWheel Temp", () -> launcherBottomMotor.getMotorTemperature()); + Shuffleboard.getTab("Launcher") + .addDouble("Top FlyWheel Temp", () -> launcherBottomMotor.getMotorTemperature()); } @Override @@ -300,8 +289,6 @@ public void periodic() { launcherAngleEntry.setDouble(getAngle()); launcherSpeedEntry.setDouble(getLauncherSpeed()); launcherAngleSpeedEntry.setDouble(getAngleSpeed()); - launcherTopFlywheelTemp.setDouble(launcherTopMotor.getMotorTemperature()); - launcherBottomFlyWheelTemp.setDouble(launcherTopMotor.getMotorTemperature()); launcherIsAtSpeed.setBoolean(isAtSpeed()); } } From df4fba9c32277be1b9e206bf6e35f2d38ca0d329 Mon Sep 17 00:00:00 2001 From: lucy Date: Thu, 29 Feb 2024 16:20:49 -0800 Subject: [PATCH 2/9] grub grub --- .../robot/subsystems/IntakeSubsystem.java | 46 +++++++++++-------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/src/main/java/frc/team2412/robot/subsystems/IntakeSubsystem.java b/src/main/java/frc/team2412/robot/subsystems/IntakeSubsystem.java index 53ff10e8..3baa3ccd 100644 --- a/src/main/java/frc/team2412/robot/subsystems/IntakeSubsystem.java +++ b/src/main/java/frc/team2412/robot/subsystems/IntakeSubsystem.java @@ -52,26 +52,14 @@ public class IntakeSubsystem extends SubsystemBase { private final ShuffleboardTab shuffleboardTab = Shuffleboard.getTab("Intake"); // speed - private final GenericEntry setIntakeInSpeedEntry = - shuffleboardTab - .addPersistent("Intake in speed - ", INTAKE_IN_SPEED) - .withSize(2, 1) - .withProperties(Map.of("Min", -1, "Max", 1)) - .getEntry(); + private GenericEntry setIntakeInSpeedEntry; - private final GenericEntry setIndexInSpeedEntry = - shuffleboardTab.add("Index in speed - ", INDEX_UPPER_IN_SPEED).withSize(1, 1).getEntry(); + private GenericEntry setIndexInSpeedEntry; - private final GenericEntry setFeederInSpeedEntry = - shuffleboardTab.add("Feeder in speed - ", FEEDER_IN_SPEED).withSize(1, 1).getEntry(); + private GenericEntry setFeederInSpeedEntry; // sensor override - private final GenericEntry sensorOverride = - shuffleboardTab - .add("Override Sensors", false) - .withSize(1, 1) - .withWidget(BuiltInWidgets.kTextView) - .getEntry(); + private GenericEntry sensorOverride; public IntakeSubsystem() { intakeMotorFront = new CANSparkMax(INTAKE_MOTOR_FRONT, MotorType.kBrushless); @@ -214,9 +202,29 @@ public void initShuffleboard() { .addDouble("Index Motor Temp", () -> feederMotor.getMotorTemperature()) .withSize(1, 1) .withWidget(BuiltInWidgets.kTextView); - - shuffleboardTab.addBoolean("Index Sensor - ", this::indexSensorHasNote).withSize(1, 1); - shuffleboardTab.addBoolean("Feeder Sensor - ", this::feederSensorHasNote).withSize(1, 1); } + + shuffleboardTab.addBoolean("Index Sensor - ", this::indexSensorHasNote).withSize(1, 1); + shuffleboardTab.addBoolean("Feeder Sensor - ", this::feederSensorHasNote).withSize(1, 1); + + setIntakeInSpeedEntry = + shuffleboardTab + .addPersistent("Intake in speed - ", INTAKE_IN_SPEED) + .withSize(2, 1) + .withProperties(Map.of("Min", -1, "Max", 1)) + .getEntry(); + + setIndexInSpeedEntry = + shuffleboardTab.add("Index in speed - ", INDEX_UPPER_IN_SPEED).withSize(1, 1).getEntry(); + + setFeederInSpeedEntry = + shuffleboardTab.add("Feeder in speed - ", FEEDER_IN_SPEED).withSize(1, 1).getEntry(); + + sensorOverride = + shuffleboardTab + .add("Override Sensors", false) + .withSize(1, 1) + .withWidget(BuiltInWidgets.kTextView) + .getEntry(); } } From d334873ff34927deb8f794df93e49655dad5fabb Mon Sep 17 00:00:00 2001 From: lucy Date: Thu, 29 Feb 2024 16:29:05 -0800 Subject: [PATCH 3/9] debug --- src/main/java/frc/team2412/robot/Robot.java | 2 +- .../robot/subsystems/LauncherSubsystem.java | 35 ++++++++++--------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/main/java/frc/team2412/robot/Robot.java b/src/main/java/frc/team2412/robot/Robot.java index db475ed7..7f439c45 100644 --- a/src/main/java/frc/team2412/robot/Robot.java +++ b/src/main/java/frc/team2412/robot/Robot.java @@ -36,7 +36,7 @@ public static Robot getInstance() { return instance; } - private static final boolean debugMode = true; + private static final boolean debugMode = false; private final RobotType robotType; public Controls controls; public Subsystems subsystems; diff --git a/src/main/java/frc/team2412/robot/subsystems/LauncherSubsystem.java b/src/main/java/frc/team2412/robot/subsystems/LauncherSubsystem.java index ddc13f90..b63b7ef9 100644 --- a/src/main/java/frc/team2412/robot/subsystems/LauncherSubsystem.java +++ b/src/main/java/frc/team2412/robot/subsystems/LauncherSubsystem.java @@ -228,6 +228,24 @@ public void setAngleSpeed(double Speed) { } private void initShuffleboard() { + if (Robot.isDebugMode()) { + Shuffleboard.getTab("Launcher") + .add(new SparkPIDWidget(launcherAngleOnePIDController, "launcherAnglePID")) + .withPosition(2, 0); + // Shuffleboard.getTab("Launcher") + // .add(new SparkPIDWidget(launcherAngleTwoPIDController, "launcherAngleTwoPIDController")); + Shuffleboard.getTab("Launcher") + .add(new SparkPIDWidget(launcherTopPIDController, "launcherTopPID")) + .withPosition(0, 0); + Shuffleboard.getTab("Launcher") + .add(new SparkPIDWidget(launcherBottomPIDController, "launcherBottomPID")) + .withPosition(1, 0); + + Shuffleboard.getTab("Launcher") + .addDouble("Bottom FlyWheel Temp", () -> launcherBottomMotor.getMotorTemperature()); + Shuffleboard.getTab("Launcher") + .addDouble("Top FlyWheel Temp", () -> launcherBottomMotor.getMotorTemperature()); + } launcherIsAtSpeed = Shuffleboard.getTab("Launcher") @@ -265,23 +283,6 @@ private void initShuffleboard() { .withProperties(Map.of("Min", -MAX_FREE_SPEED_RPM, "Max", MAX_FREE_SPEED_RPM)) .withPosition(5, 0) .getEntry(); - if (Robot.isDebugMode()) {} - Shuffleboard.getTab("Launcher") - .add(new SparkPIDWidget(launcherAngleOnePIDController, "launcherAnglePID")) - .withPosition(2, 0); - // Shuffleboard.getTab("Launcher") - // .add(new SparkPIDWidget(launcherAngleTwoPIDController, "launcherAngleTwoPIDController")); - Shuffleboard.getTab("Launcher") - .add(new SparkPIDWidget(launcherTopPIDController, "launcherTopPID")) - .withPosition(0, 0); - Shuffleboard.getTab("Launcher") - .add(new SparkPIDWidget(launcherBottomPIDController, "launcherBottomPID")) - .withPosition(1, 0); - - Shuffleboard.getTab("Launcher") - .addDouble("Bottom FlyWheel Temp", () -> launcherBottomMotor.getMotorTemperature()); - Shuffleboard.getTab("Launcher") - .addDouble("Top FlyWheel Temp", () -> launcherBottomMotor.getMotorTemperature()); } @Override From 3ba78c1bb57a4da59c1fca39577b053fcc5a5e95 Mon Sep 17 00:00:00 2001 From: kirbt <91921906+kirbt@users.noreply.github.com> Date: Thu, 29 Feb 2024 21:31:38 -0800 Subject: [PATCH 4/9] address pr comments --- .../java/frc/team2412/robot/subsystems/IntakeSubsystem.java | 6 +++++- .../frc/team2412/robot/subsystems/LauncherSubsystem.java | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/frc/team2412/robot/subsystems/IntakeSubsystem.java b/src/main/java/frc/team2412/robot/subsystems/IntakeSubsystem.java index 3baa3ccd..1e490ea1 100644 --- a/src/main/java/frc/team2412/robot/subsystems/IntakeSubsystem.java +++ b/src/main/java/frc/team2412/robot/subsystems/IntakeSubsystem.java @@ -199,7 +199,11 @@ public void initShuffleboard() { .withSize(1, 1) .withWidget(BuiltInWidgets.kTextView); shuffleboardTab - .addDouble("Index Motor Temp", () -> feederMotor.getMotorTemperature()) + .addDouble("Index Motor Temp", () -> indexMotorUpper.getMotorTemperature()) + .withSize(1, 1) + .withWidget(BuiltInWidgets.kTextView); + shuffleboardTab + .addDouble("Feeder Motor Temp", () -> feederMotor.getMotorTemperature()) .withSize(1, 1) .withWidget(BuiltInWidgets.kTextView); } diff --git a/src/main/java/frc/team2412/robot/subsystems/LauncherSubsystem.java b/src/main/java/frc/team2412/robot/subsystems/LauncherSubsystem.java index b63b7ef9..b9eb23be 100644 --- a/src/main/java/frc/team2412/robot/subsystems/LauncherSubsystem.java +++ b/src/main/java/frc/team2412/robot/subsystems/LauncherSubsystem.java @@ -244,7 +244,7 @@ private void initShuffleboard() { Shuffleboard.getTab("Launcher") .addDouble("Bottom FlyWheel Temp", () -> launcherBottomMotor.getMotorTemperature()); Shuffleboard.getTab("Launcher") - .addDouble("Top FlyWheel Temp", () -> launcherBottomMotor.getMotorTemperature()); + .addDouble("Top FlyWheel Temp", () -> launcherTopMotor.getMotorTemperature()); } launcherIsAtSpeed = From dc53f30a9d84d23ddc15e36571438db546859ed5 Mon Sep 17 00:00:00 2001 From: kirbt <91921906+kirbt@users.noreply.github.com> Date: Sat, 9 Mar 2024 10:54:39 -0800 Subject: [PATCH 5/9] wip autologic changes --- .../robot/util/{ => auto}/AutoLogic.java | 57 ++++++++++++++----- .../team2412/robot/util/auto/AutoPath.java | 19 +++++++ .../ComplexAutoPaths.java} | 20 ++++++- 3 files changed, 79 insertions(+), 17 deletions(-) rename src/main/java/frc/team2412/robot/util/{ => auto}/AutoLogic.java (61%) create mode 100644 src/main/java/frc/team2412/robot/util/auto/AutoPath.java rename src/main/java/frc/team2412/robot/util/{AutoPaths.java => auto/ComplexAutoPaths.java} (90%) diff --git a/src/main/java/frc/team2412/robot/util/AutoLogic.java b/src/main/java/frc/team2412/robot/util/auto/AutoLogic.java similarity index 61% rename from src/main/java/frc/team2412/robot/util/AutoLogic.java rename to src/main/java/frc/team2412/robot/util/auto/AutoLogic.java index 2b09dc26..e22b1d6a 100644 --- a/src/main/java/frc/team2412/robot/util/AutoLogic.java +++ b/src/main/java/frc/team2412/robot/util/auto/AutoLogic.java @@ -1,8 +1,12 @@ -package frc.team2412.robot.util; +package frc.team2412.robot.util.auto; import com.pathplanner.lib.auto.AutoBuilder; import com.pathplanner.lib.auto.NamedCommands; import com.pathplanner.lib.path.PathPlannerPath; +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; import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.InstantCommand; import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; @@ -15,12 +19,20 @@ import frc.team2412.robot.commands.launcher.FullTargetCommand; import frc.team2412.robot.commands.launcher.SetAngleLaunchCommand; import frc.team2412.robot.subsystems.LauncherSubsystem; +import java.util.HashMap; +import java.util.List; +import java.util.Map; public class AutoLogic { public static Robot r = Robot.getInstance(); public static final Subsystems s = r.subsystems; public static final Controls controls = r.controls; + List onePiecePaths = List.of(new AutoPath("Test Path", "testPath")); + + Map> commandsMap = Map.of(0, List.of(new AutoPath("Test Path", "testPath"))); + + // in place of launching command cause launcher doesnt exist public static SequentialCommandGroup vibrateControllerCommand = new SequentialCommandGroup( @@ -28,14 +40,18 @@ public class AutoLogic { new WaitCommand(1.5), new InstantCommand(() -> controls.vibrateDriveController(0.0))); - /** - * Placeholder for vision detect note - * - * @return true - */ - public static boolean dummyLogic() { - return true; - } + private static ShuffleboardTab tab = Shuffleboard.getTab("Match"); + + public static enum StartPosition { + AMP_SIDE_SUBWOOFER(), + MID_SIDE_SUBWOOFER(), + SOURCE_SIDE_SUBWOOFER(); + }; + + private static SendableChooser startPosition; + private static SendableChooser availableAutos; + private static GenericEntry amountGamePiecesEntry; + private static GenericEntry autoRoutinesEntry; public AutoLogic() { @@ -67,15 +83,15 @@ public void registerCommands() { NamedCommands.registerCommand("Intake", new AllInCommand(s.intakeSubsystem)); // Complex Autos - NamedCommands.registerCommand("AutoLogicTest", AutoPaths.testAuto); + NamedCommands.registerCommand("AutoLogicTest", ComplexAutoPaths.testAuto); NamedCommands.registerCommand( - "MidSpeakerCenterLineN5N4N3", AutoPaths.midSpeakerCenterLineN3N2N1); + "MidSpeakerCenterLineN5N4N3", ComplexAutoPaths.midSpeakerCenterLineN3N2N1); NamedCommands.registerCommand( - "LowSpeakerCenterLineN5N4N3", AutoPaths.lowSpeakerCenterLineN5N4N3); + "LowSpeakerCenterLineN5N4N3", ComplexAutoPaths.lowSpeakerCenterLineN5N4N3); NamedCommands.registerCommand( - "TopSpeakerCenterLineN1N2AutoLine1", AutoPaths.TopSpeakerCenterLineN1N2AutoLine1); + "TopSpeakerCe,nterLineN1N2AutoLine1", ComplexAutoPaths.TopSpeakerCenterLineN1N2AutoLine1); NamedCommands.registerCommand( - "TopSpeakerCenterLineN1N2AutoLine1", AutoPaths.TopSpeakerCenterLineN1N2N3); + "TopSpeakerCenterLineN1N2AutoLine1", ComplexAutoPaths.TopSpeakerCenterLineN1N2N3); } // public Command getConditionalCommand(){} @@ -93,4 +109,17 @@ public static Command getAutoCommand(String pathName) { // Create a path following command using AutoBuilder. This will also trigger event markers. return AutoBuilder.followPath(path); } + + public static void initShuffleBoard() { + + tab.add("Starting Position", startPosition).withPosition(5, 1).withSize(2, 1); + amountGamePiecesEntry = tab.add("Game Pieces", 0).withPosition(5, 2).withSize(2, 1).getEntry(); + tab.add("Available Auto Variants", availableAutos).withPosition(5, 3).withSize(2, 1); + } + + // public static void updateAvailableAutos() { + + // for () + + // } } diff --git a/src/main/java/frc/team2412/robot/util/auto/AutoPath.java b/src/main/java/frc/team2412/robot/util/auto/AutoPath.java new file mode 100644 index 00000000..330cf67b --- /dev/null +++ b/src/main/java/frc/team2412/robot/util/auto/AutoPath.java @@ -0,0 +1,19 @@ +package frc.team2412.robot.util.auto; + +import com.pathplanner.lib.auto.AutoBuilder; +import com.pathplanner.lib.commands.PathPlannerAuto; +import edu.wpi.first.math.geometry.Pose2d; +import edu.wpi.first.wpilibj2.command.Command; + +public class AutoPath { + + private Pose2d startingPose; + private String displayName; + private Command autoCommand; + + public AutoPath(String displayName, String pathPlannerAutoName) { + this.displayName = displayName; + startingPose = PathPlannerAuto.getStaringPoseFromAutoFile(pathPlannerAutoName); + autoCommand = AutoBuilder.buildAuto(pathPlannerAutoName); + } +} diff --git a/src/main/java/frc/team2412/robot/util/AutoPaths.java b/src/main/java/frc/team2412/robot/util/auto/ComplexAutoPaths.java similarity index 90% rename from src/main/java/frc/team2412/robot/util/AutoPaths.java rename to src/main/java/frc/team2412/robot/util/auto/ComplexAutoPaths.java index bf7d291f..dd36afab 100644 --- a/src/main/java/frc/team2412/robot/util/AutoPaths.java +++ b/src/main/java/frc/team2412/robot/util/auto/ComplexAutoPaths.java @@ -1,6 +1,6 @@ -package frc.team2412.robot.util; +package frc.team2412.robot.util.auto; -import static frc.team2412.robot.util.AutoLogic.*; +import static frc.team2412.robot.util.auto.AutoLogic.*; import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.Commands; @@ -10,7 +10,21 @@ import frc.team2412.robot.commands.launcher.SetAngleLaunchCommand; import frc.team2412.robot.subsystems.LauncherSubsystem; -public class AutoPaths { +public class ComplexAutoPaths { + + // Paths Hashmap + + // public static enum AutoRegistry { + // TEST("test auto", 0, testAuto); + // public final String autoName; + // public final int gamePieces; + // public final Command autoCommand; + // AutoRegistry(String autoName, int gamePieces, Command autoCommand) { + // this.autoName = autoName; + // this.gamePieces = gamePieces; + // this.autoCommand = autoCommand; + // } + // } // Test Auto From ba80250e44d63d97c6ad5ffab1962650c6409ee1 Mon Sep 17 00:00:00 2001 From: kirbt <91921906+kirbt@users.noreply.github.com> Date: Sat, 9 Mar 2024 16:30:52 -0800 Subject: [PATCH 6/9] Revert "wip autologic changes" This reverts commit dc53f30a9d84d23ddc15e36571438db546859ed5. --- .../robot/util/{auto => }/AutoLogic.java | 57 +++++-------------- .../ComplexAutoPaths.java => AutoPaths.java} | 20 +------ .../team2412/robot/util/auto/AutoPath.java | 19 ------- 3 files changed, 17 insertions(+), 79 deletions(-) rename src/main/java/frc/team2412/robot/util/{auto => }/AutoLogic.java (61%) rename src/main/java/frc/team2412/robot/util/{auto/ComplexAutoPaths.java => AutoPaths.java} (90%) delete mode 100644 src/main/java/frc/team2412/robot/util/auto/AutoPath.java diff --git a/src/main/java/frc/team2412/robot/util/auto/AutoLogic.java b/src/main/java/frc/team2412/robot/util/AutoLogic.java similarity index 61% rename from src/main/java/frc/team2412/robot/util/auto/AutoLogic.java rename to src/main/java/frc/team2412/robot/util/AutoLogic.java index e22b1d6a..2b09dc26 100644 --- a/src/main/java/frc/team2412/robot/util/auto/AutoLogic.java +++ b/src/main/java/frc/team2412/robot/util/AutoLogic.java @@ -1,12 +1,8 @@ -package frc.team2412.robot.util.auto; +package frc.team2412.robot.util; import com.pathplanner.lib.auto.AutoBuilder; import com.pathplanner.lib.auto.NamedCommands; import com.pathplanner.lib.path.PathPlannerPath; -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; import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.InstantCommand; import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; @@ -19,20 +15,12 @@ import frc.team2412.robot.commands.launcher.FullTargetCommand; import frc.team2412.robot.commands.launcher.SetAngleLaunchCommand; import frc.team2412.robot.subsystems.LauncherSubsystem; -import java.util.HashMap; -import java.util.List; -import java.util.Map; public class AutoLogic { public static Robot r = Robot.getInstance(); public static final Subsystems s = r.subsystems; public static final Controls controls = r.controls; - List onePiecePaths = List.of(new AutoPath("Test Path", "testPath")); - - Map> commandsMap = Map.of(0, List.of(new AutoPath("Test Path", "testPath"))); - - // in place of launching command cause launcher doesnt exist public static SequentialCommandGroup vibrateControllerCommand = new SequentialCommandGroup( @@ -40,18 +28,14 @@ public class AutoLogic { new WaitCommand(1.5), new InstantCommand(() -> controls.vibrateDriveController(0.0))); - private static ShuffleboardTab tab = Shuffleboard.getTab("Match"); - - public static enum StartPosition { - AMP_SIDE_SUBWOOFER(), - MID_SIDE_SUBWOOFER(), - SOURCE_SIDE_SUBWOOFER(); - }; - - private static SendableChooser startPosition; - private static SendableChooser availableAutos; - private static GenericEntry amountGamePiecesEntry; - private static GenericEntry autoRoutinesEntry; + /** + * Placeholder for vision detect note + * + * @return true + */ + public static boolean dummyLogic() { + return true; + } public AutoLogic() { @@ -83,15 +67,15 @@ public void registerCommands() { NamedCommands.registerCommand("Intake", new AllInCommand(s.intakeSubsystem)); // Complex Autos - NamedCommands.registerCommand("AutoLogicTest", ComplexAutoPaths.testAuto); + NamedCommands.registerCommand("AutoLogicTest", AutoPaths.testAuto); NamedCommands.registerCommand( - "MidSpeakerCenterLineN5N4N3", ComplexAutoPaths.midSpeakerCenterLineN3N2N1); + "MidSpeakerCenterLineN5N4N3", AutoPaths.midSpeakerCenterLineN3N2N1); NamedCommands.registerCommand( - "LowSpeakerCenterLineN5N4N3", ComplexAutoPaths.lowSpeakerCenterLineN5N4N3); + "LowSpeakerCenterLineN5N4N3", AutoPaths.lowSpeakerCenterLineN5N4N3); NamedCommands.registerCommand( - "TopSpeakerCe,nterLineN1N2AutoLine1", ComplexAutoPaths.TopSpeakerCenterLineN1N2AutoLine1); + "TopSpeakerCenterLineN1N2AutoLine1", AutoPaths.TopSpeakerCenterLineN1N2AutoLine1); NamedCommands.registerCommand( - "TopSpeakerCenterLineN1N2AutoLine1", ComplexAutoPaths.TopSpeakerCenterLineN1N2N3); + "TopSpeakerCenterLineN1N2AutoLine1", AutoPaths.TopSpeakerCenterLineN1N2N3); } // public Command getConditionalCommand(){} @@ -109,17 +93,4 @@ public static Command getAutoCommand(String pathName) { // Create a path following command using AutoBuilder. This will also trigger event markers. return AutoBuilder.followPath(path); } - - public static void initShuffleBoard() { - - tab.add("Starting Position", startPosition).withPosition(5, 1).withSize(2, 1); - amountGamePiecesEntry = tab.add("Game Pieces", 0).withPosition(5, 2).withSize(2, 1).getEntry(); - tab.add("Available Auto Variants", availableAutos).withPosition(5, 3).withSize(2, 1); - } - - // public static void updateAvailableAutos() { - - // for () - - // } } diff --git a/src/main/java/frc/team2412/robot/util/auto/ComplexAutoPaths.java b/src/main/java/frc/team2412/robot/util/AutoPaths.java similarity index 90% rename from src/main/java/frc/team2412/robot/util/auto/ComplexAutoPaths.java rename to src/main/java/frc/team2412/robot/util/AutoPaths.java index dd36afab..bf7d291f 100644 --- a/src/main/java/frc/team2412/robot/util/auto/ComplexAutoPaths.java +++ b/src/main/java/frc/team2412/robot/util/AutoPaths.java @@ -1,6 +1,6 @@ -package frc.team2412.robot.util.auto; +package frc.team2412.robot.util; -import static frc.team2412.robot.util.auto.AutoLogic.*; +import static frc.team2412.robot.util.AutoLogic.*; import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.Commands; @@ -10,21 +10,7 @@ import frc.team2412.robot.commands.launcher.SetAngleLaunchCommand; import frc.team2412.robot.subsystems.LauncherSubsystem; -public class ComplexAutoPaths { - - // Paths Hashmap - - // public static enum AutoRegistry { - // TEST("test auto", 0, testAuto); - // public final String autoName; - // public final int gamePieces; - // public final Command autoCommand; - // AutoRegistry(String autoName, int gamePieces, Command autoCommand) { - // this.autoName = autoName; - // this.gamePieces = gamePieces; - // this.autoCommand = autoCommand; - // } - // } +public class AutoPaths { // Test Auto diff --git a/src/main/java/frc/team2412/robot/util/auto/AutoPath.java b/src/main/java/frc/team2412/robot/util/auto/AutoPath.java deleted file mode 100644 index 330cf67b..00000000 --- a/src/main/java/frc/team2412/robot/util/auto/AutoPath.java +++ /dev/null @@ -1,19 +0,0 @@ -package frc.team2412.robot.util.auto; - -import com.pathplanner.lib.auto.AutoBuilder; -import com.pathplanner.lib.commands.PathPlannerAuto; -import edu.wpi.first.math.geometry.Pose2d; -import edu.wpi.first.wpilibj2.command.Command; - -public class AutoPath { - - private Pose2d startingPose; - private String displayName; - private Command autoCommand; - - public AutoPath(String displayName, String pathPlannerAutoName) { - this.displayName = displayName; - startingPose = PathPlannerAuto.getStaringPoseFromAutoFile(pathPlannerAutoName); - autoCommand = AutoBuilder.buildAuto(pathPlannerAutoName); - } -} From f8735c99814abba04cfdc439ccf9b4cad9d55a2e Mon Sep 17 00:00:00 2001 From: kirby Date: Mon, 18 Mar 2024 18:07:05 -0700 Subject: [PATCH 7/9] spotless --- .../frc/team2412/robot/subsystems/IntakeSubsystem.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/frc/team2412/robot/subsystems/IntakeSubsystem.java b/src/main/java/frc/team2412/robot/subsystems/IntakeSubsystem.java index 9b6137c0..6a9e387e 100644 --- a/src/main/java/frc/team2412/robot/subsystems/IntakeSubsystem.java +++ b/src/main/java/frc/team2412/robot/subsystems/IntakeSubsystem.java @@ -225,10 +225,10 @@ public void initShuffleboard() { shuffleboardTab.add("Feeder in speed - ", FEEDER_IN_SPEED).withSize(1, 1).getEntry(); sensorOverride = - Shuffleboard.getTab("Intake") - .add("Override Sensors", false) - .withSize(1, 1) - .withWidget(BuiltInWidgets.kToggleSwitch) - .getEntry(); + Shuffleboard.getTab("Intake") + .add("Override Sensors", false) + .withSize(1, 1) + .withWidget(BuiltInWidgets.kToggleSwitch) + .getEntry(); } } From 59d9dd70f56f4829f0b34af04e4477f3f64e203a Mon Sep 17 00:00:00 2001 From: kirby Date: Mon, 18 Mar 2024 18:11:11 -0700 Subject: [PATCH 8/9] spotless (i love merge conflicts) --- .../java/frc/team2412/robot/subsystems/LauncherSubsystem.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/frc/team2412/robot/subsystems/LauncherSubsystem.java b/src/main/java/frc/team2412/robot/subsystems/LauncherSubsystem.java index c3ed7f13..f1858fe4 100644 --- a/src/main/java/frc/team2412/robot/subsystems/LauncherSubsystem.java +++ b/src/main/java/frc/team2412/robot/subsystems/LauncherSubsystem.java @@ -321,7 +321,7 @@ private void initShuffleboard() { .withProperties(Map.of("Min", -MAX_FREE_SPEED_RPM, "Max", MAX_FREE_SPEED_RPM)) .withPosition(5, 0) .getEntry(); - + launcherAngleManual = Shuffleboard.getTab("Launcher") .add("Launcher manual increase", 0) @@ -339,7 +339,6 @@ private void initShuffleboard() { Shuffleboard.getTab("Launcher") .add(new SparkPIDWidget(launcherBottomPIDController, "launcherBottomPID")) .withPosition(1, 0); - } @Override From 50b2036bb3682e2b41d400715071f4ab91d3f9bd Mon Sep 17 00:00:00 2001 From: kirby Date: Mon, 18 Mar 2024 18:47:54 -0700 Subject: [PATCH 9/9] debug --- .../robot/subsystems/LauncherSubsystem.java | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/main/java/frc/team2412/robot/subsystems/LauncherSubsystem.java b/src/main/java/frc/team2412/robot/subsystems/LauncherSubsystem.java index f1858fe4..398ea99f 100644 --- a/src/main/java/frc/team2412/robot/subsystems/LauncherSubsystem.java +++ b/src/main/java/frc/team2412/robot/subsystems/LauncherSubsystem.java @@ -270,8 +270,6 @@ private void initShuffleboard() { Shuffleboard.getTab("Launcher") .add(new SparkPIDWidget(launcherAngleOnePIDController, "launcherAnglePID")) .withPosition(2, 0); - // Shuffleboard.getTab("Launcher") - // .add(new SparkPIDWidget(launcherAngleTwoPIDController, "launcherAngleTwoPIDController")); Shuffleboard.getTab("Launcher") .add(new SparkPIDWidget(launcherTopPIDController, "launcherTopPID")) .withPosition(0, 0); @@ -328,17 +326,6 @@ private void initShuffleboard() { .withSize(1, 1) .withWidget(BuiltInWidgets.kTextView) .getEntry(); - Shuffleboard.getTab("Launcher") - .add(new SparkPIDWidget(launcherAngleOnePIDController, "launcherAnglePID")) - .withPosition(2, 0); - // Shuffleboard.getTab("Launcher") - // .add(new SparkPIDWidget(launcherAngleTwoPIDController, "launcherAngleTwoPIDController")); - Shuffleboard.getTab("Launcher") - .add(new SparkPIDWidget(launcherTopPIDController, "launcherTopPID")) - .withPosition(0, 0); - Shuffleboard.getTab("Launcher") - .add(new SparkPIDWidget(launcherBottomPIDController, "launcherBottomPID")) - .withPosition(1, 0); } @Override