From 6a5b4a7045fb71c6557bb9294db703896c04981c Mon Sep 17 00:00:00 2001 From: TuskAct2 <112046931+TuskAct2@users.noreply.github.com> Date: Sun, 1 Oct 2023 01:10:31 +0000 Subject: [PATCH] if encoders are dc then motors will stop --- .../robotcode2023/subsystems/Arm.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/carlmontrobotics/robotcode2023/subsystems/Arm.java b/src/main/java/org/carlmontrobotics/robotcode2023/subsystems/Arm.java index 497a5459..01571f57 100644 --- a/src/main/java/org/carlmontrobotics/robotcode2023/subsystems/Arm.java +++ b/src/main/java/org/carlmontrobotics/robotcode2023/subsystems/Arm.java @@ -54,7 +54,7 @@ public class Arm extends SubsystemBase { // rad, rad/s public static TrapezoidProfile.State[] goalState = { new TrapezoidProfile.State(-Math.PI / 2, 0), new TrapezoidProfile.State(0, 0) }; - double lastWristPos; + private double lastWristPos; private double lastArmPos; private double lastMeasuredTime; private boolean isArmEncoderConnected = false; @@ -127,7 +127,16 @@ public void periodic() { isWristEncoderConnected = currTime - lastMeasuredTime < DISCONNECTED_ENCODER_TIMEOUT_SEC; SmartDashboard.putBoolean("WristEncoderConnected", isWristEncoderConnected); - + + if(isArmEncoderConnected = false) + { + armMotor.stopMotor(); + } + if(isWristEncoderConnected = false) + { + wristMotor.stopMotor(); + } + //TODO: is RobotContainer live or do you need supplier functions armConstraints = new TrapezoidProfile.Constraints( RobotContainer.isdriverchild ? MAX_FF_VEL_BABY[0] : MAX_FF_VEL_AUTO[0],