From ad77e9934ae5ca17319971c437a7787c3a149154 Mon Sep 17 00:00:00 2001 From: RuotT <25thiepruot@bprep.org> Date: Thu, 14 Mar 2024 17:47:33 -0700 Subject: [PATCH 1/4] Update AmpArmIOTalonFX.java --- .../frc/robot/hardware/AmpArmIOTalonFX.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/main/java/frc/robot/hardware/AmpArmIOTalonFX.java b/src/main/java/frc/robot/hardware/AmpArmIOTalonFX.java index d94d15d6..558ba62f 100644 --- a/src/main/java/frc/robot/hardware/AmpArmIOTalonFX.java +++ b/src/main/java/frc/robot/hardware/AmpArmIOTalonFX.java @@ -6,6 +6,8 @@ import java.util.function.DoubleSupplier; +import com.ctre.phoenix6.Orchestra; +import com.ctre.phoenix6.StatusCode; import com.ctre.phoenix6.configs.Slot0Configs; import com.ctre.phoenix6.configs.TalonFXConfiguration; import com.ctre.phoenix6.configs.TalonFXConfigurator; @@ -48,6 +50,7 @@ public class AmpArmIOTalonFX implements AmpArmIO { private boolean zeroPrev = false; private boolean brakePrev = false; + private Orchestra updateSound; private NeutralModeValue neutralMode = NeutralModeValue.Brake; /** Creates a new AmpArmIOTalonFX. */ @@ -57,6 +60,11 @@ public AmpArmIOTalonFX(DigitalInput zeroButton, DigitalInput brakeButton) { armMotor.getConfigurator().apply(new TalonFXConfiguration()); wristMotor.getConfigurator().apply(new TalonFXConfiguration()); + + updateSound = new Orchestra(); + updateSound.addInstrument(armMotor); + updateSound.addInstrument(wristMotor); + StatusCode status = updateSound.loadMusic("TetrisTheme.chrp") TalonFXConfiguration armConfig = new TalonFXConfiguration(); @@ -119,12 +127,20 @@ public void runArm(double speed) { public void setArm(double angle) { PositionVoltage positionVoltage = new PositionVoltage(angle); armMotor.setControl(positionVoltage); + if(angle == 0.0){ + updateSound.stop(); + updateSound.play(); + } } @Override public void setWrist(double angle) { PositionVoltage positionVoltage = new PositionVoltage(angle); wristMotor.setControl(positionVoltage); + if(angle == 0.0){ + updateSound.stop(); + updateSound.play(); + } } @Override @@ -192,4 +208,9 @@ public boolean getBrakeButton(){ public boolean isBrakeMode(){ return neutralMode == NeutralModeValue.Brake; } + public void stopSound(){ + if(updateSound.isPlaying()){ + updateSound.stop(); + } + } } From 4bc3b9b1c5fdb26f839f32df2b7db537fb38a58c Mon Sep 17 00:00:00 2001 From: RuotT <25thiepruot@bprep.org> Date: Sat, 16 Mar 2024 12:20:51 -0700 Subject: [PATCH 2/4] Update status var forgot about the error statement --- src/main/java/frc/robot/hardware/AmpArmIOTalonFX.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/frc/robot/hardware/AmpArmIOTalonFX.java b/src/main/java/frc/robot/hardware/AmpArmIOTalonFX.java index 558ba62f..c44fcdbf 100644 --- a/src/main/java/frc/robot/hardware/AmpArmIOTalonFX.java +++ b/src/main/java/frc/robot/hardware/AmpArmIOTalonFX.java @@ -43,7 +43,6 @@ public class AmpArmIOTalonFX implements AmpArmIO { private final double wristKI = 0.0; private final double wristKD = 0.0; private final double wristKF = 0.0; - private DigitalInput zeroButton; private DigitalInput brakeButton; @@ -64,13 +63,17 @@ public AmpArmIOTalonFX(DigitalInput zeroButton, DigitalInput brakeButton) { updateSound = new Orchestra(); updateSound.addInstrument(armMotor); updateSound.addInstrument(wristMotor); - StatusCode status = updateSound.loadMusic("TetrisTheme.chrp") + StatusCode status = updateSound.loadMusic("TetrisTheme.chrp"); + + if(status != StatusCode.OK){ + System.out.println("Error loading sound"); + } TalonFXConfiguration armConfig = new TalonFXConfiguration(); armConfig.SoftwareLimitSwitch .withForwardSoftLimitThreshold(ARM_FORWARD_LIMIT) - .withReverseSoftLimitThreshold(ARM_REVERSE_LIMIT) + .withReverseSoftLimitThreshold(ARM_REVERSE_LIMIT) .withForwardSoftLimitEnable(true) .withReverseSoftLimitEnable(true); From 9d58dcc003ec7df645a2c785241d8761e41da8ef Mon Sep 17 00:00:00 2001 From: RuotT <25thiepruot@bprep.org> Date: Mon, 18 Mar 2024 17:36:58 -0700 Subject: [PATCH 3/4] Fixed all issues with Pull Resquest --- src/main/java/frc/robot/hardware/AmpArmIOTalonFX.java | 9 +++------ src/main/java/frc/robot/io/AmpArmIO.java | 8 +++++--- src/main/java/frc/robot/subsystems/AmpArm.java | 3 +++ 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main/java/frc/robot/hardware/AmpArmIOTalonFX.java b/src/main/java/frc/robot/hardware/AmpArmIOTalonFX.java index c44fcdbf..01cb5a91 100644 --- a/src/main/java/frc/robot/hardware/AmpArmIOTalonFX.java +++ b/src/main/java/frc/robot/hardware/AmpArmIOTalonFX.java @@ -115,10 +115,11 @@ public void disableBrakeMode() { @Override public void resetArmWristPos() { - armMotor.setPosition(-78.0); wristMotor.setPosition(70.0); - + + updateSound.stop(); + updateSound.play(); } @Override @@ -130,10 +131,6 @@ public void runArm(double speed) { public void setArm(double angle) { PositionVoltage positionVoltage = new PositionVoltage(angle); armMotor.setControl(positionVoltage); - if(angle == 0.0){ - updateSound.stop(); - updateSound.play(); - } } @Override diff --git a/src/main/java/frc/robot/io/AmpArmIO.java b/src/main/java/frc/robot/io/AmpArmIO.java index 5223505c..e95e9fb5 100644 --- a/src/main/java/frc/robot/io/AmpArmIO.java +++ b/src/main/java/frc/robot/io/AmpArmIO.java @@ -56,9 +56,11 @@ public default void updateInputs(AmpArmIOInputs inputs) {} public void disableBrakeMode(); -public boolean getBrakeButton(); + public boolean getBrakeButton(); -public boolean isBrakeMode(); + public boolean isBrakeMode(); -public boolean getZeroButton(); + public boolean getZeroButton(); + + public void stopSound(); } diff --git a/src/main/java/frc/robot/subsystems/AmpArm.java b/src/main/java/frc/robot/subsystems/AmpArm.java index 527f93f1..d7de90df 100644 --- a/src/main/java/frc/robot/subsystems/AmpArm.java +++ b/src/main/java/frc/robot/subsystems/AmpArm.java @@ -234,6 +234,9 @@ public void periodic() { if(!io.isBrakeMode()){ io.enableBrakeMode(); } + // DO NOT REMOVE + // This is neccessary to run the linkage after playing the update sound + io.stopSound(); } } From 137a83417a188b8a592dd725ac25080eebd9467b Mon Sep 17 00:00:00 2001 From: RuotT <25thiepruot@bprep.org> Date: Mon, 18 Mar 2024 17:52:54 -0700 Subject: [PATCH 4/4] update the IO layer Now the merge conflict is fixed --- src/main/java/frc/robot/io/AmpArmIO.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/frc/robot/io/AmpArmIO.java b/src/main/java/frc/robot/io/AmpArmIO.java index 4e1d39fd..149123ee 100644 --- a/src/main/java/frc/robot/io/AmpArmIO.java +++ b/src/main/java/frc/robot/io/AmpArmIO.java @@ -58,14 +58,11 @@ public default void updateInputs(AmpArmIOInputs inputs) {} public void disableBrakeMode(); - public boolean getBrakeButton(); public boolean getBrakeButton(); - public boolean isBrakeMode(); public boolean isBrakeMode(); public boolean getZeroButton(); public void stopSound(); - public boolean getZeroButton(); }