]> git.taranathan.com Git - FRC2026.git/commitdiff
stuff
authorWesleyWong-972 <wesleycwong@gmail.com>
Tue, 21 Apr 2026 00:31:31 +0000 (17:31 -0700)
committerWesleyWong-972 <wesleycwong@gmail.com>
Tue, 21 Apr 2026 00:31:31 +0000 (17:31 -0700)
src/main/deploy/pathplanner/paths/Left Swipe1.path
src/main/deploy/pathplanner/paths/Right Swipe1.path
src/main/java/frc/robot/RobotContainer.java
src/main/java/frc/robot/commands/LogCommand.java
src/main/java/frc/robot/commands/auto_comm/DynamicAutoBuilder.java
src/main/java/frc/robot/commands/gpm/RunSpindexer.java
src/main/java/frc/robot/commands/gpm/RunSpindexerWithStop.java [new file with mode: 0644]
src/main/java/frc/robot/subsystems/spindexer/Spindexer.java
src/main/java/frc/robot/subsystems/spindexer/SpindexerConstants.java

index 33bf814d425a1adddf41b621054ce9fe73865580..7213bd0ed25790939f4571d434d4bf4b637dc87c 100644 (file)
     {
       "name": "Constraints Zone",
       "minWaypointRelativePos": 0.7761529808773961,
-      "maxWaypointRelativePos": 1.642294713160863,
+      "maxWaypointRelativePos": 2.2491730981256937,
       "constraints": {
         "maxVelocity": 1.0,
         "maxAcceleration": 2.0,
     }
   ],
   "pointTowardsZones": [],
-  "eventMarkers": [
-    {
-      "name": "Stop Hood Down",
-      "waypointRelativePos": 4.968503937007888,
-      "endWaypointRelativePos": null,
-      "command": {
-        "type": "named",
-        "data": {
-          "name": "Stop Hood Down"
-        }
-      }
-    },
-    {
-      "name": "Start Spindexer",
-      "waypointRelativePos": 5.0,
-      "endWaypointRelativePos": null,
-      "command": {
-        "type": "named",
-        "data": {
-          "name": "Start Spindexer"
-        }
-      }
-    }
-  ],
+  "eventMarkers": [],
   "globalConstraints": {
     "maxVelocity": 3.0,
     "maxAcceleration": 2.5,
index 3bd63f691bb3f9839b20808a755cf6d85384c441..44a9f20e37bfb917e0f39c2ffa3607c670878c51 100644 (file)
@@ -21,7 +21,7 @@
       },
       "prevControl": {
         "x": 8.155370348167532,
-        "y": 0.8386737269319345
+        "y": 0.8386737269319344
       },
       "nextControl": {
         "x": 8.45722898958081,
     {
       "name": "Constraints Zone",
       "minWaypointRelativePos": 0.7761529808773961,
-      "maxWaypointRelativePos": 1.642294713160863,
+      "maxWaypointRelativePos": 2.2491730981256826,
       "constraints": {
         "maxVelocity": 1,
         "maxAcceleration": 2,
     }
   ],
   "pointTowardsZones": [],
-  "eventMarkers": [
-    {
-      "name": "Stop Hood Down",
-      "waypointRelativePos": 4.968503937007888,
-      "endWaypointRelativePos": null,
-      "command": {
-        "type": "named",
-        "data": {
-          "name": "Stop Hood Down"
-        }
-      }
-    },
-    {
-      "name": "Start Spindexer",
-      "waypointRelativePos": 5,
-      "endWaypointRelativePos": null,
-      "command": {
-        "type": "named",
-        "data": {
-          "name": "Start Spindexer"
-        }
-      }
-    }
-  ],
+  "eventMarkers": [],
   "globalConstraints": {
     "maxVelocity": 3,
     "maxAcceleration": 2.5,
index 1018db11647458260dd8152ce2f1fe5ec1e23bc7..fcda69fcacd200c4d361fdeb19827704e71b1e81 100644 (file)
@@ -21,6 +21,7 @@ import edu.wpi.first.wpilibj2.command.InstantCommand;
 import edu.wpi.first.wpilibj2.command.ParallelCommandGroup;
 import frc.robot.commands.DoNothing;
 import frc.robot.commands.LogCommand;
+import frc.robot.commands.auto_comm.DynamicAutoBuilder;
 import frc.robot.commands.drive_comm.DefaultDriveCommand;
 import frc.robot.commands.gpm.IntakeMovementCommand;
 import frc.robot.commands.gpm.LockedShoot;
@@ -255,6 +256,15 @@ public class RobotContainer {
     }
   }
 
+  public void addAuto(String name, Command auto) {
+    try {
+      autoChooser.addOption(name, auto);
+    } catch (AutoBuilderException e){
+      e.printStackTrace();
+      System.out.println("HELLOOOO AUTO \"" + name + "\" NOT FOUND");
+    }
+  }
+
   /**
    * Initialize the SendableChooser on the SmartDashboard.
    * Fill the SendableChooser with available Commands.
@@ -284,6 +294,11 @@ public class RobotContainer {
     addAuto(rightDoNothing);
     addAuto(centerDoNothing);
 
+    DynamicAutoBuilder dynamicAutoBuilder = new DynamicAutoBuilder(spindexer, turret, hood, intake, breaker);
+    
+    String leftDynamicDoubleSwipe = "LeftDynamicDoubleLiberalSwipe";
+    addAuto(leftDynamicDoubleSwipe, dynamicAutoBuilder.getLeftDynamicDoubleLiberalSwipe());
+
     // put the Chooser on the SmartDashboard
     SmartDashboard.putData("Auto chooser", autoChooser);
   }
index 06b346db6d3354521f014136eb6085c5b263bb7c..6392304fd75f578e0737270612a3c51452402ae1 100644 (file)
@@ -4,6 +4,7 @@ import org.littletonrobotics.junction.Logger;
 
 import edu.wpi.first.wpilibj2.command.Command;
 import frc.robot.constants.Constants;
+import frc.robot.subsystems.spindexer.Spindexer;
 import frc.robot.util.Elastic;
 import frc.robot.util.HubActive;
 import frc.robot.util.Elastic.Notification;
@@ -19,9 +20,7 @@ public class LogCommand extends Command {
     @Override
     public void execute() {
         boolean current = HubActive.isHubActive();
-        if (!Constants.DISABLE_LOGGING) {
-            Logger.recordOutput("HubActive", current);
-        }
+        Logger.recordOutput("HubActive", current);
         
         if (current && !hubActive) {
             Elastic.sendNotification(new Notification(NotificationLevel.INFO, "HUB ACTIVE", ""));
index f3430b8d7da5a2cbf3f5b5a301a834ac71245c3b..98426b04911dba23b3df141b6c37bbe81d9ed144 100644 (file)
@@ -86,8 +86,11 @@ public class DynamicAutoBuilder {
         var timer = new Timer();
         timer.start();
 
-        return new RunSpindexer(spindexer, turret, hood, intake).raceWith(
-                new WaitUntilCommand(() -> breaker.getAverageCurrentDraw(BreakerConstants.SPINDEXER_PORTS) < 5.0 && timer.hasElapsed(3.0)));
+        // return new RunSpindexer(spindexer, turret, hood, intake).raceWith(
+        //         new WaitUntilCommand(() -> spindexer.spinningAir() && timer.hasElapsed(3.0)));
+        // return new RunSpindexer(spindexer, turret, hood, intake).raceWith(new WaitCommand(3.0));
+        return new RunSpindexer(spindexer, turret, hood, intake).until(() -> spindexer.spinningAir() && timer.hasElapsed(3.0));
+
 
         // return new ParallelDeadlineGroup(new WaitUntilCommand(() ->
         // spindexer.spinningAir()), new RunSpindexer(spindexer, turret, hood, intake));
index bac112310809dc58d0d115168bb88f21406d2dc8..3dbbbf1ec72469db9fb1f17374412c2094440e92 100644 (file)
@@ -1,5 +1,7 @@
 package frc.robot.commands.gpm;
 
+import org.littletonrobotics.junction.Logger;
+
 import edu.wpi.first.math.filter.Debouncer;
 import edu.wpi.first.math.filter.Debouncer.DebounceType;
 import edu.wpi.first.wpilibj.Timer;
@@ -63,7 +65,10 @@ public class RunSpindexer extends Command {
             return; // this is so the balls don't fly out when unaligned
         }
         boolean jammed = spindexer.getSubsystemStatorCurrent() / 2 > SpindexerConstants.JAM_CURRENT_THRESHOLD;
+        Logger.recordOutput("SpindexerJammed", jammed);
         if (jam_debouncer.calculate(jammed)) {
+            Logger.recordOutput("SpindexerJammedDebounced", jammed);
+
             reversing = true;
             reverseTimer.reset();
             reverseTimer.start();
diff --git a/src/main/java/frc/robot/commands/gpm/RunSpindexerWithStop.java b/src/main/java/frc/robot/commands/gpm/RunSpindexerWithStop.java
new file mode 100644 (file)
index 0000000..86b45d2
--- /dev/null
@@ -0,0 +1,113 @@
+package frc.robot.commands.gpm;
+
+import org.littletonrobotics.junction.Logger;
+
+import edu.wpi.first.math.filter.Debouncer;
+import edu.wpi.first.math.filter.Debouncer.DebounceType;
+import edu.wpi.first.units.measure.Time;
+import edu.wpi.first.wpilibj.Timer;
+import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
+import edu.wpi.first.wpilibj2.command.Command;
+import frc.robot.constants.Constants;
+import frc.robot.subsystems.Intake.Intake;
+import frc.robot.subsystems.Intake.IntakeConstants;
+import frc.robot.subsystems.hood.Hood;
+import frc.robot.subsystems.spindexer.Spindexer;
+import frc.robot.subsystems.spindexer.SpindexerConstants;
+import frc.robot.subsystems.turret.Turret;
+
+public class RunSpindexerWithStop extends Command {
+    private Spindexer spindexer;
+    private Turret turret;
+    private Hood hood;
+    private Intake intake;
+
+    private Debouncer jam_debouncer = new Debouncer(SpindexerConstants.JAM_DEBOUNCE_TIME, DebounceType.kRising); // if there is jam I would think this is 0 -> 1
+
+    private boolean reversing = false;
+    private boolean wasHoodForcedDown = false;
+
+    private Timer reverseTimer = new Timer();
+
+    private double storedIntakeSpeed = 0.0;
+
+    
+    public RunSpindexerWithStop(Spindexer spindexer, Turret turret, Hood hood, Intake intake) {
+        this.spindexer = spindexer;
+        this.turret = turret;
+        this.hood = hood;
+        this.intake = intake;
+
+        addRequirements(spindexer);
+    }
+
+        // public RunSpindexer(Spindexer spindexer) {
+        // this.spindexer = spindexer;
+        // addRequirements(spindexer);
+    // }
+
+    @Override
+    public void initialize() {
+        wasHoodForcedDown = hood.getHoodForcedDown();
+        timer.reset();
+        timer.start();
+    }
+
+    @Override
+    public void execute() {
+        boolean hoodForcedDown = hood.getHoodForcedDown();
+        
+        if (wasHoodForcedDown && !hoodForcedDown) {
+            spindexer.maxSpindexer();
+        }
+        wasHoodForcedDown = hoodForcedDown;
+        
+        if (!turret.atSetpoint() || hoodForcedDown || spindexer.noIndexing) {
+            spindexer.stopSpindexer();
+            reversing = false;
+            return; // this is so the balls don't fly out when unaligned
+        }
+        boolean jammed = spindexer.getSubsystemStatorCurrent() / 2 > SpindexerConstants.JAM_CURRENT_THRESHOLD;
+        Logger.recordOutput("SpindexerJammed", jammed);
+        if (jam_debouncer.calculate(jammed)) {
+            Logger.recordOutput("SpindexerJammedDebounced", jammed);
+
+            reversing = true;
+            reverseTimer.reset();
+            reverseTimer.start();
+            storedIntakeSpeed = intake.getSpeed();
+        }
+        if (!reversing) {
+            spindexer.maxSpindexer();
+        } else {
+            spindexer.reverseSpindexer();
+
+            if (intake.getPosition() > IntakeConstants.INTERMEDIATE_EXTENSION + 1.0) {
+                intake.spinReverse();
+            } else {
+                intake.extend();
+            }
+
+            if (reverseTimer.hasElapsed(SpindexerConstants.REVERSE_DEBOUNCE_TIME)) {
+                reversing = false;
+                intake.spin(storedIntakeSpeed);
+            }
+        }
+        if (!Constants.DISABLE_SMART_DASHBOARD) {
+            SmartDashboard.putBoolean("Spindexer Jamming", reversing);
+        }
+    }
+
+    @Override
+    public void end(boolean interrupted) {
+        spindexer.stopSpindexer();
+        reversing = false;
+    }
+
+    private Timer timer = new Timer();
+
+    @Override
+    public boolean isFinished() {
+        return spindexer.spinningAir() && timer.hasElapsed(1.0);
+    }
+}
index 6455f15cde918eb7db5abb66b74468a3a9ca68b4..08c44927f60d49fc56ec8105025ba218c795d1ee 100644 (file)
@@ -82,6 +82,9 @@ public class Spindexer extends SubsystemBase implements SpindexerIO {
         if (!Constants.DISABLE_SMART_DASHBOARD) {
             SmartDashboard.putBoolean("Spindexer Reversing", state == SpindexerState.REVERSE);
         }
+
+        Logger.recordOutput("HasBalls", spinningAir());
+
     }
 
     public void setMotorVoltages(double voltage) {
@@ -120,10 +123,22 @@ public class Spindexer extends SubsystemBase implements SpindexerIO {
         return inputs.spindexerOneStatorCurrent + inputs.spindexerTwoStatorCurrent;
     }
 
+    public double getMotorOneStatorCurrent() {
+        return inputs.spindexerOneStatorCurrent;
+    }
+
+    public double getMotorTwoStatorCurrent() {
+        return inputs.spindexerTwoStatorCurrent;
+    }
+
     public double getSubsystemSupplyCurrent() {
         return inputs.spindexerOneSupplyCurrent + inputs.spindexerTwoSupplyCurrent;
     }
 
+    public boolean spinningAir() {
+        return getMotorOneStatorCurrent() < 16.0 && getMotorTwoStatorCurrent() < 28.0;
+    }
+
     @Override
     public void updateInputs() {
         inputs.spindexerOneVelocity = motorOne.getVelocity().getValueAsDouble();
index 631a8f2e0cb722aa2c71031f23dcdef8ce2d7162..e4d5708352657ea890ff7805e51b8ab24024b1f4 100644 (file)
@@ -10,7 +10,7 @@ public class SpindexerConstants {
     public static final double CURRENT_FORWARD_STATOR_LIMIT = 150.0;
     public static final double CURRENT_REVERSE_STATOR_LIMIT = 20.0;
     public static final double CURRENT_TIME_LIMIT = 1.0; //s
-    public static final double JAM_CURRENT_THRESHOLD = 75.0; // A
+    public static final double JAM_CURRENT_THRESHOLD = 40.0; // A
     public static final double JAM_DEBOUNCE_TIME = 0.3; // seconds
     public static final double REVERSE_DEBOUNCE_TIME = 0.25; // seconds
 }