From 5417986308b3061749e7526e5a91d295c2e9ea0e Mon Sep 17 00:00:00 2001 From: Honzik Date: Fri, 31 Mar 2023 19:15:33 -0400 Subject: [PATCH] Added controller limiter --- src/main/java/frc/robot/Constants.java | 6 +++--- src/main/java/frc/robot/RobotContainer.java | 1 + src/main/java/frc/robot/commands/DriveWithJoysticks.java | 9 ++++++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index e63b6ff..39d030a 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -75,11 +75,11 @@ public static final class DriveConstants { public static final SimpleMotorFeedforward driveFF = new SimpleMotorFeedforward(0.254, 0.137); - public static final double maxDriveSpeed = 14.4; - public static final double maxTurnRate = 2 * Math.PI; + public static final double maxDriveSpeed = 3; + public static final double maxTurnRate = Math.PI; public static final double driveJoystickDeadbandPercent = 0.075; - public static final double driveMaxJerk = 200.0; + public static final double driveMaxJerk = 100.0; } diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 5fb0bad..0b4ddbe 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -57,6 +57,7 @@ private void configureSubsystems() { () -> -rightStick.getRawAxis(0), true )); + SmartDashboard.putNumber("Controller Reduction", 1); //index.setDefaultCommand(new Waiting(index)); shooter.setDefaultCommand( diff --git a/src/main/java/frc/robot/commands/DriveWithJoysticks.java b/src/main/java/frc/robot/commands/DriveWithJoysticks.java index 8ae732c..576296a 100644 --- a/src/main/java/frc/robot/commands/DriveWithJoysticks.java +++ b/src/main/java/frc/robot/commands/DriveWithJoysticks.java @@ -25,6 +25,8 @@ public class DriveWithJoysticks extends CommandBase { private final AxisProcessor yProcessor = new AxisProcessor(false); private final AxisProcessor omegaProcessor = new AxisProcessor(true); + private double controllerReduction = 0.1; + /** Creates a new DriveWithJoysticks. */ public DriveWithJoysticks(Drive drive, DoubleSupplier xPercent, DoubleSupplier yPercent, DoubleSupplier omegaPercent, boolean fieldRelative) { this.drive = drive; @@ -47,9 +49,10 @@ public void initialize() { // Called every time the scheduler runs while the command is scheduled. @Override public void execute() { - double xMPerS = xProcessor.processJoystickInputs(xPercent.getAsDouble() * 0.75) * DriveConstants.maxDriveSpeed; - double yMPerS = yProcessor.processJoystickInputs(yPercent.getAsDouble() * 0.75) * DriveConstants.maxDriveSpeed; - double omegaRadPerS = omegaProcessor.processJoystickInputs(omegaPercent.getAsDouble()) * DriveConstants.maxTurnRate; + controllerReduction = SmartDashboard.getNumber("Controller Reduction", controllerReduction); + double xMPerS = xProcessor.processJoystickInputs(xPercent.getAsDouble() * 0.75) * DriveConstants.maxDriveSpeed * controllerReduction; + double yMPerS = yProcessor.processJoystickInputs(yPercent.getAsDouble() * 0.75) * DriveConstants.maxDriveSpeed * controllerReduction; + double omegaRadPerS = omegaProcessor.processJoystickInputs(omegaPercent.getAsDouble()) * DriveConstants.maxTurnRate * controllerReduction; SmartDashboard.putNumber("XMPerS", xMPerS);