From 31dc2d9f8d5b5ec06d48e03bad375937886abbf9 Mon Sep 17 00:00:00 2001 From: C4llSiqn Date: Tue, 7 Jan 2025 08:38:21 -0700 Subject: [PATCH] add input checking --- src/main/java/frc4388/robot/subsystems/SwerveDrive.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/frc4388/robot/subsystems/SwerveDrive.java b/src/main/java/frc4388/robot/subsystems/SwerveDrive.java index bc29762..15864ff 100644 --- a/src/main/java/frc4388/robot/subsystems/SwerveDrive.java +++ b/src/main/java/frc4388/robot/subsystems/SwerveDrive.java @@ -70,9 +70,15 @@ public class SwerveDrive extends Subsystem { } public void driveWithInput(Translation2d leftStick, Translation2d rightStick, boolean fieldRelative) { + if (rightStick.getNorm() < 0.05 && leftStick.getNorm() < 0.05 && stopped == false) // if no imput and the swerve drive is still going: + swerveDriveTrain.setControl(new SwerveRequest.SwerveDriveBrake()); // stop the swerve + + if (rightStick.getNorm() < 0.05 && leftStick.getNorm() < 0.05) //if no imput + return; // don't bother doing swerve drive math and return early. + leftStick.rotateBy(Rotation2d.fromDegrees(SwerveDriveConstants.FORWARD_OFFSET)); + if (fieldRelative) { - // if (rightStick.getNorm() > 0.05 && swerveDriveTrain.setControl(new SwerveRequest.FieldCentric() .withVelocityX(leftStick.getX()*speedAdjust) .withVelocityY(leftStick.getY()*speedAdjust)