From 2c35e4dc52924fbc6b855941873fdd53b79aa569 Mon Sep 17 00:00:00 2001 From: owenflatman Date: Fri, 27 Sep 2024 09:31:55 -0500 Subject: [PATCH 1/4] add trigger to go home --- src/main/java/frc/robot/RobotContainer.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 6147a6b7..1456e611 100755 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -237,6 +237,8 @@ private void configureButtonBindings() { operator.povLeft().onTrue(Commands.runOnce(() -> { OperatorState.decrement(); }).ignoringDisable(true)); + new Trigger(() -> OperatorState.getCurrentState() == OperatorState.State.kAmp) + .and(noteInIndexer.negate()).debounce(1.0).onTrue(elevatorWrist.homePosition()); // run action based on current state as incremented through operator states list operator.a().whileTrue(new SelectCommand(Map.of( // From 8f65736a50bdd7a2139feb3ffe2d751f512551b7 Mon Sep 17 00:00:00 2001 From: Gael Date: Sat, 28 Sep 2024 07:46:38 -0500 Subject: [PATCH 2/4] Fix trigger for auto home after spit amp --- src/main/java/frc/robot/RobotContainer.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 1456e611..a1a851e6 100755 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -238,7 +238,8 @@ private void configureButtonBindings() { OperatorState.decrement(); }).ignoringDisable(true)); new Trigger(() -> OperatorState.getCurrentState() == OperatorState.State.kAmp) - .and(noteInIndexer.negate()).debounce(1.0).onTrue(elevatorWrist.homePosition()); + .and(new Trigger(() -> !this.intake.getIndexerBeamBrakeStatus()).debounce(1.0)) + .onTrue(elevatorWrist.homePosition()); // run action based on current state as incremented through operator states list operator.a().whileTrue(new SelectCommand(Map.of( // From 32e26cd2410321ce3d06c2738628a420767a8103 Mon Sep 17 00:00:00 2001 From: Gael Date: Sat, 28 Sep 2024 10:07:02 -0500 Subject: [PATCH 3/4] update photon fix script --- photon-scripts/restart-photon.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/photon-scripts/restart-photon.sh b/photon-scripts/restart-photon.sh index 821382c9..43929524 100644 --- a/photon-scripts/restart-photon.sh +++ b/photon-scripts/restart-photon.sh @@ -5,11 +5,14 @@ do error=`systemctl status photonvision.service | grep -i "Input was empty!"` if [[ $? -eq 0 ]]; then + echo "Photon Vision reporting 'Input was empty'" dmesg | grep uvc > "/opt/uvc-$(date +%y%m%d%H%M%S).txt" + echo "Stopping Photon Vision" systemctl stop photonvision.service sleep 1 modprobe uvcvideo sleep 1 + echo "Starting Photon Vision" systemctl start photonvision.service sleep 15 fi From f3dde51f977c90bc4353a292e38941d466e0dafd Mon Sep 17 00:00:00 2001 From: Gael Date: Sat, 28 Sep 2024 11:46:30 -0500 Subject: [PATCH 4/4] Add safety to prevent note come down from AMP --- src/main/java/frc/robot/RobotContainer.java | 4 ++++ .../subsystems/elevator_wrist/ElevatorWrist.java | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index a1a851e6..05e98b74 100755 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -229,6 +229,10 @@ private void configureButtonBindings() { operator.rightTrigger().and(operator.leftTrigger()).whileTrue(intake.runIndexerMotor(1)); // set shooter to home preset position operator.y().onTrue(elevatorWrist.homePosition()); + operator.y().and(elevatorWrist.elevatorAtAmp).and(noteInIndexer) + .onTrue(intake.runIntakeMotorNonStop(0, -0.2).withTimeout(2.0) + .until(new Trigger(() -> !this.intake.getIndexerBeamBrakeStatus()).debounce(.5))); + // increment once through states list to next state operator.povRight().onTrue(Commands.runOnce(() -> { OperatorState.increment(); diff --git a/src/main/java/frc/robot/subsystems/elevator_wrist/ElevatorWrist.java b/src/main/java/frc/robot/subsystems/elevator_wrist/ElevatorWrist.java index 77871a21..0c2ac60e 100644 --- a/src/main/java/frc/robot/subsystems/elevator_wrist/ElevatorWrist.java +++ b/src/main/java/frc/robot/subsystems/elevator_wrist/ElevatorWrist.java @@ -20,6 +20,7 @@ import edu.wpi.first.wpilibj2.command.Commands; import edu.wpi.first.wpilibj2.command.SubsystemBase; import edu.wpi.first.wpilibj2.command.button.CommandXboxController; +import edu.wpi.first.wpilibj2.command.button.Trigger; import frc.lib.util.FieldConstants; import frc.robot.Constants; import frc.robot.OperatorState; @@ -69,6 +70,8 @@ public class ElevatorWrist extends SubsystemBase { private double estimatedWristAngle = 0; + public Trigger elevatorAtAmp = new Trigger(() -> elevatorAtAmp()); + /** * Create new ElevatorWrist. */ @@ -392,4 +395,14 @@ public boolean elevatorAtHome() { 3); } + /** + * Check if the elevator is at the AMP position + * + * @return True if the elevator is AMP + */ + public boolean elevatorAtAmp() { + return MathUtil.isNear(Constants.ElevatorWristConstants.SetPoints.AMP_HEIGHT, getHeight(), + 3); + } + }