From d6d8e1821bda5eb406c957d0a4d58b6192882fb7 Mon Sep 17 00:00:00 2001 From: iamawesomecat Date: Mon, 18 Mar 2024 18:11:22 -0700 Subject: [PATCH 1/2] pivot soft stop constants --- .../team2412/robot/subsystems/LauncherSubsystem.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/frc/team2412/robot/subsystems/LauncherSubsystem.java b/src/main/java/frc/team2412/robot/subsystems/LauncherSubsystem.java index 524568eb..b8eeccf8 100644 --- a/src/main/java/frc/team2412/robot/subsystems/LauncherSubsystem.java +++ b/src/main/java/frc/team2412/robot/subsystems/LauncherSubsystem.java @@ -33,6 +33,8 @@ public class LauncherSubsystem extends SubsystemBase { // HARDWARE private static final double PIVOT_GEARING_RATIO = 1.0 / 180.0; + private static final float PIVOT_SOFTSTOP_FORWARD = 0.96f; + private static final float PIVOT_SOFTSTOP_BACKWARD = 0.80f; // ANGLE VALUES public static final int AMP_AIM_ANGLE = 335; public static final int SUBWOOFER_AIM_ANGLE = 298; @@ -150,8 +152,8 @@ public void configMotors() { launcherAngleOneMotor.setSmartCurrentLimit(60); launcherAngleTwoMotor.setSmartCurrentLimit(60); - launcherAngleOneMotor.setSoftLimit(CANSparkBase.SoftLimitDirection.kForward, 0.96f); - launcherAngleOneMotor.setSoftLimit(CANSparkBase.SoftLimitDirection.kReverse, 0.80f); + launcherAngleOneMotor.setSoftLimit(CANSparkBase.SoftLimitDirection.kForward, PIVOT_SOFTSTOP_FORWARD); + launcherAngleOneMotor.setSoftLimit(CANSparkBase.SoftLimitDirection.kReverse, PIVOT_SOFTSTOP_BACKWARD); launcherAngleOneMotor.enableSoftLimit(CANSparkBase.SoftLimitDirection.kForward, true); launcherAngleOneMotor.enableSoftLimit(CANSparkBase.SoftLimitDirection.kReverse, true); @@ -249,10 +251,10 @@ public double getAngleSpeed() { public void setAngleManual(double joystickInput) { manualAngleSetpoint = - MathUtil.clamp(manualAngleSetpoint + joystickInput * MANUAL_MODIFIER, 0.80f, 0.96f); + MathUtil.clamp(manualAngleSetpoint + joystickInput * MANUAL_MODIFIER, PIVOT_SOFTSTOP_BACKWARD, PIVOT_SOFTSTOP_FORWARD); - if (Units.degreesToRotations(getAngle()) > 0.80 - && Units.degreesToRotations(getAngle()) < 0.96) { + if (Units.degreesToRotations(getAngle()) > PIVOT_SOFTSTOP_BACKWARD + && Units.degreesToRotations(getAngle()) < PIVOT_SOFTSTOP_FORWARD) { launcherAngleOnePIDController.setReference( manualAngleSetpoint, ControlType.kPosition, From d034d16cf10df9aa830d9626904f3224383ca9c6 Mon Sep 17 00:00:00 2001 From: iamawesomecat Date: Mon, 18 Mar 2024 18:15:38 -0700 Subject: [PATCH 2/2] spotless --- .../team2412/robot/subsystems/LauncherSubsystem.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/frc/team2412/robot/subsystems/LauncherSubsystem.java b/src/main/java/frc/team2412/robot/subsystems/LauncherSubsystem.java index b8eeccf8..19b48563 100644 --- a/src/main/java/frc/team2412/robot/subsystems/LauncherSubsystem.java +++ b/src/main/java/frc/team2412/robot/subsystems/LauncherSubsystem.java @@ -152,8 +152,10 @@ public void configMotors() { launcherAngleOneMotor.setSmartCurrentLimit(60); launcherAngleTwoMotor.setSmartCurrentLimit(60); - launcherAngleOneMotor.setSoftLimit(CANSparkBase.SoftLimitDirection.kForward, PIVOT_SOFTSTOP_FORWARD); - launcherAngleOneMotor.setSoftLimit(CANSparkBase.SoftLimitDirection.kReverse, PIVOT_SOFTSTOP_BACKWARD); + launcherAngleOneMotor.setSoftLimit( + CANSparkBase.SoftLimitDirection.kForward, PIVOT_SOFTSTOP_FORWARD); + launcherAngleOneMotor.setSoftLimit( + CANSparkBase.SoftLimitDirection.kReverse, PIVOT_SOFTSTOP_BACKWARD); launcherAngleOneMotor.enableSoftLimit(CANSparkBase.SoftLimitDirection.kForward, true); launcherAngleOneMotor.enableSoftLimit(CANSparkBase.SoftLimitDirection.kReverse, true); @@ -251,7 +253,10 @@ public double getAngleSpeed() { public void setAngleManual(double joystickInput) { manualAngleSetpoint = - MathUtil.clamp(manualAngleSetpoint + joystickInput * MANUAL_MODIFIER, PIVOT_SOFTSTOP_BACKWARD, PIVOT_SOFTSTOP_FORWARD); + MathUtil.clamp( + manualAngleSetpoint + joystickInput * MANUAL_MODIFIER, + PIVOT_SOFTSTOP_BACKWARD, + PIVOT_SOFTSTOP_FORWARD); if (Units.degreesToRotations(getAngle()) > PIVOT_SOFTSTOP_BACKWARD && Units.degreesToRotations(getAngle()) < PIVOT_SOFTSTOP_FORWARD) {