-
-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/stow update #64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ad0a345
fc4c007
521389d
4749b4e
c34030c
7e9c230
80f2d4a
6b66f49
564befc
853bd7f
3389dc0
8a1c7dc
ccc69d6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -45,6 +45,8 @@ public static class Drive { | |||||
|
|
||||||
| public static final double TARGET_TRANSLATION_RADIUS = 2.0; | ||||||
|
|
||||||
| public static final double SHOOTING_SPEED_SCALE = 0.5; // Scale factor applied to drive speed while shooting | ||||||
|
|
||||||
| } | ||||||
|
|
||||||
| public static class Misc { | ||||||
|
|
@@ -407,18 +409,23 @@ public static class Turret { | |||||
| public static final double TURN_TABLE_RATIO = 24.0 / 200.0; | ||||||
| public static final double ENCODER_FACTOR = (TURRET_GEAR_REDUCTION) / (2.0 * Math.PI * TURN_TABLE_RATIO); | ||||||
|
|
||||||
| public static final double STOW_PUSH_DOWN_SPEED = -0.3; // percent of max speed | ||||||
| public static final double STOW_PUSH_DOWN_TIME = 0.5; // seconds | ||||||
| public static final double STOW_PUSH_DOWN_SPEED = 0.6; // percent of max speed | ||||||
| public static final double STOW_PUSH_DOWN_TIME = 0.1; // seconds | ||||||
|
|
||||||
| public static final double PITCH_GEAR_RATIO = (26.0 / 447.2); | ||||||
| public static final double PITCH_ENCODER_FACTOR = PITCH_GEAR_RATIO * (2.0 * Math.PI); | ||||||
|
|
||||||
| public static final boolean PITCH_INVERTED = true; | ||||||
|
|
||||||
| public static final Rotation2d MAX_PITCH = Rotation2d.fromDegrees(45.0); | ||||||
| public static final Rotation2d MIN_PITCH = Rotation2d.fromDegrees(3.00); | ||||||
| public static final Rotation2d HOOD_START_POSITION = Rotation2d.fromDegrees(5.00); | ||||||
| public static final Rotation2d HOOD_STOW_POSITION = Rotation2d.fromDegrees(3.00); | ||||||
| public static final Rotation2d MIN_PITCH = Rotation2d.fromDegrees(8.00); | ||||||
| public static final Rotation2d HOOD_START_POSITION = Rotation2d.fromDegrees(8.00); | ||||||
|
|
||||||
| public static final double HOOD_STABLE_TIME = 0.1; | ||||||
| public static final double HOOD_STABLE = 5; | ||||||
|
||||||
| public static final double HOOD_STABLE = 5; |
Copilot
AI
Apr 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOAD_DELAY is newly added but not referenced anywhere in the codebase. If the intent is to enforce a shooter-before-transfer delay, incorporate this into the relevant command scheduling logic; otherwise remove the unused constant.
| public static final double LOAD_DELAY = 0.1; //Time between shooter and transfer being triggered, shooter should always activate first |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -267,6 +267,26 @@ public void updateFieldObjects() { | |||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| public void configureBindings() { | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| new Trigger( | ||||||||||||||||||||||||||||||||||||||||
| () -> operatorController.getAButton()).onTrue( | ||||||||||||||||||||||||||||||||||||||||
| new InstantCommand(() -> selectedFixedTarget = FixedTarget.A)); | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| new Trigger( | ||||||||||||||||||||||||||||||||||||||||
| () -> operatorController.getBButton()).onTrue( | ||||||||||||||||||||||||||||||||||||||||
| new InstantCommand(() -> selectedFixedTarget = FixedTarget.B)); | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| new Trigger( | ||||||||||||||||||||||||||||||||||||||||
| () -> operatorController.getXButton()).onTrue( | ||||||||||||||||||||||||||||||||||||||||
| new InstantCommand(() -> xHeld = true)) | ||||||||||||||||||||||||||||||||||||||||
| .onFalse( | ||||||||||||||||||||||||||||||||||||||||
| new InstantCommand(() -> xHeld = false)); | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| new Trigger( | ||||||||||||||||||||||||||||||||||||||||
| () -> operatorController.getYButton()).onTrue( | ||||||||||||||||||||||||||||||||||||||||
| new InstantCommand(() -> yHeld = true)) | ||||||||||||||||||||||||||||||||||||||||
| .onFalse( | ||||||||||||||||||||||||||||||||||||||||
| new InstantCommand(() -> yHeld = false)); | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+270
to
+289
|
||||||||||||||||||||||||||||||||||||||||
| new Trigger( | |
| () -> operatorController.getAButton()).onTrue( | |
| new InstantCommand(() -> selectedFixedTarget = FixedTarget.A)); | |
| new Trigger( | |
| () -> operatorController.getBButton()).onTrue( | |
| new InstantCommand(() -> selectedFixedTarget = FixedTarget.B)); | |
| new Trigger( | |
| () -> operatorController.getXButton()).onTrue( | |
| new InstantCommand(() -> xHeld = true)) | |
| .onFalse( | |
| new InstantCommand(() -> xHeld = false)); | |
| new Trigger( | |
| () -> operatorController.getYButton()).onTrue( | |
| new InstantCommand(() -> yHeld = true)) | |
| .onFalse( | |
| new InstantCommand(() -> yHeld = false)); |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -58,6 +58,9 @@ public class DriveSubsystem extends SubsystemBase { | |||||||
| // Feature Flags | ||||||||
| private boolean useVisionOdometry = true; | ||||||||
|
|
||||||||
| // Speed scaling (e.g. 0.5 to limit to 50% while shooting) | ||||||||
| private Supplier<Double> speedScaleSupplier = () -> 1.0; | ||||||||
|
|
||||||||
|
Comment on lines
+61
to
+63
|
||||||||
| // Speed scaling (e.g. 0.5 to limit to 50% while shooting) | |
| private Supplier<Double> speedScaleSupplier = () -> 1.0; |
Copilot
AI
Apr 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MathUtil.clamp(...) does not guard against NaN/Infinity; if the supplier ever returns a non-finite value, the chassis speeds become non-finite and could propagate into the swerve drive. Consider sanitizing the supplier output (e.g., treat non-finite as 1.0 or 0.0) before applying it.
| double scale = MathUtil.clamp(speedScaleSupplier.get(), 0.0, 1.0); | |
| double rawScale = speedScaleSupplier.get(); | |
| double scale = MathUtil.clamp(Double.isFinite(rawScale) ? rawScale : 1.0, 0.0, 1.0); |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -22,6 +22,7 @@ | |||||||||||||||||||||||||||
| import edu.wpi.first.math.kinematics.ChassisSpeeds; | ||||||||||||||||||||||||||||
| import edu.wpi.first.wpilibj.DriverStation; | ||||||||||||||||||||||||||||
| import edu.wpi.first.wpilibj.PWM; | ||||||||||||||||||||||||||||
| import edu.wpi.first.wpilibj.Timer; | ||||||||||||||||||||||||||||
| import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; | ||||||||||||||||||||||||||||
| import edu.wpi.first.wpilibj2.command.Command; | ||||||||||||||||||||||||||||
| import edu.wpi.first.wpilibj2.command.Commands; | ||||||||||||||||||||||||||||
|
|
@@ -194,6 +195,10 @@ public Rotation2d getHoodAngle() { | |||||||||||||||||||||||||||
| - hoodOffsetSupplier.get().getRadians()); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| public double getHoodVelocity() { | ||||||||||||||||||||||||||||
| return pitchEncoder.getVelocity().getValueAsDouble() * Constants.Turret.PITCH_ENCODER_FACTOR; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||
| * @return the current turret yaw in the field frame | ||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||
|
|
@@ -336,36 +341,50 @@ public Command getAngleCommand( | |||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| public Command getStowCommand() { | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Command moveToTarget = new FunctionalCommand( | ||||||||||||||||||||||||||||
| () -> SmartDashboard.putBoolean("Turret/IsStowing", true), | ||||||||||||||||||||||||||||
| final Timer settleTimer = new Timer(); | ||||||||||||||||||||||||||||
| double stopThreshold = Math.max(1e-3, Math.abs(Constants.Turret.HOOD_FINISH_VELOCITY)); // rad/s | ||||||||||||||||||||||||||||
| double stableTime = Constants.Turret.HOOD_STABLE_TIME; // seconds, or a separate constant | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Command settleDown = Commands.run( | ||||||||||||||||||||||||||||
| () -> { | ||||||||||||||||||||||||||||
| setHoodAngle(Constants.Turret.HOOD_STOW_POSITION); | ||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| interrupted -> { | ||||||||||||||||||||||||||||
| pitchServo.setSpeed((Constants.Turret.PITCH_INVERTED ? -1.0 : 1.0) * -Constants.Turret.STOW_PUSH_DOWN_SPEED); | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
| pitchServo.setSpeed((Constants.Turret.PITCH_INVERTED ? -1.0 : 1.0) * -Constants.Turret.STOW_PUSH_DOWN_SPEED); | |
| pitchServo.setSpeed((Constants.Turret.PITCH_INVERTED ? 1.0 : -1.0) * Constants.Turret.STOW_PUSH_DOWN_SPEED); |
Copilot
AI
Apr 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
settleDown drives the hood servo open-loop but never disables hoodClosedLoopActive; periodic() will keep writing PID output while closed-loop is active, which can override/fight this command. Consider explicitly disabling closed-loop at the start of stow (e.g., call stopHoodServo() / set hoodClosedLoopActive = false) before applying the constant push-down speed.
Copilot
AI
Apr 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The servo stop/reset logic is in an .andThen(...), which only runs on normal completion. If getStowCommand() is interrupted (e.g., by a targeting command), the hood servo can be left running at the last push-down speed. Use a command form that defines an end(interrupted)/finallyDo to always stop the servo and reset/stop the timer on both completion and interruption.
| // ensure the servo is stopped when this command completes | |
| .andThen(() -> { | |
| pitchServo.setSpeed(0.0); | |
| settleTimer.stop(); | |
| settleTimer.reset(); | |
| } | |
| ); | |
| // ensure the servo and timer are cleaned up on both completion and interruption | |
| .finallyDo(() -> { | |
| pitchServo.setSpeed(0.0); | |
| settleTimer.stop(); | |
| settleTimer.reset(); | |
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
STOW_PUSH_DOWN_TIMEis still defined but is no longer used bygetStowCommand(). Either remove the constant or reintroduce a timeout/safety bound that uses it (especially if the velocity-based settle condition could fail due to encoder noise).