From 8c28beb75b011c50093bb8afca026d210fe3694f Mon Sep 17 00:00:00 2001 From: JJTech0130 Date: Fri, 9 Feb 2024 17:53:29 -0500 Subject: [PATCH] R: Minor fixes --- .../ftc/teamcode/drive/RoboticaBot.java | 2 +- .../ftc/teamcode/hardware/AxonServo.java | 32 +++++++++++-------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/drive/RoboticaBot.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/drive/RoboticaBot.java index 9489980d..740f5d34 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/drive/RoboticaBot.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/drive/RoboticaBot.java @@ -65,7 +65,7 @@ public static double getMotorVelocityF(double ticksPerSecond) { public static double X_MULTIPLIER = 1; public static double Y_MULTIPLIER = 1; public static double FORWARD_OFFSET = -3.0; - public static double LATERAL_DISTANCE = 16; + public static double LATERAL_DISTANCE = 16.083; public static double DW_GEAR_RATIO = 1; public static double DW_WHEEL_RADIUS = 0.944882; public static double DW_TICKS_PER_REV = 2000; diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/hardware/AxonServo.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/hardware/AxonServo.java index bfa3f26e..1604cd1d 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/hardware/AxonServo.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/hardware/AxonServo.java @@ -18,21 +18,25 @@ private class ServoCounter extends Thread { private int count = 0; public void run() { - android.util.Log.w("AXON_THREAD", "Starting thread"); - double lastPosition = getCurrentPosition(); - while (!GlobalOpMode.opMode.isStopRequested()) { - //android.util.Log.w("AXON_THREAD", "LOOP"); - Thread.yield(); - double currentPosition = getCurrentPosition(); - // Positive wrap-around from 0 -> 360 - if (currentPosition > 180 && lastPosition < 180 && innerServo.getPower() > 0) { - count--; + try { + android.util.Log.w("AXON_THREAD", "Starting thread"); + double lastPosition = getCurrentPosition(); + while (!GlobalOpMode.opMode.isStopRequested()) { + //android.util.Log.w("AXON_THREAD", "LOOP"); + Thread.yield(); + double currentPosition = getCurrentPosition(); + // Positive wrap-around from 0 -> 360 + if (currentPosition > 180 && lastPosition < 180 && innerServo.getPower() > 0) { + count--; + } + // Negative wrap-around from 360 -> 0 + if (currentPosition < 180 && lastPosition > 180 && innerServo.getPower() < 0) { + count++; + } + lastPosition = currentPosition; } - // Negative wrap-around from 360 -> 0 - if (currentPosition < 180 && lastPosition > 180 && innerServo.getPower() < 0) { - count++; - } - lastPosition = currentPosition; + } catch (Exception e) { + android.util.Log.e("AXON_THREAD", "Crashed with error: " + e); } }