From a24e9d540a19b8b1655bc0970d2cae8137bf68f3 Mon Sep 17 00:00:00 2001 From: Collin McIntyre Date: Mon, 15 Jun 2026 20:25:54 -0500 Subject: [PATCH] First flywheel turret net variables, yay --- src/main/java/frc/robot/Constants.java | 6 +++--- src/main/java/frc/robot/NetParams.java | 13 +++++++++++++ src/main/java/frc/robot/RobotContainer.java | 18 +++++++----------- .../frc/robot/subsystems/shooter/Shooter.java | 5 +++++ 4 files changed, 28 insertions(+), 14 deletions(-) create mode 100644 src/main/java/frc/robot/NetParams.java diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 7f8db9e..54f808a 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -277,9 +277,9 @@ public static class ShooterConstants public static final Current FEEDER_CURRENT_LIMIT = Amps.of(60); public static final Voltage FEEDER_VOLTAGE = Volts.of(6); public static final Current ROTOR_CURRENT_LIMIT = Amps.of(80); - public static final Voltage ROTOR_FAST_VOLTAGE = Volts.of(3.0); - public static final Voltage ROTOR_MID_VOLTAGE = Volts.of(1.5); - public static final Voltage ROTOR_RETRACTED_VOLTAGE = Volts.of(1.0); + public static final Voltage ROTOR_FAST_VOLTAGE = Volts.of(8.0); + public static final Voltage ROTOR_MID_VOLTAGE = Volts.of(8.0); + public static final Voltage ROTOR_RETRACTED_VOLTAGE = Volts.of(8.0); // TODO: Tune these values with testing! public static AngularVelocity getFlywheelSpeedForDistance(Distance distance) diff --git a/src/main/java/frc/robot/NetParams.java b/src/main/java/frc/robot/NetParams.java new file mode 100644 index 0000000..5e3f39f --- /dev/null +++ b/src/main/java/frc/robot/NetParams.java @@ -0,0 +1,13 @@ +package frc.robot; + +public class NetParams +{ + public NetParams() + { + turretAngle = 0; + flywheelSpeed = 70; + } + + public double turretAngle; + public double flywheelSpeed; +} diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 8f51349..e463808 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -13,6 +13,7 @@ import edu.wpi.first.units.measure.AngularVelocity; import edu.wpi.first.units.measure.Dimensionless; import edu.wpi.first.units.measure.LinearVelocity; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.Commands; import edu.wpi.first.wpilibj2.command.button.CommandJoystick; @@ -24,6 +25,7 @@ import frc.robot.subsystems.intake.Intake; import frc.robot.subsystems.shooter.Shooter; import frc.robot.util.MeasureUtil; +import frc.robot.NetParams; @Logged public class RobotContainer @@ -39,7 +41,8 @@ public class RobotContainer private final Shooter _shooter = new Shooter(_drive::getState, _intake::isExtended, _intake::isRetracted); private final Autos _autos = new Autos(_drive, _shooter, _intake); // private Dimensionless _driveMultiplier = DriveConstants.FULL_SPEED_SCALE; - private double _manualFlywheelRPM = MANUAL_FLYWHEEL_START_RPM; + private double _manualFlywheelRPM = MANUAL_FLYWHEEL_START_RPM; + private NetParams _params; public RobotContainer() { @@ -66,12 +69,6 @@ private SwerveRequest.FieldCentric getFieldCentricRequest() return _fieldCentric.withVelocityX(getDrive()).withVelocityY(getStrafe()).withRotationalRate(getRotate()); } - private void setManualFlywheelRPM(double rpm) - { - _manualFlywheelRPM = Math.max(0.0, rpm); - _shooter.setManualFlywheel(_manualFlywheelRPM); - } - private void configureBindings() { _drive.setDefaultCommand(_drive.applyRequest(this::getFieldCentricRequest)); @@ -82,7 +79,7 @@ private void configureBindings() // _driver.button(1).whileTrue(Commands.parallel(_shooter.shoot(), // Commands.startEnd(() -> _drive.disableVisionPoseCorrection(true), () -> // _drive.disableVisionPoseCorrection(false)))); - _driver.button(1).whileTrue(_shooter.manualShootCmd(() -> _manualFlywheelRPM)); + _driver.button(1).whileTrue(_shooter.manualShootCmd(() -> _params.flywheelSpeed)); // _driver.button(2).whileTrue(Commands.startEnd(() -> _driveMultiplier = // DriveConstants.SLOW_MODE_SCALE, () -> _driveMultiplier = // DriveConstants.FULL_SPEED_SCALE)); @@ -104,13 +101,12 @@ private void configureBindings() _operator.leftTrigger().whileTrue(_intake.runRollersForward()); _operator.leftBumper().whileTrue(_intake.runRollersReverse()); _operator.rightTrigger().whileTrue(_intake.jiggle()); - _operator.y().onTrue(Commands.runOnce(() -> setManualFlywheelRPM(MANUAL_FLYWHEEL_START_RPM))); - _operator.x().onTrue(Commands.runOnce(() -> setManualFlywheelRPM(_manualFlywheelRPM - MANUAL_FLYWHEEL_STEP_RPM))); - _operator.b().onTrue(Commands.runOnce(() -> setManualFlywheelRPM(_manualFlywheelRPM + MANUAL_FLYWHEEL_STEP_RPM))); _operator.a().onTrue(Commands.runOnce(_shooter::stopManualFlywheel)); _operator.rightBumper().whileTrue(_shooter.runManualFeeder()); _operator.povDown().onTrue(_intake.getRetractCmd()); _operator.povUp().onTrue(_intake.getExtendCmd()); + + SmartDashboard.putData(_shooter.setTurretAngleCmd(() -> _params.turretAngle)); } public Command getAutonomousCommand() diff --git a/src/main/java/frc/robot/subsystems/shooter/Shooter.java b/src/main/java/frc/robot/subsystems/shooter/Shooter.java index f9159bf..7386fc1 100644 --- a/src/main/java/frc/robot/subsystems/shooter/Shooter.java +++ b/src/main/java/frc/robot/subsystems/shooter/Shooter.java @@ -201,6 +201,11 @@ public Command setManualTurretAngle(Angle angle) return runOnce(() -> setManualTurretAngleCommand(angle)); } + public Command setTurretAngleCmd(DoubleSupplier angle) + { + return runOnce(() -> setManualTurretAngleCommand(Degrees.of(angle.getAsDouble()))); + } + public Command manualShootCmd(DoubleSupplier speed) { // @formatter:off